Class: Whatsapp::Webhook::Entry

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

Overview

A single entry[] item — one WhatsApp Business Account, with one or more changes[] (each a distinct notification).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, changes:) ⇒ Entry

Returns a new instance of Entry.



16
17
18
19
# File 'lib/ruby/whatsapp/webhook/entry.rb', line 16

def initialize(id:, changes:)
  @id = id
  @changes = changes
end

Instance Attribute Details

#changesArray<Change>

Returns:



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

def changes
  @changes
end

#idString

Returns:

  • (String)


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

def id
  @id
end

Class Method Details

.deserialize(data) ⇒ Entry

Parameters:

  • data (Hash)

    A raw entry[] item.

Returns:



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

def deserialize(data)
  data ||= {}

  new(
    id: data["id"],
    changes: Array(data["changes"]).map { |change_data| Change.deserialize(change_data) }
  )
end