Class: Whatsapp::Webhook::Message::System

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

Overview

A system notice, e.g. that the customer changed their phone number.

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(body:, identity:, wa_id:, change_type:, **base_attributes) ⇒ System

Returns a new instance of System.



24
25
26
27
28
29
30
31
# File 'lib/ruby/whatsapp/webhook/message/system.rb', line 24

def initialize(body:, identity:, wa_id:, change_type:, **base_attributes)
  super(**base_attributes)

  @body = body
  @identity = identity
  @wa_id = wa_id
  @change_type = change_type
end

Instance Attribute Details

#bodyString?

Returns Human-readable description of the change.

Returns:

  • (String, nil)

    Human-readable description of the change.



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

def body
  @body
end

#change_typeString?

Returns e.g. "customer_changed_number", "customer_identity_changed".

Returns:

  • (String, nil)

    e.g. "customer_changed_number", "customer_identity_changed".



22
23
24
# File 'lib/ruby/whatsapp/webhook/message/system.rb', line 22

def change_type
  @change_type
end

#identityString?

Returns:

  • (String, nil)


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

def identity
  @identity
end

#wa_idString?

Returns The customer's (possibly new) WhatsApp ID.

Returns:

  • (String, nil)

    The customer's (possibly new) WhatsApp ID.



18
19
20
# File 'lib/ruby/whatsapp/webhook/message/system.rb', line 18

def wa_id
  @wa_id
end

Class Method Details

.deserialize(data) ⇒ System

Parameters:

  • data (Hash)

    The raw message hash.

Returns:



36
37
38
39
40
41
42
43
44
# File 'lib/ruby/whatsapp/webhook/message/system.rb', line 36

def deserialize(data)
  new(
    body: data.dig("system", "body"),
    identity: data.dig("system", "identity"),
    wa_id: data.dig("system", "wa_id"),
    change_type: data.dig("system", "type"),
    **common_attributes(data)
  )
end