Class: Courier::Resources::Send

Inherits:
Object
  • Object
show all
Defined in:
lib/courier/resources/send.rb,
sig/courier/resources/send.rbs

Overview

Send a message to one or more recipients — users, lists, audiences, or tenants — across every channel you have configured.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Send

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 Send.

Parameters:



44
45
46
# File 'lib/courier/resources/send.rb', line 44

def initialize(client:)
  @client = client
end

Instance Method Details

#message(message:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::SendMessageResponse

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

Sends a message to one or more recipients and returns a requestId. Courier routes it to email, SMS, push, chat, or in-app based on your rules.

Parameters:

  • message (Courier::Models::SendMessageParams::Message)

    Body param: The message property has the following primary top-level properties.

  • idempotency_key (String)

    Header param: A unique key that makes this request idempotent. If Courier receiv

  • x_idempotency_expiration (String)

    Header param: How long the idempotency key remains valid, as a Unix epoch timest

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

Returns:

See Also:



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/courier/resources/send.rb', line 27

def message(params)
  parsed, options = Courier::SendMessageParams.dump_request(params)
  header_params =
    {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"}
  @client.request(
    method: :post,
    path: "send",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Courier::Models::SendMessageResponse,
    options: options
  )
end