Class: WhatsAppCloudApi::Image
- Defined in:
- lib/whats_app_cloud_api/models/image.rb
Overview
Image Model.
Instance Attribute Summary collapse
-
#caption ⇒ String
Describes the specified image media.
-
#id ⇒ String
The media object ID.
-
#link ⇒ String
The protocol and URL of the media to be sent.
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(id = nil, link = nil, caption = nil) ⇒ Image
constructor
A new instance of Image.
-
#nullables ⇒ Object
An array for nullable fields.
-
#optionals ⇒ Object
An array for optional fields.
Methods inherited from BaseModel
Constructor Details
#initialize(id = nil, link = nil, caption = nil) ⇒ Image
Returns a new instance of Image.
48 49 50 51 52 53 54 |
# File 'lib/whats_app_cloud_api/models/image.rb', line 48 def initialize(id = nil, link = nil, caption = nil) @id = id unless id == SKIP @link = link unless link == SKIP @caption = caption unless caption == SKIP end |
Instance Attribute Details
#caption ⇒ String
Describes the specified image media.
23 24 25 |
# File 'lib/whats_app_cloud_api/models/image.rb', line 23 def caption @caption end |
#id ⇒ String
The media object ID. Required when you are not using a link.
14 15 16 |
# File 'lib/whats_app_cloud_api/models/image.rb', line 14 def id @id end |
#link ⇒ String
The protocol and URL of the media to be sent. Use only with HTTP/HTTPS URLs. Required when you are not using an uploaded media ID.
19 20 21 |
# File 'lib/whats_app_cloud_api/models/image.rb', line 19 def link @link 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/image.rb', line 57 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : SKIP link = hash.key?('link') ? hash['link'] : SKIP caption = hash.key?('caption') ? hash['caption'] : SKIP # Create object from extracted values. Image.new(id, link, caption) end |
.names ⇒ Object
A mapping from model property names to API property names.
26 27 28 29 30 31 32 |
# File 'lib/whats_app_cloud_api/models/image.rb', line 26 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['link'] = 'link' @_hash['caption'] = 'caption' @_hash end |
Instance Method Details
#nullables ⇒ Object
An array for nullable fields
44 45 46 |
# File 'lib/whats_app_cloud_api/models/image.rb', line 44 def nullables [] end |
#optionals ⇒ Object
An array for optional fields
35 36 37 38 39 40 41 |
# File 'lib/whats_app_cloud_api/models/image.rb', line 35 def optionals %w[ id link caption ] end |