Class: WhatsAppCloudApi::ButtonParameter

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/whats_app_cloud_api/models/button_parameter.rb

Overview

ButtonParameter Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(type = nil, payload = nil, text = nil) ⇒ ButtonParameter

Returns a new instance of ButtonParameter.



49
50
51
52
53
54
55
# File 'lib/whats_app_cloud_api/models/button_parameter.rb', line 49

def initialize(type = nil,
               payload = nil,
               text = nil)
  @type = type unless type == SKIP
  @payload = payload unless payload == SKIP
  @text = text unless text == SKIP
end

Instance Attribute Details

#payloadString

Required for quick_reply buttons. Developer-defined payload that is returned when the button is clicked in addition to the display text on the button.

Returns:

  • (String)


20
21
22
# File 'lib/whats_app_cloud_api/models/button_parameter.rb', line 20

def payload
  @payload
end

#textString

Required for URL buttons. Developer-provided suffix that is appended to the predefined prefix URL in the template.

Returns:

  • (String)


25
26
27
# File 'lib/whats_app_cloud_api/models/button_parameter.rb', line 25

def text
  @text
end

#typeButtonParameterTypeEnum

Indicates the type of parameter for the button.



14
15
16
# File 'lib/whats_app_cloud_api/models/button_parameter.rb', line 14

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/whats_app_cloud_api/models/button_parameter.rb', line 58

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  type = hash.key?('type') ? hash['type'] : SKIP
  payload = hash.key?('payload') ? hash['payload'] : SKIP
  text = hash.key?('text') ? hash['text'] : SKIP

  # Create object from extracted values.
  ButtonParameter.new(type,
                      payload,
                      text)
end

.namesObject

A mapping from model property names to API property names.



28
29
30
31
32
33
34
# File 'lib/whats_app_cloud_api/models/button_parameter.rb', line 28

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['type'] = 'type'
  @_hash['payload'] = 'payload'
  @_hash['text'] = 'text'
  @_hash
end

Instance Method Details

#nullablesObject

An array for nullable fields



45
46
47
# File 'lib/whats_app_cloud_api/models/button_parameter.rb', line 45

def nullables
  []
end

#optionalsObject

An array for optional fields



37
38
39
40
41
42
# File 'lib/whats_app_cloud_api/models/button_parameter.rb', line 37

def optionals
  %w[
    payload
    text
  ]
end