Class: WhatsappSdk::Resource::MediaComponent
- Inherits:
-
Object
- Object
- WhatsappSdk::Resource::MediaComponent
- Defined in:
- lib/whatsapp_sdk/resource/media_component.rb
Defined Under Namespace
Modules: Type Classes: InvalidMedia
Instance Attribute Summary collapse
-
#caption ⇒ Object
Describes the specified document or image media.
-
#filename ⇒ Object
Describes the filename for the specific document.
-
#id ⇒ Object
Returns media id.
-
#link ⇒ Object
The protocol and URL of the media to be sent.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type:, id: nil, link: nil, caption: nil, filename: nil) ⇒ MediaComponent
constructor
A new instance of MediaComponent.
- #to_json ⇒ Object
Constructor Details
#initialize(type:, id: nil, link: nil, caption: nil, filename: nil) ⇒ MediaComponent
Returns a new instance of MediaComponent.
50 51 52 53 54 55 56 57 |
# File 'lib/whatsapp_sdk/resource/media_component.rb', line 50 def initialize(type:, id: nil, link: nil, caption: nil, filename: nil) @type = type @id = id @link = link @caption = caption @filename = filename validate_media end |
Instance Attribute Details
#caption ⇒ Object
Describes the specified document or image media.
43 44 45 |
# File 'lib/whatsapp_sdk/resource/media_component.rb', line 43 def caption @caption end |
#filename ⇒ Object
Describes the filename for the specific document. Use only with document media.
48 49 50 |
# File 'lib/whatsapp_sdk/resource/media_component.rb', line 48 def filename @filename end |
#id ⇒ Object
Returns media id.
21 22 23 |
# File 'lib/whatsapp_sdk/resource/media_component.rb', line 21 def id @id end |
#link ⇒ Object
The protocol and URL of the media to be sent. Use only with HTTP/HTTPS URLs. Do not use this field when the message type is set to text.
38 39 40 |
# File 'lib/whatsapp_sdk/resource/media_component.rb', line 38 def link @link end |
#type ⇒ Object
Returns the value of attribute type.
32 33 34 |
# File 'lib/whatsapp_sdk/resource/media_component.rb', line 32 def type @type end |
Instance Method Details
#to_json ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/whatsapp_sdk/resource/media_component.rb', line 59 def to_json json = {} json[:id] = id unless id.nil? json[:link] = link unless link.nil? json[:caption] = caption unless caption.nil? json[:filename] = filename unless filename.nil? json end |