Class: Whatsapp::Messages::Image
- Defined in:
- lib/ruby/whatsapp/messages/image.rb
Overview
Image messages display an image with an optional caption. Source: https://developers.facebook.com/documentation/business-messaging/whatsapp/messages/image-messages
To send an image you must either:
- Upload the image via Whatsapp::Media#upload to obtain a media_id, then pass it as `id`
- Pass a publicly hosted URL as `link` (not recommended by Meta)
Defined Under Namespace
Modules: Defaults
Instance Attribute Summary collapse
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(id: nil, link: nil, caption: nil) ⇒ Image
constructor
A new instance of Image.
-
#serialize ⇒ Hash
Serializes the image message to a hash format suitable for the WhatsApp API.
Constructor Details
#initialize(id: nil, link: nil, caption: nil) ⇒ Image
Returns a new instance of Image.
36 37 38 39 40 41 42 43 44 |
# File 'lib/ruby/whatsapp/messages/image.rb', line 36 def initialize(id: nil, link: nil, caption: nil, **) super(**) @id = id @link = link @caption = caption validate! end |
Instance Attribute Details
#caption ⇒ String?
26 27 28 |
# File 'lib/ruby/whatsapp/messages/image.rb', line 26 def caption @caption end |
#id ⇒ String?
18 19 20 |
# File 'lib/ruby/whatsapp/messages/image.rb', line 18 def id @id end |
#link ⇒ String?
22 23 24 |
# File 'lib/ruby/whatsapp/messages/image.rb', line 22 def link @link end |