Class: WhatsappSdk::Resource::ButtonParameter
- Inherits:
-
Object
- Object
- WhatsappSdk::Resource::ButtonParameter
- Defined in:
- lib/whatsapp_sdk/resource/button_parameter.rb
Defined Under Namespace
Modules: Type
Instance Attribute Summary collapse
-
#payload ⇒ Object
Required for quick_reply buttons.
-
#text ⇒ Object
Required for URL buttons.
-
#type ⇒ Object
Returns the button parameter type.
Instance Method Summary collapse
-
#initialize(type:, payload: nil, text: nil) ⇒ ButtonParameter
constructor
A new instance of ButtonParameter.
- #to_json ⇒ Object
Constructor Details
#initialize(type:, payload: nil, text: nil) ⇒ ButtonParameter
29 30 31 32 33 |
# File 'lib/whatsapp_sdk/resource/button_parameter.rb', line 29 def initialize(type:, payload: nil, text: nil) @type = type @payload = payload @text = text end |
Instance Attribute Details
#payload ⇒ Object
Required for quick_reply buttons. Returns the button payload. Developer-defined payload that is returned when the button is clicked in addition to the display text on the button.
21 22 23 |
# File 'lib/whatsapp_sdk/resource/button_parameter.rb', line 21 def payload @payload end |
#text ⇒ Object
Required for URL buttons. Developer-provided suffix that is appended to the predefined prefix URL in the template.
27 28 29 |
# File 'lib/whatsapp_sdk/resource/button_parameter.rb', line 27 def text @text end |
#type ⇒ Object
Returns the button parameter type.
9 10 11 |
# File 'lib/whatsapp_sdk/resource/button_parameter.rb', line 9 def type @type end |
Instance Method Details
#to_json ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/whatsapp_sdk/resource/button_parameter.rb', line 35 def to_json json = { type: type } json[:payload] = payload if payload json[:text] = text if text json end |