Class: WhatsappSdk::Resource::InteractiveActionReplyButton

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

Defined Under Namespace

Modules: Type

Constant Summary collapse

ACTION_BUTTON_TITLE_MAXIMUM =
20
ACTION_BUTTON_ID_MAXIMUM =
256

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title:, id:) ⇒ InteractiveActionReplyButton



29
30
31
32
33
34
# File 'lib/whatsapp_sdk/resource/interactive_action_reply_button.rb', line 29

def initialize(title:, id:)
  @type = Type::REPLY
  @title = title
  @id = id
  validate
end

Instance Attribute Details

#idObject

Returns the ActionButton unique identifier you want to send. This ID is returned in the webhook when the button is clicked by the user.



24
25
26
# File 'lib/whatsapp_sdk/resource/interactive_action_reply_button.rb', line 24

def id
  @id
end

#titleObject

Returns the ActionButton title you want to send.



18
19
20
# File 'lib/whatsapp_sdk/resource/interactive_action_reply_button.rb', line 18

def title
  @title
end

#typeObject

Returns the ActionButton type of message you want to send.



13
14
15
# File 'lib/whatsapp_sdk/resource/interactive_action_reply_button.rb', line 13

def type
  @type
end

Instance Method Details

#to_jsonObject



36
37
38
39
40
41
42
43
44
# File 'lib/whatsapp_sdk/resource/interactive_action_reply_button.rb', line 36

def to_json
  json = { type: type }
  json[type.to_sym] = {
    id: id,
    title: title
  }

  json
end