Class: Whatsapp::Webhook::Message::Text

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

Overview

An inbound plain-text message.

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:, **base_attributes) ⇒ Text

Returns a new instance of Text.



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

def initialize(body:, **base_attributes)
  super(**base_attributes)

  @body = body
end

Instance Attribute Details

#bodyString?

Returns:

  • (String, nil)


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

def body
  @body
end

Class Method Details

.deserialize(data) ⇒ Text

Parameters:

  • data (Hash)

    The raw message hash.

Returns:



21
22
23
# File 'lib/ruby/whatsapp/webhook/message/text.rb', line 21

def deserialize(data)
  new(body: data.dig("text", "body"), **common_attributes(data))
end