Class: Whatsapp::Messages::MarkMessageAsRead

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/ruby/whatsapp/messages/mark_message_as_read.rb

Overview

Marks a previously received message (and every earlier message in the conversation) as read. Unlike every other message class, this has no recipient or type envelope — it targets an existing message by ID. Meta requires this within 30 days of receipt. Source: https://developers.facebook.com/documentation/business-messaging/whatsapp/messages/mark-message-as-read

Defined Under Namespace

Modules: Defaults

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message_id:) ⇒ MarkMessageAsRead

Returns a new instance of MarkMessageAsRead.

Parameters:

  • message_id (String)

    The WhatsApp message ID (WAMID) to mark as read. @raise [ActiveModel::ValidationError] if validation fails.



26
27
28
29
30
# File 'lib/ruby/whatsapp/messages/mark_message_as_read.rb', line 26

def initialize(message_id:)
  @message_id = message_id

  validate!
end

Instance Attribute Details

#message_idString

Returns:

  • (String)


20
21
22
# File 'lib/ruby/whatsapp/messages/mark_message_as_read.rb', line 20

def message_id
  @message_id
end

Instance Method Details

#serializeHash

Returns Serialized representation for the WhatsApp API.

Returns:

  • (Hash)

    Serialized representation for the WhatsApp API.



33
34
35
36
37
38
39
# File 'lib/ruby/whatsapp/messages/mark_message_as_read.rb', line 33

def serialize
  {
    messaging_product: Defaults::MESSAGING_PRODUCT,
    status: Defaults::STATUS,
    message_id:,
  }
end