Class: Whatsapp::Webhook::SmbAppStateSync::StateSync

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

Overview

A single contact-sync entry within an smb_app_state_sync notification.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, action:, contact:) ⇒ StateSync

Returns a new instance of StateSync.



20
21
22
23
24
# File 'lib/ruby/whatsapp/webhook/smb_app_state_sync/state_sync.rb', line 20

def initialize(type:, action:, contact:)
  @type = type
  @action = action
  @contact = contact
end

Instance Attribute Details

#actionString?

Returns e.g. "add", "remove", "update".

Returns:

  • (String, nil)

    e.g. "add", "remove", "update".



14
15
16
# File 'lib/ruby/whatsapp/webhook/smb_app_state_sync/state_sync.rb', line 14

def action
  @action
end

#contactHash

Returns Left untyped — Meta's docs don't publish this entry's schema.

Returns:

  • (Hash)

    Left untyped — Meta's docs don't publish this entry's schema.



18
19
20
# File 'lib/ruby/whatsapp/webhook/smb_app_state_sync/state_sync.rb', line 18

def contact
  @contact
end

#typeString?

Returns:

  • (String, nil)


10
11
12
# File 'lib/ruby/whatsapp/webhook/smb_app_state_sync/state_sync.rb', line 10

def type
  @type
end

Class Method Details

.deserialize(data) ⇒ StateSync

Parameters:

  • data (Hash)

    A raw state_sync[] entry.

Returns:



29
30
31
32
33
# File 'lib/ruby/whatsapp/webhook/smb_app_state_sync/state_sync.rb', line 29

def deserialize(data)
  data ||= {}

  new(type: data["type"], action: data["action"], contact: data["contact"] || {})
end