Class: WhatsappSdk::Resource::ButtonParameter

Inherits:
Object
  • Object
show all
Defined in:
lib/whatsapp_sdk/resource/button_parameter.rb

Defined Under Namespace

Modules: Type

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#payloadObject

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

#textObject

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

#typeObject

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_jsonObject



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