Class: Courier::Resources::Providers

Inherits:
Object
  • Object
show all
Defined in:
lib/courier/resources/providers.rb,
lib/courier/resources/providers/catalog.rb,
sig/courier/resources/providers.rbs,
sig/courier/resources/providers/catalog.rbs

Overview

Configure the channel providers Courier delivers through, and browse the provider types it supports.

Defined Under Namespace

Classes: Catalog

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Providers

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

Parameters:



155
156
157
158
# File 'lib/courier/resources/providers.rb', line 155

def initialize(client:)
  @client = client
  @catalog = Courier::Resources::Providers::Catalog.new(client: client)
end

Instance Attribute Details

#catalogCourier::Resources::Providers::Catalog (readonly)

Configure the channel providers Courier delivers through, and browse the provider types it supports.



11
12
13
# File 'lib/courier/resources/providers.rb', line 11

def catalog
  @catalog
end

Instance Method Details

#create(provider:, alias_: nil, settings: nil, title: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::Provider

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

Configures a provider integration from a Courier provider key and its settings. Check the catalog endpoint for the schema each provider expects.

Parameters:

  • provider (String)

    Body param: The provider key identifying the type (e.g. "sendgrid", "twilio"). M

  • alias_ (String)

    Body param: Optional alias for this configuration.

  • settings (Hash{Symbol=>Object})

    Body param: Provider-specific settings (snake_case keys). Defaults to an empty o

  • title (String)

    Body param: Optional display title. Omit to use "Default Configuration".

  • idempotency_key (String)

    Header param: A unique key that makes this request idempotent. If Courier receiv

  • x_idempotency_expiration (String)

    Header param: How long the idempotency key remains valid, as a Unix epoch timest

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

Returns:

See Also:



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/courier/resources/providers.rb', line 38

def create(params)
  parsed, options = Courier::ProviderCreateParams.dump_request(params)
  header_params =
    {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"}
  @client.request(
    method: :post,
    path: "providers",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Courier::Provider,
    options: options
  )
end

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

Deletes a provider configuration, which fails while routing strategies or templates still reference it. Update those references first.

Parameters:

  • id (String)

    A unique identifier of the provider configuration to delete.

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

Returns:

  • (nil)

See Also:



143
144
145
146
147
148
149
150
# File 'lib/courier/resources/providers.rb', line 143

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

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

Lists the provider integrations configured in the workspace, one entry per channel and provider key with its alias and settings.

Parameters:

  • cursor (String)

    Opaque cursor for fetching the next page.

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

Returns:

See Also:



119
120
121
122
123
124
125
126
127
128
129
# File 'lib/courier/resources/providers.rb', line 119

def list(params = {})
  parsed, options = Courier::ProviderListParams.dump_request(params)
  query = Courier::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "providers",
    query: query,
    model: Courier::Models::ProviderListResponse,
    options: options
  )
end

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

Returns one configured provider by id, including its channel, provider key, alias, title, and current settings.

Parameters:

  • id (String)

    A unique identifier of the provider configuration.

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

Returns:

See Also:



64
65
66
67
68
69
70
71
# File 'lib/courier/resources/providers.rb', line 64

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

#update(id, provider:, alias_: nil, settings: nil, title: nil, request_options: {}) ⇒ Courier::Models::Provider

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

Replaces a provider's configuration in full, clearing any field you omit rather than merging it. Send the complete settings object.

Parameters:

  • id (String)

    A unique identifier of the provider configuration to update.

  • provider (String)

    The provider key identifying the type. Required on every request because it sele

  • alias_ (String)

    Updated alias. Omit to clear.

  • settings (Hash{Symbol=>Object})

    Provider-specific settings (snake_case keys). Replaces the full settings object

  • title (String)

    Updated display title.

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

Returns:

See Also:



96
97
98
99
100
101
102
103
104
105
# File 'lib/courier/resources/providers.rb', line 96

def update(id, params)
  parsed, options = Courier::ProviderUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["providers/%1$s", id],
    body: parsed,
    model: Courier::Provider,
    options: options
  )
end