Class: Trycourier::Resources::Messages

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

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:



154
155
156
# File 'lib/trycourier/resources/messages.rb', line 154

def initialize(client:)
  @client = client
end

Instance Method Details

#cancel(message_id, request_options: {}) ⇒ Trycourier::Models::MessageDetails

Cancel a message that is currently in the process of being delivered. A well-formatted API call to the cancel message API will return either ‘200` status code for a successful cancellation or `409` status code for an unsuccessful cancellation. Both cases will include the actual message record in the response body (see details below).

Parameters:

  • message_id (String)

    A unique identifier representing the message ID

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

Returns:

See Also:



95
96
97
98
99
100
101
102
# File 'lib/trycourier/resources/messages.rb', line 95

def cancel(message_id, params = {})
  @client.request(
    method: :post,
    path: ["messages/%1$s/cancel", message_id],
    model: Trycourier::MessageDetails,
    options: params[:request_options]
  )
end

#content(message_id, request_options: {}) ⇒ Trycourier::Models::MessageContentResponse

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

Get message content

Parameters:

  • message_id (String)

    A unique identifier associated with the message you wish to retrieve (results fr

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

Returns:

See Also:



118
119
120
121
122
123
124
125
# File 'lib/trycourier/resources/messages.rb', line 118

def content(message_id, params = {})
  @client.request(
    method: :get,
    path: ["messages/%1$s/output", message_id],
    model: Trycourier::Models::MessageContentResponse,
    options: params[:request_options]
  )
end

#history(message_id, type: nil, request_options: {}) ⇒ Trycourier::Models::MessageHistoryResponse

Fetch the array of events of a message you’ve previously sent.

Parameters:

  • message_id (String)

    A unique identifier representing the message ID

  • type (String, nil)

    A supported Message History type that will filter the events returned.

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

Returns:

See Also:



140
141
142
143
144
145
146
147
148
149
# File 'lib/trycourier/resources/messages.rb', line 140

def history(message_id, params = {})
  parsed, options = Trycourier::MessageHistoryParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["messages/%1$s/history", message_id],
    query: parsed,
    model: Trycourier::Models::MessageHistoryResponse,
    options: 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: {}) ⇒ Trycourier::Models::MessageListResponse

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

Fetch the statuses of messages you’ve previously sent.

Parameters:

  • archived (Boolean, nil)

    A boolean value that indicates whether archived messages should be included in t

  • cursor (String, nil)

    A unique identifier that allows for fetching the next set of messages.

  • enqueued_after (String, nil)

    The enqueued datetime of a message to filter out messages received before.

  • event (String, nil)

    A unique identifier representing the event that was used to send the event.

  • list (String, nil)

    A unique identifier representing the list the message was sent to.

  • message_id (String, nil)

    A unique identifier representing the message_id returned from either /send or /s

  • notification (String, nil)

    A unique identifier representing the notification that was used to send the even

  • provider (Array<String, nil>)

    The key assocated to the provider you want to filter on. E.g., sendgrid, inbox,

  • recipient (String, nil)

    A unique identifier representing the recipient associated with the requested pro

  • status (Array<String, nil>)

    An indicator of the current status of the message. Allows multiple values to be

  • tag (Array<String, nil>)

    A tag placed in the metadata.tags during a notification send. Allows multiple va

  • tags (String, nil)

    A comma delimited list of ‘tags’. Messages will be returned if they match any of

  • tenant_id (String, nil)

    Messages sent with the context of a Tenant

  • trace_id (String, nil)

    The unique identifier used to trace the requests

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

Returns:

See Also:



69
70
71
72
73
74
75
76
77
78
# File 'lib/trycourier/resources/messages.rb', line 69

def list(params = {})
  parsed, options = Trycourier::MessageListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "messages",
    query: parsed.transform_keys(message_id: "messageId", trace_id: "traceId"),
    model: Trycourier::Models::MessageListResponse,
    options: options
  )
end

#retrieve(message_id, request_options: {}) ⇒ Trycourier::Models::MessageRetrieveResponse

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

Fetch the status of a message you’ve previously sent.

Parameters:

  • message_id (String)

    A unique identifier associated with the message you wish to retrieve (results fr

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

Returns:

See Also:



20
21
22
23
24
25
26
27
# File 'lib/trycourier/resources/messages.rb', line 20

def retrieve(message_id, params = {})
  @client.request(
    method: :get,
    path: ["messages/%1$s", message_id],
    model: Trycourier::Models::MessageRetrieveResponse,
    options: params[:request_options]
  )
end