Class: WhatsAppCloudApi::Header
- Defined in:
- lib/whats_app_cloud_api/models/header.rb
Overview
Header Model.
Instance Attribute Summary collapse
-
#document ⇒ Document
Required if type is set to document.
-
#image ⇒ Image
Required if type is set to image.
-
#text ⇒ String
Required if type is set to text.
-
#type ⇒ HeaderTypeEnum
The header type you would like to use.
-
#video ⇒ Video
Required if type is set to video.
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, text = nil, video = nil, image = nil, document = nil) ⇒ Header
constructor
A new instance of Header.
-
#nullables ⇒ Object
An array for nullable fields.
-
#optionals ⇒ Object
An array for optional fields.
Methods inherited from BaseModel
Constructor Details
#initialize(type = nil, text = nil, video = nil, image = nil, document = nil) ⇒ Header
Returns a new instance of Header.
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/whats_app_cloud_api/models/header.rb', line 62 def initialize(type = nil, text = nil, video = nil, image = nil, document = nil) @type = type unless type == SKIP @text = text unless text == SKIP @video = video unless video == SKIP @image = image unless image == SKIP @document = document unless document == SKIP end |
Instance Attribute Details
#document ⇒ Document
Required if type is set to document. Contains the media object for this document.
34 35 36 |
# File 'lib/whats_app_cloud_api/models/header.rb', line 34 def document @document end |
#image ⇒ Image
Required if type is set to image. Contains the media object for this image.
29 30 31 |
# File 'lib/whats_app_cloud_api/models/header.rb', line 29 def image @image end |
#text ⇒ String
Required if type is set to text. Text for the header. Formatting allows emojis, but not markdown.
19 20 21 |
# File 'lib/whats_app_cloud_api/models/header.rb', line 19 def text @text end |
#type ⇒ HeaderTypeEnum
The header type you would like to use.
14 15 16 |
# File 'lib/whats_app_cloud_api/models/header.rb', line 14 def type @type end |
#video ⇒ Video
Required if type is set to video. Contains the media object for this video.
24 25 26 |
# File 'lib/whats_app_cloud_api/models/header.rb', line 24 def video @video end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/whats_app_cloud_api/models/header.rb', line 75 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. type = hash.key?('type') ? hash['type'] : SKIP text = hash.key?('text') ? hash['text'] : SKIP video = Video.from_hash(hash['video']) if hash['video'] image = Image.from_hash(hash['image']) if hash['image'] document = Document.from_hash(hash['document']) if hash['document'] # Create object from extracted values. Header.new(type, text, video, image, document) end |
.names ⇒ Object
A mapping from model property names to API property names.
37 38 39 40 41 42 43 44 45 |
# File 'lib/whats_app_cloud_api/models/header.rb', line 37 def self.names @_hash = {} if @_hash.nil? @_hash['type'] = 'type' @_hash['text'] = 'text' @_hash['video'] = 'video' @_hash['image'] = 'image' @_hash['document'] = 'document' @_hash end |
Instance Method Details
#nullables ⇒ Object
An array for nullable fields
58 59 60 |
# File 'lib/whats_app_cloud_api/models/header.rb', line 58 def nullables [] end |
#optionals ⇒ Object
An array for optional fields
48 49 50 51 52 53 54 55 |
# File 'lib/whats_app_cloud_api/models/header.rb', line 48 def optionals %w[ text video image document ] end |