Class: WhatsAppCloudApi::Action
- Defined in:
- lib/whats_app_cloud_api/models/action.rb
Overview
Action Model.
Instance Attribute Summary collapse
-
#button ⇒ String
Required for List Messages.
-
#buttons ⇒ List of Button
Required for Reply Buttons.
-
#sections ⇒ List of Section
Required for List Messages.
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(button = nil, buttons = nil, sections = nil) ⇒ Action
constructor
A new instance of Action.
-
#nullables ⇒ Object
An array for nullable fields.
-
#optionals ⇒ Object
An array for optional fields.
Methods inherited from BaseModel
Constructor Details
#initialize(button = nil, buttons = nil, sections = nil) ⇒ Action
Returns a new instance of Action.
50 51 52 53 54 55 56 |
# File 'lib/whats_app_cloud_api/models/action.rb', line 50 def initialize( = nil, = nil, sections = nil) @button = unless == SKIP @buttons = unless == SKIP @sections = sections unless sections == SKIP end |
Instance Attribute Details
#button ⇒ String
Required for List Messages. Button content. It cannot be an empty string and must be unique within the message. Emojis are supported, markdown is not.
16 17 18 |
# File 'lib/whats_app_cloud_api/models/action.rb', line 16 def @button end |
#buttons ⇒ List of Button
Required for Reply Buttons. You can have up to 3 buttons. You cannot have leading or trailing spaces when setting the ID.
21 22 23 |
# File 'lib/whats_app_cloud_api/models/action.rb', line 21 def @buttons end |
#sections ⇒ List of Section
Required for List Messages.
25 26 27 |
# File 'lib/whats_app_cloud_api/models/action.rb', line 25 def sections @sections end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/whats_app_cloud_api/models/action.rb', line 59 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. = hash.key?('button') ? hash['button'] : SKIP # Parameter is an array, so we need to iterate through it = nil unless hash['buttons'].nil? = [] hash['buttons'].each do |structure| << (Button.from_hash(structure) if structure) end end = SKIP unless hash.key?('buttons') # Parameter is an array, so we need to iterate through it sections = nil unless hash['sections'].nil? sections = [] hash['sections'].each do |structure| sections << (Section.from_hash(structure) if structure) end end sections = SKIP unless hash.key?('sections') # Create object from extracted values. Action.new(, , sections) 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/action.rb', line 28 def self.names @_hash = {} if @_hash.nil? @_hash['button'] = 'button' @_hash['buttons'] = 'buttons' @_hash['sections'] = 'sections' @_hash end |
Instance Method Details
#nullables ⇒ Object
An array for nullable fields
46 47 48 |
# File 'lib/whats_app_cloud_api/models/action.rb', line 46 def nullables [] end |
#optionals ⇒ Object
An array for optional fields
37 38 39 40 41 42 43 |
# File 'lib/whats_app_cloud_api/models/action.rb', line 37 def optionals %w[ button buttons sections ] end |