Class: Whatsapp::Webhook::Message::Audio

Inherits:
Media
  • Object
show all
Defined in:
lib/ruby/whatsapp/webhook/message/audio.rb

Overview

An inbound audio message (voice note or audio clip).

Constant Summary

Constants included from ResponseHandling

ResponseHandling::MAX_ERROR_BODY

Instance Attribute Summary collapse

Attributes inherited from Media

#client

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Media

#delete, #download, #get_url, #upload

Constructor Details

#initialize(voice: nil, **media_and_base_attributes) ⇒ Audio

Returns a new instance of Audio.



12
13
14
15
16
# File 'lib/ruby/whatsapp/webhook/message/audio.rb', line 12

def initialize(voice: nil, **media_and_base_attributes)
  super(**media_and_base_attributes)

  @voice = voice
end

Instance Attribute Details

#voiceBoolean?

Returns Whether this was recorded as a voice note.

Returns:

  • (Boolean, nil)

    Whether this was recorded as a voice note.



10
11
12
# File 'lib/ruby/whatsapp/webhook/message/audio.rb', line 10

def voice
  @voice
end

Class Method Details

.deserialize(data) ⇒ Audio

Parameters:

  • data (Hash)

    The raw message hash.

Returns:



21
22
23
# File 'lib/ruby/whatsapp/webhook/message/audio.rb', line 21

def deserialize(data)
  new(voice: data.dig("audio", "voice"), **media_attributes(data, "audio"), **common_attributes(data))
end