Class: Courier::Resources::Messages
- Inherits:
-
Object
- Object
- Courier::Resources::Messages
- Defined in:
- lib/courier/resources/messages.rb,
sig/courier/resources/messages.rbs
Overview
Look up the messages Courier has accepted, inspect their delivery history and rendered output, and cancel, resend, or archive them.
Instance Method Summary collapse
-
#cancel(message_id, request_options: {}) ⇒ Courier::Models::MessageDetails
Cancels a message that is still in the delivery pipeline and returns the message record with its resulting canceled or failed status.
-
#content(message_id, request_options: {}) ⇒ Courier::Models::MessageContentResponse
Some parameter documentations has been truncated, see Models::MessageContentParams for more details.
-
#history(message_id, type: nil, request_options: {}) ⇒ Courier::Models::MessageHistoryResponse
Returns the ordered event history for a sent message, one entry per status transition with its timestamp.
-
#initialize(client:) ⇒ Messages
constructor
private
A new instance of Messages.
-
#list(archived: nil, cursor: nil, enqueued_after: nil, event: nil, list: nil, message_id: nil, notification: nil, provider: nil, recipient: nil, status: nil, tag: nil, tags: nil, tenant_id: nil, trace_id: nil, request_options: {}) ⇒ Courier::Models::MessageListResponse
Some parameter documentations has been truncated, see Models::MessageListParams for more details.
-
#resend(message_id, request_options: {}) ⇒ Courier::Models::MessageResendResponse
Some parameter documentations has been truncated, see Models::MessageResendParams for more details.
-
#retrieve(message_id, request_options: {}) ⇒ Courier::Models::MessageRetrieveResponse
Some parameter documentations has been truncated, see Models::MessageRetrieveParams for more details.
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.
183 184 185 |
# File 'lib/courier/resources/messages.rb', line 183 def initialize(client:) @client = client end |
Instance Method Details
#cancel(message_id, request_options: {}) ⇒ Courier::Models::MessageDetails
Cancels a message that is still in the delivery pipeline and returns the message record with its resulting canceled or failed status.
97 98 99 100 101 102 103 104 |
# File 'lib/courier/resources/messages.rb', line 97 def cancel(, params = {}) @client.request( method: :post, path: ["messages/%1$s/cancel", ], model: Courier::MessageDetails, options: params[:request_options] ) end |
#content(message_id, request_options: {}) ⇒ Courier::Models::MessageContentResponse
Some parameter documentations has been truncated, see Models::MessageContentParams for more details.
Returns the rendered content Courier delivered for a message, broken out per channel, to confirm what the recipient received.
121 122 123 124 125 126 127 128 |
# File 'lib/courier/resources/messages.rb', line 121 def content(, params = {}) @client.request( method: :get, path: ["messages/%1$s/output", ], model: Courier::Models::MessageContentResponse, options: params[:request_options] ) end |
#history(message_id, type: nil, request_options: {}) ⇒ Courier::Models::MessageHistoryResponse
Returns the ordered event history for a sent message, one entry per status transition with its timestamp.
144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/courier/resources/messages.rb', line 144 def history(, params = {}) parsed, = Courier::MessageHistoryParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["messages/%1$s/history", ], query: query, model: Courier::Models::MessageHistoryResponse, options: ) end |
#list(archived: nil, cursor: nil, enqueued_after: nil, event: nil, list: nil, message_id: nil, notification: nil, provider: nil, recipient: nil, status: nil, tag: nil, tags: nil, tenant_id: nil, trace_id: nil, request_options: {}) ⇒ Courier::Models::MessageListResponse
Some parameter documentations has been truncated, see Models::MessageListParams for more details.
Returns previously sent messages, most recent first, each carrying its status, recipient, channel, and provider. Paged by cursor.
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/courier/resources/messages.rb', line 73 def list(params = {}) parsed, = Courier::MessageListParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "messages", query: query.transform_keys(message_id: "messageId", trace_id: "traceId"), model: Courier::Models::MessageListResponse, options: ) end |
#resend(message_id, request_options: {}) ⇒ Courier::Models::MessageResendResponse
Some parameter documentations has been truncated, see Models::MessageResendParams for more details.
Resends a previously sent message to the same recipient and content, returning a new messageId. The original send request is not modified.
171 172 173 174 175 176 177 178 |
# File 'lib/courier/resources/messages.rb', line 171 def resend(, params = {}) @client.request( method: :post, path: ["messages/%1$s/resend", ], model: Courier::Models::MessageResendResponse, options: params[:request_options] ) end |
#retrieve(message_id, request_options: {}) ⇒ Courier::Models::MessageRetrieveResponse
Some parameter documentations has been truncated, see Models::MessageRetrieveParams for more details.
Returns a sent message's status, recipient, event, and per-provider delivery detail, with timestamps for enqueued, sent, delivered, opened, and clicked.
23 24 25 26 27 28 29 30 |
# File 'lib/courier/resources/messages.rb', line 23 def retrieve(, params = {}) @client.request( method: :get, path: ["messages/%1$s", ], model: Courier::Models::MessageRetrieveResponse, options: params[:request_options] ) end |