Class: Courier::Resources::RoutingStrategies

Inherits:
Object
  • Object
show all
Defined in:
lib/courier/resources/routing_strategies.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ RoutingStrategies

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

Parameters:



174
175
176
# File 'lib/courier/resources/routing_strategies.rb', line 174

def initialize(client:)
  @client = client
end

Instance Method Details

#archive(id, request_options: {}) ⇒ nil

Archive a routing strategy. The strategy must not have associated notification templates. Unlink all templates before archiving.

Parameters:

  • id (String)

    Routing strategy ID (rs_ prefix).

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

Returns:

  • (nil)

See Also:



99
100
101
102
103
104
105
106
# File 'lib/courier/resources/routing_strategies.rb', line 99

def archive(id, params = {})
  @client.request(
    method: :delete,
    path: ["routing-strategies/%1$s", id],
    model: NilClass,
    options: params[:request_options]
  )
end

#create(name:, routing:, channels: nil, description: nil, providers: nil, tags: nil, request_options: {}) ⇒ Courier::Models::RoutingStrategyGetResponse

Create a routing strategy. Requires a name and routing configuration at minimum. Channels and providers default to empty if omitted.

Parameters:

  • name (String)

    Human-readable name for the routing strategy.

  • routing (Courier::Models::MessageRouting)

    Routing tree defining channel selection method and order.

  • channels (Hash{Symbol=>Courier::Models::Channel}, nil)

    Per-channel delivery configuration. Defaults to empty if omitted.

  • description (String, nil)

    Optional description of the routing strategy.

  • providers (Hash{Symbol=>Courier::Models::MessageProvidersType}, nil)

    Per-provider delivery configuration. Defaults to empty if omitted.

  • tags (Array<String>, nil)

    Optional tags for categorization.

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

Returns:

See Also:



28
29
30
31
32
33
34
35
36
37
# File 'lib/courier/resources/routing_strategies.rb', line 28

def create(params)
  parsed, options = Courier::RoutingStrategyCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "routing-strategies",
    body: parsed,
    model: Courier::RoutingStrategyGetResponse,
    options: options
  )
end

#list(cursor: nil, limit: nil, request_options: {}) ⇒ Courier::Models::RoutingStrategyListResponse

List routing strategies in your workspace. Returns metadata only (no routing/channels/providers content). Use GET /routing-strategies/id for full details.

Parameters:

  • cursor (String, nil)

    Opaque pagination cursor from a previous response. Omit for the first page.

  • limit (Integer)

    Maximum number of results per page. Default 20, max 100.

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

Returns:

See Also:



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/courier/resources/routing_strategies.rb', line 75

def list(params = {})
  parsed, options = Courier::RoutingStrategyListParams.dump_request(params)
  query = Courier::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "routing-strategies",
    query: query,
    model: Courier::RoutingStrategyListResponse,
    options: options
  )
end

#list_notifications(id, cursor: nil, limit: nil, request_options: {}) ⇒ Courier::Models::AssociatedNotificationListResponse

List notification templates associated with a routing strategy. Includes template metadata only, not full content.

Parameters:

  • id (String)

    Routing strategy ID (‘rs_` prefix).

  • cursor (String, nil)

    Opaque pagination cursor from a previous response. Omit for the first page.

  • limit (Integer)

    Maximum number of results per page. Default 20, max 100.

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

Returns:

See Also:



124
125
126
127
128
129
130
131
132
133
134
# File 'lib/courier/resources/routing_strategies.rb', line 124

def list_notifications(id, params = {})
  parsed, options = Courier::RoutingStrategyListNotificationsParams.dump_request(params)
  query = Courier::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["routing-strategies/%1$s/notifications", id],
    query: query,
    model: Courier::AssociatedNotificationListResponse,
    options: options
  )
end

#replace(id, name:, routing:, channels: nil, description: nil, providers: nil, tags: nil, request_options: {}) ⇒ Courier::Models::RoutingStrategyGetResponse

Replace a routing strategy. Full document replacement; the caller must send the complete desired state. Missing optional fields are cleared.

Parameters:

  • id (String)

    Routing strategy ID (rs_ prefix).

  • name (String)

    Human-readable name for the routing strategy.

  • routing (Courier::Models::MessageRouting)

    Routing tree defining channel selection method and order.

  • channels (Hash{Symbol=>Courier::Models::Channel}, nil)

    Per-channel delivery configuration. Omit to clear.

  • description (String, nil)

    Optional description. Omit or null to clear.

  • providers (Hash{Symbol=>Courier::Models::MessageProvidersType}, nil)

    Per-provider delivery configuration. Omit to clear.

  • tags (Array<String>, nil)

    Optional tags. Omit or null to clear.

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

Returns:

See Also:



160
161
162
163
164
165
166
167
168
169
# File 'lib/courier/resources/routing_strategies.rb', line 160

def replace(id, params)
  parsed, options = Courier::RoutingStrategyReplaceParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["routing-strategies/%1$s", id],
    body: parsed,
    model: Courier::RoutingStrategyGetResponse,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ Courier::Models::RoutingStrategyGetResponse

Retrieve a routing strategy by ID. Returns the full entity including routing content and metadata.

Parameters:

  • id (String)

    Routing strategy ID (rs_ prefix).

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

Returns:

See Also:



51
52
53
54
55
56
57
58
# File 'lib/courier/resources/routing_strategies.rb', line 51

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["routing-strategies/%1$s", id],
    model: Courier::RoutingStrategyGetResponse,
    options: params[:request_options]
  )
end