Class: Sentdm::Resources::Messages

Inherits:
Object
  • Object
show all
Defined in:
lib/sentdm/resources/messages.rb

Overview

Send and track SMS and WhatsApp messages

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Messages

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Messages.

Parameters:



107
108
109
# File 'lib/sentdm/resources/messages.rb', line 107

def initialize(client:)
  @client = client
end

Instance Method Details

#retrieve_activities(id, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::MessageRetrieveActivitiesResponse

Some parameter documentations has been truncated, see Models::MessageRetrieveActivitiesParams for more details.

Retrieves the activity log for a specific message. Activities track the message lifecycle including acceptance, processing, sending, delivery, and any errors.

Parameters:

  • id (String)

    Message ID from route parameter

  • x_profile_id (String)

    Profile UUID to scope the request to a child profile. Only organization API keys

  • request_options (Sentdm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



24
25
26
27
28
29
30
31
32
33
# File 'lib/sentdm/resources/messages.rb', line 24

def retrieve_activities(id, params = {})
  parsed, options = Sentdm::MessageRetrieveActivitiesParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["v3/messages/%1$s/activities", id],
    headers: parsed.transform_keys(x_profile_id: "x-profile-id"),
    model: Sentdm::Models::MessageRetrieveActivitiesResponse,
    options: options
  )
end

#retrieve_status(id, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::MessageRetrieveStatusResponse

Some parameter documentations has been truncated, see Models::MessageRetrieveStatusParams for more details.

Retrieves the current status and details of a message by ID. Includes delivery status, timestamps, and error information if applicable.

Parameters:

  • id (String)

    Message ID

  • x_profile_id (String)

    Profile UUID to scope the request to a child profile. Only organization API keys

  • request_options (Sentdm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



52
53
54
55
56
57
58
59
60
61
# File 'lib/sentdm/resources/messages.rb', line 52

def retrieve_status(id, params = {})
  parsed, options = Sentdm::MessageRetrieveStatusParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["v3/messages/%1$s", id],
    headers: parsed.transform_keys(x_profile_id: "x-profile-id"),
    model: Sentdm::Models::MessageRetrieveStatusResponse,
    options: options
  )
end

#send_(channel: nil, sandbox: nil, template: nil, to: nil, idempotency_key: nil, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::MessageSendResponse

Some parameter documentations has been truncated, see Models::MessageSendParams for more details.

Sends a message to one or more recipients using a template. Supports multi-channel broadcast — when multiple channels are specified (e.g. [“sms”, “whatsapp”]), a separate message is created for each (recipient, channel) pair. Returns immediately with per-recipient message IDs for async tracking via webhooks or the GET /messages/id endpoint.

Parameters:

  • channel (Array<String>, nil)

    Body param: Channels to broadcast on, e.g. [“whatsapp”, “sms”].

  • sandbox (Boolean)

    Body param: Sandbox flag - when true, the operation is simulated without side ef

  • template (Sentdm::Models::MessageSendParams::Template)

    Body param: SDK-style template reference: resolve by ID or by name, with optiona

  • to (Array<String>)

    Body param: List of recipient phone numbers in E.164 format (multi-recipient fan

  • idempotency_key (String)

    Header param: Unique key to ensure idempotent request processing. Must be 1-255

  • x_profile_id (String)

    Header param: Profile UUID to scope the request to a child profile. Only organiz

  • request_options (Sentdm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/sentdm/resources/messages.rb', line 91

def send_(params = {})
  parsed, options = Sentdm::MessageSendParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"}
  @client.request(
    method: :post,
    path: "v3/messages",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Sentdm::Models::MessageSendResponse,
    options: options
  )
end