Class: Whatsapp::Messages::Audio
- Defined in:
- lib/ruby/whatsapp/messages/audio.rb
Overview
Audio messages allow you to send an audio file to a WhatsApp user. Source: https://developers.facebook.com/documentation/business-messaging/whatsapp/messages/audio-messages
Audio messages do not support captions. To send audio you must either:
- Upload the audio 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) ⇒ Audio
constructor
A new instance of Audio.
-
#serialize ⇒ Hash
Serializes the audio message to a hash format suitable for the WhatsApp API.
Constructor Details
#initialize(id: nil, link: nil) ⇒ Audio
Returns a new instance of Audio.
30 31 32 33 34 35 36 37 |
# File 'lib/ruby/whatsapp/messages/audio.rb', line 30 def initialize(id: nil, link: nil, **) super(**) @id = id @link = link validate! end |
Instance Attribute Details
#id ⇒ String?
18 19 20 |
# File 'lib/ruby/whatsapp/messages/audio.rb', line 18 def id @id end |
#link ⇒ String?
22 23 24 |
# File 'lib/ruby/whatsapp/messages/audio.rb', line 22 def link @link end |