Class: WhatsAppCloudApi::ButtonParameter
- Defined in:
- lib/whats_app_cloud_api/models/button_parameter.rb
Overview
ButtonParameter Model.
Instance Attribute Summary collapse
-
#payload ⇒ String
Required for quick_reply buttons.
-
#text ⇒ String
Required for URL buttons.
-
#type ⇒ ButtonParameterTypeEnum
Indicates the type of parameter for the button.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#initialize(type = nil, payload = nil, text = nil) ⇒ ButtonParameter
constructor
A new instance of ButtonParameter.
-
#nullables ⇒ Object
An array for nullable fields.
-
#optionals ⇒ Object
An array for optional fields.
Methods inherited from BaseModel
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
#payload ⇒ String
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.
20 21 22 |
# File 'lib/whats_app_cloud_api/models/button_parameter.rb', line 20 def payload @payload end |
#text ⇒ String
Required for URL buttons. Developer-provided suffix that is appended to the predefined prefix URL in the template.
25 26 27 |
# File 'lib/whats_app_cloud_api/models/button_parameter.rb', line 25 def text @text end |
#type ⇒ ButtonParameterTypeEnum
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 |
.names ⇒ Object
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
#nullables ⇒ Object
An array for nullable fields
45 46 47 |
# File 'lib/whats_app_cloud_api/models/button_parameter.rb', line 45 def nullables [] end |
#optionals ⇒ Object
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 |