Class: WhatsappSdk::Resource::ParameterObject
- Inherits:
-
Object
- Object
- WhatsappSdk::Resource::ParameterObject
- Defined in:
- lib/whatsapp_sdk/resource/parameter_object.rb
Defined Under Namespace
Modules: Format, Type Classes: InvalidType
Instance Attribute Summary collapse
-
#currency ⇒ Object
Returns Currency if the parameter object type is currency.
-
#date_time ⇒ Object
Returns date_time if the parameter object type is date_time.
-
#document ⇒ Object
Returns document if the parameter object type is document.
-
#image ⇒ Object
Returns image if the parameter object type is image.
-
#location ⇒ Object
Returns location if the parameter object type is location.
-
#text ⇒ Object
Returns Text string if the parameter object type is text.
-
#type ⇒ Object
Returns the parameter type.
-
#video ⇒ Object
Returns video if the parameter object type is video.
Instance Method Summary collapse
-
#initialize(type:, text: nil, currency: nil, date_time: nil, image: nil, document: nil, video: nil, location: nil) ⇒ ParameterObject
constructor
A new instance of ParameterObject.
- #to_json ⇒ Object
Constructor Details
#initialize(type:, text: nil, currency: nil, date_time: nil, image: nil, document: nil, video: nil, location: nil) ⇒ ParameterObject
Returns a new instance of ParameterObject.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/whatsapp_sdk/resource/parameter_object.rb', line 95 def initialize( type:, text: nil, currency: nil, date_time: nil, image: nil, document: nil, video: nil, location: nil ) @type = type @text = text @currency = currency @date_time = date_time @image = image @document = document @video = video @location = location validate end |
Instance Attribute Details
#currency ⇒ Object
Returns Currency if the parameter object type is currency.
68 69 70 |
# File 'lib/whatsapp_sdk/resource/parameter_object.rb', line 68 def currency @currency end |
#date_time ⇒ Object
Returns date_time if the parameter object type is date_time.
73 74 75 |
# File 'lib/whatsapp_sdk/resource/parameter_object.rb', line 73 def date_time @date_time end |
#document ⇒ Object
Returns document if the parameter object type is document.
83 84 85 |
# File 'lib/whatsapp_sdk/resource/parameter_object.rb', line 83 def document @document end |
#image ⇒ Object
Returns image if the parameter object type is image.
78 79 80 |
# File 'lib/whatsapp_sdk/resource/parameter_object.rb', line 78 def image @image end |
#location ⇒ Object
Returns location if the parameter object type is location
93 94 95 |
# File 'lib/whatsapp_sdk/resource/parameter_object.rb', line 93 def location @location end |
#text ⇒ Object
Returns Text string if the parameter object type is text. For the header component, the character limit is 60 characters. For the body component, the character limit is 1024 characters.
63 64 65 |
# File 'lib/whatsapp_sdk/resource/parameter_object.rb', line 63 def text @text end |
#type ⇒ Object
Returns the parameter type.
19 20 21 |
# File 'lib/whatsapp_sdk/resource/parameter_object.rb', line 19 def type @type end |
#video ⇒ Object
Returns video if the parameter object type is video.
88 89 90 |
# File 'lib/whatsapp_sdk/resource/parameter_object.rb', line 88 def video @video end |
Instance Method Details
#to_json ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/whatsapp_sdk/resource/parameter_object.rb', line 116 def to_json json = { type: type } json[type.to_sym] = case type when "text" text when "currency" currency.to_json when "date_time" date_time.to_json when "image" image.to_json when "document" document.to_json when "video" video.to_json when "location" location.to_json else raise "Invalid type: #{type}" end json end |