Class: Courier::Resources::RoutingStrategies
- Inherits:
-
Object
- Object
- Courier::Resources::RoutingStrategies
- Defined in:
- lib/courier/resources/routing_strategies.rb,
sig/courier/resources/routing_strategies.rbs
Overview
Define reusable channel routing and failover strategies, and see which templates use them.
Instance Method Summary collapse
-
#archive(id, request_options: {}) ⇒ nil
Archive a routing strategy.
-
#create(name:, routing:, channels: nil, description: nil, providers: nil, tags: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::RoutingStrategyGetResponse
Some parameter documentations has been truncated, see Models::RoutingStrategyCreateParams for more details.
-
#initialize(client:) ⇒ RoutingStrategies
constructor
private
A new instance of RoutingStrategies.
-
#list(cursor: nil, limit: nil, request_options: {}) ⇒ Courier::Models::RoutingStrategyListResponse
List routing strategies in your workspace.
-
#list_notifications(id, cursor: nil, limit: nil, request_options: {}) ⇒ Courier::Models::AssociatedNotificationListResponse
Returns the notification templates using a routing strategy, with paging.
-
#replace(id, name:, routing:, channels: nil, description: nil, providers: nil, tags: nil, request_options: {}) ⇒ Courier::Models::RoutingStrategyGetResponse
Replace a routing strategy.
-
#retrieve(id, request_options: {}) ⇒ Courier::Models::RoutingStrategyGetResponse
Returns one routing strategy by id with its name, tags, channels, and the routing rules that decide provider order and fallback.
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.
186 187 188 |
# File 'lib/courier/resources/routing_strategies.rb', line 186 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.
111 112 113 114 115 116 117 118 |
# File 'lib/courier/resources/routing_strategies.rb', line 111 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, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::RoutingStrategyGetResponse
Some parameter documentations has been truncated, see Models::RoutingStrategyCreateParams for more details.
Create a routing strategy. Requires a name and routing configuration at minimum. Channels and providers default to empty if omitted.
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/courier/resources/routing_strategies.rb', line 37 def create(params) parsed, = Courier::RoutingStrategyCreateParams.dump_request(params) header_params = {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: "routing-strategies", headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Courier::RoutingStrategyGetResponse, 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.
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/courier/resources/routing_strategies.rb', line 87 def list(params = {}) parsed, = 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: ) end |
#list_notifications(id, cursor: nil, limit: nil, request_options: {}) ⇒ Courier::Models::AssociatedNotificationListResponse
Returns the notification templates using a routing strategy, with paging. Check this before changing a strategy that templates depend on.
136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/courier/resources/routing_strategies.rb', line 136 def list_notifications(id, params = {}) parsed, = 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: ) 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.
172 173 174 175 176 177 178 179 180 181 |
# File 'lib/courier/resources/routing_strategies.rb', line 172 def replace(id, params) parsed, = Courier::RoutingStrategyReplaceParams.dump_request(params) @client.request( method: :put, path: ["routing-strategies/%1$s", id], body: parsed, model: Courier::RoutingStrategyGetResponse, options: ) end |
#retrieve(id, request_options: {}) ⇒ Courier::Models::RoutingStrategyGetResponse
Returns one routing strategy by id with its name, tags, channels, and the routing rules that decide provider order and fallback.
63 64 65 66 67 68 69 70 |
# File 'lib/courier/resources/routing_strategies.rb', line 63 def retrieve(id, params = {}) @client.request( method: :get, path: ["routing-strategies/%1$s", id], model: Courier::RoutingStrategyGetResponse, options: params[:request_options] ) end |