Class: Telnyx::Resources::Messages

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/messages.rb,
lib/telnyx/resources/messages/rcs.rb

Defined Under Namespace

Classes: Rcs

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:



421
422
423
424
# File 'lib/telnyx/resources/messages.rb', line 421

def initialize(client:)
  @client = client
  @rcs = Telnyx::Resources::Messages::Rcs.new(client: client)
end

Instance Attribute Details

#rcsTelnyx::Resources::Messages::Rcs (readonly)

Send RCS messages



8
9
10
# File 'lib/telnyx/resources/messages.rb', line 8

def rcs
  @rcs
end

Instance Method Details

#cancel_scheduled(id, request_options: {}) ⇒ Telnyx::Models::MessageCancelScheduledResponse

Cancel a scheduled message that has not yet been sent. Only messages with ‘status=scheduled` and `send_at` more than a minute from now can be cancelled.

Parameters:

  • id (String)

    The id of the message to cancel

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

Returns:

See Also:



45
46
47
48
49
50
51
52
# File 'lib/telnyx/resources/messages.rb', line 45

def cancel_scheduled(id, params = {})
  @client.request(
    method: :delete,
    path: ["messages/%1$s", id],
    model: Telnyx::Models::MessageCancelScheduledResponse,
    options: params[:request_options]
  )
end

#retrieve(id, request_options: {}) ⇒ Telnyx::Models::MessageRetrieveResponse

Note: This API endpoint can only retrieve messages that are no older than 10 days since their creation. If you require messages older than this, please generate an [MDR report.](developers.telnyx.com/api-reference/mdr-usage-reports/create-mdr-usage-report)

Parameters:

Returns:

See Also:



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

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

#retrieve_group_messages(message_id, request_options: {}) ⇒ Telnyx::Models::MessageRetrieveGroupMessagesResponse

Retrieve all messages in a group MMS conversation by the group message ID.

Parameters:

  • message_id (String)

    The group message ID.

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

Returns:

See Also:



65
66
67
68
69
70
71
72
# File 'lib/telnyx/resources/messages.rb', line 65

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

#schedule(to:, auto_detect: nil, from: nil, media_urls: nil, messaging_profile_id: nil, send_at: nil, subject: nil, text: nil, type: nil, use_profile_webhooks: nil, webhook_failover_url: nil, webhook_url: nil, request_options: {}) ⇒ Telnyx::Models::MessageScheduleResponse

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

Schedule a message with a Phone Number, Alphanumeric Sender ID, Short Code or Number Pool.

This endpoint allows you to schedule a message with any messaging resource. Current messaging resources include: long-code, short-code, number-pool, and alphanumeric-sender-id.

Parameters:

  • to (String)

    Receiving address (+E.164 formatted phone number or short code).

  • auto_detect (Boolean)

    Automatically detect if an SMS message is unusually long and exceeds a recommend

  • from (String)

    Sending address (+E.164 formatted phone number, alphanumeric sender ID, or short

  • media_urls (Array<String>)

    A list of media URLs. The total media size must be less than 1 MB.

  • messaging_profile_id (String)

    Unique identifier for a messaging profile.

  • send_at (Time)

    ISO 8601 formatted date indicating when to send the message - accurate up till a

  • subject (String)

    Subject of multimedia message

  • text (String)

    Message body (i.e., content) as a non-empty string.

  • type (Symbol, Telnyx::Models::MessageScheduleParams::Type)

    The protocol for sending the message, either SMS or MMS.

  • use_profile_webhooks (Boolean)

    If the profile this number is associated with has webhooks, use them for deliver

  • webhook_failover_url (String)

    The failover URL where webhooks related to this message will be sent if sending

  • webhook_url (String)

    The URL where webhooks related to this message will be sent.

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

Returns:

See Also:



115
116
117
118
119
120
121
122
123
124
# File 'lib/telnyx/resources/messages.rb', line 115

def schedule(params)
  parsed, options = Telnyx::MessageScheduleParams.dump_request(params)
  @client.request(
    method: :post,
    path: "messages/schedule",
    body: parsed,
    model: Telnyx::Models::MessageScheduleResponse,
    options: options
  )
end

#send_(to:, auto_detect: nil, encoding: nil, from: nil, media_urls: nil, messaging_profile_id: nil, send_at: nil, subject: nil, text: nil, type: nil, use_profile_webhooks: nil, webhook_failover_url: nil, webhook_url: nil, request_options: {}) ⇒ Telnyx::Models::MessageSendResponse

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

Send a message with a Phone Number, Alphanumeric Sender ID, Short Code or Number Pool.

This endpoint allows you to send a message with any messaging resource. Current messaging resources include: long-code, short-code, number-pool, and alphanumeric-sender-id.

Parameters:

  • to (String)

    Receiving address (+E.164 formatted phone number or short code).

  • auto_detect (Boolean)

    Automatically detect if an SMS message is unusually long and exceeds a recommend

  • encoding (Symbol, Telnyx::Models::MessageSendParams::Encoding)

    Encoding to use for the message. ‘auto` (default) uses smart encoding to automat

  • from (String)

    Sending address (+E.164 formatted phone number, alphanumeric sender ID, or short

  • media_urls (Array<String>)

    A list of media URLs. The total media size must be less than 1 MB.

  • messaging_profile_id (String)

    Unique identifier for a messaging profile.

  • send_at (Time, nil)

    ISO 8601 formatted date indicating when to send the message - accurate up till a

  • subject (String)

    Subject of multimedia message

  • text (String)

    Message body (i.e., content) as a non-empty string.

  • type (Symbol, Telnyx::Models::MessageSendParams::Type)

    The protocol for sending the message, either SMS or MMS.

  • use_profile_webhooks (Boolean)

    If the profile this number is associated with has webhooks, use them for deliver

  • webhook_failover_url (String)

    The failover URL where webhooks related to this message will be sent if sending

  • webhook_url (String)

    The URL where webhooks related to this message will be sent.

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

Returns:

See Also:



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

def send_(params)
  parsed, options = Telnyx::MessageSendParams.dump_request(params)
  @client.request(
    method: :post,
    path: "messages",
    body: parsed,
    model: Telnyx::Models::MessageSendResponse,
    options: options
  )
end

#send_group_mms(from:, to:, media_urls: nil, subject: nil, text: nil, use_profile_webhooks: nil, webhook_failover_url: nil, webhook_url: nil, request_options: {}) ⇒ Telnyx::Models::MessageSendGroupMmsResponse

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

Send a group MMS message

Parameters:

  • from (String)

    Phone number, in +E.164 format, used to send the message.

  • to (Array<String>)

    A list of destinations. No more than 8 destinations are allowed.

  • media_urls (Array<String>)

    A list of media URLs. The total media size must be less than 1 MB.

  • subject (String)

    Subject of multimedia message

  • text (String)

    Message body (i.e., content) as a non-empty string.

  • use_profile_webhooks (Boolean)

    If the profile this number is associated with has webhooks, use them for deliver

  • webhook_failover_url (String)

    The failover URL where webhooks related to this message will be sent if sending

  • webhook_url (String)

    The URL where webhooks related to this message will be sent.

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

Returns:

See Also:



208
209
210
211
212
213
214
215
216
217
# File 'lib/telnyx/resources/messages.rb', line 208

def send_group_mms(params)
  parsed, options = Telnyx::MessageSendGroupMmsParams.dump_request(params)
  @client.request(
    method: :post,
    path: "messages/group_mms",
    body: parsed,
    model: Telnyx::Models::MessageSendGroupMmsResponse,
    options: options
  )
end

#send_long_code(from:, to:, auto_detect: nil, encoding: nil, media_urls: nil, subject: nil, text: nil, type: nil, use_profile_webhooks: nil, webhook_failover_url: nil, webhook_url: nil, request_options: {}) ⇒ Telnyx::Models::MessageSendLongCodeResponse

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

Send a long code message

Parameters:

  • from (String)

    Phone number, in +E.164 format, used to send the message.

  • to (String)

    Receiving address (+E.164 formatted phone number or short code).

  • auto_detect (Boolean)

    Automatically detect if an SMS message is unusually long and exceeds a recommend

  • encoding (Symbol, Telnyx::Models::MessageSendLongCodeParams::Encoding)

    Encoding to use for the message. ‘auto` (default) uses smart encoding to automat

  • media_urls (Array<String>)

    A list of media URLs. The total media size must be less than 1 MB.

  • subject (String)

    Subject of multimedia message

  • text (String)

    Message body (i.e., content) as a non-empty string.

  • type (Symbol, Telnyx::Models::MessageSendLongCodeParams::Type)

    The protocol for sending the message, either SMS or MMS.

  • use_profile_webhooks (Boolean)

    If the profile this number is associated with has webhooks, use them for deliver

  • webhook_failover_url (String)

    The failover URL where webhooks related to this message will be sent if sending

  • webhook_url (String)

    The URL where webhooks related to this message will be sent.

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

Returns:

See Also:



253
254
255
256
257
258
259
260
261
262
# File 'lib/telnyx/resources/messages.rb', line 253

def send_long_code(params)
  parsed, options = Telnyx::MessageSendLongCodeParams.dump_request(params)
  @client.request(
    method: :post,
    path: "messages/long_code",
    body: parsed,
    model: Telnyx::Models::MessageSendLongCodeResponse,
    options: options
  )
end

#send_number_pool(messaging_profile_id:, to:, auto_detect: nil, encoding: nil, media_urls: nil, subject: nil, text: nil, type: nil, use_profile_webhooks: nil, webhook_failover_url: nil, webhook_url: nil, request_options: {}) ⇒ Telnyx::Models::MessageSendNumberPoolResponse

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

Send a message using number pool

Parameters:

  • messaging_profile_id (String)

    Unique identifier for a messaging profile.

  • to (String)

    Receiving address (+E.164 formatted phone number or short code).

  • auto_detect (Boolean)

    Automatically detect if an SMS message is unusually long and exceeds a recommend

  • encoding (Symbol, Telnyx::Models::MessageSendNumberPoolParams::Encoding)

    Encoding to use for the message. ‘auto` (default) uses smart encoding to automat

  • media_urls (Array<String>)

    A list of media URLs. The total media size must be less than 1 MB.

  • subject (String)

    Subject of multimedia message

  • text (String)

    Message body (i.e., content) as a non-empty string.

  • type (Symbol, Telnyx::Models::MessageSendNumberPoolParams::Type)

    The protocol for sending the message, either SMS or MMS.

  • use_profile_webhooks (Boolean)

    If the profile this number is associated with has webhooks, use them for deliver

  • webhook_failover_url (String)

    The failover URL where webhooks related to this message will be sent if sending

  • webhook_url (String)

    The URL where webhooks related to this message will be sent.

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

Returns:

See Also:



298
299
300
301
302
303
304
305
306
307
# File 'lib/telnyx/resources/messages.rb', line 298

def send_number_pool(params)
  parsed, options = Telnyx::MessageSendNumberPoolParams.dump_request(params)
  @client.request(
    method: :post,
    path: "messages/number_pool",
    body: parsed,
    model: Telnyx::Models::MessageSendNumberPoolResponse,
    options: options
  )
end

#send_short_code(from:, to:, auto_detect: nil, encoding: nil, media_urls: nil, subject: nil, text: nil, type: nil, use_profile_webhooks: nil, webhook_failover_url: nil, webhook_url: nil, request_options: {}) ⇒ Telnyx::Models::MessageSendShortCodeResponse

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

Send a short code message

Parameters:

  • from (String)

    Phone number, in +E.164 format, used to send the message.

  • to (String)

    Receiving address (+E.164 formatted phone number or short code).

  • auto_detect (Boolean)

    Automatically detect if an SMS message is unusually long and exceeds a recommend

  • encoding (Symbol, Telnyx::Models::MessageSendShortCodeParams::Encoding)

    Encoding to use for the message. ‘auto` (default) uses smart encoding to automat

  • media_urls (Array<String>)

    A list of media URLs. The total media size must be less than 1 MB.

  • subject (String)

    Subject of multimedia message

  • text (String)

    Message body (i.e., content) as a non-empty string.

  • type (Symbol, Telnyx::Models::MessageSendShortCodeParams::Type)

    The protocol for sending the message, either SMS or MMS.

  • use_profile_webhooks (Boolean)

    If the profile this number is associated with has webhooks, use them for deliver

  • webhook_failover_url (String)

    The failover URL where webhooks related to this message will be sent if sending

  • webhook_url (String)

    The URL where webhooks related to this message will be sent.

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

Returns:

See Also:



343
344
345
346
347
348
349
350
351
352
# File 'lib/telnyx/resources/messages.rb', line 343

def send_short_code(params)
  parsed, options = Telnyx::MessageSendShortCodeParams.dump_request(params)
  @client.request(
    method: :post,
    path: "messages/short_code",
    body: parsed,
    model: Telnyx::Models::MessageSendShortCodeResponse,
    options: options
  )
end

#send_whatsapp(from:, to:, whatsapp_message:, type: nil, webhook_url: nil, request_options: {}) ⇒ Telnyx::Models::MessageSendWhatsappResponse

Send a Whatsapp message

Parameters:

Returns:

See Also:



373
374
375
376
377
378
379
380
381
382
# File 'lib/telnyx/resources/messages.rb', line 373

def send_whatsapp(params)
  parsed, options = Telnyx::MessageSendWhatsappParams.dump_request(params)
  @client.request(
    method: :post,
    path: "messages/whatsapp",
    body: parsed,
    model: Telnyx::Models::MessageSendWhatsappResponse,
    options: options
  )
end

#send_with_alphanumeric_sender(from:, messaging_profile_id:, text:, to:, use_profile_webhooks: nil, webhook_failover_url: nil, webhook_url: nil, request_options: {}) ⇒ Telnyx::Models::MessageSendWithAlphanumericSenderResponse

Send an SMS message using an alphanumeric sender ID. This is SMS only.

Parameters:

  • from (String)

    A valid alphanumeric sender ID on the user’s account.

  • messaging_profile_id (String)

    The messaging profile ID to use.

  • text (String)

    The message body.

  • to (String)

    Receiving address (+E.164 formatted phone number).

  • use_profile_webhooks (Boolean)

    If true, use the messaging profile’s webhook settings.

  • webhook_failover_url (String, nil)

    Failover callback URL for delivery status updates.

  • webhook_url (String, nil)

    Callback URL for delivery status updates.

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

Returns:

See Also:



407
408
409
410
411
412
413
414
415
416
# File 'lib/telnyx/resources/messages.rb', line 407

def send_with_alphanumeric_sender(params)
  parsed, options = Telnyx::MessageSendWithAlphanumericSenderParams.dump_request(params)
  @client.request(
    method: :post,
    path: "messages/alphanumeric_sender_id",
    body: parsed,
    model: Telnyx::Models::MessageSendWithAlphanumericSenderResponse,
    options: options
  )
end