Class: WhatsAppCloudApi::Button
- Defined in:
- lib/whats_app_cloud_api/models/button.rb
Overview
Button Model.
Instance Attribute Summary collapse
-
#id ⇒ String
Unique identifier for your button.
-
#title ⇒ String
Button title.
-
#type ⇒ String
TODO: Write general description for this method.
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 = 'reply', title = nil, id = nil) ⇒ Button
constructor
A new instance of Button.
-
#nullables ⇒ Object
An array for nullable fields.
-
#optionals ⇒ Object
An array for optional fields.
Methods inherited from BaseModel
Constructor Details
#initialize(type = 'reply', title = nil, id = nil) ⇒ Button
Returns a new instance of Button.
48 49 50 51 52 53 54 |
# File 'lib/whats_app_cloud_api/models/button.rb', line 48 def initialize(type = 'reply', title = nil, id = nil) @type = type unless type == SKIP @title = title unless title == SKIP @id = id unless id == SKIP end |
Instance Attribute Details
#id ⇒ String
Unique identifier for your button. This ID is returned in the webhook when the button is clicked by the user.
24 25 26 |
# File 'lib/whats_app_cloud_api/models/button.rb', line 24 def id @id end |
#title ⇒ String
Button title. It cannot be an empty string and must be unique within the message. Emojis are supported, markdown is not.
19 20 21 |
# File 'lib/whats_app_cloud_api/models/button.rb', line 19 def title @title end |
#type ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/whats_app_cloud_api/models/button.rb', line 14 def type @type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/whats_app_cloud_api/models/button.rb', line 57 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. type = hash['type'] ||= 'reply' title = hash.key?('title') ? hash['title'] : SKIP id = hash.key?('id') ? hash['id'] : SKIP # Create object from extracted values. Button.new(type, title, id) end |
.names ⇒ Object
A mapping from model property names to API property names.
27 28 29 30 31 32 33 |
# File 'lib/whats_app_cloud_api/models/button.rb', line 27 def self.names @_hash = {} if @_hash.nil? @_hash['type'] = 'type' @_hash['title'] = 'title' @_hash['id'] = 'id' @_hash end |
Instance Method Details
#nullables ⇒ Object
An array for nullable fields
44 45 46 |
# File 'lib/whats_app_cloud_api/models/button.rb', line 44 def nullables [] end |
#optionals ⇒ Object
An array for optional fields
36 37 38 39 40 41 |
# File 'lib/whats_app_cloud_api/models/button.rb', line 36 def optionals %w[ title id ] end |