Class: PreludeSDK::Resources::Notify

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

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:



254
255
256
# File 'lib/prelude_sdk/resources/notify.rb', line 254

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.

Parameters:

  • config_id (String)

    The subscription configuration ID

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

Returns:

See Also:



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

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.

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:



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/prelude_sdk/resources/notify.rb', line 41

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.

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:



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/prelude_sdk/resources/notify.rb', line 72

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

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:



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/prelude_sdk/resources/notify.rb', line 104

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

Parameters:

Returns:

See Also:



144
145
146
147
148
149
150
151
152
153
154
# File 'lib/prelude_sdk/resources/notify.rb', line 144

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

#send_(template_id:, to:, callback_url: nil, context: nil, correlation_id: nil, document: nil, expires_at: nil, from: nil, locale: nil, preferred_channel: nil, schedule_at: nil, text: 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.

  • context (PreludeSDK::Models::NotifySendParams::Context)

    Context for replying to an inbound message. When provided, the message is sent a

  • 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

  • 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

  • text (String)

    The reply message body. Required when ‘context.reply_to` is provided. Used for 2

  • variables (Hash{Symbol=>String})

    The variables to be replaced in the template.

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

Returns:

See Also:



195
196
197
198
199
200
201
202
203
204
# File 'lib/prelude_sdk/resources/notify.rb', line 195

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

  • 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:



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

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