Class: Telnyx::Resources::EmailInboxes::Messages

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/email_inboxes/messages.rb,
lib/telnyx/resources/email_inboxes/messages/labels.rb,
lib/telnyx/resources/email_inboxes/messages/actions.rb,
sig/telnyx/resources/email_inboxes/messages.rbs,
sig/telnyx/resources/email_inboxes/messages/labels.rbs,
sig/telnyx/resources/email_inboxes/messages/actions.rbs

Defined Under Namespace

Classes: Actions, Labels

Instance Attribute Summary collapse

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:



183
184
185
186
187
# File 'lib/telnyx/resources/email_inboxes/messages.rb', line 183

def initialize(client:)
  @client = client
  @actions = Telnyx::Resources::EmailInboxes::Messages::Actions.new(client: client)
  @labels = Telnyx::Resources::EmailInboxes::Messages::Labels.new(client: client)
end

Instance Attribute Details

#actionsTelnyx::Resources::EmailInboxes::Messages::Actions (readonly)

Create and manage agent inboxes, retrieve inbound messages and threads, and reply to or forward messages.



10
11
12
# File 'lib/telnyx/resources/email_inboxes/messages.rb', line 10

def actions
  @actions
end

#labelsTelnyx::Resources::EmailInboxes::Messages::Labels (readonly)

Create and manage agent inboxes, retrieve inbound messages and threads, and reply to or forward messages.



15
16
17
# File 'lib/telnyx/resources/email_inboxes/messages.rb', line 15

def labels
  @labels
end

Instance Method Details

#drafts(message_id, inbox_id:, attachments: nil, bcc: nil, cc: nil, from_email: nil, from_name: nil, headers: nil, html: nil, html_body: nil, labels: nil, metadata: nil, reply_to: nil, subject: nil, tags: nil, text: nil, text_body: nil, to: nil, request_options: {}) ⇒ Telnyx::Models::EmailInboxes::EmailDraftResponse

Creates an unsent reply draft for an inbound message. Unlike the /actions/reply endpoint, which sends immediately, this stores a draft that can be reviewed and edited before sending.

reply_to_message_id and thread_id are inherited from the parent message and cannot be set by the caller. The recipient, Re: subject and In-Reply-To/References headers are pre-filled from the parent using the same rules as a live reply, so sending the draft threads identically. Supplying to or subject explicitly overrides the pre-filled value.

Parameters:

  • message_id (String)

    Path param: Inbound message UUID to reply to.

  • inbox_id (String)

    Path param: Email inbox UUID.

  • attachments (Array<Object>)

    Body param

  • bcc (Array<String, Telnyx::Models::EmailInboxes::EmailAddress>)

    Body param

  • cc (Array<String, Telnyx::Models::EmailInboxes::EmailAddress>)

    Body param

  • from_email (String)

    Body param

  • from_name (String)

    Body param

  • headers (Hash{Symbol=>String})

    Body param

  • html (String)

    Body param: Alias for html_body, matching the send endpoint.

  • html_body (String)

    Body param

  • labels (Array<String>)

    Body param

  • metadata (Object)

    Body param

  • reply_to (String)

    Body param

  • subject (String)

    Body param

  • tags (Array<String>)

    Body param

  • text (String)

    Body param: Alias for text_body, matching the send endpoint.

  • text_body (String)

    Body param

  • to (Array<String, Telnyx::Models::EmailInboxes::EmailAddress>)

    Body param

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

Returns:

See Also:



165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/telnyx/resources/email_inboxes/messages.rb', line 165

def drafts(message_id, params)
  parsed, options = Telnyx::EmailInboxes::MessageDraftsParams.dump_request(params)
  inbox_id =
    parsed.delete(:inbox_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["email_inboxes/%1$s/messages/%2$s/drafts", inbox_id, message_id],
    body: parsed,
    model: Telnyx::EmailInboxes::EmailDraftResponse,
    options: options
  )
end

#list(inbox_id, filter_from: nil, filter_label: nil, filter_read: nil, filter_received_after: nil, filter_received_before: nil, filter_search: nil, filter_subject: nil, filter_unread: nil, page_after: nil, page_size: nil, request_options: {}) ⇒ Telnyx::Models::EmailInboxes::MessageListResponse

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

Lists inbound messages newest first. All access is scoped to the authenticated account. filter[search] performs PostgreSQL full-text search over the subject, plain-text body, and HTML body. Filters compose with stable cursor pagination.

Parameters:

  • inbox_id (String)

    Email inbox UUID.

  • filter_from (String)

    Case-insensitive literal substring of the sender address.

  • filter_label (String)

    Returns only messages carrying this label. Matching is exact and case-sensitive.

  • filter_read (Boolean)

    Whether the message has a read timestamp.

  • filter_received_after (Time)

    Inclusive ISO 8601 lower bound for the received timestamp.

  • filter_received_before (Time)

    Inclusive ISO 8601 upper bound for the received timestamp.

  • filter_search (String)

    Full-text query over subject and body, up to 500 characters.

  • filter_subject (String)

    Case-insensitive literal substring of the subject.

  • filter_unread (Boolean)

    Whether the message has no read timestamp. Set to true to return only unread m

  • page_after (String)

    Opaque cursor returned by the previous page.

  • page_size (Integer)

    Number of results to return. Defaults to 25; maximum is 100.

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

Returns:

See Also:



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/telnyx/resources/email_inboxes/messages.rb', line 89

def list(inbox_id, params = {})
  parsed, options = Telnyx::EmailInboxes::MessageListParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["email_inboxes/%1$s/messages", inbox_id],
    query: query.transform_keys(
      filter_from: "filter[from]",
      filter_label: "filter[label]",
      filter_read: "filter[read]",
      filter_received_after: "filter[received_after]",
      filter_received_before: "filter[received_before]",
      filter_search: "filter[search]",
      filter_subject: "filter[subject]",
      filter_unread: "filter[unread]",
      page_after: "page[after]",
      page_size: "page[size]"
    ),
    model: Telnyx::Models::EmailInboxes::MessageListResponse,
    options: options
  )
end

#update(message_id, inbox_id:, read_at:, request_options: {}) ⇒ Telnyx::Models::EmailInboxes::MessageUpdateResponse

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

Updates the explicit read state of an account-scoped inbound message. Set read_at to true to mark the message read at the server's current time, to an ISO 8601 timestamp to use that timestamp, or to null to mark the message unread. Repeating the same update is idempotent.

Parameters:

Returns:

See Also:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/telnyx/resources/email_inboxes/messages.rb', line 38

def update(message_id, params)
  parsed, options = Telnyx::EmailInboxes::MessageUpdateParams.dump_request(params)
  inbox_id =
    parsed.delete(:inbox_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :patch,
    path: ["email_inboxes/%1$s/messages/%2$s", inbox_id, message_id],
    body: parsed,
    model: Telnyx::Models::EmailInboxes::MessageUpdateResponse,
    options: options
  )
end