Class: WhatsAppCloudApi::Parameter
- Defined in:
- lib/whats_app_cloud_api/models/parameter.rb
Overview
Parameter Model.
Instance Attribute Summary collapse
-
#currency ⇒ Currency
Required when type=currency.
-
#date_time ⇒ DateTimeObject
Required when type=date_time.
-
#document ⇒ Document
Required when type=document.
-
#image ⇒ Image
Required when type=image.
-
#text ⇒ String
Required when type=text.
-
#type ⇒ ParameterTypeEnum
Describes the parameter type.
-
#video ⇒ Video
Required when type=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, currency = nil, date_time = nil, image = nil, document = nil, video = nil) ⇒ Parameter
constructor
A new instance of Parameter.
-
#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, currency = nil, date_time = nil, image = nil, document = nil, video = nil) ⇒ Parameter
Returns a new instance of Parameter.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/whats_app_cloud_api/models/parameter.rb', line 74 def initialize(type = nil, text = nil, currency = nil, date_time = nil, image = nil, document = nil, video = nil) @type = type unless type == SKIP @text = text unless text == SKIP @currency = currency unless currency == SKIP @date_time = date_time unless date_time == SKIP @image = image unless image == SKIP @document = document unless document == SKIP @video = video unless video == SKIP end |
Instance Attribute Details
#currency ⇒ Currency
Required when type=currency.
25 26 27 |
# File 'lib/whats_app_cloud_api/models/parameter.rb', line 25 def currency @currency end |
#date_time ⇒ DateTimeObject
Required when type=date_time.
29 30 31 |
# File 'lib/whats_app_cloud_api/models/parameter.rb', line 29 def date_time @date_time end |
#document ⇒ Document
Required when type=document. Only PDF documents are supported for media-based message templates.
38 39 40 |
# File 'lib/whats_app_cloud_api/models/parameter.rb', line 38 def document @document end |
#image ⇒ Image
Required when type=image.
33 34 35 |
# File 'lib/whats_app_cloud_api/models/parameter.rb', line 33 def image @image end |
#text ⇒ String
Required when type=text. The message’s text. For the header component, the character limit is 60 characters. For the body component, the character limit is 1024 characters.
21 22 23 |
# File 'lib/whats_app_cloud_api/models/parameter.rb', line 21 def text @text end |
#type ⇒ ParameterTypeEnum
Describes the parameter type. For text-based templates, the only supported parameter types are text, currency, date_time.
15 16 17 |
# File 'lib/whats_app_cloud_api/models/parameter.rb', line 15 def type @type end |
#video ⇒ Video
Required when type=video.
42 43 44 |
# File 'lib/whats_app_cloud_api/models/parameter.rb', line 42 def video @video end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/whats_app_cloud_api/models/parameter.rb', line 91 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 currency = Currency.from_hash(hash['currency']) if hash['currency'] date_time = DateTimeObject.from_hash(hash['date_time']) if hash['date_time'] image = Image.from_hash(hash['image']) if hash['image'] document = Document.from_hash(hash['document']) if hash['document'] video = Video.from_hash(hash['video']) if hash['video'] # Create object from extracted values. Parameter.new(type, text, currency, date_time, image, document, video) end |
.names ⇒ Object
A mapping from model property names to API property names.
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/whats_app_cloud_api/models/parameter.rb', line 45 def self.names @_hash = {} if @_hash.nil? @_hash['type'] = 'type' @_hash['text'] = 'text' @_hash['currency'] = 'currency' @_hash['date_time'] = 'date_time' @_hash['image'] = 'image' @_hash['document'] = 'document' @_hash['video'] = 'video' @_hash end |
Instance Method Details
#nullables ⇒ Object
An array for nullable fields
70 71 72 |
# File 'lib/whats_app_cloud_api/models/parameter.rb', line 70 def nullables [] end |
#optionals ⇒ Object
An array for optional fields
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/whats_app_cloud_api/models/parameter.rb', line 58 def optionals %w[ text currency date_time image document video ] end |