Class: WhatsappSdk::Resource::InteractiveAction
- Inherits:
-
Object
- Object
- WhatsappSdk::Resource::InteractiveAction
- Defined in:
- lib/whatsapp_sdk/resource/interactive_action.rb
Defined Under Namespace
Modules: Type
Constant Summary collapse
- REPLY_BUTTONS_MINIMUM =
1
- REPLY_BUTTONS_MAXIMUM =
3
- LIST_BUTTON_TITLE_MAXIMUM =
20
- LIST_SECTIONS_MINIMUM =
1
- LIST_SECTIONS_MAXIMUM =
10
Instance Attribute Summary collapse
-
#button ⇒ Object
Returns the button of the Action.
-
#buttons ⇒ Object
Returns the buttons of the Action.
-
#sections ⇒ Object
Returns the sections of the Action.
-
#type ⇒ Object
Returns the type of interactive action you want to send.
Instance Method Summary collapse
-
#add_reply_button(reply_button) ⇒ Object
TODO: attr_accessor :catalog_id TODO: attr_accessor :product_retailer_id.
- #add_section(section) ⇒ Object
-
#initialize(type:, buttons: [], button: "", sections: []) ⇒ InteractiveAction
constructor
A new instance of InteractiveAction.
- #to_json ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(type:, buttons: [], button: "", sections: []) ⇒ InteractiveAction
Returns a new instance of InteractiveAction.
54 55 56 57 58 59 |
# File 'lib/whatsapp_sdk/resource/interactive_action.rb', line 54 def initialize(type:, buttons: [], button: "", sections: []) @type = type @buttons = @button = @sections = sections end |
Instance Attribute Details
#button ⇒ Object
Returns the button of the Action. For list_message type, it’s required.
30 31 32 |
# File 'lib/whatsapp_sdk/resource/interactive_action.rb', line 30 def @button end |
#buttons ⇒ Object
Returns the buttons of the Action. For reply_button type, it’s required.
25 26 27 |
# File 'lib/whatsapp_sdk/resource/interactive_action.rb', line 25 def @buttons end |
#sections ⇒ Object
Returns the sections of the Action. For list_message type, it’s required.
35 36 37 |
# File 'lib/whatsapp_sdk/resource/interactive_action.rb', line 35 def sections @sections end |
#type ⇒ Object
Returns the type of interactive action you want to send.
20 21 22 |
# File 'lib/whatsapp_sdk/resource/interactive_action.rb', line 20 def type @type end |
Instance Method Details
#add_reply_button(reply_button) ⇒ Object
TODO: attr_accessor :catalog_id TODO: attr_accessor :product_retailer_id
40 41 42 |
# File 'lib/whatsapp_sdk/resource/interactive_action.rb', line 40 def () @buttons << end |
#add_section(section) ⇒ Object
44 45 46 |
# File 'lib/whatsapp_sdk/resource/interactive_action.rb', line 44 def add_section(section) @sections << section end |
#to_json ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/whatsapp_sdk/resource/interactive_action.rb', line 61 def to_json json = {} case type when "list_message" json = { button: , sections: sections.map(&:to_json) } when "reply_button" json = { buttons: .map(&:to_json) } end json end |
#validate ⇒ Object
73 74 75 |
# File 'lib/whatsapp_sdk/resource/interactive_action.rb', line 73 def validate validate_fields end |