Class: Whatsapp::Webhook::Message::Context

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

Overview

Present when an inbound message replies to a previous one (e.g. a reply swipe, or a tap on an interactive button/list from an earlier message).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from:, id:, forwarded: nil, frequently_forwarded: nil) ⇒ Context

Returns a new instance of Context.



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

def initialize(from:, id:, forwarded: nil, frequently_forwarded: nil)
  @from = from
  @id = id
  @forwarded = forwarded
  @frequently_forwarded = frequently_forwarded
end

Instance Attribute Details

#forwardedBoolean?

Returns:

  • (Boolean, nil)


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

def forwarded
  @forwarded
end

#frequently_forwardedBoolean?

Returns:

  • (Boolean, nil)


23
24
25
# File 'lib/ruby/whatsapp/webhook/message/context.rb', line 23

def frequently_forwarded
  @frequently_forwarded
end

#fromString?

Returns:

  • (String, nil)


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

def from
  @from
end

#idString?

Returns The wamid of the message being replied to.

Returns:

  • (String, nil)

    The wamid of the message being replied to.



15
16
17
# File 'lib/ruby/whatsapp/webhook/message/context.rb', line 15

def id
  @id
end

Class Method Details

.deserialize(data) ⇒ Context?

Parameters:

  • data (Hash, nil)

    The raw context hash.

Returns:



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

def deserialize(data)
  return if data.nil?

  new(
    from: data["from"],
    id: data["id"],
    forwarded: data["forwarded"],
    frequently_forwarded: data["frequently_forwarded"]
  )
end