Class: Whatsapp::Messages::Reaction

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby/whatsapp/messages/reaction.rb

Overview

Reaction messages are emoji-reactions applied to a WhatsApp message you have received. Source: https://developers.facebook.com/documentation/business-messaging/whatsapp/messages/reaction-messages

Defined Under Namespace

Modules: Defaults

Instance Attribute Summary collapse

Attributes inherited from Base

#to

Instance Method Summary collapse

Constructor Details

#initialize(message_id:, emoji:) ⇒ Reaction

Returns a new instance of Reaction.

Parameters:

  • message_id (String)

    The ID of the message being reacted to.

  • emoji (String)

    The emoji used for the reaction.

  • kwargs (Hash)

    Additional keyword arguments. @raise [ActiveModel::ValidationError] if validation fails.



27
28
29
30
31
32
33
34
# File 'lib/ruby/whatsapp/messages/reaction.rb', line 27

def initialize(message_id:, emoji:, **)
  super(**)

  @message_id = message_id
  @emoji = emoji

  validate!
end

Instance Attribute Details

#emojiString

Returns:

  • (String)


18
19
20
# File 'lib/ruby/whatsapp/messages/reaction.rb', line 18

def emoji
  @emoji
end

#message_idString

Returns:

  • (String)


14
15
16
# File 'lib/ruby/whatsapp/messages/reaction.rb', line 14

def message_id
  @message_id
end

Instance Method Details

#serializeHash

Serializes the reaction message to a hash format suitable for the WhatsApp API.

Returns:

  • (Hash)

    The serialized reaction message.



38
39
40
# File 'lib/ruby/whatsapp/messages/reaction.rb', line 38

def serialize
  envelope(type: Defaults::TYPE, reaction: { message_id:, emoji: })
end