Class: PreludeSDK::Resources::Notify

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

Overview

Send transactional and marketing messages with compliance enforcement.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Notify

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

Parameters:



299
300
301
# File 'lib/prelude_sdk/resources/notify.rb', line 299

def initialize(client:)
  @client = client
end

Instance Method Details

#get_subscription_config(config_id, request_options: {}) ⇒ PreludeSDK::Models::NotifyGetSubscriptionConfigResponse

Retrieve a specific subscription management configuration by its ID.

In order to get access to this endpoint, contact our support team.

Parameters:

  • config_id (String) —

    The subscription configuration ID

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

Returns:

See Also:



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

def get_subscription_config(config_id, params = {})
  @client.request(
    method: :get,
    path: ["v2/notify/management/subscriptions/%1$s", config_id],
    model: PreludeSDK::Models::NotifyGetSubscriptionConfigResponse,
    options: params[:request_options]
  )
end

#get_subscription_phone_number(phone_number, config_id:, request_options: {}) ⇒ PreludeSDK::Models::NotifyGetSubscriptionPhoneNumberResponse

Retrieve the current subscription status for a specific phone number within a subscription configuration.

In order to get access to this endpoint, contact our support team.

Parameters:

  • phone_number (String) —

    The phone number in E.164 format (e.g., +33612345678)

  • config_id (String) —

    The subscription configuration ID

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

Returns:

See Also:



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/prelude_sdk/resources/notify.rb', line 45

def get_subscription_phone_number(phone_number, params)
  parsed, options = PreludeSDK::NotifyGetSubscriptionPhoneNumberParams.dump_request(params)
  config_id =
    parsed.delete(:config_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["v2/notify/management/subscriptions/%1$s/phone_numbers/%2$s", config_id, phone_number],
    model: PreludeSDK::Models::NotifyGetSubscriptionPhoneNumberResponse,
    options: options
  )
end

#list_subscription_configs(cursor: nil, limit: nil, request_options: {}) ⇒ PreludeSDK::Models::NotifyListSubscriptionConfigsResponse

Retrieve a paginated list of subscription management configurations for your account.

Each configuration represents a subscription management setup with phone numbers for receiving opt-out/opt-in requests and a callback URL for webhook events.

In order to get access to this endpoint, contact our support team.

Parameters:

  • cursor (String) —

    Pagination cursor from the previous response

  • limit (Integer) —

    Maximum number of configurations to return per page

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

Returns:

See Also:



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/prelude_sdk/resources/notify.rb', line 78

def list_subscription_configs(params = {})
  parsed, options = PreludeSDK::NotifyListSubscriptionConfigsParams.dump_request(params)
  query = PreludeSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "v2/notify/management/subscriptions",
    query: query,
    model: PreludeSDK::Models::NotifyListSubscriptionConfigsResponse,
    options: options
  )
end

#list_subscription_phone_number_events(phone_number, config_id:, cursor: nil, limit: nil, request_options: {}) ⇒ PreludeSDK::Models::NotifyListSubscriptionPhoneNumberEventsResponse

Retrieve a paginated list of subscription events (status changes) for a specific phone number within a subscription configuration.

Events are ordered by timestamp in descending order (most recent first).

In order to get access to this endpoint, contact our support team.

Parameters:

  • phone_number (String) —

    Path param: The phone number in E.164 format (e.g., +33612345678)

  • config_id (String) —

    Path param: The subscription configuration ID

  • cursor (String) —

    Query param: Pagination cursor from the previous response

  • limit (Integer) —

    Query param: Maximum number of events to return per page

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

Returns:

See Also:



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/prelude_sdk/resources/notify.rb', line 112

def list_subscription_phone_number_events(phone_number, params)
  parsed, options = PreludeSDK::NotifyListSubscriptionPhoneNumberEventsParams.dump_request(params)
  query = PreludeSDK::Internal::Util.encode_query_params(parsed)
  config_id =
    parsed.delete(:config_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: [
      "v2/notify/management/subscriptions/%1$s/phone_numbers/%2$s/events",
      config_id,
      phone_number
    ],
    query: query,
    model: PreludeSDK::Models::NotifyListSubscriptionPhoneNumberEventsResponse,
    options: options
  )
end

#list_subscription_phone_numbers(config_id, cursor: nil, limit: nil, state: nil, request_options: {}) ⇒ PreludeSDK::Models::NotifyListSubscriptionPhoneNumbersResponse

Retrieve a paginated list of phone numbers and their subscription statuses for a specific subscription configuration.

You can optionally filter by subscription state (SUB or UNSUB).

In order to get access to this endpoint, contact our support team.

Parameters:

Returns:

See Also:



154
155
156
157
158
159
160
161
162
163
164
# File 'lib/prelude_sdk/resources/notify.rb', line 154

def list_subscription_phone_numbers(config_id, params = {})
  parsed, options = PreludeSDK::NotifyListSubscriptionPhoneNumbersParams.dump_request(params)
  query = PreludeSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["v2/notify/management/subscriptions/%1$s/phone_numbers", config_id],
    query: query,
    model: PreludeSDK::Models::NotifyListSubscriptionPhoneNumbersResponse,
    options: options
  )
