Class: WhatsAppCloudApi::Section
- Defined in:
- lib/whats_app_cloud_api/models/section.rb
Overview
Section Model.
Instance Attribute Summary collapse
-
#rows ⇒ List of Row
Required for List Messages.
-
#title ⇒ String
Required if the message has more than one section.
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(title = nil, rows = nil) ⇒ Section
constructor
A new instance of Section.
-
#nullables ⇒ Object
An array for nullable fields.
-
#optionals ⇒ Object
An array for optional fields.
Methods inherited from BaseModel
Constructor Details
#initialize(title = nil, rows = nil) ⇒ Section
Returns a new instance of Section.
44 45 46 47 48 |
# File 'lib/whats_app_cloud_api/models/section.rb', line 44 def initialize(title = nil, rows = nil) @title = title unless title == SKIP @rows = rows unless rows == SKIP end |
Instance Attribute Details
#rows ⇒ List of Row
Required for List Messages. Contains a list of rows. You can have a total of 10 rows across your sections. Each row must have a title (Maximum length: 24 characters) and an ID (Maximum length: 200 characters). You can add a description (Maximum length: 72 characters), but it is optional.
21 22 23 |
# File 'lib/whats_app_cloud_api/models/section.rb', line 21 def rows @rows end |
#title ⇒ String
Required if the message has more than one section. Title of the section.
14 15 16 |
# File 'lib/whats_app_cloud_api/models/section.rb', line 14 def title @title end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/whats_app_cloud_api/models/section.rb', line 51 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. title = hash.key?('title') ? hash['title'] : SKIP # Parameter is an array, so we need to iterate through it rows = nil unless hash['rows'].nil? rows = [] hash['rows'].each do |structure| rows << (Row.from_hash(structure) if structure) end end rows = SKIP unless hash.key?('rows') # Create object from extracted values. Section.new(title, rows) end |
.names ⇒ Object
A mapping from model property names to API property names.
24 25 26 27 28 29 |
# File 'lib/whats_app_cloud_api/models/section.rb', line 24 def self.names @_hash = {} if @_hash.nil? @_hash['title'] = 'title' @_hash['rows'] = 'rows' @_hash end |
Instance Method Details
#nullables ⇒ Object
An array for nullable fields
40 41 42 |
# File 'lib/whats_app_cloud_api/models/section.rb', line 40 def nullables [] end |
#optionals ⇒ Object
An array for optional fields
32 33 34 35 36 37 |
# File 'lib/whats_app_cloud_api/models/section.rb', line 32 def optionals %w[ title rows ] end |