Class: Whatsapp::Webhook::UnknownField

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/whatsapp/webhook/unknown_field.rb

Overview

Fallback value wrapper for any webhook field not in Change::FIELDS — either a field Meta added after this gem was released, or one deliberately left generic. Keeps the raw hash accessible instead of raising on an unrecognized notification.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw:) ⇒ UnknownField

Returns a new instance of UnknownField.



13
14
15
# File 'lib/ruby/whatsapp/webhook/unknown_field.rb', line 13

def initialize(raw:)
  @raw = raw
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



11
12
13
# File 'lib/ruby/whatsapp/webhook/unknown_field.rb', line 11

def raw
  @raw
end

Class Method Details

.deserialize(data) ⇒ UnknownField

Parameters:

  • data (Hash, nil)

    The raw value hash.

Returns:



31
32
33
# File 'lib/ruby/whatsapp/webhook/unknown_field.rb', line 31

def deserialize(data)
  new(raw: data || {})
end

Instance Method Details

#[](key) ⇒ Object?

Parameters:

  • key (String)

Returns:

  • (Object, nil)


19
20
21
# File 'lib/ruby/whatsapp/webhook/unknown_field.rb', line 19

def [](key)
  raw[key]
end

#to_hHash

Returns:

  • (Hash)


24
25
26
# File 'lib/ruby/whatsapp/webhook/unknown_field.rb', line 24

def to_h
  raw
end