end

#reply(reply_to:, text:, to:, callback_url: nil, correlation_id: nil, request_options: {}) ⇒ PreludeSDK::Models::NotifyReplyResponse

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

Send a free-form text reply to an inbound WhatsApp message within the 24-hour conversation window. See WhatsApp 2-Way Messaging for details.

Parameters:

  • reply_to (String) —

    The inbound message ID (prefixed with im_) to reply to. This ID is provided in

  • text (String) —

    The reply message body sent as a free-form WhatsApp text.

  • to (String) —

    The recipient's phone number in E.164 format. Must match the phone number that s

  • callback_url (String) —

    The URL where webhooks will be sent for delivery events of this reply.

  • correlation_id (String) —

    A user-defined identifier to correlate this reply with your internal systems. It

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

Returns:

See Also:



190
191
192
193
194
195
196
197
198
199
# File 'lib/prelude_sdk/resources/notify.rb', line 190

def reply(params)
  parsed, options = PreludeSDK::NotifyReplyParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v2/notify/reply",
    body: parsed,
    model: PreludeSDK::Models::NotifyReplyResponse,
    options: options
  )
end

#send_(template_id:, to:, callback_url: nil, correlation_id: nil, document: nil, expires_at: nil, from: nil, locale: nil, max_auto_retries: nil, preferred_channel: nil, schedule_at: nil, variables: nil, request_options: {}) ⇒ PreludeSDK::Models::NotifySendResponse

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

Send transactional and marketing messages to your users via SMS, RCS and WhatsApp with automatic compliance enforcement.

Parameters:

  • template_id (String) —

    The template identifier configured by your Customer Success team.

  • to (String) —

    The recipient's phone number in E.164 format.

  • callback_url (String) —

    The URL where webhooks will be sent for message delivery events.

  • correlation_id (String) —

    A user-defined identifier to correlate this message with your internal systems.

  • document (PreludeSDK::Models::NotifySendParams::Document) —

    A media attachment to include in the message header. Supported on

  • expires_at (Time) —

    The message expiration date in RFC3339 format. The message will not be sent if t

  • from (String) —

    The Sender ID. Must be approved for your account.

  • locale (String) —

    A BCP-47 formatted locale string with the language the text message will be sent

  • max_auto_retries (Integer) —

    Maximum number of automatic retry attempts across channels for this send, in add

  • preferred_channel (Symbol, PreludeSDK::Models::NotifySendParams::PreferredChannel) —

    The preferred channel to be used in priority for message delivery. If the channe

  • schedule_at (Time) —

    Schedule the message for future delivery in RFC3339 format. Marketing messages c

  • variables (Hash{Symbol=>String}) —

    The variables to be replaced in the template.

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

Returns:

See Also:



238
239
240
241
242
243
244
245
246
247
# File 'lib/prelude_sdk/resources/notify.rb', line 238

def send_(params)
  parsed, options = PreludeSDK::NotifySendParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v2/notify",
    body: parsed,
    model: PreludeSDK::Models::NotifySendResponse,
    options: options
  )
end

#send_batch(template_id:, to:, callback_url: nil, correlation_id: nil, document: nil, expires_at: nil, from: nil, locale: nil, max_auto_retries: nil, preferred_channel: nil, schedule_at: nil, variables: nil, request_options: {}) ⇒ PreludeSDK::Models::NotifySendBatchResponse

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

Send the same message to multiple recipients in a single request.

Parameters:

  • template_id (String) —

    The template identifier configured by your Customer Success team.

  • to (Array<String>) —

    The list of recipients' phone numbers in E.164 format.

  • callback_url (String) —

    The URL where webhooks will be sent for delivery events.

  • correlation_id (String) —

    A user-defined identifier to correlate this request with your internal systems.

  • document (PreludeSDK::Models::NotifySendBatchParams::Document) —

    A media attachment to include in the message header. Supported on

  • expires_at (Time) —

    The message expiration date in RFC3339 format. Messages will not be sent after t

  • from (String) —

    The Sender ID. Must be approved for your account.

  • locale (String) —

    A BCP-47 formatted locale string.

  • max_auto_retries (Integer) —

    Maximum number of automatic retry attempts across channels for each send in the

  • preferred_channel (Symbol, PreludeSDK::Models::NotifySendBatchParams::PreferredChannel) —

    Preferred channel for delivery. If unavailable, automatic fallback applies.

  • schedule_at (Time) —

    Schedule delivery in RFC3339 format. Marketing sends may be adjusted to comply w

  • variables (Hash{Symbol=>String}) —

    The variables to be replaced in the template.

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

Returns:

See Also:



285
286
287
288
289
290
291
292
293
294
# File 'lib/prelude_sdk/resources/notify.rb', line 285

def send_batch(params)
  parsed, options = PreludeSDK::NotifySendBatchParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v2/notify/batch",
    body: parsed,
    model: PreludeSDK::Models::NotifySendBatchResponse,
    options: options
  )
end