Class: Whatsapp::Webhook::History

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

Overview

Chat history synchronization for onboarded business customers.

Best-effort schema: Meta's public docs describe this field in one line with no published JSON example; threads' entry shape isn't confidently typeable from that description alone, so it's kept as a raw array rather than guessing further. Validate against a real payload before relying on this in production. Source: https://developers.facebook.com/documentation/business-messaging/whatsapp/webhooks/overview

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(phase:, chunk_order:, progress:, threads:) ⇒ History

Returns a new instance of History.



30
31
32
33
34
35
# File 'lib/ruby/whatsapp/webhook/history.rb', line 30

def initialize(phase:, chunk_order:, progress:, threads:)
  @phase = phase
  @chunk_order = chunk_order
  @progress = progress
  @threads = threads
end

Instance Attribute Details

#chunk_orderInteger?

Returns:

  • (Integer, nil)


20
21
22
# File 'lib/ruby/whatsapp/webhook/history.rb', line 20

def chunk_order
  @chunk_order
end

#phaseInteger?

Returns:

  • (Integer, nil)


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

def phase
  @phase
end

#progressInteger?

Returns:

  • (Integer, nil)


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

def progress
  @progress
end

#threadsArray<Hash>

Returns:

  • (Array<Hash>)


28
29
30
# File 'lib/ruby/whatsapp/webhook/history.rb', line 28

def threads
  @threads
end

Class Method Details

.deserialize(data) ⇒ History

Parameters:

  • data (Hash)

    The raw value hash.

Returns:



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ruby/whatsapp/webhook/history.rb', line 40

def deserialize(data)
  data ||= {}
   = data["metadata"] || {}

  new(
    phase: ["phase"],
    chunk_order: ["chunk_order"],
    progress: ["progress"],
    threads: Array(data["threads"])
  )
end