Class: Whatsapp::Messages::Document
- Defined in:
- lib/ruby/whatsapp/messages/document.rb
Overview
Document messages allow you to send a document file with an optional caption and custom filename. Source: https://developers.facebook.com/documentation/business-messaging/whatsapp/messages/document-messages
To send a document you must either:
- Upload the document 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, filename: nil) ⇒ Document
constructor
A new instance of Document.
-
#serialize ⇒ Hash
Serializes the document message to a hash format suitable for the WhatsApp API.
Constructor Details
#initialize(id: nil, link: nil, caption: nil, filename: nil) ⇒ Document
Returns a new instance of Document.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ruby/whatsapp/messages/document.rb', line 41 def initialize(id: nil, link: nil, caption: nil, filename: nil, **) super(**) @id = id @link = link @caption = caption @filename = filename validate! end |
Instance Attribute Details
#caption ⇒ String?
26 27 28 |
# File 'lib/ruby/whatsapp/messages/document.rb', line 26 def caption @caption end |
#filename ⇒ String?
30 31 32 |
# File 'lib/ruby/whatsapp/messages/document.rb', line 30 def filename @filename end |
#id ⇒ String?
18 19 20 |
# File 'lib/ruby/whatsapp/messages/document.rb', line 18 def id @id end |
#link ⇒ String?
22 23 24 |
# File 'lib/ruby/whatsapp/messages/document.rb', line 22 def link @link end |