Class: Courier::Resources::Providers

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

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:



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

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

Instance Attribute Details

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



7
8
9
# File 'lib/courier/resources/providers.rb', line 7

def catalog
  @catalog
end

Instance Method Details

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

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

Create a new provider configuration. The ‘provider` field must be a known Courier provider key (see catalog).

Parameters:

  • provider (String)

    The provider key identifying the type (e.g. “sendgrid”, “twilio”). Must be a kno

  • alias_ (String)

    Optional alias for this configuration.

  • settings (Hash{Symbol=>Object})

    Provider-specific settings (snake_case keys). Defaults to an empty object when o

  • title (String)

    Optional display title. Omit to use “Default Configuration”.

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

Returns:

See Also:



30
31
32
33
34
35
36
37
38
39
# File 'lib/courier/resources/providers.rb', line 30

def create(params)
  parsed, options = Courier::ProviderCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "providers",
    body: parsed,
    model: Courier::Provider,
    options: options
  )
end

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

Delete a provider configuration. Returns 409 if the provider is still referenced by routing or notifications.

Parameters:

  • id (String)

    A unique identifier of the provider configuration to delete.

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

Returns:

  • (nil)

See Also:



134
135
136
137
138
139
140
141
# File 'lib/courier/resources/providers.rb', line 134

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

List configured provider integrations for the current workspace. Supports cursor-based pagination.

Parameters:

  • cursor (String)

    Opaque cursor for fetching the next page.

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

Returns:

See Also:



110
111
112
113
114
115
116
117
118
119
120
# File 'lib/courier/resources/providers.rb', line 110

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

Fetch a single provider configuration by ID.

Parameters:

  • id (String)

    A unique identifier of the provider configuration.

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

Returns:

See Also:



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

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.

Replace an existing provider configuration. The ‘provider` key is required and determines which provider-specific settings schema is applied. All other fields are optional — omitted fields are cleared from the stored configuration (this is a full replacement, not a partial merge). Changing the provider type for an existing configuration is not supported.

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:



87
88
89
90
91
92
93
94
95
96
# File 'lib/courier/resources/providers.rb', line 87

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