Class: WhatsAppCloudApi::Document
- Defined in:
- lib/whats_app_cloud_api/models/document.rb
Overview
Document Model.
Instance Attribute Summary collapse
-
#caption ⇒ String
Describes the specified document media.
-
#filename ⇒ String
Describes the filename for the specific document.
-
#id ⇒ String
It is 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, filename = nil) ⇒ Document
constructor
A new instance of Document.
-
#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, filename = nil) ⇒ Document
Returns a new instance of Document.
54 55 56 57 58 59 60 61 62 |
# File 'lib/whats_app_cloud_api/models/document.rb', line 54 def initialize(id = nil, link = nil, caption = nil, filename = nil) @id = id unless id == SKIP @link = link unless link == SKIP @caption = caption unless caption == SKIP @filename = filename unless filename == SKIP end |
Instance Attribute Details
#caption ⇒ String
Describes the specified document media.
23 24 25 |
# File 'lib/whats_app_cloud_api/models/document.rb', line 23 def caption @caption end |
#filename ⇒ String
Describes the filename for the specific document.
27 28 29 |
# File 'lib/whats_app_cloud_api/models/document.rb', line 27 def filename @filename end |
#id ⇒ String
It is the media object ID. Required when you are not using a link.
14 15 16 |
# File 'lib/whats_app_cloud_api/models/document.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/document.rb', line 19 def link @link end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/whats_app_cloud_api/models/document.rb', line 65 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 filename = hash.key?('filename') ? hash['filename'] : SKIP # Create object from extracted values. Document.new(id, link, caption, filename) end |
.names ⇒ Object
A mapping from model property names to API property names.
30 31 32 33 34 35 36 37 |
# File 'lib/whats_app_cloud_api/models/document.rb', line 30 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['link'] = 'link' @_hash['caption'] = 'caption' @_hash['filename'] = 'filename' @_hash end |
Instance Method Details
#nullables ⇒ Object
An array for nullable fields
50 51 52 |
# File 'lib/whats_app_cloud_api/models/document.rb', line 50 def nullables [] end |
#optionals ⇒ Object
An array for optional fields
40 41 42 43 44 45 46 47 |
# File 'lib/whats_app_cloud_api/models/document.rb', line 40 def optionals %w[ id link caption filename ] end |