Class: Whatsapp::Webhook::Message::Unknown

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

Overview

Fallback for a message type not in MESSAGE_TYPES — either a type Meta added after this gem was released, or a message the Cloud API itself couldn't process (carries an errors[] array in that case).

Instance Attribute Summary collapse

Attributes inherited from Base

#context, #from, #id, #referral, #timestamp, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

common_attributes

Constructor Details

#initialize(raw:, errors:, **base_attributes) ⇒ Unknown

Returns a new instance of Unknown.



18
19
20
21
22
23
# File 'lib/ruby/whatsapp/webhook/message/unknown.rb', line 18

def initialize(raw:, errors:, **base_attributes)
  super(**base_attributes)

  @raw = raw
  @errors = errors
end

Instance Attribute Details

#errorsArray<Error>

Returns:



16
17
18
# File 'lib/ruby/whatsapp/webhook/message/unknown.rb', line 16

def errors
  @errors
end

#rawHash

Returns The full, untyped raw message hash.

Returns:

  • (Hash)

    The full, untyped raw message hash.



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

def raw
  @raw
end

Class Method Details

.deserialize(data) ⇒ Unknown

Parameters:

  • data (Hash)

    The raw message hash.

Returns:



28
29
30
31
32
33
34
# File 'lib/ruby/whatsapp/webhook/message/unknown.rb', line 28

def deserialize(data)
  new(
    raw: data,
    errors: Array(data["errors"]).map { |error_data| Error.deserialize(error_data) },
    **common_attributes(data)
  )
end