diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b9e06599..c032d311 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.21.0" + ".": "4.22.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index e2794c72..91c3ad3d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 134 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier/courier-b053468fefe6d757f86f3233ebbc52d80329ed2a6e7a6740fee01e4028a4c3b9.yml -openapi_spec_hash: 416835e693de0fe19945be90a787d3f3 -config_hash: 8d28dbeabe9d4dcc7d5b8c021a4cbbd7 +configured_endpoints: 136 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier/courier-e0b0d58ce19411b3126e6d5cb0f9ae93061e2ec859aae4ec17a15f80dc74cd04.yml +openapi_spec_hash: 38d1ecc4bd77bb5245afe86f2d8ffb48 +config_hash: b30c4b3086cd9f3da06a63b256d8c189 diff --git a/CHANGELOG.md b/CHANGELOG.md index 43e23949..f3babae1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## 4.22.0 (2026-07-28) + +Full Changelog: [v4.21.0...v4.22.0](https://github.com/trycourier/courier-ruby/compare/v4.21.0...v4.22.0) + +### Features + +* Document DELETE/PUT restore for inbox messages (C-19268) ([#175](https://github.com/trycourier/courier-ruby/issues/175)) ([36c1d01](https://github.com/trycourier/courier-ruby/commit/36c1d0116770621edfefe94781e72a8061e43781)) + + +### Documentation + +* **openapi:** describe user topic-preference fields explicitly ([#172](https://github.com/trycourier/courier-ruby/issues/172)) ([c540bdb](https://github.com/trycourier/courier-ruby/commit/c540bdb855f180d850feeabf1a30ed4394092b50)) +* **openapi:** document Idempotency-Key header on idempotent POST endpoints ([#176](https://github.com/trycourier/courier-ruby/issues/176)) ([b76b6bb](https://github.com/trycourier/courier-ruby/commit/b76b6bbbd0e856d486037d7d140b2d934eb150ea)) +* **openapi:** rewrite operation descriptions for agents and SEO ([#174](https://github.com/trycourier/courier-ruby/issues/174)) ([8a8c25b](https://github.com/trycourier/courier-ruby/commit/8a8c25b54b9a8db2cd906ab09ac8729423fa35b8)) + ## 4.21.0 (2026-07-23) Full Changelog: [v4.20.0...v4.21.0](https://github.com/trycourier/courier-ruby/compare/v4.20.0...v4.21.0) diff --git a/Gemfile.lock b/Gemfile.lock index ed874bea..dee5cfef 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: . specs: - trycourier (4.21.0) + trycourier (4.22.0) cgi connection_pool diff --git a/lib/courier.rb b/lib/courier.rb index 36d016d5..25a28bc8 100644 --- a/lib/courier.rb +++ b/lib/courier.rb @@ -158,6 +158,8 @@ require_relative "courier/models/icons" require_relative "courier/models/inbound_track_event_params" require_relative "courier/models/inbound_track_event_response" +require_relative "courier/models/inbox/message_delete_params" +require_relative "courier/models/inbox/message_restore_params" require_relative "courier/models/intercom" require_relative "courier/models/intercom_recipient" require_relative "courier/models/journey" @@ -424,6 +426,8 @@ require_relative "courier/resources/digests" require_relative "courier/resources/digests/schedules" require_relative "courier/resources/inbound" +require_relative "courier/resources/inbox" +require_relative "courier/resources/inbox/messages" require_relative "courier/resources/journeys" require_relative "courier/resources/journeys/templates" require_relative "courier/resources/lists" diff --git a/lib/courier/client.rb b/lib/courier/client.rb index e71efdf4..90a8aa5a 100644 --- a/lib/courier/client.rb +++ b/lib/courier/client.rb @@ -51,6 +51,9 @@ class Client < Courier::Internal::Transport::BaseClient # @return [Courier::Resources::Lists] attr_reader :lists + # @return [Courier::Resources::Inbox] + attr_reader :inbox + # @return [Courier::Resources::Messages] attr_reader :messages @@ -150,6 +153,7 @@ def initialize( @digests = Courier::Resources::Digests.new(client: self) @inbound = Courier::Resources::Inbound.new(client: self) @lists = Courier::Resources::Lists.new(client: self) + @inbox = Courier::Resources::Inbox.new(client: self) @messages = Courier::Resources::Messages.new(client: self) @requests = Courier::Resources::Requests.new(client: self) @notifications = Courier::Resources::Notifications.new(client: self) diff --git a/lib/courier/models.rb b/lib/courier/models.rb index 3c8ee022..a60e69e2 100644 --- a/lib/courier/models.rb +++ b/lib/courier/models.rb @@ -185,6 +185,8 @@ module Courier InboundTrackEventParams = Courier::Models::InboundTrackEventParams + Inbox = Courier::Models::Inbox + Intercom = Courier::Models::Intercom IntercomRecipient = Courier::Models::IntercomRecipient diff --git a/lib/courier/models/automations/invoke_invoke_ad_hoc_params.rb b/lib/courier/models/automations/invoke_invoke_ad_hoc_params.rb index 70e6e3d6..70b2718b 100644 --- a/lib/courier/models/automations/invoke_invoke_ad_hoc_params.rb +++ b/lib/courier/models/automations/invoke_invoke_ad_hoc_params.rb @@ -38,13 +38,25 @@ class InvokeInvokeAdHocParams < Courier::Internal::Type::BaseModel # @return [String, nil] optional :template, String, nil?: true - # @!method initialize(automation:, brand: nil, data: nil, profile: nil, recipient: nil, template: nil, request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(automation:, brand: nil, data: nil, profile: nil, recipient: nil, template: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # @param automation [Courier::Models::Automations::InvokeInvokeAdHocParams::Automation] # @param brand [String, nil] # @param data [Hash{Symbol=>Object}, nil] # @param profile [Hash{Symbol=>Object}, nil] # @param recipient [String, nil] # @param template [String, nil] + # @param idempotency_key [String] + # @param x_idempotency_expiration [String] # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] class Automation < Courier::Internal::Type::BaseModel diff --git a/lib/courier/models/automations/invoke_invoke_by_template_params.rb b/lib/courier/models/automations/invoke_invoke_by_template_params.rb index 9be2cd2c..2bd33d8f 100644 --- a/lib/courier/models/automations/invoke_invoke_by_template_params.rb +++ b/lib/courier/models/automations/invoke_invoke_by_template_params.rb @@ -38,13 +38,25 @@ class InvokeInvokeByTemplateParams < Courier::Internal::Type::BaseModel # @return [String, nil] optional :template, String, nil?: true - # @!method initialize(template_id:, recipient:, brand: nil, data: nil, profile: nil, template: nil, request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(template_id:, recipient:, brand: nil, data: nil, profile: nil, template: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # @param template_id [String] # @param recipient [String, nil] # @param brand [String, nil] # @param data [Hash{Symbol=>Object}, nil] # @param profile [Hash{Symbol=>Object}, nil] # @param template [String, nil] + # @param idempotency_key [String] + # @param x_idempotency_expiration [String] # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] end end diff --git a/lib/courier/models/brand_create_params.rb b/lib/courier/models/brand_create_params.rb index f9de3d9d..c06fa03b 100644 --- a/lib/courier/models/brand_create_params.rb +++ b/lib/courier/models/brand_create_params.rb @@ -27,11 +27,23 @@ class BrandCreateParams < Courier::Internal::Type::BaseModel # @return [Courier::Models::BrandSnippets, nil] optional :snippets, -> { Courier::BrandSnippets }, nil?: true - # @!method initialize(name:, settings:, id: nil, snippets: nil, request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(name:, settings:, id: nil, snippets: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # @param name [String] # @param settings [Courier::Models::BrandSettings] # @param id [String, nil] # @param snippets [Courier::Models::BrandSnippets, nil] + # @param idempotency_key [String] + # @param x_idempotency_expiration [String] # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] end end diff --git a/lib/courier/models/inbox/message_delete_params.rb b/lib/courier/models/inbox/message_delete_params.rb new file mode 100644 index 00000000..c305383d --- /dev/null +++ b/lib/courier/models/inbox/message_delete_params.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Courier + module Models + module Inbox + # @see Courier::Resources::Inbox::Messages#delete + class MessageDeleteParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + # @!attribute message_id + # + # @return [String] + required :message_id, String + + # @!method initialize(message_id:, request_options: {}) + # @param message_id [String] + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/courier/models/inbox/message_restore_params.rb b/lib/courier/models/inbox/message_restore_params.rb new file mode 100644 index 00000000..0f54704b --- /dev/null +++ b/lib/courier/models/inbox/message_restore_params.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Courier + module Models + module Inbox + # @see Courier::Resources::Inbox::Messages#restore + class MessageRestoreParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + # @!attribute message_id + # + # @return [String] + required :message_id, String + + # @!method initialize(message_id:, request_options: {}) + # @param message_id [String] + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/courier/models/journey_cancel_params.rb b/lib/courier/models/journey_cancel_params.rb index 5301099d..b34ea0cb 100644 --- a/lib/courier/models/journey_cancel_params.rb +++ b/lib/courier/models/journey_cancel_params.rb @@ -7,7 +7,19 @@ class JourneyCancelParams < Courier::Internal::Type::BaseModel extend Courier::Internal::Type::RequestParameters::Converter include Courier::Internal::Type::RequestParameters - # @!method initialize(request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) + # @param idempotency_key [String] + # @param x_idempotency_expiration [String] # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] end end diff --git a/lib/courier/models/journey_create_params.rb b/lib/courier/models/journey_create_params.rb index aeb28611..9fce95b2 100644 --- a/lib/courier/models/journey_create_params.rb +++ b/lib/courier/models/journey_create_params.rb @@ -7,7 +7,19 @@ class JourneyCreateParams < Courier::Models::CreateJourneyRequest extend Courier::Internal::Type::RequestParameters::Converter include Courier::Internal::Type::RequestParameters - # @!method initialize(request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) + # @param idempotency_key [String] + # @param x_idempotency_expiration [String] # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] end end diff --git a/lib/courier/models/journey_invoke_params.rb b/lib/courier/models/journey_invoke_params.rb index 37963f61..e8c36660 100644 --- a/lib/courier/models/journey_invoke_params.rb +++ b/lib/courier/models/journey_invoke_params.rb @@ -12,8 +12,20 @@ class JourneyInvokeParams < Courier::Models::JourneysInvokeRequest # @return [String] required :template_id, String - # @!method initialize(template_id:, request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(template_id:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # @param template_id [String] + # @param idempotency_key [String] + # @param x_idempotency_expiration [String] # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] end end diff --git a/lib/courier/models/journey_publish_params.rb b/lib/courier/models/journey_publish_params.rb index 271f4f6e..fc9c9f52 100644 --- a/lib/courier/models/journey_publish_params.rb +++ b/lib/courier/models/journey_publish_params.rb @@ -12,8 +12,20 @@ class JourneyPublishParams < Courier::Models::JourneyPublishRequest # @return [String] required :template_id, String - # @!method initialize(template_id:, request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(template_id:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # @param template_id [String] + # @param idempotency_key [String] + # @param x_idempotency_expiration [String] # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] end end diff --git a/lib/courier/models/journeys/template_create_params.rb b/lib/courier/models/journeys/template_create_params.rb index 3f1ed294..84f9bdcb 100644 --- a/lib/courier/models/journeys/template_create_params.rb +++ b/lib/courier/models/journeys/template_create_params.rb @@ -13,8 +13,20 @@ class TemplateCreateParams < Courier::Models::JourneyTemplateCreateRequest # @return [String] required :template_id, String - # @!method initialize(template_id:, request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(template_id:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # @param template_id [String] + # @param idempotency_key [String] + # @param x_idempotency_expiration [String] # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] end end diff --git a/lib/courier/models/journeys/template_publish_params.rb b/lib/courier/models/journeys/template_publish_params.rb index bc30e390..60fc8c64 100644 --- a/lib/courier/models/journeys/template_publish_params.rb +++ b/lib/courier/models/journeys/template_publish_params.rb @@ -18,9 +18,21 @@ class TemplatePublishParams < Courier::Models::JourneyTemplatePublishRequest # @return [String] required :notification_id, String - # @!method initialize(template_id:, notification_id:, request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(template_id:, notification_id:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # @param template_id [String] # @param notification_id [String] + # @param idempotency_key [String] + # @param x_idempotency_expiration [String] # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] end end diff --git a/lib/courier/models/lists/subscription_add_params.rb b/lib/courier/models/lists/subscription_add_params.rb index 2d7ac968..9f225fce 100644 --- a/lib/courier/models/lists/subscription_add_params.rb +++ b/lib/courier/models/lists/subscription_add_params.rb @@ -18,9 +18,21 @@ class SubscriptionAddParams < Courier::Internal::Type::BaseModel # @return [Array] required :recipients, -> { Courier::Internal::Type::ArrayOf[Courier::PutSubscriptionsRecipient] } - # @!method initialize(list_id:, recipients:, request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(list_id:, recipients:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # @param list_id [String] # @param recipients [Array] + # @param idempotency_key [String] + # @param x_idempotency_expiration [String] # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] end end diff --git a/lib/courier/models/notification_create_params.rb b/lib/courier/models/notification_create_params.rb index 9127b7e6..31b45756 100644 --- a/lib/courier/models/notification_create_params.rb +++ b/lib/courier/models/notification_create_params.rb @@ -7,7 +7,19 @@ class NotificationCreateParams < Courier::Models::NotificationTemplateCreateRequ extend Courier::Internal::Type::RequestParameters::Converter include Courier::Internal::Type::RequestParameters - # @!method initialize(request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) + # @param idempotency_key [String] + # @param x_idempotency_expiration [String] # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] end end diff --git a/lib/courier/models/notification_publish_params.rb b/lib/courier/models/notification_publish_params.rb index 51e26377..838ba96f 100644 --- a/lib/courier/models/notification_publish_params.rb +++ b/lib/courier/models/notification_publish_params.rb @@ -12,8 +12,20 @@ class NotificationPublishParams < Courier::Models::NotificationTemplatePublishRe # @return [String] required :id, String - # @!method initialize(id:, request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(id:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # @param id [String] + # @param idempotency_key [String] + # @param x_idempotency_expiration [String] # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] end end diff --git a/lib/courier/models/profile_create_params.rb b/lib/courier/models/profile_create_params.rb index d1be11a0..19276c17 100644 --- a/lib/courier/models/profile_create_params.rb +++ b/lib/courier/models/profile_create_params.rb @@ -17,9 +17,21 @@ class ProfileCreateParams < Courier::Internal::Type::BaseModel # @return [Hash{Symbol=>Object}] required :profile, Courier::Internal::Type::HashOf[Courier::Internal::Type::Unknown] - # @!method initialize(user_id:, profile:, request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(user_id:, profile:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # @param user_id [String] # @param profile [Hash{Symbol=>Object}] + # @param idempotency_key [String] + # @param x_idempotency_expiration [String] # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] end end diff --git a/lib/courier/models/profiles/list_subscribe_params.rb b/lib/courier/models/profiles/list_subscribe_params.rb index e16199f7..7ed533b7 100644 --- a/lib/courier/models/profiles/list_subscribe_params.rb +++ b/lib/courier/models/profiles/list_subscribe_params.rb @@ -18,9 +18,21 @@ class ListSubscribeParams < Courier::Internal::Type::BaseModel # @return [Array] required :lists, -> { Courier::Internal::Type::ArrayOf[Courier::SubscribeToListsRequestItem] } - # @!method initialize(user_id:, lists:, request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(user_id:, lists:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # @param user_id [String] # @param lists [Array] + # @param idempotency_key [String] + # @param x_idempotency_expiration [String] # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] end end diff --git a/lib/courier/models/provider_create_params.rb b/lib/courier/models/provider_create_params.rb index 7deaeac7..645f2ce1 100644 --- a/lib/courier/models/provider_create_params.rb +++ b/lib/courier/models/provider_create_params.rb @@ -34,7 +34,17 @@ class ProviderCreateParams < Courier::Internal::Type::BaseModel # @return [String, nil] optional :title, String - # @!method initialize(provider:, alias_: nil, settings: nil, title: nil, request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(provider:, alias_: nil, settings: nil, title: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # Some parameter documentations has been truncated, see # {Courier::Models::ProviderCreateParams} for more details. # @@ -46,6 +56,10 @@ class ProviderCreateParams < Courier::Internal::Type::BaseModel # # @param title [String] Optional display title. Omit to use "Default Configuration". # + # @param idempotency_key [String] + # + # @param x_idempotency_expiration [String] + # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] end end diff --git a/lib/courier/models/routing_strategy_create_params.rb b/lib/courier/models/routing_strategy_create_params.rb index 501ddf3c..f8cb471d 100644 --- a/lib/courier/models/routing_strategy_create_params.rb +++ b/lib/courier/models/routing_strategy_create_params.rb @@ -7,7 +7,19 @@ class RoutingStrategyCreateParams < Courier::Models::RoutingStrategyCreateReques extend Courier::Internal::Type::RequestParameters::Converter include Courier::Internal::Type::RequestParameters - # @!method initialize(request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) + # @param idempotency_key [String] + # @param x_idempotency_expiration [String] # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] end end diff --git a/lib/courier/models/send_message_params.rb b/lib/courier/models/send_message_params.rb index 3014f151..bf7beb18 100644 --- a/lib/courier/models/send_message_params.rb +++ b/lib/courier/models/send_message_params.rb @@ -14,12 +14,26 @@ class SendMessageParams < Courier::Internal::Type::BaseModel # @return [Courier::Models::SendMessageParams::Message] required :message, -> { Courier::SendMessageParams::Message } - # @!method initialize(message:, request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(message:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # Some parameter documentations has been truncated, see # {Courier::Models::SendMessageParams} for more details. # # @param message [Courier::Models::SendMessageParams::Message] The message property has the following primary top-level properties. They define # + # @param idempotency_key [String] + # + # @param x_idempotency_expiration [String] + # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] class Message < Courier::Internal::Type::BaseModel diff --git a/lib/courier/models/users/preference_bulk_update_params.rb b/lib/courier/models/users/preference_bulk_update_params.rb index 0f8f28c8..a27482cd 100644 --- a/lib/courier/models/users/preference_bulk_update_params.rb +++ b/lib/courier/models/users/preference_bulk_update_params.rb @@ -27,7 +27,17 @@ class PreferenceBulkUpdateParams < Courier::Internal::Type::BaseModel # @return [String, nil] optional :tenant_id, String, nil?: true - # @!method initialize(user_id:, topics:, tenant_id: nil, request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(user_id:, topics:, tenant_id: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # Some parameter documentations has been truncated, see # {Courier::Models::Users::PreferenceBulkUpdateParams} for more details. # @@ -37,6 +47,10 @@ class PreferenceBulkUpdateParams < Courier::Internal::Type::BaseModel # # @param tenant_id [String, nil] Update the preferences of a user for this specific tenant context. # + # @param idempotency_key [String] + # + # @param x_idempotency_expiration [String] + # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] class Topic < Courier::Internal::Type::BaseModel diff --git a/lib/courier/models/users/preference_update_or_create_topic_params.rb b/lib/courier/models/users/preference_update_or_create_topic_params.rb index 4b1a26e5..c8ef9c49 100644 --- a/lib/courier/models/users/preference_update_or_create_topic_params.rb +++ b/lib/courier/models/users/preference_update_or_create_topic_params.rb @@ -42,12 +42,16 @@ class PreferenceUpdateOrCreateTopicParams < Courier::Internal::Type::BaseModel class Topic < Courier::Internal::Type::BaseModel # @!attribute status + # The subscription status to set: OPTED_IN or OPTED_OUT. REQUIRED is a topic-level + # default, not a user choice; the API rejects opting a user out of a REQUIRED + # topic. # # @return [Symbol, Courier::Models::PreferenceStatus] required :status, enum: -> { Courier::PreferenceStatus } # @!attribute custom_routing - # The Channels a user has chosen to receive notifications through for this topic + # The channels to deliver this topic on when has_custom_routing is true. One or + # more of: direct_message, email, push, sms, webhook, inbox. # # @return [Array, nil] optional :custom_routing, @@ -55,16 +59,22 @@ class Topic < Courier::Internal::Type::BaseModel nil?: true # @!attribute has_custom_routing + # Set to true to route this topic to the channels in custom_routing instead of the + # topic's default routing. # # @return [Boolean, nil] optional :has_custom_routing, Courier::Internal::Type::Boolean, nil?: true # @!method initialize(status:, custom_routing: nil, has_custom_routing: nil) - # @param status [Symbol, Courier::Models::PreferenceStatus] + # Some parameter documentations has been truncated, see + # {Courier::Models::Users::PreferenceUpdateOrCreateTopicParams::Topic} for more + # details. # - # @param custom_routing [Array, nil] The Channels a user has chosen to receive notifications through for this topic + # @param status [Symbol, Courier::Models::PreferenceStatus] The subscription status to set: OPTED_IN or OPTED_OUT. REQUIRED is a topic-level # - # @param has_custom_routing [Boolean, nil] + # @param custom_routing [Array, nil] The channels to deliver this topic on when has_custom_routing is true. One or mo + # + # @param has_custom_routing [Boolean, nil] Set to true to route this topic to the channels in custom_routing instead of the end end end diff --git a/lib/courier/models/users/topic_preference.rb b/lib/courier/models/users/topic_preference.rb index 6035e8f9..15873002 100644 --- a/lib/courier/models/users/topic_preference.rb +++ b/lib/courier/models/users/topic_preference.rb @@ -5,27 +5,36 @@ module Models module Users class TopicPreference < Courier::Internal::Type::BaseModel # @!attribute default_status + # The topic's default status, returned on reads. It applies whenever the user has + # no override of their own (status equals this value). # # @return [Symbol, Courier::Models::PreferenceStatus] required :default_status, enum: -> { Courier::PreferenceStatus } # @!attribute status + # The user's subscription status for this topic. OPTED_IN or OPTED_OUT reflect the + # user's own choice; REQUIRED is a topic-level default set in the preferences + # editor, not a user choice. # # @return [Symbol, Courier::Models::PreferenceStatus] required :status, enum: -> { Courier::PreferenceStatus } # @!attribute topic_id + # The unique identifier of the subscription topic this preference applies to. # # @return [String] required :topic_id, String # @!attribute topic_name + # The display name of the subscription topic, returned on reads. # # @return [String] required :topic_name, String # @!attribute custom_routing - # The Channels a user has chosen to receive notifications through for this topic + # The channels the user has chosen to receive this topic on, present only when + # has_custom_routing is true. One or more of: direct_message, email, push, sms, + # webhook, inbox. # # @return [Array, nil] optional :custom_routing, @@ -33,22 +42,27 @@ class TopicPreference < Courier::Internal::Type::BaseModel nil?: true # @!attribute has_custom_routing + # Whether the user has chosen specific delivery channels for this topic (listed in + # custom_routing) rather than the topic's default routing. # # @return [Boolean, nil] optional :has_custom_routing, Courier::Internal::Type::Boolean, nil?: true # @!method initialize(default_status:, status:, topic_id:, topic_name:, custom_routing: nil, has_custom_routing: nil) - # @param default_status [Symbol, Courier::Models::PreferenceStatus] + # Some parameter documentations has been truncated, see + # {Courier::Models::Users::TopicPreference} for more details. # - # @param status [Symbol, Courier::Models::PreferenceStatus] + # @param default_status [Symbol, Courier::Models::PreferenceStatus] The topic's default status, returned on reads. It applies whenever the user has # - # @param topic_id [String] + # @param status [Symbol, Courier::Models::PreferenceStatus] The user's subscription status for this topic. OPTED_IN or OPTED_OUT reflect the # - # @param topic_name [String] + # @param topic_id [String] The unique identifier of the subscription topic this preference applies to. # - # @param custom_routing [Array, nil] The Channels a user has chosen to receive notifications through for this topic + # @param topic_name [String] The display name of the subscription topic, returned on reads. # - # @param has_custom_routing [Boolean, nil] + # @param custom_routing [Array, nil] The channels the user has chosen to receive this topic on, present only when has + # + # @param has_custom_routing [Boolean, nil] Whether the user has chosen specific delivery channels for this topic (listed in end end end diff --git a/lib/courier/models/workspace_preference_create_params.rb b/lib/courier/models/workspace_preference_create_params.rb index 46baf01c..d2583ebd 100644 --- a/lib/courier/models/workspace_preference_create_params.rb +++ b/lib/courier/models/workspace_preference_create_params.rb @@ -7,7 +7,19 @@ class WorkspacePreferenceCreateParams < Courier::Models::WorkspacePreferenceCrea extend Courier::Internal::Type::RequestParameters::Converter include Courier::Internal::Type::RequestParameters - # @!method initialize(request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) + # @param idempotency_key [String] + # @param x_idempotency_expiration [String] # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] end end diff --git a/lib/courier/models/workspace_preference_publish_params.rb b/lib/courier/models/workspace_preference_publish_params.rb index e7156d78..2c646895 100644 --- a/lib/courier/models/workspace_preference_publish_params.rb +++ b/lib/courier/models/workspace_preference_publish_params.rb @@ -7,7 +7,19 @@ class WorkspacePreferencePublishParams < Courier::Models::PublishPreferencesRequ extend Courier::Internal::Type::RequestParameters::Converter include Courier::Internal::Type::RequestParameters - # @!method initialize(request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) + # @param idempotency_key [String] + # @param x_idempotency_expiration [String] # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] end end diff --git a/lib/courier/models/workspace_preferences/topic_create_params.rb b/lib/courier/models/workspace_preferences/topic_create_params.rb index 97773db0..c6adcc77 100644 --- a/lib/courier/models/workspace_preferences/topic_create_params.rb +++ b/lib/courier/models/workspace_preferences/topic_create_params.rb @@ -13,8 +13,20 @@ class TopicCreateParams < Courier::Models::WorkspacePreferenceTopicCreateRequest # @return [String] required :section_id, String - # @!method initialize(section_id:, request_options: {}) + # @!attribute idempotency_key + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute x_idempotency_expiration + # + # @return [String, nil] + optional :x_idempotency_expiration, String + + # @!method initialize(section_id:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # @param section_id [String] + # @param idempotency_key [String] + # @param x_idempotency_expiration [String] # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] end end diff --git a/lib/courier/resources/audiences.rb b/lib/courier/resources/audiences.rb index d406a3d6..ba71e57b 100644 --- a/lib/courier/resources/audiences.rb +++ b/lib/courier/resources/audiences.rb @@ -3,7 +3,8 @@ module Courier module Resources class Audiences - # Returns the specified audience by id. + # Returns one audience with its name, description, and the filter and AND or OR + # operator that decide which users belong to it. # # @overload retrieve(audience_id, request_options: {}) # @@ -26,7 +27,8 @@ def retrieve(audience_id, params = {}) # Some parameter documentations has been truncated, see # {Courier::Models::AudienceUpdateParams} for more details. # - # Creates or updates audience. + # Creates or replaces an audience from a filter and an AND or OR operator. + # Membership recalculates automatically as profiles change. # # @overload update(audience_id, description: nil, filter: nil, name: nil, operator: nil, request_options: {}) # @@ -56,7 +58,8 @@ def update(audience_id, params = {}) ) end - # Get the audiences associated with the authorization token. + # Returns the audiences in the workspace with paging. Audiences are filter-based + # groups that recalculate as user profiles change. # # @overload list(cursor: nil, request_options: {}) # @@ -79,7 +82,8 @@ def list(params = {}) ) end - # Deletes the specified audience. + # Deletes an audience permanently, so update any caller sending to it by audience + # id first. Those sends fail once the audience is gone. # # @overload delete(audience_id, request_options: {}) # @@ -99,7 +103,8 @@ def delete(audience_id, params = {}) ) end - # Get list of members of an audience. + # Returns the users currently matching an audience filter, with paging. Membership + # is recalculated, so results shift as profiles change. # # @overload list_members(audience_id, cursor: nil, request_options: {}) # diff --git a/lib/courier/resources/audit_events.rb b/lib/courier/resources/audit_events.rb index 1fcb8c85..8d95714c 100644 --- a/lib/courier/resources/audit_events.rb +++ b/lib/courier/resources/audit_events.rb @@ -3,7 +3,8 @@ module Courier module Resources class AuditEvents - # Fetch a specific audit event by ID. + # Returns one audit event by id, including the actor who performed it, the target + # they changed, the source, the event type, and a timestamp. # # @overload retrieve(audit_event_id, request_options: {}) # @@ -23,7 +24,8 @@ def retrieve(audit_event_id, params = {}) ) end - # Fetch the list of audit events + # Returns the workspace's audit event log with cursor paging. Each event records + # the actor, target, source, type, and timestamp of a change. # # @overload list(cursor: nil, request_options: {}) # diff --git a/lib/courier/resources/auth.rb b/lib/courier/resources/auth.rb index b9f9aac9..756e7588 100644 --- a/lib/courier/resources/auth.rb +++ b/lib/courier/resources/auth.rb @@ -6,7 +6,8 @@ class Auth # Some parameter documentations has been truncated, see # {Courier::Models::AuthIssueTokenParams} for more details. # - # Returns a new access token. + # Returns a JWT for authenticating client-side SDKs such as the Inbox. You supply + # the scope and an expires_in duration, both required. # # @overload issue_token(expires_in:, scope:, request_options: {}) # diff --git a/lib/courier/resources/automations.rb b/lib/courier/resources/automations.rb index 738c4ac4..71ddaeea 100644 --- a/lib/courier/resources/automations.rb +++ b/lib/courier/resources/automations.rb @@ -9,7 +9,8 @@ class Automations # Some parameter documentations has been truncated, see # {Courier::Models::AutomationListParams} for more details. # - # Get the list of automations. + # Lists the workspace's saved automation templates, each with its id and a cursor + # for paging to the next page of results. # # @overload list(cursor: nil, version: nil, request_options: {}) # diff --git a/lib/courier/resources/automations/invoke.rb b/lib/courier/resources/automations/invoke.rb index 9a5fc62f..77a769bf 100644 --- a/lib/courier/resources/automations/invoke.rb +++ b/lib/courier/resources/automations/invoke.rb @@ -4,19 +4,30 @@ module Courier module Resources class Automations class Invoke - # Invoke an ad hoc automation run. This endpoint accepts a JSON payload with a - # series of automation steps. For information about what steps are available, - # checkout the ad hoc automation guide - # [here](https://www.courier.com/docs/automations/steps/). - # - # @overload invoke_ad_hoc(automation:, brand: nil, data: nil, profile: nil, recipient: nil, template: nil, request_options: {}) - # - # @param automation [Courier::Models::Automations::InvokeInvokeAdHocParams::Automation] - # @param brand [String, nil] - # @param data [Hash{Symbol=>Object}, nil] - # @param profile [Hash{Symbol=>Object}, nil] - # @param recipient [String, nil] - # @param template [String, nil] + # Some parameter documentations has been truncated, see + # {Courier::Models::Automations::InvokeInvokeAdHocParams} for more details. + # + # Runs a series of automation steps supplied inline, without a saved template, and + # returns a runId. + # + # @overload invoke_ad_hoc(automation:, brand: nil, data: nil, profile: nil, recipient: nil, template: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) + # + # @param automation [Courier::Models::Automations::InvokeInvokeAdHocParams::Automation] Body param + # + # @param brand [String, nil] Body param + # + # @param data [Hash{Symbol=>Object}, nil] Body param + # + # @param profile [Hash{Symbol=>Object}, nil] Body param + # + # @param recipient [String, nil] Body param + # + # @param template [String, nil] Body param + # + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv + # + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest + # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # # @return [Courier::Models::AutomationInvokeResponse] @@ -24,10 +35,13 @@ class Invoke # @see Courier::Models::Automations::InvokeInvokeAdHocParams def invoke_ad_hoc(params) parsed, options = Courier::Automations::InvokeInvokeAdHocParams.dump_request(params) + header_params = + {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: "automations/invoke", - body: parsed, + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*header_params.keys), model: Courier::AutomationInvokeResponse, options: options ) @@ -36,21 +50,26 @@ def invoke_ad_hoc(params) # Some parameter documentations has been truncated, see # {Courier::Models::Automations::InvokeInvokeByTemplateParams} for more details. # - # Invoke an automation run from an automation template. + # Starts an automation run from a saved template for one recipient, with optional + # data and profile, and returns a runId. + # + # @overload invoke_by_template(template_id, recipient:, brand: nil, data: nil, profile: nil, template: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) + # + # @param template_id [String] Path param: A unique identifier representing the automation template to be invok # - # @overload invoke_by_template(template_id, recipient:, brand: nil, data: nil, profile: nil, template: nil, request_options: {}) + # @param recipient [String, nil] Body param # - # @param template_id [String] A unique identifier representing the automation template to be invoked. This cou + # @param brand [String, nil] Body param # - # @param recipient [String, nil] + # @param data [Hash{Symbol=>Object}, nil] Body param # - # @param brand [String, nil] + # @param profile [Hash{Symbol=>Object}, nil] Body param # - # @param data [Hash{Symbol=>Object}, nil] + # @param template [String, nil] Body param # - # @param profile [Hash{Symbol=>Object}, nil] + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv # - # @param template [String, nil] + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # @@ -59,10 +78,13 @@ def invoke_ad_hoc(params) # @see Courier::Models::Automations::InvokeInvokeByTemplateParams def invoke_by_template(template_id, params) parsed, options = Courier::Automations::InvokeInvokeByTemplateParams.dump_request(params) + header_params = + {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: ["automations/%1$s/invoke", template_id], - body: parsed, + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*header_params.keys), model: Courier::AutomationInvokeResponse, options: options ) diff --git a/lib/courier/resources/brands.rb b/lib/courier/resources/brands.rb index 19e56383..b88552b7 100644 --- a/lib/courier/resources/brands.rb +++ b/lib/courier/resources/brands.rb @@ -3,15 +3,26 @@ module Courier module Resources class Brands - # Create a new brand. Requires `name` and `settings` (with at least - # `colors.primary` and `colors.secondary`). + # Some parameter documentations has been truncated, see + # {Courier::Models::BrandCreateParams} for more details. # - # @overload create(name:, settings:, id: nil, snippets: nil, request_options: {}) + # Creates a brand from a name and settings, including primary and secondary + # colors. Brands supply the logo, colors, and styling that templates render with. + # + # @overload create(name:, settings:, id: nil, snippets: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) + # + # @param name [String] Body param + # + # @param settings [Courier::Models::BrandSettings] Body param + # + # @param id [String, nil] Body param + # + # @param snippets [Courier::Models::BrandSnippets, nil] Body param + # + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv + # + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest # - # @param name [String] - # @param settings [Courier::Models::BrandSettings] - # @param id [String, nil] - # @param snippets [Courier::Models::BrandSnippets, nil] # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # # @return [Courier::Models::Brand] @@ -19,10 +30,20 @@ class Brands # @see Courier::Models::BrandCreateParams def create(params) parsed, options = Courier::BrandCreateParams.dump_request(params) - @client.request(method: :post, path: "brands", body: parsed, model: Courier::Brand, options: options) + header_params = + {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} + @client.request( + method: :post, + path: "brands", + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*header_params.keys), + model: Courier::Brand, + options: options + ) end - # Fetch a specific brand by brand ID. + # Returns one brand by id, including its colors, logo and styling settings, + # Handlebars snippets, and published version. # # @overload retrieve(brand_id, request_options: {}) # @@ -42,7 +63,8 @@ def retrieve(brand_id, params = {}) ) end - # Replace an existing brand with the supplied values. + # Replaces a brand with the values you supply, so send the complete settings and + # snippets rather than only the fields you want changed. # # @overload update(brand_id, name:, settings: nil, snippets: nil, request_options: {}) # @@ -70,7 +92,8 @@ def update(brand_id, params) ) end - # Get the list of brands. + # Lists the workspace's brands. Every entry carries its name, styling settings, + # snippets, and published version. # # @overload list(cursor: nil, request_options: {}) # @@ -93,7 +116,8 @@ def list(params = {}) ) end - # Delete a brand by brand ID. + # Deletes a brand by id. Reassign any template or tenant that references it before + # deleting to keep their styling intact. # # @overload delete(brand_id, request_options: {}) # diff --git a/lib/courier/resources/digests/schedules.rb b/lib/courier/resources/digests/schedules.rb index decde45f..d976d4f8 100644 --- a/lib/courier/resources/digests/schedules.rb +++ b/lib/courier/resources/digests/schedules.rb @@ -7,9 +7,8 @@ class Schedules # Some parameter documentations has been truncated, see # {Courier::Models::Digests::ScheduleListInstancesParams} for more details. # - # List the digest instances for a schedule. Each instance represents the events - # accumulated for a single user against the schedule, and can be used to monitor - # digest accumulation before the digest is released. + # Returns the digest instances for a schedule, one per user, with cursor paging. + # Use it to see what has accumulated before a digest releases. # # @overload list_instances(schedule_id, cursor: nil, limit: nil, request_options: {}) # diff --git a/lib/courier/resources/inbound.rb b/lib/courier/resources/inbound.rb index 59c070bd..868240f1 100644 --- a/lib/courier/resources/inbound.rb +++ b/lib/courier/resources/inbound.rb @@ -6,7 +6,8 @@ class Inbound # Some parameter documentations has been truncated, see # {Courier::Models::InboundTrackEventParams} for more details. # - # Courier Track Event + # Records an inbound event that can trigger a journey. Requires an event name, a + # messageId you generate, a type, and a properties object. # # @overload track_event(event:, message_id:, properties:, type:, user_id: nil, request_options: {}) # diff --git a/lib/courier/resources/inbox.rb b/lib/courier/resources/inbox.rb new file mode 100644 index 00000000..08329e79 --- /dev/null +++ b/lib/courier/resources/inbox.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Courier + module Resources + class Inbox + # @return [Courier::Resources::Inbox::Messages] + attr_reader :messages + + # @api private + # + # @param client [Courier::Client] + def initialize(client:) + @client = client + @messages = Courier::Resources::Inbox::Messages.new(client: client) + end + end + end +end diff --git a/lib/courier/resources/inbox/messages.rb b/lib/courier/resources/inbox/messages.rb new file mode 100644 index 00000000..e6d30005 --- /dev/null +++ b/lib/courier/resources/inbox/messages.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +module Courier + module Resources + class Inbox + class Messages + # Delete a user's inbox message. The message is removed from every inbox read (it + # stops appearing in the recipient's Inbox); it can be restored. + # + # @overload delete(message_id, request_options: {}) + # + # @param message_id [String] The message ID of the inbox message to delete. + # + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [nil] + # + # @see Courier::Models::Inbox::MessageDeleteParams + def delete(message_id, params = {}) + @client.request( + method: :delete, + path: ["inbox/messages/%1$s", message_id], + model: NilClass, + options: params[:request_options] + ) + end + + # Restore a previously deleted inbox message. + # + # @overload restore(message_id, request_options: {}) + # + # @param message_id [String] The message ID of the inbox message to restore. + # + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [nil] + # + # @see Courier::Models::Inbox::MessageRestoreParams + def restore(message_id, params = {}) + @client.request( + method: :put, + path: ["inbox/messages/%1$s/restore", message_id], + model: NilClass, + options: params[:request_options] + ) + end + + # @api private + # + # @param client [Courier::Client] + def initialize(client:) + @client = client + end + end + end + end +end diff --git a/lib/courier/resources/journeys.rb b/lib/courier/resources/journeys.rb index 298afc57..b464d6c1 100644 --- a/lib/courier/resources/journeys.rb +++ b/lib/courier/resources/journeys.rb @@ -6,22 +6,25 @@ class Journeys # @return [Courier::Resources::Journeys::Templates] attr_reader :templates - # Create a journey. Defaults to `DRAFT` state; pass `state: "PUBLISHED"` to - # publish on create. Send nodes are not allowed on `POST`. The standard flow is: - # create the journey shell here, add notification templates with - # `POST /journeys/{templateId}/templates`, then wire them into the journey with - # `PUT /journeys/{templateId}`. Call `POST /journeys/{templateId}/publish` to - # publish a draft after the fact. + # Some parameter documentations has been truncated, see + # {Courier::Models::JourneyCreateParams} for more details. # - # @overload create(name:, nodes:, enabled: nil, state: nil, request_options: {}) + # Creates a journey from a set of nodes, in draft state unless you pass a + # published state. Send nodes cannot be included until their templates exist. # - # @param name [String] + # @overload create(name:, nodes:, enabled: nil, state: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # - # @param nodes [Array] + # @param name [String] Body param # - # @param enabled [Boolean] + # @param nodes [Array] Body param # - # @param state [Symbol, Courier::Models::JourneyState] Lifecycle state of a journey. + # @param enabled [Boolean] Body param + # + # @param state [Symbol, Courier::Models::JourneyState] Body param: Lifecycle state of a journey. + # + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv + # + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # @@ -30,10 +33,13 @@ class Journeys # @see Courier::Models::JourneyCreateParams def create(params) parsed, options = Courier::JourneyCreateParams.dump_request(params) + header_params = + {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: "journeys", - body: parsed, + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*header_params.keys), model: Courier::JourneyResponse, options: options ) @@ -68,7 +74,8 @@ def retrieve(template_id, params = {}) # Some parameter documentations has been truncated, see # {Courier::Models::JourneyListParams} for more details. # - # Get the list of journeys. + # Lists the workspace's journeys, each carrying a name, state, and enabled flag. + # Paged by cursor. # # @overload list(cursor: nil, version: nil, request_options: {}) # @@ -93,8 +100,8 @@ def list(params = {}) ) end - # Archive a journey. Archived journeys cannot be invoked. Existing journey runs - # continue to completion. + # Archives a journey so it can no longer be invoked. Runs already in flight + # continue to completion, so archiving never strands a user mid-sequence. # # @overload archive(template_id, request_options: {}) # @@ -117,16 +124,16 @@ def archive(template_id, params = {}) # Some parameter documentations has been truncated, see # {Courier::Models::JourneyCancelParams} for more details. # - # Cancel journey runs. The request body must include EXACTLY ONE of - # `cancelation_token` (cancels every run associated with the token) or `run_id` - # (cancels a single tenant-scoped run). Supplying both or neither returns a `400`. - # A `run_id` that does not match a run for the tenant returns `404`. Cancelation - # is idempotent: a run that has already finished (`PROCESSED`/`ERROR`) or was - # already `CANCELED` is left unchanged and its current status is returned. + # Cancels in-flight journey runs, either every run sharing a cancelation token or + # one run by id. Use it to stop a sequence when the event resolves. + # + # @overload cancel(cancel_journey_request:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # - # @overload cancel(cancel_journey_request:, request_options: {}) + # @param cancel_journey_request [Courier::Models::CancelJourneyRequest::ByCancelationToken, Courier::Models::CancelJourneyRequest::ByRunID] Body param: Request body for `POST /journeys/cancel`. Provide EXACTLY ONE of `ca # - # @param cancel_journey_request [Courier::Models::CancelJourneyRequest::ByCancelationToken, Courier::Models::CancelJourneyRequest::ByRunID] Request body for `POST /journeys/cancel`. Provide EXACTLY ONE of `cancelation_to + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv + # + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # @@ -138,6 +145,10 @@ def cancel(params) @client.request( method: :post, path: "journeys/cancel", + headers: parsed.except(:cancel_journey_request).transform_keys( + idempotency_key: "idempotency-key", + x_idempotency_expiration: "x-idempotency-expiration" + ), body: parsed[:cancel_journey_request], model: Courier::CancelJourneyResponse, options: options @@ -147,18 +158,22 @@ def cancel(params) # Some parameter documentations has been truncated, see # {Courier::Models::JourneyInvokeParams} for more details. # - # Invoke a journey by id or alias to start a new run. The response includes a - # `runId` identifying the run. + # Starts a journey run for one user and returns a runId. Runs execute + # asynchronously, so the response arrives before any message is sent. + # + # @overload invoke(template_id, data: nil, profile: nil, user_id: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) + # + # @param template_id [String] Path param: A unique identifier representing the journey to be invoked. Accepts # - # @overload invoke(template_id, data: nil, profile: nil, user_id: nil, request_options: {}) + # @param data [Hash{Symbol=>Object}] Body param: Data payload passed to the journey. The expected shape can be predef # - # @param template_id [String] A unique identifier representing the journey to be invoked. Accepts a Journey ID + # @param profile [Hash{Symbol=>Object}] Body param: Profile data for the user. Can contain contact information (email, p # - # @param data [Hash{Symbol=>Object}] Data payload passed to the journey. The expected shape can be predefined using t + # @param user_id [String] Body param: A unique identifier for the user. If not provided, the system will a # - # @param profile [Hash{Symbol=>Object}] Profile data for the user. Can contain contact information (email, phone_number) + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv # - # @param user_id [String] A unique identifier for the user. If not provided, the system will attempt to re + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # @@ -167,16 +182,20 @@ def cancel(params) # @see Courier::Models::JourneyInvokeParams def invoke(template_id, params = {}) parsed, options = Courier::JourneyInvokeParams.dump_request(params) + header_params = + {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: ["journeys/%1$s/invoke", template_id], - body: parsed, + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*header_params.keys), model: Courier::JourneysInvokeResponse, options: options ) end - # List published versions of a journey, ordered most recent first. + # Lists a journey's published versions, most recent first, so you have a version + # id to roll back to. Paged by cursor. # # @overload list_versions(template_id, request_options: {}) # @@ -196,15 +215,21 @@ def list_versions(template_id, params = {}) ) end - # Publish the current draft as a new version. Body is optional; pass - # `{ "version": "vN" }` to roll back to a prior version instead. Returns 404 if - # the journey has no draft to publish. + # Some parameter documentations has been truncated, see + # {Courier::Models::JourneyPublishParams} for more details. # - # @overload publish(template_id, version: nil, request_options: {}) + # Publishes a journey's current draft as a new version, making it live for new + # runs. Pass a version instead to roll back to an earlier one. # - # @param template_id [String] Journey id + # @overload publish(template_id, version: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) + # + # @param template_id [String] Path param: Journey id + # + # @param version [String] Body param # - # @param version [String] + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv + # + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # @@ -213,20 +238,20 @@ def list_versions(template_id, params = {}) # @see Courier::Models::JourneyPublishParams def publish(template_id, params = {}) parsed, options = Courier::JourneyPublishParams.dump_request(params) + header_params = + {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: ["journeys/%1$s/publish", template_id], - body: parsed, + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*header_params.keys), model: Courier::JourneyResponse, options: options ) end - # Replace the journey draft. Updates the working draft only; call - # `POST /journeys/{templateId}/publish` to make it live, or pass - # `state: "PUBLISHED"` in this request to publish immediately. Send-node - # `template` ids must already exist and be scoped to this journey, and node ids - # must not be claimed by another journey. + # Replaces a journey's working draft, leaving the published version live until you + # publish. Reach for this when editing a journey already running. # # @overload replace(template_id, name:, nodes:, enabled: nil, state: nil, request_options: {}) # diff --git a/lib/courier/resources/journeys/templates.rb b/lib/courier/resources/journeys/templates.rb index 8ce57501..25614715 100644 --- a/lib/courier/resources/journeys/templates.rb +++ b/lib/courier/resources/journeys/templates.rb @@ -4,20 +4,27 @@ module Courier module Resources class Journeys class Templates + # Some parameter documentations has been truncated, see + # {Courier::Models::Journeys::TemplateCreateParams} for more details. + # # Create a notification template scoped to this journey. Defaults to `DRAFT` # state; pass `state: "PUBLISHED"` to publish on create. # - # @overload create(template_id, channel:, notification:, provider_key: nil, state: nil, request_options: {}) + # @overload create(template_id, channel:, notification:, provider_key: nil, state: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # - # @param template_id [String] Journey id + # @param template_id [String] Path param: Journey id # - # @param channel [String] + # @param channel [String] Body param # - # @param notification [Courier::Models::JourneyTemplateCreateRequest::Notification] + # @param notification [Courier::Models::JourneyTemplateCreateRequest::Notification] Body param + # + # @param provider_key [String] Body param + # + # @param state [String] Body param # - # @param provider_key [String] + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv # - # @param state [String] + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # @@ -26,18 +33,20 @@ class Templates # @see Courier::Models::Journeys::TemplateCreateParams def create(template_id, params) parsed, options = Courier::Journeys::TemplateCreateParams.dump_request(params) + header_params = + {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: ["journeys/%1$s/templates", template_id], - body: parsed, + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*header_params.keys), model: Courier::JourneyTemplateGetResponse, options: options ) end - # Fetch a journey-scoped notification template by id. Pass `?version=draft` - # (default `published`) to retrieve the working draft, or `?version=vN` for a - # historical version. + # Returns a journey's own notification template with its name, brand, subscription + # topic, and content. Defaults to the published version. # # @overload retrieve(notification_id, template_id:, request_options: {}) # @@ -92,8 +101,8 @@ def list(template_id, params = {}) ) end - # Archive the journey-scoped notification template. Archived templates cannot be - # sent. + # Archives one journey's notification template, preventing further sends. Detach + # any send node referencing it beforehand. # # @overload archive(notification_id, template_id:, request_options: {}) # @@ -120,8 +129,8 @@ def archive(notification_id, params) ) end - # List published versions of the journey-scoped notification template, ordered - # most recent first. + # Lists the published versions of a template that belongs to a journey, most + # recent first. Paged by cursor. # # @overload list_versions(notification_id, template_id:, request_options: {}) # @@ -148,11 +157,13 @@ def list_versions(notification_id, params) ) end - # Publish the current draft of the journey-scoped notification template as a new - # version. Optionally roll back to a prior version by passing - # `{ "version": "vN" }`. + # Some parameter documentations has been truncated, see + # {Courier::Models::Journeys::TemplatePublishParams} for more details. + # + # Publishes a journey-scoped template's draft as a new version. Pass a version + # instead to roll back the template to an earlier publish. # - # @overload publish(notification_id, template_id:, version: nil, request_options: {}) + # @overload publish(notification_id, template_id:, version: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # # @param notification_id [String] Path param: Notification template id # @@ -160,6 +171,10 @@ def list_versions(notification_id, params) # # @param version [String] Body param # + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv + # + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest + # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # # @return [nil] @@ -171,10 +186,13 @@ def publish(notification_id, params) parsed.delete(:template_id) do raise ArgumentError.new("missing required path argument #{_1}") end + header_params = + {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: ["journeys/%1$s/templates/%2$s/publish", template_id, notification_id], - body: parsed, + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*header_params.keys), model: NilClass, options: options ) @@ -255,7 +273,8 @@ def put_locale(locale_id, params) ) end - # Replace the journey-scoped notification template draft. + # Replaces the draft content of one journey's notification template. Publish it + # before send nodes referencing it render the change. # # @overload replace(notification_id, template_id:, notification:, state: nil, request_options: {}) # @@ -290,11 +309,8 @@ def replace(notification_id, params) # Some parameter documentations has been truncated, see # {Courier::Models::Journeys::TemplateRetrieveContentParams} for more details. # - # Retrieve the elemental content of a journey-scoped notification template. The - # response contains the versioned elements along with their content checksums, - # which can be used to detect changes between versions. Pass `?version=draft` - # (default `published`) to retrieve the working draft, or `?version=vN` for a - # historical version. + # Returns the Elemental elements and version of a journey-scoped template's + # content. Compare versions to see what changed between publishes. # # @overload retrieve_content(notification_id, template_id:, version: nil, request_options: {}) # diff --git a/lib/courier/resources/lists.rb b/lib/courier/resources/lists.rb index 81c52668..487b1c3e 100644 --- a/lib/courier/resources/lists.rb +++ b/lib/courier/resources/lists.rb @@ -6,7 +6,8 @@ class Lists # @return [Courier::Resources::Lists::Subscriptions] attr_reader :subscriptions - # Returns a list based on the list ID provided. + # Returns one list by id with its name and created and updated timestamps. Fetch + # its subscribers separately with the subscriptions endpoint. # # @overload retrieve(list_id, request_options: {}) # @@ -26,7 +27,8 @@ def retrieve(list_id, params = {}) ) end - # Create or replace an existing list with the supplied values. + # Creates or replaces a list from a name and preferences. Subscribers are managed + # through the separate subscriptions endpoints. # # @overload update(list_id, name:, preferences: nil, request_options: {}) # @@ -55,7 +57,8 @@ def update(list_id, params) # Some parameter documentations has been truncated, see # {Courier::Models::ListListParams} for more details. # - # Returns all of the lists, with the ability to filter based on a pattern. + # Returns the workspace's lists, filterable by a pattern to fetch a subset such as + # every regional list. Paged by cursor. # # @overload list(cursor: nil, pattern: nil, request_options: {}) # @@ -80,7 +83,8 @@ def list(params = {}) ) end - # Delete a list by list ID. + # Deletes a list, halting sends that target it. A previously deleted list can be + # brought back with the companion restore endpoint. # # @overload delete(list_id, request_options: {}) # @@ -100,7 +104,8 @@ def delete(list_id, params = {}) ) end - # Restore a previously deleted list. + # Restores a previously deleted list along with its subscribers, so a list removed + # by mistake can be brought back rather than rebuilt. # # @overload restore(list_id, request_options: {}) # diff --git a/lib/courier/resources/lists/subscriptions.rb b/lib/courier/resources/lists/subscriptions.rb index c99377a9..7cc3f0b7 100644 --- a/lib/courier/resources/lists/subscriptions.rb +++ b/lib/courier/resources/lists/subscriptions.rb @@ -4,7 +4,8 @@ module Courier module Resources class Lists class Subscriptions - # Get the list's subscriptions. + # Returns the users subscribed to a list with paging, each with the preferences + # recorded for that subscription. # # @overload list(list_id, cursor: nil, request_options: {}) # @@ -29,14 +30,21 @@ def list(list_id, params = {}) ) end + # Some parameter documentations has been truncated, see + # {Courier::Models::Lists::SubscriptionAddParams} for more details. + # # Subscribes additional users to the list, without modifying existing # subscriptions. If the list does not exist, it will be automatically created. # - # @overload add(list_id, recipients:, request_options: {}) + # @overload add(list_id, recipients:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # - # @param list_id [String] A unique identifier representing the list you wish to retrieve. + # @param list_id [String] Path param: A unique identifier representing the list you wish to retrieve. # - # @param recipients [Array] + # @param recipients [Array] Body param + # + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv + # + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # @@ -45,10 +53,13 @@ def list(list_id, params = {}) # @see Courier::Models::Lists::SubscriptionAddParams def add(list_id, params) parsed, options = Courier::Lists::SubscriptionAddParams.dump_request(params) + header_params = + {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: ["lists/%1$s/subscriptions", list_id], - body: parsed, + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*header_params.keys), model: NilClass, options: options ) @@ -82,8 +93,8 @@ def subscribe(list_id, params) # Some parameter documentations has been truncated, see # {Courier::Models::Lists::SubscriptionSubscribeUserParams} for more details. # - # Subscribe a user to an existing list (note: if the List does not exist, it will - # be automatically created). + # Subscribes one user to a list, creating the list if it does not yet exist. + # Optional preferences apply to this subscription only. # # @overload subscribe_user(user_id, list_id:, preferences: nil, request_options: {}) # @@ -113,7 +124,8 @@ def subscribe_user(user_id, params) ) end - # Delete a subscription to a list by list ID and user ID. + # Removes one user's subscription to a list, addressed by list id and user id. The + # user's profile and other subscriptions are separate resources. # # @overload unsubscribe_user(user_id, list_id:, request_options: {}) # diff --git a/lib/courier/resources/messages.rb b/lib/courier/resources/messages.rb index 504a57ab..a07ed48e 100644 --- a/lib/courier/resources/messages.rb +++ b/lib/courier/resources/messages.rb @@ -6,7 +6,8 @@ class Messages # Some parameter documentations has been truncated, see # {Courier::Models::MessageRetrieveParams} for more details. # - # Fetch the status of a message you've previously sent. + # Returns a sent message's status, recipient, event, and per-provider delivery + # detail, with timestamps for enqueued, sent, delivered, opened, and clicked. # # @overload retrieve(message_id, request_options: {}) # @@ -29,7 +30,8 @@ def retrieve(message_id, params = {}) # Some parameter documentations has been truncated, see # {Courier::Models::MessageListParams} for more details. # - # Fetch the statuses of messages you've previously sent. + # Returns previously sent messages, most recent first, each carrying its status, + # recipient, channel, and provider. Paged by cursor. # # @overload list(archived: nil, cursor: nil, enqueued_after: nil, event: nil, list: nil, message_id: nil, notification: nil, provider: nil, recipient: nil, status: nil, tag: nil, tags: nil, tenant_id: nil, trace_id: nil, request_options: {}) # @@ -78,11 +80,8 @@ def list(params = {}) ) end - # Cancel a message that is currently in the process of being delivered. A - # well-formatted API call to the cancel message API will return either `200` - # status code for a successful cancellation or `409` status code for an - # unsuccessful cancellation. Both cases will include the actual message record in - # the response body (see details below). + # Cancels a message that is still in the delivery pipeline and returns the message + # record with its resulting canceled or failed status. # # @overload cancel(message_id, request_options: {}) # @@ -105,7 +104,8 @@ def cancel(message_id, params = {}) # Some parameter documentations has been truncated, see # {Courier::Models::MessageContentParams} for more details. # - # Get message content + # Returns the rendered content Courier delivered for a message, broken out per + # channel, to confirm what the recipient received. # # @overload content(message_id, request_options: {}) # @@ -125,7 +125,8 @@ def content(message_id, params = {}) ) end - # Fetch the array of events of a message you've previously sent. + # Returns the ordered event history for a sent message, one entry per status + # transition with its timestamp. # # @overload history(message_id, type: nil, request_options: {}) # @@ -153,11 +154,8 @@ def history(message_id, params = {}) # Some parameter documentations has been truncated, see # {Courier::Models::MessageResendParams} for more details. # - # Resend a previously sent message. The original send request is loaded from - # storage and a brand-new send is enqueued for the same recipient and content, - # producing a **new** `messageId` — the original message is not modified. - # Throttled by a per-message rate limit; a repeat inside the limit window returns - # `429 Too Many Requests`. + # Resends a previously sent message to the same recipient and content, returning a + # new messageId. The original send request is not modified. # # @overload resend(message_id, request_options: {}) # diff --git a/lib/courier/resources/notifications.rb b/lib/courier/resources/notifications.rb index 410d855e..3208b2b5 100644 --- a/lib/courier/resources/notifications.rb +++ b/lib/courier/resources/notifications.rb @@ -12,11 +12,15 @@ class Notifications # Create a notification template. Requires all fields in the notification object. # Templates are created in draft state by default. # - # @overload create(notification:, state: nil, request_options: {}) + # @overload create(notification:, state: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # - # @param notification [Courier::Models::NotificationTemplatePayload] Core template fields used in POST and PUT request bodies (nested under a `notifi + # @param notification [Courier::Models::NotificationTemplatePayload] Body param: Core template fields used in POST and PUT request bodies (nested und + # + # @param state [Symbol, Courier::Models::NotificationTemplateCreateRequest::State] Body param: Template state after creation. Case-insensitive input, normalized to + # + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv # - # @param state [Symbol, Courier::Models::NotificationTemplateCreateRequest::State] Template state after creation. Case-insensitive input, normalized to uppercase i + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # @@ -25,10 +29,13 @@ class Notifications # @see Courier::Models::NotificationCreateParams def create(params) parsed, options = Courier::NotificationCreateParams.dump_request(params) + header_params = + {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: "notifications", - body: parsed, + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*header_params.keys), model: Courier::NotificationTemplateResponse, options: options ) @@ -63,7 +70,8 @@ def retrieve(id, params = {}) ) end - # List notification templates in your workspace. + # Lists the workspace's notification templates. Each carries a name, tags, brand, + # routing, and its draft or published state. # # @overload list(cursor: nil, event_id: nil, notes: nil, request_options: {}) # @@ -90,7 +98,8 @@ def list(params = {}) ) end - # Archive a notification template. + # Archives a notification template, preventing new sends from referencing it. The + # template stays retrievable for its version history. # # @overload archive(id, request_options: {}) # @@ -110,12 +119,9 @@ def archive(id, params = {}) ) end - # Duplicate a notification template. Creates a standalone copy within the same - # workspace and environment, with " COPY" appended to the title. The copy clones - # the source draft's tags, brand, subscription topic, routing strategy, channels, - # and content, and is always created as a standalone template (it is not linked to - # any journey or broadcast, even if the source was). Templates that are scoped to - # a journey or a broadcast cannot be duplicated through this endpoint. + # Copies a notification template within the same workspace and environment, + # appending " COPY" to the title. The copy is standalone and independently + # editable. # # @overload duplicate(id, request_options: {}) # @@ -135,7 +141,8 @@ def duplicate(id, params = {}) ) end - # List versions of a notification template. + # Returns a notification template's published versions, most recent first, for + # comparison or rollback. Paged. # # @overload list_versions(id, cursor: nil, limit: nil, request_options: {}) # @@ -162,14 +169,21 @@ def list_versions(id, params = {}) ) end + # Some parameter documentations has been truncated, see + # {Courier::Models::NotificationPublishParams} for more details. + # # Publish a notification template. Publishes the current draft by default. Pass a # version in the request body to publish a specific historical version. # - # @overload publish(id, version: nil, request_options: {}) + # @overload publish(id, version: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # - # @param id [String] Template ID (nt\_ prefix). + # @param id [String] Path param: Template ID (nt\_ prefix). + # + # @param version [String] Body param: Historical version to publish (e.g. "v001"). Omit to publish the cur # - # @param version [String] Historical version to publish (e.g. "v001"). Omit to publish the current draft. + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv + # + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # @@ -178,18 +192,20 @@ def list_versions(id, params = {}) # @see Courier::Models::NotificationPublishParams def publish(id, params = {}) parsed, options = Courier::NotificationPublishParams.dump_request(params) + header_params = + {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: ["notifications/%1$s/publish", id], - body: parsed, + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*header_params.keys), model: NilClass, options: options ) end - # Replace the elemental content of a notification template. Overwrites all - # elements in the template with the provided content. Only supported for V2 - # (elemental) templates. + # Replaces all Elemental content in a template, overwriting every existing + # element. Supported for V2 templates only, not V1 blocks and channels. # # @overload put_content(id, content:, state: nil, request_options: {}) # @@ -215,8 +231,8 @@ def put_content(id, params) ) end - # Update a single element within a notification template. Only supported for V2 - # (elemental) templates. + # Replaces one Elemental element in a template, addressed by its element id. + # Supported for V2 templates only, not V1 blocks and channels. # # @overload put_element(element_id, id:, type:, channels: nil, data: nil, if_: nil, loop_: nil, ref: nil, state: nil, request_options: {}) # @@ -258,9 +274,8 @@ def put_element(element_id, params) ) end - # Set locale-specific content overrides for a notification template. Each element - # override must reference an existing element by ID. Only supported for V2 - # (elemental) templates. + # Sets locale-specific content overrides for a template. Each override must + # reference an element that already exists in the default content. # # @overload put_locale(locale_id, id:, elements:, state: nil, request_options: {}) # @@ -295,7 +310,8 @@ def put_locale(locale_id, params) # Some parameter documentations has been truncated, see # {Courier::Models::NotificationReplaceParams} for more details. # - # Replace a notification template. All fields are required. + # Replaces a notification template in full, so send every field rather than only + # the ones you want changed. Publish separately to make it live. # # @overload replace(id, notification:, state: nil, request_options: {}) # @@ -324,10 +340,8 @@ def replace(id, params) # Some parameter documentations has been truncated, see # {Courier::Models::NotificationRetrieveContentParams} for more details. # - # Retrieve the content of a notification template. The response shape depends on - # whether the template uses V1 (blocks/channels) or V2 (elemental) content. Use - # the `version` query parameter to select draft, published, or a specific - # historical version. + # Returns a template's content and checksum. V2 templates return Elemental + # elements, while V1 templates return blocks and channels instead. # # @overload retrieve_content(id, version: nil, request_options: {}) # diff --git a/lib/courier/resources/notifications/checks.rb b/lib/courier/resources/notifications/checks.rb index f9a2524c..fc2df7d5 100644 --- a/lib/courier/resources/notifications/checks.rb +++ b/lib/courier/resources/notifications/checks.rb @@ -4,7 +4,8 @@ module Courier module Resources class Notifications class Checks - # Replace the submission checks for a notification template. + # Replaces the approval checks on a template submission with the complete set + # supplied in the request body. # # @overload update(submission_id, id:, checks:, request_options: {}) # @@ -34,7 +35,8 @@ def update(submission_id, params) ) end - # Retrieve the submission checks for a notification template. + # Returns the approval checks recorded for a template submission, each with its + # pass or fail result. # # @overload list(submission_id, id:, request_options: {}) # @@ -61,7 +63,8 @@ def list(submission_id, params) ) end - # Cancel a submission for a notification template. + # Cancels a pending template submission, withdrawing it from the approval + # workflow. The template stays in draft and can be resubmitted later. # # @overload delete(submission_id, id:, request_options: {}) # diff --git a/lib/courier/resources/profiles.rb b/lib/courier/resources/profiles.rb index d0d7fd32..b2d66452 100644 --- a/lib/courier/resources/profiles.rb +++ b/lib/courier/resources/profiles.rb @@ -9,14 +9,18 @@ class Profiles # Some parameter documentations has been truncated, see # {Courier::Models::ProfileCreateParams} for more details. # - # Merge the supplied values with an existing profile or create a new profile if - # one doesn't already exist. + # Merges the supplied values into a user's profile, creating it if absent and + # leaving any key you omit untouched. Prefer this for everyday writes. # - # @overload create(user_id, profile:, request_options: {}) + # @overload create(user_id, profile:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # - # @param user_id [String] A unique identifier representing the user associated with the requested profile. + # @param user_id [String] Path param: A unique identifier representing the user associated with the reques # - # @param profile [Hash{Symbol=>Object}] + # @param profile [Hash{Symbol=>Object}] Body param + # + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv + # + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # @@ -25,10 +29,13 @@ class Profiles # @see Courier::Models::ProfileCreateParams def create(user_id, params) parsed, options = Courier::ProfileCreateParams.dump_request(params) + header_params = + {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: ["profiles/%1$s", user_id], - body: parsed, + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*header_params.keys), model: Courier::Models::ProfileCreateResponse, options: options ) @@ -37,7 +44,8 @@ def create(user_id, params) # Some parameter documentations has been truncated, see # {Courier::Models::ProfileRetrieveParams} for more details. # - # Returns the specified user profile. + # Returns a user's stored profile and preferences, including the email address, + # phone number, and push tokens Courier can reach them on. # # @overload retrieve(user_id, request_options: {}) # @@ -60,7 +68,8 @@ def retrieve(user_id, params = {}) # Some parameter documentations has been truncated, see # {Courier::Models::ProfileUpdateParams} for more details. # - # Update a profile + # Applies a JSON Patch to a user profile, adding, removing, or replacing + # individual fields without sending the whole object. # # @overload update(user_id, patch:, request_options: {}) # @@ -87,7 +96,8 @@ def update(user_id, params) # Some parameter documentations has been truncated, see # {Courier::Models::ProfileDeleteParams} for more details. # - # Deletes the specified user profile. + # Deletes a user's profile and stored contact details. List subscriptions and + # preferences are separate resources, so remove those too if required. # # @overload delete(user_id, request_options: {}) # @@ -110,11 +120,8 @@ def delete(user_id, params = {}) # Some parameter documentations has been truncated, see # {Courier::Models::ProfileReplaceParams} for more details. # - # When using `PUT`, be sure to include all the key-value pairs required by the - # recipient's profile. Any key-value pairs that exist in the profile but fail to - # be included in the `PUT` request will be removed from the profile. Remember, a - # `PUT` update is a full replacement of the data. For partial updates, use the - # [Patch](https://www.courier.com/docs/reference/profiles/patch/) request. + # Overwrites a user profile in full, removing any key absent from the request + # body. Use the patch endpoint when changing a single field. # # @overload replace(user_id, profile:, request_options: {}) # diff --git a/lib/courier/resources/profiles/lists.rb b/lib/courier/resources/profiles/lists.rb index ea96c78b..6f5999b4 100644 --- a/lib/courier/resources/profiles/lists.rb +++ b/lib/courier/resources/profiles/lists.rb @@ -7,7 +7,8 @@ class Lists # Some parameter documentations has been truncated, see # {Courier::Models::Profiles::ListRetrieveParams} for more details. # - # Returns the subscribed lists for a specified user. + # Returns the lists a user is subscribed to, with paging. Use it to check what a + # recipient will receive before sending to a list. # # @overload retrieve(user_id, cursor: nil, request_options: {}) # @@ -35,7 +36,8 @@ def retrieve(user_id, params = {}) # Some parameter documentations has been truncated, see # {Courier::Models::Profiles::ListDeleteParams} for more details. # - # Removes all list subscriptions for given user. + # Removes every list subscription for a user at once. Their profile and + # preferences are untouched, so this only affects list-targeted sends. # # @overload delete(user_id, request_options: {}) # @@ -58,14 +60,18 @@ def delete(user_id, params = {}) # Some parameter documentations has been truncated, see # {Courier::Models::Profiles::ListSubscribeParams} for more details. # - # Subscribes the given user to one or more lists. If the list does not exist, it - # will be created. + # Subscribes a user to one or more lists, creating any list that does not yet + # exist. Optional preferences apply to each subscription. # - # @overload subscribe(user_id, lists:, request_options: {}) + # @overload subscribe(user_id, lists:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # - # @param user_id [String] A unique identifier representing the user associated with the requested user pro + # @param user_id [String] Path param: A unique identifier representing the user associated with the reques + # + # @param lists [Array] Body param + # + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv # - # @param lists [Array] + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # @@ -74,10 +80,13 @@ def delete(user_id, params = {}) # @see Courier::Models::Profiles::ListSubscribeParams def subscribe(user_id, params) parsed, options = Courier::Profiles::ListSubscribeParams.dump_request(params) + header_params = + {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: ["profiles/%1$s/lists", user_id], - body: parsed, + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*header_params.keys), model: Courier::Models::Profiles::ListSubscribeResponse, options: options ) diff --git a/lib/courier/resources/providers.rb b/lib/courier/resources/providers.rb index 3fca502e..d48db7e3 100644 --- a/lib/courier/resources/providers.rb +++ b/lib/courier/resources/providers.rb @@ -9,18 +9,22 @@ class Providers # Some parameter documentations has been truncated, see # {Courier::Models::ProviderCreateParams} for more details. # - # Create a new provider configuration. The `provider` field must be a known - # Courier provider key (see catalog). + # Configures a provider integration from a Courier provider key and its settings. + # Check the catalog endpoint for the schema each provider expects. # - # @overload create(provider:, alias_: nil, settings: nil, title: nil, request_options: {}) + # @overload create(provider:, alias_: nil, settings: nil, title: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # - # @param provider [String] The provider key identifying the type (e.g. "sendgrid", "twilio"). Must be a kno + # @param provider [String] Body param: The provider key identifying the type (e.g. "sendgrid", "twilio"). M # - # @param alias_ [String] Optional alias for this configuration. + # @param alias_ [String] Body param: Optional alias for this configuration. # - # @param settings [Hash{Symbol=>Object}] Provider-specific settings (snake_case keys). Defaults to an empty object when o + # @param settings [Hash{Symbol=>Object}] Body param: Provider-specific settings (snake_case keys). Defaults to an empty o # - # @param title [String] Optional display title. Omit to use "Default Configuration". + # @param title [String] Body param: Optional display title. Omit to use "Default Configuration". + # + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv + # + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # @@ -29,16 +33,20 @@ class Providers # @see Courier::Models::ProviderCreateParams 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", - body: parsed, + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*header_params.keys), model: Courier::Provider, options: options ) end - # Fetch a single provider configuration by ID. + # Returns one configured provider by id, including its channel, provider key, + # alias, title, and current settings. # # @overload retrieve(id, request_options: {}) # @@ -61,11 +69,8 @@ def retrieve(id, params = {}) # Some parameter documentations has been truncated, see # {Courier::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. + # Replaces a provider's configuration in full, clearing any field you omit rather + # than merging it. Send the complete settings object. # # @overload update(id, provider:, alias_: nil, settings: nil, title: nil, request_options: {}) # @@ -95,8 +100,8 @@ def update(id, params) ) end - # List configured provider integrations for the current workspace. Supports - # cursor-based pagination. + # Lists the provider integrations configured in the workspace, one entry per + # channel and provider key with its alias and settings. # # @overload list(cursor: nil, request_options: {}) # @@ -119,8 +124,8 @@ def list(params = {}) ) end - # Delete a provider configuration. Returns 409 if the provider is still referenced - # by routing or notifications. + # Deletes a provider configuration, which fails while routing strategies or + # templates still reference it. Update those references first. # # @overload delete(id, request_options: {}) # diff --git a/lib/courier/resources/providers/catalog.rb b/lib/courier/resources/providers/catalog.rb index e5611c84..f298f891 100644 --- a/lib/courier/resources/providers/catalog.rb +++ b/lib/courier/resources/providers/catalog.rb @@ -7,10 +7,8 @@ class Catalog # Some parameter documentations has been truncated, see # {Courier::Models::Providers::CatalogListParams} for more details. # - # Returns the catalog of available provider types with their display names, - # descriptions, and configuration schema fields (snake_case, with `type` and - # `required`). Providers with no configurable schema return only `provider`, - # `name`, and `description`. + # Returns the provider types Courier supports, each with a display name, + # description, and the configuration fields it requires. # # @overload list(channel: nil, keys: nil, name: nil, request_options: {}) # diff --git a/lib/courier/resources/requests.rb b/lib/courier/resources/requests.rb index 6d848dfd..4f665343 100644 --- a/lib/courier/resources/requests.rb +++ b/lib/courier/resources/requests.rb @@ -3,7 +3,8 @@ module Courier module Resources class Requests - # Archive message + # Archives a send request by its request id. Use it to remove test sends or + # superseded requests from the message list without deleting them. # # @overload archive(request_id, request_options: {}) # diff --git a/lib/courier/resources/routing_strategies.rb b/lib/courier/resources/routing_strategies.rb index 2121c931..f98215dc 100644 --- a/lib/courier/resources/routing_strategies.rb +++ b/lib/courier/resources/routing_strategies.rb @@ -3,22 +3,29 @@ module Courier module Resources class RoutingStrategies + # Some parameter documentations has been truncated, see + # {Courier::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. # - # @overload create(name:, routing:, channels: nil, description: nil, providers: nil, tags: nil, request_options: {}) + # @overload create(name:, routing:, channels: nil, description: nil, providers: nil, tags: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # - # @param name [String] Human-readable name for the routing strategy. + # @param name [String] Body param: Human-readable name for the routing strategy. # - # @param routing [Courier::Models::MessageRouting] Routing tree defining channel selection method and order. + # @param routing [Courier::Models::MessageRouting] Body param: Routing tree defining channel selection method and order. # - # @param channels [Hash{Symbol=>Courier::Models::Channel}, nil] Per-channel delivery configuration. Defaults to empty if omitted. + # @param channels [Hash{Symbol=>Courier::Models::Channel}, nil] Body param: Per-channel delivery configuration. Defaults to empty if omitted. # - # @param description [String, nil] Optional description of the routing strategy. + # @param description [String, nil] Body param: Optional description of the routing strategy. # - # @param providers [Hash{Symbol=>Courier::Models::MessageProvidersType}, nil] Per-provider delivery configuration. Defaults to empty if omitted. + # @param providers [Hash{Symbol=>Courier::Models::MessageProvidersType}, nil] Body param: Per-provider delivery configuration. Defaults to empty if omitted. # - # @param tags [Array, nil] Optional tags for categorization. + # @param tags [Array, nil] Body param: Optional tags for categorization. + # + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv + # + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # @@ -27,17 +34,20 @@ class RoutingStrategies # @see Courier::Models::RoutingStrategyCreateParams def create(params) parsed, options = Courier::RoutingStrategyCreateParams.dump_request(params) + header_params = + {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: "routing-strategies", - body: parsed, + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*header_params.keys), model: Courier::RoutingStrategyGetResponse, options: options ) end - # Retrieve a routing strategy by ID. Returns the full entity including routing - # content and metadata. + # Returns one routing strategy by id with its name, tags, channels, and the + # routing rules that decide provider order and fallback. # # @overload retrieve(id, request_options: {}) # @@ -105,8 +115,8 @@ def archive(id, params = {}) ) end - # List notification templates associated with a routing strategy. Includes - # template metadata only, not full content. + # Returns the notification templates using a routing strategy, with paging. Check + # this before changing a strategy that templates depend on. # # @overload list_notifications(id, cursor: nil, limit: nil, request_options: {}) # diff --git a/lib/courier/resources/send.rb b/lib/courier/resources/send.rb index 43c50dbc..047d99b4 100644 --- a/lib/courier/resources/send.rb +++ b/lib/courier/resources/send.rb @@ -6,11 +6,16 @@ class Send # Some parameter documentations has been truncated, see # {Courier::Models::SendMessageParams} for more details. # - # Send a message to one or more recipients. + # Sends a message to one or more recipients and returns a requestId. Courier + # routes it to email, SMS, push, chat, or in-app based on your rules. # - # @overload message(message:, request_options: {}) + # @overload message(message:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # - # @param message [Courier::Models::SendMessageParams::Message] The message property has the following primary top-level properties. They define + # @param message [Courier::Models::SendMessageParams::Message] Body param: The message property has the following primary top-level properties. + # + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv + # + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # @@ -19,10 +24,13 @@ class Send # @see Courier::Models::SendMessageParams def message(params) parsed, options = Courier::SendMessageParams.dump_request(params) + header_params = + {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: "send", - body: parsed, + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*header_params.keys), model: Courier::Models::SendMessageResponse, options: options ) diff --git a/lib/courier/resources/tenants.rb b/lib/courier/resources/tenants.rb index 52be0202..9bb7dbfd 100644 --- a/lib/courier/resources/tenants.rb +++ b/lib/courier/resources/tenants.rb @@ -9,7 +9,8 @@ class Tenants # @return [Courier::Resources::Tenants::Templates] attr_reader :templates - # Get a Tenant + # Returns one tenant with its name, parent tenant id, default preferences, + # properties, and the user profile applied to its members. # # @overload retrieve(tenant_id, request_options: {}) # @@ -32,7 +33,8 @@ def retrieve(tenant_id, params = {}) # Some parameter documentations has been truncated, see # {Courier::Models::TenantUpdateParams} for more details. # - # Create or Replace a Tenant + # Creates or replaces a tenant from a name, parent, brand, properties, and default + # preferences supplied in the request body. # # @overload update(tenant_id, name:, brand_id: nil, default_preferences: nil, parent_tenant_id: nil, properties: nil, user_profile: nil, request_options: {}) # @@ -69,7 +71,8 @@ def update(tenant_id, params) # Some parameter documentations has been truncated, see # {Courier::Models::TenantListParams} for more details. # - # Get a List of Tenants + # Lists the workspace's tenants, each carrying a name, parent tenant, properties, + # and default preferences. Paged. # # @overload list(cursor: nil, limit: nil, parent_tenant_id: nil, request_options: {}) # @@ -96,7 +99,8 @@ def list(params = {}) ) end - # Delete a Tenant + # Deletes a tenant. Its members' workspace-level profiles and preferences live + # outside the tenant and are managed separately. # # @overload delete(tenant_id, request_options: {}) # @@ -119,7 +123,8 @@ def delete(tenant_id, params = {}) # Some parameter documentations has been truncated, see # {Courier::Models::TenantListUsersParams} for more details. # - # Get Users in Tenant + # Returns the users belonging to a tenant with cursor paging. Use it to see who a + # tenant-scoped send will reach. # # @overload list_users(tenant_id, cursor: nil, limit: nil, request_options: {}) # diff --git a/lib/courier/resources/tenants/preferences/items.rb b/lib/courier/resources/tenants/preferences/items.rb index 7e2f0e8b..7e67ce83 100644 --- a/lib/courier/resources/tenants/preferences/items.rb +++ b/lib/courier/resources/tenants/preferences/items.rb @@ -8,7 +8,8 @@ class Items # Some parameter documentations has been truncated, see # {Courier::Models::Tenants::Preferences::ItemUpdateParams} for more details. # - # Create or Replace Default Preferences For Topic + # Sets a tenant's default opt-in status for one subscription topic, which applies + # to every member unless a user sets their own override. # # @overload update(topic_id, tenant_id:, status:, custom_routing: nil, has_custom_routing: nil, request_options: {}) # @@ -42,7 +43,8 @@ def update(topic_id, params) ) end - # Remove Default Preferences For Topic + # Removes a tenant's default preference for one subscription topic, addressed by + # tenant id and topic id. # # @overload delete(topic_id, tenant_id:, request_options: {}) # diff --git a/lib/courier/resources/tenants/templates.rb b/lib/courier/resources/tenants/templates.rb index 4816549d..d1beb190 100644 --- a/lib/courier/resources/tenants/templates.rb +++ b/lib/courier/resources/tenants/templates.rb @@ -7,7 +7,8 @@ class Templates # @return [Courier::Resources::Tenants::Templates::Versions] attr_reader :versions - # Get a Template in Tenant + # Returns a tenant's notification template with its content, version, and created, + # updated, and published timestamps. # # @overload retrieve(template_id, tenant_id:, request_options: {}) # @@ -34,7 +35,8 @@ def retrieve(template_id, params) ) end - # List Templates in Tenant + # Lists a tenant's notification templates, each carrying its version and published + # timestamp. Paged. # # @overload list(tenant_id, cursor: nil, limit: nil, request_options: {}) # @@ -61,12 +63,8 @@ def list(tenant_id, params = {}) ) end - # Deletes the tenant's notification template with the given `template_id`. - # - # Returns **204 No Content** with an empty body on success. - # - # Returns **404** if there is no template with this ID for the tenant, including a - # second `DELETE` after a successful removal. + # Deletes a tenant's notification template by id. Sends for that tenant then use + # the workspace template registered under the same id. # # @overload delete(template_id, tenant_id:, request_options: {}) # @@ -96,10 +94,8 @@ def delete(template_id, params) # Some parameter documentations has been truncated, see # {Courier::Models::Tenants::TemplatePublishParams} for more details. # - # Publishes a specific version of a notification template for a tenant. - # - # The template must already exist in the tenant's notification map. If no version - # is specified, defaults to publishing the "latest" version. + # Publishes a version of a tenant's notification template, making it the content + # that tenant's sends render from until you publish another. # # @overload publish(template_id, tenant_id:, version: nil, request_options: {}) # @@ -132,13 +128,8 @@ def publish(template_id, params) # Some parameter documentations has been truncated, see # {Courier::Models::Tenants::TemplateReplaceParams} for more details. # - # Creates or updates a notification template for a tenant. - # - # If the template already exists for the tenant, it will be updated (200). - # Otherwise, a new template is created (201). - # - # Optionally publishes the template immediately if the `published` flag is set to - # true. + # Creates or updates a notification template scoped to one tenant, letting a + # tenant override the content the workspace template would send. # # @overload replace(template_id, tenant_id:, template:, published: nil, request_options: {}) # diff --git a/lib/courier/resources/tenants/templates/versions.rb b/lib/courier/resources/tenants/templates/versions.rb index 628c2864..57dce05b 100644 --- a/lib/courier/resources/tenants/templates/versions.rb +++ b/lib/courier/resources/tenants/templates/versions.rb @@ -8,13 +8,8 @@ class Versions # Some parameter documentations has been truncated, see # {Courier::Models::Tenants::Templates::VersionRetrieveParams} for more details. # - # Fetches a specific version of a tenant template. - # - # Supports the following version formats: - # - # - `latest` - The most recent version of the template - # - `published` - The currently published version - # - `v{version}` - A specific version (e.g., "v1", "v2", "v1.0.0") + # Returns one version of a tenant template, addressed by version number or by + # latest, with its content and publish timestamp. # # @overload retrieve(version, tenant_id:, template_id:, request_options: {}) # diff --git a/lib/courier/resources/translations.rb b/lib/courier/resources/translations.rb index 3be02c21..3b58dd9d 100644 --- a/lib/courier/resources/translations.rb +++ b/lib/courier/resources/translations.rb @@ -6,7 +6,8 @@ class Translations # Some parameter documentations has been truncated, see # {Courier::Models::TranslationRetrieveParams} for more details. # - # Get translations by locale + # Returns the translation strings stored for one domain and locale, for use in + # localized notification content. # # @overload retrieve(locale, domain:, request_options: {}) # @@ -36,7 +37,8 @@ def retrieve(locale, params) # Some parameter documentations has been truncated, see # {Courier::Models::TranslationUpdateParams} for more details. # - # Update a translation + # Uploads the translation strings for one domain and locale. Courier uses them to + # render localized content for recipients in that locale. # # @overload update(locale, domain:, body:, request_options: {}) # diff --git a/lib/courier/resources/users/preferences.rb b/lib/courier/resources/users/preferences.rb index c2f7693a..9b1531b8 100644 --- a/lib/courier/resources/users/preferences.rb +++ b/lib/courier/resources/users/preferences.rb @@ -7,7 +7,8 @@ class Preferences # Some parameter documentations has been truncated, see # {Courier::Models::Users::PreferenceRetrieveParams} for more details. # - # Fetch all user preferences. + # Returns a user's preference overrides with paging, one entry per subscription + # topic they have set a choice for. # # @overload retrieve(user_id, tenant_id: nil, request_options: {}) # @@ -35,23 +36,8 @@ def retrieve(user_id, params = {}) # Some parameter documentations has been truncated, see # {Courier::Models::Users::PreferenceBulkReplaceParams} for more details. # - # Replace a user's complete set of preference overrides in a single request. The - # topics in the request body become the recipient's entire set of overrides: - # listed topics are created or updated, and every existing override that is not - # included in the body is reset to its topic default. Submitting an empty `topics` - # array is a valid clear-all that resets every existing override. - # - # This operation is validation-atomic (all-or-nothing): structural validation - # fails fast with a single `400`, and if any topic is semantically invalid (an - # unknown topic, a `REQUIRED` topic that cannot be opted out, or a custom routing - # request that is not available on the workspace's plan) the request returns a - # single `400` aggregating every failure in `errors` and writes nothing. On - # success it returns `200` with `items` (the complete resulting override set) and - # `deleted` (the ids of the overrides that were reset to default). - # - # Every `topic_id` in the response — in `items`, `deleted`, and any `errors` — is - # returned in Courier's canonical topic id form, regardless of the form supplied - # in the request. + # Replaces a user's entire set of preference overrides. Any topic you leave out is + # reset to its default, so send the full set rather than a subset. # # @overload bulk_replace(user_id, topics:, tenant_id: nil, request_options: {}) # @@ -83,25 +69,10 @@ def bulk_replace(user_id, params) # Some parameter documentations has been truncated, see # {Courier::Models::Users::PreferenceBulkUpdateParams} for more details. # - # Additively create or update a user's preferences for one or more subscription - # topics in a single request. Only the topics included in the request body are - # created or updated; any existing overrides for topics not listed are left - # untouched. - # - # Structural validation of the request body fails fast with a single `400`. Beyond - # that, each topic is processed independently (partial-success, not - # all-or-nothing): valid topics are written and returned in `items`, while topics - # that cannot be applied are collected in `errors` with a per-topic `reason` (for - # example an unknown topic, a `REQUIRED` topic that cannot be opted out, a custom - # routing request that is not available on the workspace's plan, or a write - # failure). The request therefore returns `200` with both lists whenever the body - # is structurally valid. - # - # Every `topic_id` in the response — in both `items` and `errors` — is returned in - # Courier's canonical topic id form, regardless of the form supplied in the - # request. + # Adds or updates a user's preferences for several subscription topics at once. + # Topics you leave out keep whatever they were set to before. # - # @overload bulk_update(user_id, topics:, tenant_id: nil, request_options: {}) + # @overload bulk_update(user_id, topics:, tenant_id: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # # @param user_id [String] Path param: A unique identifier associated with the user whose preferences you w # @@ -109,6 +80,10 @@ def bulk_replace(user_id, params) # # @param tenant_id [String, nil] Query param: Update the preferences of a user for this specific tenant context. # + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv + # + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest + # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # # @return [Courier::Models::Users::PreferenceBulkUpdateResponse] @@ -116,13 +91,16 @@ def bulk_replace(user_id, params) # @see Courier::Models::Users::PreferenceBulkUpdateParams def bulk_update(user_id, params) query_params = [:tenant_id] + header_params = + {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} parsed, options = Courier::Users::PreferenceBulkUpdateParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed.slice(*query_params)) @client.request( method: :post, path: ["users/%1$s/preferences", user_id], query: query, - body: parsed.except(*query_params), + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*query_params, *header_params.keys), model: Courier::Models::Users::PreferenceBulkUpdateResponse, options: options ) @@ -131,9 +109,8 @@ def bulk_update(user_id, params) # Some parameter documentations has been truncated, see # {Courier::Models::Users::PreferenceDeleteTopicParams} for more details. # - # Remove a user's preferences for a specific subscription topic, resetting the - # topic to its effective default. This operation is idempotent: deleting a - # preference that does not exist succeeds with no error. + # Removes a user's override for one subscription topic, resetting it to the + # effective default from the tenant or workspace. # # @overload delete_topic(topic_id, user_id:, tenant_id: nil, request_options: {}) # @@ -167,7 +144,8 @@ def delete_topic(topic_id, params) # Some parameter documentations has been truncated, see # {Courier::Models::Users::PreferenceRetrieveTopicParams} for more details. # - # Fetch user preferences for a specific subscription topic. + # Returns a user's opt-in status and channel choices for one subscription topic, + # or the effective default if they have set no override. # # @overload retrieve_topic(topic_id, user_id:, tenant_id: nil, request_options: {}) # @@ -201,7 +179,8 @@ def retrieve_topic(topic_id, params) # Some parameter documentations has been truncated, see # {Courier::Models::Users::PreferenceUpdateOrCreateTopicParams} for more details. # - # Update or Create user preferences for a specific subscription topic. + # Sets a user's opt-in status and channel choices for one subscription topic, + # overriding the tenant default for that topic only. # # @overload update_or_create_topic(topic_id, user_id:, topic:, tenant_id: nil, request_options: {}) # diff --git a/lib/courier/resources/users/tenants.rb b/lib/courier/resources/users/tenants.rb index 5ea9251e..e21010dc 100644 --- a/lib/courier/resources/users/tenants.rb +++ b/lib/courier/resources/users/tenants.rb @@ -7,7 +7,8 @@ class Tenants # Some parameter documentations has been truncated, see # {Courier::Models::Users::TenantListParams} for more details. # - # Returns a paginated list of user tenant associations. + # Returns the tenants a user belongs to, with cursor paging. A user can belong to + # many tenants, each with its own profile and preferences. # # @overload list(user_id, cursor: nil, limit: nil, request_options: {}) # @@ -34,9 +35,8 @@ def list(user_id, params = {}) ) end - # This endpoint is used to add a user to multiple tenants in one call. A custom - # profile can also be supplied for each tenant. This profile will be merged with - # the user's main profile when sending to the user with that tenant. + # Adds a user to several tenants in one call, each optionally with a per-tenant + # profile that overrides their workspace profile. # # @overload add_multiple(user_id, tenants:, request_options: {}) # @@ -60,10 +60,8 @@ def add_multiple(user_id, params) ) end - # This endpoint is used to add a single tenant. - # - # A custom profile can also be supplied with the tenant. This profile will be - # merged with the user's main profile when sending to the user with that tenant. + # Adds a user to one tenant, optionally with a tenant-specific profile that + # overrides their workspace profile for sends in that tenant. # # @overload add_single(tenant_id, user_id:, profile: nil, request_options: {}) # @@ -93,7 +91,8 @@ def add_single(tenant_id, params) ) end - # Removes a user from any tenants they may have been associated with. + # Removes a user from every tenant they belong to in one call. Their + # workspace-level profile is a separate resource. # # @overload remove_all(user_id, request_options: {}) # @@ -113,7 +112,8 @@ def remove_all(user_id, params = {}) ) end - # Removes a user from the supplied tenant. + # Removes a user from one tenant. Their other tenant memberships and workspace + # profile are managed through separate endpoints. # # @overload remove_single(tenant_id, user_id:, request_options: {}) # diff --git a/lib/courier/resources/users/tokens.rb b/lib/courier/resources/users/tokens.rb index 61bf81a8..81e19671 100644 --- a/lib/courier/resources/users/tokens.rb +++ b/lib/courier/resources/users/tokens.rb @@ -4,7 +4,8 @@ module Courier module Resources class Users class Tokens - # Get single token available for a `:token` + # Returns one device token with its provider key, status and status reason, expiry + # date, and any properties stored alongside it. # # @overload retrieve(token, user_id:, request_options: {}) # @@ -31,7 +32,8 @@ def retrieve(token, params) ) end - # Apply a JSON Patch (RFC 6902) to the specified token. + # Applies a JSON Patch to a device token, changing its status, expiry, or + # properties without re-registering it. # # @overload update(token, user_id:, patch:, request_options: {}) # @@ -61,7 +63,8 @@ def update(token, params) ) end - # Gets all tokens available for a :user_id + # Returns every device token registered for a user, each with its provider key, + # status, and expiry date. # # @overload list(user_id, request_options: {}) # @@ -81,7 +84,8 @@ def list(user_id, params = {}) ) end - # Delete User Token + # Deletes one device token for a user, addressed by the token value, so push sends + # no longer target that device. # # @overload delete(token, user_id:, request_options: {}) # @@ -108,7 +112,8 @@ def delete(token, params) ) end - # Adds multiple tokens to a user and overwrites matching existing tokens. + # Registers several device tokens for a user in one call, overwriting any stored + # token with a matching value. # # @overload add_multiple(user_id, request_options: {}) # @@ -131,7 +136,8 @@ def add_multiple(user_id, params = {}) # Some parameter documentations has been truncated, see # {Courier::Models::Users::TokenAddSingleParams} for more details. # - # Adds a single token to a user and overwrites a matching existing token. + # Registers one device token for a user against a provider key, overwriting the + # token if it already exists. Push sends resolve tokens per user. # # @overload add_single(token, user_id:, provider_key:, device: nil, expiry_date: nil, properties: nil, tracking: nil, request_options: {}) # diff --git a/lib/courier/resources/workspace_preferences.rb b/lib/courier/resources/workspace_preferences.rb index 1204552d..512d5ce0 100644 --- a/lib/courier/resources/workspace_preferences.rb +++ b/lib/courier/resources/workspace_preferences.rb @@ -6,19 +6,25 @@ class WorkspacePreferences # @return [Courier::Resources::WorkspacePreferences::Topics] attr_reader :topics - # Create a workspace preference. The workspace preference id is generated and - # returned. Topics are created inside a workspace preference via POST - # /preferences/sections/{section_id}/topics. + # Some parameter documentations has been truncated, see + # {Courier::Models::WorkspacePreferenceCreateParams} for more details. # - # @overload create(name:, description: nil, has_custom_routing: nil, routing_options: nil, request_options: {}) + # Creates a workspace preference and returns its generated id. Add subscription + # topics to it afterwards with the topics endpoint. # - # @param name [String] Human-readable name for the workspace preference. + # @overload create(name:, description: nil, has_custom_routing: nil, routing_options: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # - # @param description [String, nil] Optional description shown under the section on the hosted preferences page. + # @param name [String] Body param: Human-readable name for the workspace preference. # - # @param has_custom_routing [Boolean, nil] Whether the workspace preference defines custom routing for its topics. + # @param description [String, nil] Body param: Optional description shown under the section on the hosted preferenc + # + # @param has_custom_routing [Boolean, nil] Body param: Whether the workspace preference defines custom routing for its topi + # + # @param routing_options [Array, nil] Body param: Default channels for the workspace preference. Defaults to empty if # - # @param routing_options [Array, nil] Default channels for the workspace preference. Defaults to empty if omitted. + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv + # + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # @@ -27,16 +33,20 @@ class WorkspacePreferences # @see Courier::Models::WorkspacePreferenceCreateParams def create(params) parsed, options = Courier::WorkspacePreferenceCreateParams.dump_request(params) + header_params = + {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: "preferences/sections", - body: parsed, + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*header_params.keys), model: Courier::WorkspacePreferenceGetResponse, options: options ) end - # Retrieve a workspace preference by id, including its topics. + # Returns one workspace preference by id, including its subscription topics, + # routing options, and custom routing flag. # # @overload retrieve(section_id, request_options: {}) # @@ -56,8 +66,8 @@ def retrieve(section_id, params = {}) ) end - # List the workspace's preferences. Each workspace preference embeds its topics. - # Scoped to the workspace of the API key. + # Returns the workspace's preferences, each embedding its subscription topics, + # routing options, and whether custom routing is allowed. # # @overload list(request_options: {}) # @@ -99,17 +109,20 @@ def archive(section_id, params = {}) # Some parameter documentations has been truncated, see # {Courier::Models::WorkspacePreferencePublishParams} for more details. # - # Publish the workspace's preferences page. Takes a snapshot of every workspace - # preference with its topics under a new published version, making the current - # state visible on the hosted preferences page (non-draft). + # Publishes the workspace preference page, snapshotting every preference and + # topic, and returns the page id and a preview URL. + # + # @overload publish(brand_id: nil, description: nil, heading: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # - # @overload publish(brand_id: nil, description: nil, heading: nil, request_options: {}) + # @param brand_id [String, nil] Body param: Brand for the hosted page - "default" (workspace default brand), "no # - # @param brand_id [String, nil] Brand for the hosted page - "default" (workspace default brand), "none" (no bran + # @param description [String, nil] Body param: Description shown under the heading on the hosted preferences page. # - # @param description [String, nil] Description shown under the heading on the hosted preferences page. + # @param heading [String, nil] Body param: Heading shown at the top of the hosted preferences page. # - # @param heading [String, nil] Heading shown at the top of the hosted preferences page. + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv + # + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # @@ -118,10 +131,13 @@ def archive(section_id, params = {}) # @see Courier::Models::WorkspacePreferencePublishParams def publish(params = {}) parsed, options = Courier::WorkspacePreferencePublishParams.dump_request(params) + header_params = + {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: "preferences/publish", - body: parsed, + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*header_params.keys), model: Courier::PublishPreferencesResponse, options: options ) diff --git a/lib/courier/resources/workspace_preferences/topics.rb b/lib/courier/resources/workspace_preferences/topics.rb index cdc53bd1..a738ed63 100644 --- a/lib/courier/resources/workspace_preferences/topics.rb +++ b/lib/courier/resources/workspace_preferences/topics.rb @@ -7,27 +7,30 @@ class Topics # Some parameter documentations has been truncated, see # {Courier::Models::WorkspacePreferences::TopicCreateParams} for more details. # - # Create a subscription preference topic inside a workspace preference. Fails with - # 404 if the workspace preference does not exist. The topic id is generated and - # returned. + # Creates a subscription topic inside a workspace preference. The default status + # sets whether users start opted in, opted out, or required. # - # @overload create(section_id, default_status:, name:, allowed_preferences: nil, description: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, request_options: {}) + # @overload create(section_id, default_status:, name:, allowed_preferences: nil, description: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) # - # @param section_id [String] Id of the workspace preference to create the topic in. + # @param section_id [String] Path param: Id of the workspace preference to create the topic in. # - # @param default_status [Symbol, Courier::Models::WorkspacePreferenceTopicCreateRequest::DefaultStatus] The default subscription status applied when a recipient has not set their own. + # @param default_status [Symbol, Courier::Models::WorkspacePreferenceTopicCreateRequest::DefaultStatus] Body param: The default subscription status applied when a recipient has not set # - # @param name [String] Human-readable name for the preference topic. + # @param name [String] Body param: Human-readable name for the preference topic. + # + # @param allowed_preferences [Array, nil] Body param: Preference controls a recipient may customize for this topic. Defaul + # + # @param description [String, nil] Body param: Optional description shown under the topic on the hosted preferences # - # @param allowed_preferences [Array, nil] Preference controls a recipient may customize for this topic. Defaults to empty + # @param include_unsubscribe_header [Boolean, nil] Body param: Whether to include a list-unsubscribe header on emails for this topi # - # @param description [String, nil] Optional description shown under the topic on the hosted preferences page. + # @param routing_options [Array, nil] Body param: Default channels delivered for this topic. Defaults to empty if omit # - # @param include_unsubscribe_header [Boolean, nil] Whether to include a list-unsubscribe header on emails for this topic. + # @param topic_data [Hash{Symbol=>Object}, nil] Body param: Arbitrary metadata associated with the topic. # - # @param routing_options [Array, nil] Default channels delivered for this topic. Defaults to empty if omitted. + # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv # - # @param topic_data [Hash{Symbol=>Object}, nil] Arbitrary metadata associated with the topic. + # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest # # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] # @@ -36,18 +39,20 @@ class Topics # @see Courier::Models::WorkspacePreferences::TopicCreateParams def create(section_id, params) parsed, options = Courier::WorkspacePreferences::TopicCreateParams.dump_request(params) + header_params = + {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: ["preferences/sections/%1$s/topics", section_id], - body: parsed, + headers: parsed.slice(*header_params.keys).transform_keys(header_params), + body: parsed.except(*header_params.keys), model: Courier::WorkspacePreferenceTopicGetResponse, options: options ) end - # Retrieve a topic within a workspace preference. Returns 404 if the workspace - # preference does not exist, the topic does not exist, or the topic belongs to a - # different workspace preference. + # Returns one subscription topic with its default status, routing options, allowed + # preferences, and unsubscribe header setting. # # @overload retrieve(topic_id, section_id:, request_options: {}) # @@ -74,7 +79,8 @@ def retrieve(topic_id, params) ) end - # List the topics in a workspace preference. + # Returns the subscription topics inside a workspace preference, each with its + # default status and routing options. # # @overload list(section_id, request_options: {}) # @@ -94,8 +100,8 @@ def list(section_id, params = {}) ) end - # Archive a topic and remove it from its workspace preference. Same 404 rules as - # GET. + # Archives a subscription topic and removes it from its workspace preference, + # addressed by section id and topic id. # # @overload archive(topic_id, section_id:, request_options: {}) # diff --git a/lib/courier/version.rb b/lib/courier/version.rb index f25582f1..6d6c6fda 100644 --- a/lib/courier/version.rb +++ b/lib/courier/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Courier - VERSION = "4.21.0" + VERSION = "4.22.0" end diff --git a/rbi/courier/client.rbi b/rbi/courier/client.rbi index 62ccdaf6..41c6c5ea 100644 --- a/rbi/courier/client.rbi +++ b/rbi/courier/client.rbi @@ -46,6 +46,9 @@ module Courier sig { returns(Courier::Resources::Lists) } attr_reader :lists + sig { returns(Courier::Resources::Inbox) } + attr_reader :inbox + sig { returns(Courier::Resources::Messages) } attr_reader :messages diff --git a/rbi/courier/models.rbi b/rbi/courier/models.rbi index 455deb57..f94f9f27 100644 --- a/rbi/courier/models.rbi +++ b/rbi/courier/models.rbi @@ -149,6 +149,8 @@ module Courier InboundTrackEventParams = Courier::Models::InboundTrackEventParams + Inbox = Courier::Models::Inbox + Intercom = Courier::Models::Intercom IntercomRecipient = Courier::Models::IntercomRecipient diff --git a/rbi/courier/models/automations/invoke_invoke_ad_hoc_params.rbi b/rbi/courier/models/automations/invoke_invoke_ad_hoc_params.rbi index dc01094f..ef960889 100644 --- a/rbi/courier/models/automations/invoke_invoke_ad_hoc_params.rbi +++ b/rbi/courier/models/automations/invoke_invoke_ad_hoc_params.rbi @@ -43,6 +43,18 @@ module Courier sig { returns(T.nilable(String)) } attr_accessor :template + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do params( automation: @@ -52,6 +64,8 @@ module Courier profile: T.nilable(T::Hash[Symbol, T.anything]), recipient: T.nilable(String), template: T.nilable(String), + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(T.attached_class) end @@ -62,6 +76,8 @@ module Courier profile: nil, recipient: nil, template: nil, + idempotency_key: nil, + x_idempotency_expiration: nil, request_options: {} ) end @@ -76,6 +92,8 @@ module Courier profile: T.nilable(T::Hash[Symbol, T.anything]), recipient: T.nilable(String), template: T.nilable(String), + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } ) diff --git a/rbi/courier/models/automations/invoke_invoke_by_template_params.rbi b/rbi/courier/models/automations/invoke_invoke_by_template_params.rbi index 726039b0..d43708b5 100644 --- a/rbi/courier/models/automations/invoke_invoke_by_template_params.rbi +++ b/rbi/courier/models/automations/invoke_invoke_by_template_params.rbi @@ -33,6 +33,18 @@ module Courier sig { returns(T.nilable(String)) } attr_accessor :template + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do params( template_id: String, @@ -41,6 +53,8 @@ module Courier data: T.nilable(T::Hash[Symbol, T.anything]), profile: T.nilable(T::Hash[Symbol, T.anything]), template: T.nilable(String), + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(T.attached_class) end @@ -51,6 +65,8 @@ module Courier data: nil, profile: nil, template: nil, + idempotency_key: nil, + x_idempotency_expiration: nil, request_options: {} ) end @@ -64,6 +80,8 @@ module Courier data: T.nilable(T::Hash[Symbol, T.anything]), profile: T.nilable(T::Hash[Symbol, T.anything]), template: T.nilable(String), + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } ) diff --git a/rbi/courier/models/brand_create_params.rbi b/rbi/courier/models/brand_create_params.rbi index 55eb9d87..ab563110 100644 --- a/rbi/courier/models/brand_create_params.rbi +++ b/rbi/courier/models/brand_create_params.rbi @@ -29,12 +29,26 @@ module Courier sig { params(snippets: T.nilable(Courier::BrandSnippets::OrHash)).void } attr_writer :snippets + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do params( name: String, settings: Courier::BrandSettings::OrHash, id: T.nilable(String), snippets: T.nilable(Courier::BrandSnippets::OrHash), + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(T.attached_class) end @@ -43,6 +57,8 @@ module Courier settings:, id: nil, snippets: nil, + idempotency_key: nil, + x_idempotency_expiration: nil, request_options: {} ) end @@ -54,6 +70,8 @@ module Courier settings: Courier::BrandSettings, id: T.nilable(String), snippets: T.nilable(Courier::BrandSnippets), + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } ) diff --git a/rbi/courier/models/inbox/message_delete_params.rbi b/rbi/courier/models/inbox/message_delete_params.rbi new file mode 100644 index 00000000..f99d5b95 --- /dev/null +++ b/rbi/courier/models/inbox/message_delete_params.rbi @@ -0,0 +1,40 @@ +# typed: strong + +module Courier + module Models + module Inbox + class MessageDeleteParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Courier::Inbox::MessageDeleteParams, + Courier::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :message_id + + sig do + params( + message_id: String, + request_options: Courier::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(message_id:, request_options: {}) + end + + sig do + override.returns( + { message_id: String, request_options: Courier::RequestOptions } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/courier/models/inbox/message_restore_params.rbi b/rbi/courier/models/inbox/message_restore_params.rbi new file mode 100644 index 00000000..e22527fd --- /dev/null +++ b/rbi/courier/models/inbox/message_restore_params.rbi @@ -0,0 +1,40 @@ +# typed: strong + +module Courier + module Models + module Inbox + class MessageRestoreParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Courier::Inbox::MessageRestoreParams, + Courier::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :message_id + + sig do + params( + message_id: String, + request_options: Courier::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(message_id:, request_options: {}) + end + + sig do + override.returns( + { message_id: String, request_options: Courier::RequestOptions } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/courier/models/journey_cancel_params.rbi b/rbi/courier/models/journey_cancel_params.rbi index 1f39bed7..244f64bf 100644 --- a/rbi/courier/models/journey_cancel_params.rbi +++ b/rbi/courier/models/journey_cancel_params.rbi @@ -11,15 +11,41 @@ module Courier T.any(Courier::JourneyCancelParams, Courier::Internal::AnyHash) end + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do - params(request_options: Courier::RequestOptions::OrHash).returns( - T.attached_class - ) + params( + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions::OrHash + ).returns(T.attached_class) end - def self.new(request_options: {}) + def self.new( + idempotency_key: nil, + x_idempotency_expiration: nil, + request_options: {} + ) end - sig { override.returns({ request_options: Courier::RequestOptions }) } + sig do + override.returns( + { + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions + } + ) + end def to_hash end end diff --git a/rbi/courier/models/journey_create_params.rbi b/rbi/courier/models/journey_create_params.rbi index ad84e882..c1bb7ba0 100644 --- a/rbi/courier/models/journey_create_params.rbi +++ b/rbi/courier/models/journey_create_params.rbi @@ -11,15 +11,41 @@ module Courier T.any(Courier::JourneyCreateParams, Courier::Internal::AnyHash) end + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do - params(request_options: Courier::RequestOptions::OrHash).returns( - T.attached_class - ) + params( + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions::OrHash + ).returns(T.attached_class) end - def self.new(request_options: {}) + def self.new( + idempotency_key: nil, + x_idempotency_expiration: nil, + request_options: {} + ) end - sig { override.returns({ request_options: Courier::RequestOptions }) } + sig do + override.returns( + { + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions + } + ) + end def to_hash end end diff --git a/rbi/courier/models/journey_invoke_params.rbi b/rbi/courier/models/journey_invoke_params.rbi index e615a880..a564b4df 100644 --- a/rbi/courier/models/journey_invoke_params.rbi +++ b/rbi/courier/models/journey_invoke_params.rbi @@ -14,18 +14,42 @@ module Courier sig { returns(String) } attr_accessor :template_id + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do params( template_id: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(T.attached_class) end - def self.new(template_id:, request_options: {}) + def self.new( + template_id:, + idempotency_key: nil, + x_idempotency_expiration: nil, + request_options: {} + ) end sig do override.returns( - { template_id: String, request_options: Courier::RequestOptions } + { + template_id: String, + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions + } ) end def to_hash diff --git a/rbi/courier/models/journey_publish_params.rbi b/rbi/courier/models/journey_publish_params.rbi index 5687c690..6f294adf 100644 --- a/rbi/courier/models/journey_publish_params.rbi +++ b/rbi/courier/models/journey_publish_params.rbi @@ -14,18 +14,42 @@ module Courier sig { returns(String) } attr_accessor :template_id + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do params( template_id: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(T.attached_class) end - def self.new(template_id:, request_options: {}) + def self.new( + template_id:, + idempotency_key: nil, + x_idempotency_expiration: nil, + request_options: {} + ) end sig do override.returns( - { template_id: String, request_options: Courier::RequestOptions } + { + template_id: String, + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions + } ) end def to_hash diff --git a/rbi/courier/models/journeys/template_create_params.rbi b/rbi/courier/models/journeys/template_create_params.rbi index bdf8b46a..e3c55ba5 100644 --- a/rbi/courier/models/journeys/template_create_params.rbi +++ b/rbi/courier/models/journeys/template_create_params.rbi @@ -18,18 +18,42 @@ module Courier sig { returns(String) } attr_accessor :template_id + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do params( template_id: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(T.attached_class) end - def self.new(template_id:, request_options: {}) + def self.new( + template_id:, + idempotency_key: nil, + x_idempotency_expiration: nil, + request_options: {} + ) end sig do override.returns( - { template_id: String, request_options: Courier::RequestOptions } + { + template_id: String, + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions + } ) end def to_hash diff --git a/rbi/courier/models/journeys/template_publish_params.rbi b/rbi/courier/models/journeys/template_publish_params.rbi index b1297f8a..bab4e296 100644 --- a/rbi/courier/models/journeys/template_publish_params.rbi +++ b/rbi/courier/models/journeys/template_publish_params.rbi @@ -21,14 +21,34 @@ module Courier sig { returns(String) } attr_accessor :notification_id + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do params( template_id: String, notification_id: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(T.attached_class) end - def self.new(template_id:, notification_id:, request_options: {}) + def self.new( + template_id:, + notification_id:, + idempotency_key: nil, + x_idempotency_expiration: nil, + request_options: {} + ) end sig do @@ -36,6 +56,8 @@ module Courier { template_id: String, notification_id: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } ) diff --git a/rbi/courier/models/lists/subscription_add_params.rbi b/rbi/courier/models/lists/subscription_add_params.rbi index 8ff07204..dad412a0 100644 --- a/rbi/courier/models/lists/subscription_add_params.rbi +++ b/rbi/courier/models/lists/subscription_add_params.rbi @@ -21,14 +21,34 @@ module Courier sig { returns(T::Array[Courier::PutSubscriptionsRecipient]) } attr_accessor :recipients + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do params( list_id: String, recipients: T::Array[Courier::PutSubscriptionsRecipient::OrHash], + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(T.attached_class) end - def self.new(list_id:, recipients:, request_options: {}) + def self.new( + list_id:, + recipients:, + idempotency_key: nil, + x_idempotency_expiration: nil, + request_options: {} + ) end sig do @@ -36,6 +56,8 @@ module Courier { list_id: String, recipients: T::Array[Courier::PutSubscriptionsRecipient], + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } ) diff --git a/rbi/courier/models/notification_create_params.rbi b/rbi/courier/models/notification_create_params.rbi index 90e727a3..6fb8a024 100644 --- a/rbi/courier/models/notification_create_params.rbi +++ b/rbi/courier/models/notification_create_params.rbi @@ -11,15 +11,41 @@ module Courier T.any(Courier::NotificationCreateParams, Courier::Internal::AnyHash) end + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do - params(request_options: Courier::RequestOptions::OrHash).returns( - T.attached_class - ) + params( + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions::OrHash + ).returns(T.attached_class) end - def self.new(request_options: {}) + def self.new( + idempotency_key: nil, + x_idempotency_expiration: nil, + request_options: {} + ) end - sig { override.returns({ request_options: Courier::RequestOptions }) } + sig do + override.returns( + { + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions + } + ) + end def to_hash end end diff --git a/rbi/courier/models/notification_publish_params.rbi b/rbi/courier/models/notification_publish_params.rbi index c5a382dd..d2070c4d 100644 --- a/rbi/courier/models/notification_publish_params.rbi +++ b/rbi/courier/models/notification_publish_params.rbi @@ -14,18 +14,42 @@ module Courier sig { returns(String) } attr_accessor :id + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do params( id: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(T.attached_class) end - def self.new(id:, request_options: {}) + def self.new( + id:, + idempotency_key: nil, + x_idempotency_expiration: nil, + request_options: {} + ) end sig do override.returns( - { id: String, request_options: Courier::RequestOptions } + { + id: String, + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions + } ) end def to_hash diff --git a/rbi/courier/models/profile_create_params.rbi b/rbi/courier/models/profile_create_params.rbi index 13109a7e..d63ca533 100644 --- a/rbi/courier/models/profile_create_params.rbi +++ b/rbi/courier/models/profile_create_params.rbi @@ -17,14 +17,34 @@ module Courier sig { returns(T::Hash[Symbol, T.anything]) } attr_accessor :profile + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do params( user_id: String, profile: T::Hash[Symbol, T.anything], + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(T.attached_class) end - def self.new(user_id:, profile:, request_options: {}) + def self.new( + user_id:, + profile:, + idempotency_key: nil, + x_idempotency_expiration: nil, + request_options: {} + ) end sig do @@ -32,6 +52,8 @@ module Courier { user_id: String, profile: T::Hash[Symbol, T.anything], + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } ) diff --git a/rbi/courier/models/profiles/list_subscribe_params.rbi b/rbi/courier/models/profiles/list_subscribe_params.rbi index 8e19bc08..791ff43b 100644 --- a/rbi/courier/models/profiles/list_subscribe_params.rbi +++ b/rbi/courier/models/profiles/list_subscribe_params.rbi @@ -21,14 +21,34 @@ module Courier sig { returns(T::Array[Courier::SubscribeToListsRequestItem]) } attr_accessor :lists + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do params( user_id: String, lists: T::Array[Courier::SubscribeToListsRequestItem::OrHash], + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(T.attached_class) end - def self.new(user_id:, lists:, request_options: {}) + def self.new( + user_id:, + lists:, + idempotency_key: nil, + x_idempotency_expiration: nil, + request_options: {} + ) end sig do @@ -36,6 +56,8 @@ module Courier { user_id: String, lists: T::Array[Courier::SubscribeToListsRequestItem], + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } ) diff --git a/rbi/courier/models/provider_create_params.rbi b/rbi/courier/models/provider_create_params.rbi index 3aaee74f..60ca049a 100644 --- a/rbi/courier/models/provider_create_params.rbi +++ b/rbi/courier/models/provider_create_params.rbi @@ -39,12 +39,26 @@ module Courier sig { params(title: String).void } attr_writer :title + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do params( provider: String, alias_: String, settings: T::Hash[Symbol, T.anything], title: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(T.attached_class) end @@ -60,6 +74,8 @@ module Courier settings: nil, # Optional display title. Omit to use "Default Configuration". title: nil, + idempotency_key: nil, + x_idempotency_expiration: nil, request_options: {} ) end @@ -71,6 +87,8 @@ module Courier alias_: String, settings: T::Hash[Symbol, T.anything], title: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } ) diff --git a/rbi/courier/models/routing_strategy_create_params.rbi b/rbi/courier/models/routing_strategy_create_params.rbi index 5138dc2b..f5152b08 100644 --- a/rbi/courier/models/routing_strategy_create_params.rbi +++ b/rbi/courier/models/routing_strategy_create_params.rbi @@ -14,15 +14,41 @@ module Courier ) end + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do - params(request_options: Courier::RequestOptions::OrHash).returns( - T.attached_class - ) + params( + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions::OrHash + ).returns(T.attached_class) end - def self.new(request_options: {}) + def self.new( + idempotency_key: nil, + x_idempotency_expiration: nil, + request_options: {} + ) end - sig { override.returns({ request_options: Courier::RequestOptions }) } + sig do + override.returns( + { + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions + } + ) + end def to_hash end end diff --git a/rbi/courier/models/send_message_params.rbi b/rbi/courier/models/send_message_params.rbi index f4a20957..2513efcc 100644 --- a/rbi/courier/models/send_message_params.rbi +++ b/rbi/courier/models/send_message_params.rbi @@ -19,9 +19,23 @@ module Courier sig { params(message: Courier::SendMessageParams::Message::OrHash).void } attr_writer :message + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do params( message: Courier::SendMessageParams::Message::OrHash, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(T.attached_class) end @@ -29,6 +43,8 @@ module Courier # The message property has the following primary top-level properties. They define # the destination and content of the message. message:, + idempotency_key: nil, + x_idempotency_expiration: nil, request_options: {} ) end @@ -37,6 +53,8 @@ module Courier override.returns( { message: Courier::SendMessageParams::Message, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } ) diff --git a/rbi/courier/models/users/preference_bulk_update_params.rbi b/rbi/courier/models/users/preference_bulk_update_params.rbi index 4f8f878a..ac3e1362 100644 --- a/rbi/courier/models/users/preference_bulk_update_params.rbi +++ b/rbi/courier/models/users/preference_bulk_update_params.rbi @@ -29,6 +29,18 @@ module Courier sig { returns(T.nilable(String)) } attr_accessor :tenant_id + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do params( user_id: String, @@ -37,6 +49,8 @@ module Courier Courier::Users::PreferenceBulkUpdateParams::Topic::OrHash ], tenant_id: T.nilable(String), + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(T.attached_class) end @@ -47,6 +61,8 @@ module Courier topics:, # Update the preferences of a user for this specific tenant context. tenant_id: nil, + idempotency_key: nil, + x_idempotency_expiration: nil, request_options: {} ) end @@ -58,6 +74,8 @@ module Courier topics: T::Array[Courier::Users::PreferenceBulkUpdateParams::Topic], tenant_id: T.nilable(String), + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } ) diff --git a/rbi/courier/models/users/preference_update_or_create_topic_params.rbi b/rbi/courier/models/users/preference_update_or_create_topic_params.rbi index 7f7e3c51..8aa2256f 100644 --- a/rbi/courier/models/users/preference_update_or_create_topic_params.rbi +++ b/rbi/courier/models/users/preference_update_or_create_topic_params.rbi @@ -81,10 +81,14 @@ module Courier ) end + # The subscription status to set: OPTED_IN or OPTED_OUT. REQUIRED is a topic-level + # default, not a user choice; the API rejects opting a user out of a REQUIRED + # topic. sig { returns(Courier::PreferenceStatus::OrSymbol) } attr_accessor :status - # The Channels a user has chosen to receive notifications through for this topic + # The channels to deliver this topic on when has_custom_routing is true. One or + # more of: direct_message, email, push, sms, webhook, inbox. sig do returns( T.nilable(T::Array[Courier::ChannelClassification::OrSymbol]) @@ -92,6 +96,8 @@ module Courier end attr_accessor :custom_routing + # Set to true to route this topic to the channels in custom_routing instead of the + # topic's default routing. sig { returns(T.nilable(T::Boolean)) } attr_accessor :has_custom_routing @@ -104,9 +110,15 @@ module Courier ).returns(T.attached_class) end def self.new( + # The subscription status to set: OPTED_IN or OPTED_OUT. REQUIRED is a topic-level + # default, not a user choice; the API rejects opting a user out of a REQUIRED + # topic. status:, - # The Channels a user has chosen to receive notifications through for this topic + # The channels to deliver this topic on when has_custom_routing is true. One or + # more of: direct_message, email, push, sms, webhook, inbox. custom_routing: nil, + # Set to true to route this topic to the channels in custom_routing instead of the + # topic's default routing. has_custom_routing: nil ) end diff --git a/rbi/courier/models/users/topic_preference.rbi b/rbi/courier/models/users/topic_preference.rbi index caef61b9..6c7c9e0b 100644 --- a/rbi/courier/models/users/topic_preference.rbi +++ b/rbi/courier/models/users/topic_preference.rbi @@ -9,19 +9,28 @@ module Courier T.any(Courier::Users::TopicPreference, Courier::Internal::AnyHash) end + # The topic's default status, returned on reads. It applies whenever the user has + # no override of their own (status equals this value). sig { returns(Courier::PreferenceStatus::TaggedSymbol) } attr_accessor :default_status + # The user's subscription status for this topic. OPTED_IN or OPTED_OUT reflect the + # user's own choice; REQUIRED is a topic-level default set in the preferences + # editor, not a user choice. sig { returns(Courier::PreferenceStatus::TaggedSymbol) } attr_accessor :status + # The unique identifier of the subscription topic this preference applies to. sig { returns(String) } attr_accessor :topic_id + # The display name of the subscription topic, returned on reads. sig { returns(String) } attr_accessor :topic_name - # The Channels a user has chosen to receive notifications through for this topic + # The channels the user has chosen to receive this topic on, present only when + # has_custom_routing is true. One or more of: direct_message, email, push, sms, + # webhook, inbox. sig do returns( T.nilable(T::Array[Courier::ChannelClassification::TaggedSymbol]) @@ -29,6 +38,8 @@ module Courier end attr_accessor :custom_routing + # Whether the user has chosen specific delivery channels for this topic (listed in + # custom_routing) rather than the topic's default routing. sig { returns(T.nilable(T::Boolean)) } attr_accessor :has_custom_routing @@ -44,12 +55,23 @@ module Courier ).returns(T.attached_class) end def self.new( + # The topic's default status, returned on reads. It applies whenever the user has + # no override of their own (status equals this value). default_status:, + # The user's subscription status for this topic. OPTED_IN or OPTED_OUT reflect the + # user's own choice; REQUIRED is a topic-level default set in the preferences + # editor, not a user choice. status:, + # The unique identifier of the subscription topic this preference applies to. topic_id:, + # The display name of the subscription topic, returned on reads. topic_name:, - # The Channels a user has chosen to receive notifications through for this topic + # The channels the user has chosen to receive this topic on, present only when + # has_custom_routing is true. One or more of: direct_message, email, push, sms, + # webhook, inbox. custom_routing: nil, + # Whether the user has chosen specific delivery channels for this topic (listed in + # custom_routing) rather than the topic's default routing. has_custom_routing: nil ) end diff --git a/rbi/courier/models/workspace_preference_create_params.rbi b/rbi/courier/models/workspace_preference_create_params.rbi index d9dda670..89b0102b 100644 --- a/rbi/courier/models/workspace_preference_create_params.rbi +++ b/rbi/courier/models/workspace_preference_create_params.rbi @@ -14,15 +14,41 @@ module Courier ) end + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do - params(request_options: Courier::RequestOptions::OrHash).returns( - T.attached_class - ) + params( + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions::OrHash + ).returns(T.attached_class) end - def self.new(request_options: {}) + def self.new( + idempotency_key: nil, + x_idempotency_expiration: nil, + request_options: {} + ) end - sig { override.returns({ request_options: Courier::RequestOptions }) } + sig do + override.returns( + { + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions + } + ) + end def to_hash end end diff --git a/rbi/courier/models/workspace_preference_publish_params.rbi b/rbi/courier/models/workspace_preference_publish_params.rbi index b7f8249d..746d13f5 100644 --- a/rbi/courier/models/workspace_preference_publish_params.rbi +++ b/rbi/courier/models/workspace_preference_publish_params.rbi @@ -14,15 +14,41 @@ module Courier ) end + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do - params(request_options: Courier::RequestOptions::OrHash).returns( - T.attached_class - ) + params( + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions::OrHash + ).returns(T.attached_class) end - def self.new(request_options: {}) + def self.new( + idempotency_key: nil, + x_idempotency_expiration: nil, + request_options: {} + ) end - sig { override.returns({ request_options: Courier::RequestOptions }) } + sig do + override.returns( + { + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions + } + ) + end def to_hash end end diff --git a/rbi/courier/models/workspace_preferences/topic_create_params.rbi b/rbi/courier/models/workspace_preferences/topic_create_params.rbi index 1783c423..f6034ec6 100644 --- a/rbi/courier/models/workspace_preferences/topic_create_params.rbi +++ b/rbi/courier/models/workspace_preferences/topic_create_params.rbi @@ -18,18 +18,42 @@ module Courier sig { returns(String) } attr_accessor :section_id + sig { returns(T.nilable(String)) } + attr_reader :idempotency_key + + sig { params(idempotency_key: String).void } + attr_writer :idempotency_key + + sig { returns(T.nilable(String)) } + attr_reader :x_idempotency_expiration + + sig { params(x_idempotency_expiration: String).void } + attr_writer :x_idempotency_expiration + sig do params( section_id: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(T.attached_class) end - def self.new(section_id:, request_options: {}) + def self.new( + section_id:, + idempotency_key: nil, + x_idempotency_expiration: nil, + request_options: {} + ) end sig do override.returns( - { section_id: String, request_options: Courier::RequestOptions } + { + section_id: String, + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions + } ) end def to_hash diff --git a/rbi/courier/resources/audiences.rbi b/rbi/courier/resources/audiences.rbi index ff070bf3..d14694ef 100644 --- a/rbi/courier/resources/audiences.rbi +++ b/rbi/courier/resources/audiences.rbi @@ -3,7 +3,8 @@ module Courier module Resources class Audiences - # Returns the specified audience by id. + # Returns one audience with its name, description, and the filter and AND or OR + # operator that decide which users belong to it. sig do params( audience_id: String, @@ -17,7 +18,8 @@ module Courier ) end - # Creates or updates audience. + # Creates or replaces an audience from a filter and an AND or OR operator. + # Membership recalculates automatically as profiles change. sig do params( audience_id: String, @@ -46,7 +48,8 @@ module Courier ) end - # Get the audiences associated with the authorization token. + # Returns the audiences in the workspace with paging. Audiences are filter-based + # groups that recalculate as user profiles change. sig do params( cursor: T.nilable(String), @@ -60,7 +63,8 @@ module Courier ) end - # Deletes the specified audience. + # Deletes an audience permanently, so update any caller sending to it by audience + # id first. Those sends fail once the audience is gone. sig do params( audience_id: String, @@ -74,7 +78,8 @@ module Courier ) end - # Get list of members of an audience. + # Returns the users currently matching an audience filter, with paging. Membership + # is recalculated, so results shift as profiles change. sig do params( audience_id: String, diff --git a/rbi/courier/resources/audit_events.rbi b/rbi/courier/resources/audit_events.rbi index 215f6a6a..6debbd55 100644 --- a/rbi/courier/resources/audit_events.rbi +++ b/rbi/courier/resources/audit_events.rbi @@ -3,7 +3,8 @@ module Courier module Resources class AuditEvents - # Fetch a specific audit event by ID. + # Returns one audit event by id, including the actor who performed it, the target + # they changed, the source, the event type, and a timestamp. sig do params( audit_event_id: String, @@ -17,7 +18,8 @@ module Courier ) end - # Fetch the list of audit events + # Returns the workspace's audit event log with cursor paging. Each event records + # the actor, target, source, type, and timestamp of a change. sig do params( cursor: T.nilable(String), diff --git a/rbi/courier/resources/auth.rbi b/rbi/courier/resources/auth.rbi index 9895f00e..deea43a9 100644 --- a/rbi/courier/resources/auth.rbi +++ b/rbi/courier/resources/auth.rbi @@ -3,7 +3,8 @@ module Courier module Resources class Auth - # Returns a new access token. + # Returns a JWT for authenticating client-side SDKs such as the Inbox. You supply + # the scope and an expires_in duration, both required. sig do params( expires_in: String, diff --git a/rbi/courier/resources/automations.rbi b/rbi/courier/resources/automations.rbi index 3cbd6111..58f56a65 100644 --- a/rbi/courier/resources/automations.rbi +++ b/rbi/courier/resources/automations.rbi @@ -6,7 +6,8 @@ module Courier sig { returns(Courier::Resources::Automations::Invoke) } attr_reader :invoke - # Get the list of automations. + # Lists the workspace's saved automation templates, each with its id and a cursor + # for paging to the next page of results. sig do params( cursor: String, diff --git a/rbi/courier/resources/automations/invoke.rbi b/rbi/courier/resources/automations/invoke.rbi index 2e583c26..45d30193 100644 --- a/rbi/courier/resources/automations/invoke.rbi +++ b/rbi/courier/resources/automations/invoke.rbi @@ -4,10 +4,8 @@ module Courier module Resources class Automations class Invoke - # Invoke an ad hoc automation run. This endpoint accepts a JSON payload with a - # series of automation steps. For information about what steps are available, - # checkout the ad hoc automation guide - # [here](https://www.courier.com/docs/automations/steps/). + # Runs a series of automation steps supplied inline, without a saved template, and + # returns a runId. sig do params( automation: @@ -17,21 +15,42 @@ module Courier profile: T.nilable(T::Hash[Symbol, T.anything]), recipient: T.nilable(String), template: T.nilable(String), + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(Courier::AutomationInvokeResponse) end def invoke_ad_hoc( + # Body param automation:, + # Body param brand: nil, + # Body param data: nil, + # Body param profile: nil, + # Body param recipient: nil, + # Body param template: nil, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end - # Invoke an automation run from an automation template. + # Starts an automation run from a saved template for one recipient, with optional + # data and profile, and returns a runId. sig do params( template_id: String, @@ -40,18 +59,38 @@ module Courier data: T.nilable(T::Hash[Symbol, T.anything]), profile: T.nilable(T::Hash[Symbol, T.anything]), template: T.nilable(String), + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(Courier::AutomationInvokeResponse) end def invoke_by_template( - # A unique identifier representing the automation template to be invoked. This - # could be the Automation Template ID or the Automation Template Alias. + # Path param: A unique identifier representing the automation template to be + # invoked. This could be the Automation Template ID or the Automation Template + # Alias. template_id, + # Body param recipient:, + # Body param brand: nil, + # Body param data: nil, + # Body param profile: nil, + # Body param template: nil, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end diff --git a/rbi/courier/resources/brands.rbi b/rbi/courier/resources/brands.rbi index afb3d19f..ceb3656b 100644 --- a/rbi/courier/resources/brands.rbi +++ b/rbi/courier/resources/brands.rbi @@ -3,21 +3,46 @@ module Courier module Resources class Brands - # Create a new brand. Requires `name` and `settings` (with at least - # `colors.primary` and `colors.secondary`). + # Creates a brand from a name and settings, including primary and secondary + # colors. Brands supply the logo, colors, and styling that templates render with. sig do params( name: String, settings: Courier::BrandSettings::OrHash, id: T.nilable(String), snippets: T.nilable(Courier::BrandSnippets::OrHash), + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(Courier::Brand) end - def create(name:, settings:, id: nil, snippets: nil, request_options: {}) + def create( + # Body param + name:, + # Body param + settings:, + # Body param + id: nil, + # Body param + snippets: nil, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, + request_options: {} + ) end - # Fetch a specific brand by brand ID. + # Returns one brand by id, including its colors, logo and styling settings, + # Handlebars snippets, and published version. sig do params( brand_id: String, @@ -31,7 +56,8 @@ module Courier ) end - # Replace an existing brand with the supplied values. + # Replaces a brand with the values you supply, so send the complete settings and + # snippets rather than only the fields you want changed. sig do params( brand_id: String, @@ -52,7 +78,8 @@ module Courier ) end - # Get the list of brands. + # Lists the workspace's brands. Every entry carries its name, styling settings, + # snippets, and published version. sig do params( cursor: T.nilable(String), @@ -66,7 +93,8 @@ module Courier ) end - # Delete a brand by brand ID. + # Deletes a brand by id. Reassign any template or tenant that references it before + # deleting to keep their styling intact. sig do params( brand_id: String, diff --git a/rbi/courier/resources/digests/schedules.rbi b/rbi/courier/resources/digests/schedules.rbi index 3b8acbbd..72b60a76 100644 --- a/rbi/courier/resources/digests/schedules.rbi +++ b/rbi/courier/resources/digests/schedules.rbi @@ -4,9 +4,8 @@ module Courier module Resources class Digests class Schedules - # List the digest instances for a schedule. Each instance represents the events - # accumulated for a single user against the schedule, and can be used to monitor - # digest accumulation before the digest is released. + # Returns the digest instances for a schedule, one per user, with cursor paging. + # Use it to see what has accumulated before a digest releases. sig do params( schedule_id: String, diff --git a/rbi/courier/resources/inbound.rbi b/rbi/courier/resources/inbound.rbi index 4ebfdf65..64c703be 100644 --- a/rbi/courier/resources/inbound.rbi +++ b/rbi/courier/resources/inbound.rbi @@ -3,7 +3,8 @@ module Courier module Resources class Inbound - # Courier Track Event + # Records an inbound event that can trigger a journey. Requires an event name, a + # messageId you generate, a type, and a properties object. sig do params( event: String, diff --git a/rbi/courier/resources/inbox.rbi b/rbi/courier/resources/inbox.rbi new file mode 100644 index 00000000..167008f8 --- /dev/null +++ b/rbi/courier/resources/inbox.rbi @@ -0,0 +1,15 @@ +# typed: strong + +module Courier + module Resources + class Inbox + sig { returns(Courier::Resources::Inbox::Messages) } + attr_reader :messages + + # @api private + sig { params(client: Courier::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end +end diff --git a/rbi/courier/resources/inbox/messages.rbi b/rbi/courier/resources/inbox/messages.rbi new file mode 100644 index 00000000..75787d64 --- /dev/null +++ b/rbi/courier/resources/inbox/messages.rbi @@ -0,0 +1,43 @@ +# typed: strong + +module Courier + module Resources + class Inbox + class Messages + # Delete a user's inbox message. The message is removed from every inbox read (it + # stops appearing in the recipient's Inbox); it can be restored. + sig do + params( + message_id: String, + request_options: Courier::RequestOptions::OrHash + ).void + end + def delete( + # The message ID of the inbox message to delete. + message_id, + request_options: {} + ) + end + + # Restore a previously deleted inbox message. + sig do + params( + message_id: String, + request_options: Courier::RequestOptions::OrHash + ).void + end + def restore( + # The message ID of the inbox message to restore. + message_id, + request_options: {} + ) + end + + # @api private + sig { params(client: Courier::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end +end diff --git a/rbi/courier/resources/journeys.rbi b/rbi/courier/resources/journeys.rbi index ca7a28a7..40021785 100644 --- a/rbi/courier/resources/journeys.rbi +++ b/rbi/courier/resources/journeys.rbi @@ -6,12 +6,8 @@ module Courier sig { returns(Courier::Resources::Journeys::Templates) } attr_reader :templates - # Create a journey. Defaults to `DRAFT` state; pass `state: "PUBLISHED"` to - # publish on create. Send nodes are not allowed on `POST`. The standard flow is: - # create the journey shell here, add notification templates with - # `POST /journeys/{templateId}/templates`, then wire them into the journey with - # `PUT /journeys/{templateId}`. Call `POST /journeys/{templateId}/publish` to - # publish a draft after the fact. + # Creates a journey from a set of nodes, in draft state unless you pass a + # published state. Send nodes cannot be included until their templates exist. sig do params( name: String, @@ -36,15 +32,32 @@ module Courier ], enabled: T::Boolean, state: Courier::JourneyState::OrSymbol, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(Courier::JourneyResponse) end def create( + # Body param name:, + # Body param nodes:, + # Body param enabled: nil, - # Lifecycle state of a journey. + # Body param: Lifecycle state of a journey. state: nil, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end @@ -67,7 +80,8 @@ module Courier ) end - # Get the list of journeys. + # Lists the workspace's journeys, each carrying a name, state, and enabled flag. + # Paged by cursor. sig do params( cursor: String, @@ -86,8 +100,8 @@ module Courier ) end - # Archive a journey. Archived journeys cannot be invoked. Existing journey runs - # continue to completion. + # Archives a journey so it can no longer be invoked. Runs already in flight + # continue to completion, so archiving never strands a user mid-sequence. sig do params( template_id: String, @@ -101,12 +115,8 @@ module Courier ) end - # Cancel journey runs. The request body must include EXACTLY ONE of - # `cancelation_token` (cancels every run associated with the token) or `run_id` - # (cancels a single tenant-scoped run). Supplying both or neither returns a `400`. - # A `run_id` that does not match a run for the tenant returns `404`. Cancelation - # is idempotent: a run that has already finished (`PROCESSED`/`ERROR`) or was - # already `CANCELED` is left unchanged and its current status is returned. + # Cancels in-flight journey runs, either every run sharing a cancelation token or + # one run by id. Use it to stop a sequence when the event resolves. sig do params( cancel_journey_request: @@ -114,53 +124,82 @@ module Courier Courier::CancelJourneyRequest::ByCancelationToken::OrHash, Courier::CancelJourneyRequest::ByRunID::OrHash ), + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(Courier::CancelJourneyResponse::Variants) end def cancel( - # Request body for `POST /journeys/cancel`. Provide EXACTLY ONE of + # Body param: Request body for `POST /journeys/cancel`. Provide EXACTLY ONE of # `cancelation_token` (cancels every run associated with the token) or `run_id` # (cancels a single tenant-scoped run). cancel_journey_request:, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end - # Invoke a journey by id or alias to start a new run. The response includes a - # `runId` identifying the run. + # Starts a journey run for one user and returns a runId. Runs execute + # asynchronously, so the response arrives before any message is sent. sig do params( template_id: String, data: T::Hash[Symbol, T.anything], profile: T::Hash[Symbol, T.anything], user_id: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(Courier::JourneysInvokeResponse) end def invoke( - # A unique identifier representing the journey to be invoked. Accepts a Journey ID - # or Journey Alias. + # Path param: A unique identifier representing the journey to be invoked. Accepts + # a Journey ID or Journey Alias. template_id, - # Data payload passed to the journey. The expected shape can be predefined using - # the schema builder in the journey editor. This data is available in journey - # steps for condition evaluation and template variable interpolation. Can also - # contain user identifiers (user_id, userId, anonymousId) if not provided - # elsewhere. + # Body param: Data payload passed to the journey. The expected shape can be + # predefined using the schema builder in the journey editor. This data is + # available in journey steps for condition evaluation and template variable + # interpolation. Can also contain user identifiers (user_id, userId, anonymousId) + # if not provided elsewhere. data: nil, - # Profile data for the user. Can contain contact information (email, + # Body param: Profile data for the user. Can contain contact information (email, # phone_number), user identifiers (user_id, userId, anonymousId), or any custom # profile fields. Profile fields are merged with any existing stored profile for # the user. Include context.tenant_id to load a tenant-scoped profile for # multi-tenant scenarios. profile: nil, - # A unique identifier for the user. If not provided, the system will attempt to - # resolve the user identifier from profile or data objects. + # Body param: A unique identifier for the user. If not provided, the system will + # attempt to resolve the user identifier from profile or data objects. user_id: nil, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end - # List published versions of a journey, ordered most recent first. + # Lists a journey's published versions, most recent first, so you have a version + # id to roll back to. Paged by cursor. sig do params( template_id: String, @@ -174,29 +213,40 @@ module Courier ) end - # Publish the current draft as a new version. Body is optional; pass - # `{ "version": "vN" }` to roll back to a prior version instead. Returns 404 if - # the journey has no draft to publish. + # Publishes a journey's current draft as a new version, making it live for new + # runs. Pass a version instead to roll back to an earlier one. sig do params( template_id: String, version: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(Courier::JourneyResponse) end def publish( - # Journey id + # Path param: Journey id template_id, + # Body param version: nil, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end - # Replace the journey draft. Updates the working draft only; call - # `POST /journeys/{templateId}/publish` to make it live, or pass - # `state: "PUBLISHED"` in this request to publish immediately. Send-node - # `template` ids must already exist and be scoped to this journey, and node ids - # must not be claimed by another journey. + # Replaces a journey's working draft, leaving the published version live until you + # publish. Reach for this when editing a journey already running. sig do params( template_id: String, diff --git a/rbi/courier/resources/journeys/templates.rbi b/rbi/courier/resources/journeys/templates.rbi index 3477413a..352efc22 100644 --- a/rbi/courier/resources/journeys/templates.rbi +++ b/rbi/courier/resources/journeys/templates.rbi @@ -14,23 +14,40 @@ module Courier Courier::JourneyTemplateCreateRequest::Notification::OrHash, provider_key: String, state: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(Courier::JourneyTemplateGetResponse) end def create( - # Journey id + # Path param: Journey id template_id, + # Body param channel:, + # Body param notification:, + # Body param provider_key: nil, + # Body param state: nil, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end - # Fetch a journey-scoped notification template by id. Pass `?version=draft` - # (default `published`) to retrieve the working draft, or `?version=vN` for a - # historical version. + # Returns a journey's own notification template with its name, brand, subscription + # topic, and content. Defaults to the published version. sig do params( notification_id: String, @@ -68,8 +85,8 @@ module Courier ) end - # Archive the journey-scoped notification template. Archived templates cannot be - # sent. + # Archives one journey's notification template, preventing further sends. Detach + # any send node referencing it beforehand. sig do params( notification_id: String, @@ -86,8 +103,8 @@ module Courier ) end - # List published versions of the journey-scoped notification template, ordered - # most recent first. + # Lists the published versions of a template that belongs to a journey, most + # recent first. Paged by cursor. sig do params( notification_id: String, @@ -104,14 +121,15 @@ module Courier ) end - # Publish the current draft of the journey-scoped notification template as a new - # version. Optionally roll back to a prior version by passing - # `{ "version": "vN" }`. + # Publishes a journey-scoped template's draft as a new version. Pass a version + # instead to roll back the template to an earlier publish. sig do params( notification_id: String, template_id: String, version: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).void end @@ -122,6 +140,18 @@ module Courier template_id:, # Body param version: nil, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end @@ -179,7 +209,8 @@ module Courier ) end - # Replace the journey-scoped notification template draft. + # Replaces the draft content of one journey's notification template. Publish it + # before send nodes referencing it render the change. sig do params( notification_id: String, @@ -203,11 +234,8 @@ module Courier ) end - # Retrieve the elemental content of a journey-scoped notification template. The - # response contains the versioned elements along with their content checksums, - # which can be used to detect changes between versions. Pass `?version=draft` - # (default `published`) to retrieve the working draft, or `?version=vN` for a - # historical version. + # Returns the Elemental elements and version of a journey-scoped template's + # content. Compare versions to see what changed between publishes. sig do params( notification_id: String, diff --git a/rbi/courier/resources/lists.rbi b/rbi/courier/resources/lists.rbi index 9afb8d45..45101763 100644 --- a/rbi/courier/resources/lists.rbi +++ b/rbi/courier/resources/lists.rbi @@ -6,7 +6,8 @@ module Courier sig { returns(Courier::Resources::Lists::Subscriptions) } attr_reader :subscriptions - # Returns a list based on the list ID provided. + # Returns one list by id with its name and created and updated timestamps. Fetch + # its subscribers separately with the subscriptions endpoint. sig do params( list_id: String, @@ -20,7 +21,8 @@ module Courier ) end - # Create or replace an existing list with the supplied values. + # Creates or replaces a list from a name and preferences. Subscribers are managed + # through the separate subscriptions endpoints. sig do params( list_id: String, @@ -38,7 +40,8 @@ module Courier ) end - # Returns all of the lists, with the ability to filter based on a pattern. + # Returns the workspace's lists, filterable by a pattern to fetch a subset such as + # every regional list. Paged by cursor. sig do params( cursor: T.nilable(String), @@ -58,7 +61,8 @@ module Courier ) end - # Delete a list by list ID. + # Deletes a list, halting sends that target it. A previously deleted list can be + # brought back with the companion restore endpoint. sig do params( list_id: String, @@ -72,7 +76,8 @@ module Courier ) end - # Restore a previously deleted list. + # Restores a previously deleted list along with its subscribers, so a list removed + # by mistake can be brought back rather than rebuilt. sig do params( list_id: String, diff --git a/rbi/courier/resources/lists/subscriptions.rbi b/rbi/courier/resources/lists/subscriptions.rbi index 85db5ed2..5478c19c 100644 --- a/rbi/courier/resources/lists/subscriptions.rbi +++ b/rbi/courier/resources/lists/subscriptions.rbi @@ -4,7 +4,8 @@ module Courier module Resources class Lists class Subscriptions - # Get the list's subscriptions. + # Returns the users subscribed to a list with paging, each with the preferences + # recorded for that subscription. sig do params( list_id: String, @@ -27,13 +28,28 @@ module Courier params( list_id: String, recipients: T::Array[Courier::PutSubscriptionsRecipient::OrHash], + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).void end def add( - # A unique identifier representing the list you wish to retrieve. + # Path param: A unique identifier representing the list you wish to retrieve. list_id, + # Body param recipients:, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end @@ -55,8 +71,8 @@ module Courier ) end - # Subscribe a user to an existing list (note: if the List does not exist, it will - # be automatically created). + # Subscribes one user to a list, creating the list if it does not yet exist. + # Optional preferences apply to this subscription only. sig do params( user_id: String, @@ -77,7 +93,8 @@ module Courier ) end - # Delete a subscription to a list by list ID and user ID. + # Removes one user's subscription to a list, addressed by list id and user id. The + # user's profile and other subscriptions are separate resources. sig do params( user_id: String, diff --git a/rbi/courier/resources/messages.rbi b/rbi/courier/resources/messages.rbi index acf25449..c5906ab4 100644 --- a/rbi/courier/resources/messages.rbi +++ b/rbi/courier/resources/messages.rbi @@ -3,7 +3,8 @@ module Courier module Resources class Messages - # Fetch the status of a message you've previously sent. + # Returns a sent message's status, recipient, event, and per-provider delivery + # detail, with timestamps for enqueued, sent, delivered, opened, and clicked. sig do params( message_id: String, @@ -18,7 +19,8 @@ module Courier ) end - # Fetch the statuses of messages you've previously sent. + # Returns previously sent messages, most recent first, each carrying its status, + # recipient, channel, and provider. Paged by cursor. sig do params( archived: T.nilable(T::Boolean), @@ -80,11 +82,8 @@ module Courier ) end - # Cancel a message that is currently in the process of being delivered. A - # well-formatted API call to the cancel message API will return either `200` - # status code for a successful cancellation or `409` status code for an - # unsuccessful cancellation. Both cases will include the actual message record in - # the response body (see details below). + # Cancels a message that is still in the delivery pipeline and returns the message + # record with its resulting canceled or failed status. sig do params( message_id: String, @@ -98,7 +97,8 @@ module Courier ) end - # Get message content + # Returns the rendered content Courier delivered for a message, broken out per + # channel, to confirm what the recipient received. sig do params( message_id: String, @@ -113,7 +113,8 @@ module Courier ) end - # Fetch the array of events of a message you've previously sent. + # Returns the ordered event history for a sent message, one entry per status + # transition with its timestamp. sig do params( message_id: String, @@ -130,11 +131,8 @@ module Courier ) end - # Resend a previously sent message. The original send request is loaded from - # storage and a brand-new send is enqueued for the same recipient and content, - # producing a **new** `messageId` — the original message is not modified. - # Throttled by a per-message rate limit; a repeat inside the limit window returns - # `429 Too Many Requests`. + # Resends a previously sent message to the same recipient and content, returning a + # new messageId. The original send request is not modified. sig do params( message_id: String, diff --git a/rbi/courier/resources/notifications.rbi b/rbi/courier/resources/notifications.rbi index bdb459a6..c4649dd8 100644 --- a/rbi/courier/resources/notifications.rbi +++ b/rbi/courier/resources/notifications.rbi @@ -12,16 +12,30 @@ module Courier params( notification: Courier::NotificationTemplatePayload::OrHash, state: Courier::NotificationTemplateCreateRequest::State::OrSymbol, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(Courier::NotificationTemplateResponse) end def create( - # Core template fields used in POST and PUT request bodies (nested under a - # `notification` key) and returned at the top level in responses. + # Body param: Core template fields used in POST and PUT request bodies (nested + # under a `notification` key) and returned at the top level in responses. notification:, - # Template state after creation. Case-insensitive input, normalized to uppercase - # in the response. Defaults to "DRAFT". + # Body param: Template state after creation. Case-insensitive input, normalized to + # uppercase in the response. Defaults to "DRAFT". state: nil, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end @@ -45,7 +59,8 @@ module Courier ) end - # List notification templates in your workspace. + # Lists the workspace's notification templates. Each carries a name, tags, brand, + # routing, and its draft or published state. sig do params( cursor: T.nilable(String), @@ -65,7 +80,8 @@ module Courier ) end - # Archive a notification template. + # Archives a notification template, preventing new sends from referencing it. The + # template stays retrievable for its version history. sig do params( id: String, @@ -79,12 +95,9 @@ module Courier ) end - # Duplicate a notification template. Creates a standalone copy within the same - # workspace and environment, with " COPY" appended to the title. The copy clones - # the source draft's tags, brand, subscription topic, routing strategy, channels, - # and content, and is always created as a standalone template (it is not linked to - # any journey or broadcast, even if the source was). Templates that are scoped to - # a journey or a broadcast cannot be duplicated through this endpoint. + # Copies a notification template within the same workspace and environment, + # appending " COPY" to the title. The copy is standalone and independently + # editable. sig do params( id: String, @@ -98,7 +111,8 @@ module Courier ) end - # List versions of a notification template. + # Returns a notification template's published versions, most recent first, for + # comparison or rollback. Paged. sig do params( id: String, @@ -124,21 +138,35 @@ module Courier params( id: String, version: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).void end def publish( - # Template ID (nt\_ prefix). + # Path param: Template ID (nt\_ prefix). id, - # Historical version to publish (e.g. "v001"). Omit to publish the current draft. + # Body param: Historical version to publish (e.g. "v001"). Omit to publish the + # current draft. version: nil, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end - # Replace the elemental content of a notification template. Overwrites all - # elements in the template with the provided content. Only supported for V2 - # (elemental) templates. + # Replaces all Elemental content in a template, overwriting every existing + # element. Supported for V2 templates only, not V1 blocks and channels. sig do params( id: String, @@ -158,8 +186,8 @@ module Courier ) end - # Update a single element within a notification template. Only supported for V2 - # (elemental) templates. + # Replaces one Elemental element in a template, addressed by its element id. + # Supported for V2 templates only, not V1 blocks and channels. sig do params( element_id: String, @@ -197,9 +225,8 @@ module Courier ) end - # Set locale-specific content overrides for a notification template. Each element - # override must reference an existing element by ID. Only supported for V2 - # (elemental) templates. + # Sets locale-specific content overrides for a template. Each override must + # reference an element that already exists in the default content. sig do params( locale_id: String, @@ -223,7 +250,8 @@ module Courier ) end - # Replace a notification template. All fields are required. + # Replaces a notification template in full, so send every field rather than only + # the ones you want changed. Publish separately to make it live. sig do params( id: String, @@ -245,10 +273,8 @@ module Courier ) end - # Retrieve the content of a notification template. The response shape depends on - # whether the template uses V1 (blocks/channels) or V2 (elemental) content. Use - # the `version` query parameter to select draft, published, or a specific - # historical version. + # Returns a template's content and checksum. V2 templates return Elemental + # elements, while V1 templates return blocks and channels instead. sig do params( id: String, diff --git a/rbi/courier/resources/notifications/checks.rbi b/rbi/courier/resources/notifications/checks.rbi index 2b6ed984..2bd63c3e 100644 --- a/rbi/courier/resources/notifications/checks.rbi +++ b/rbi/courier/resources/notifications/checks.rbi @@ -4,7 +4,8 @@ module Courier module Resources class Notifications class Checks - # Replace the submission checks for a notification template. + # Replaces the approval checks on a template submission with the complete set + # supplied in the request body. sig do params( submission_id: String, @@ -24,7 +25,8 @@ module Courier ) end - # Retrieve the submission checks for a notification template. + # Returns the approval checks recorded for a template submission, each with its + # pass or fail result. sig do params( submission_id: String, @@ -41,7 +43,8 @@ module Courier ) end - # Cancel a submission for a notification template. + # Cancels a pending template submission, withdrawing it from the approval + # workflow. The template stays in draft and can be resubmitted later. sig do params( submission_id: String, diff --git a/rbi/courier/resources/profiles.rbi b/rbi/courier/resources/profiles.rbi index 418d0b6b..c6798594 100644 --- a/rbi/courier/resources/profiles.rbi +++ b/rbi/courier/resources/profiles.rbi @@ -6,24 +6,41 @@ module Courier sig { returns(Courier::Resources::Profiles::Lists) } attr_reader :lists - # Merge the supplied values with an existing profile or create a new profile if - # one doesn't already exist. + # Merges the supplied values into a user's profile, creating it if absent and + # leaving any key you omit untouched. Prefer this for everyday writes. sig do params( user_id: String, profile: T::Hash[Symbol, T.anything], + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(Courier::Models::ProfileCreateResponse) end def create( - # A unique identifier representing the user associated with the requested profile. + # Path param: A unique identifier representing the user associated with the + # requested profile. user_id, + # Body param profile:, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end - # Returns the specified user profile. + # Returns a user's stored profile and preferences, including the email address, + # phone number, and push tokens Courier can reach them on. sig do params( user_id: String, @@ -37,7 +54,8 @@ module Courier ) end - # Update a profile + # Applies a JSON Patch to a user profile, adding, removing, or replacing + # individual fields without sending the whole object. sig do params( user_id: String, @@ -55,7 +73,8 @@ module Courier ) end - # Deletes the specified user profile. + # Deletes a user's profile and stored contact details. List subscriptions and + # preferences are separate resources, so remove those too if required. sig do params( user_id: String, @@ -70,11 +89,8 @@ module Courier ) end - # When using `PUT`, be sure to include all the key-value pairs required by the - # recipient's profile. Any key-value pairs that exist in the profile but fail to - # be included in the `PUT` request will be removed from the profile. Remember, a - # `PUT` update is a full replacement of the data. For partial updates, use the - # [Patch](https://www.courier.com/docs/reference/profiles/patch/) request. + # Overwrites a user profile in full, removing any key absent from the request + # body. Use the patch endpoint when changing a single field. sig do params( user_id: String, diff --git a/rbi/courier/resources/profiles/lists.rbi b/rbi/courier/resources/profiles/lists.rbi index 8a2fd818..8728a9a8 100644 --- a/rbi/courier/resources/profiles/lists.rbi +++ b/rbi/courier/resources/profiles/lists.rbi @@ -4,7 +4,8 @@ module Courier module Resources class Profiles class Lists - # Returns the subscribed lists for a specified user. + # Returns the lists a user is subscribed to, with paging. Use it to check what a + # recipient will receive before sending to a list. sig do params( user_id: String, @@ -22,7 +23,8 @@ module Courier ) end - # Removes all list subscriptions for given user. + # Removes every list subscription for a user at once. Their profile and + # preferences are untouched, so this only affects list-targeted sends. sig do params( user_id: String, @@ -36,20 +38,35 @@ module Courier ) end - # Subscribes the given user to one or more lists. If the list does not exist, it - # will be created. + # Subscribes a user to one or more lists, creating any list that does not yet + # exist. Optional preferences apply to each subscription. sig do params( user_id: String, lists: T::Array[Courier::SubscribeToListsRequestItem::OrHash], + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(Courier::Models::Profiles::ListSubscribeResponse) end def subscribe( - # A unique identifier representing the user associated with the requested user - # profile. + # Path param: A unique identifier representing the user associated with the + # requested user profile. user_id, + # Body param lists:, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end diff --git a/rbi/courier/resources/providers.rbi b/rbi/courier/resources/providers.rbi index 3b06b579..c9fa9d92 100644 --- a/rbi/courier/resources/providers.rbi +++ b/rbi/courier/resources/providers.rbi @@ -6,34 +6,49 @@ module Courier sig { returns(Courier::Resources::Providers::Catalog) } attr_reader :catalog - # Create a new provider configuration. The `provider` field must be a known - # Courier provider key (see catalog). + # Configures a provider integration from a Courier provider key and its settings. + # Check the catalog endpoint for the schema each provider expects. sig do params( provider: String, alias_: String, settings: T::Hash[Symbol, T.anything], title: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(Courier::Provider) end def create( - # The provider key identifying the type (e.g. "sendgrid", "twilio"). Must be a - # known Courier provider — see the catalog endpoint for valid keys. + # Body param: The provider key identifying the type (e.g. "sendgrid", "twilio"). + # Must be a known Courier provider — see the catalog endpoint for valid keys. provider:, - # Optional alias for this configuration. + # Body param: Optional alias for this configuration. alias_: nil, - # Provider-specific settings (snake_case keys). Defaults to an empty object when - # omitted. Use the catalog endpoint to discover required fields for a given - # provider — omitting a required field returns a 400 validation error. + # Body param: Provider-specific settings (snake_case keys). Defaults to an empty + # object when omitted. Use the catalog endpoint to discover required fields for a + # given provider — omitting a required field returns a 400 validation error. settings: nil, - # Optional display title. Omit to use "Default Configuration". + # Body param: Optional display title. Omit to use "Default Configuration". title: nil, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end - # Fetch a single provider configuration by ID. + # Returns one configured provider by id, including its channel, provider key, + # alias, title, and current settings. sig do params( id: String, @@ -47,11 +62,8 @@ module Courier ) end - # 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. + # Replaces a provider's configuration in full, clearing any field you omit rather + # than merging it. Send the complete settings object. sig do params( id: String, @@ -80,8 +92,8 @@ module Courier ) end - # List configured provider integrations for the current workspace. Supports - # cursor-based pagination. + # Lists the provider integrations configured in the workspace, one entry per + # channel and provider key with its alias and settings. sig do params( cursor: String, @@ -95,8 +107,8 @@ module Courier ) end - # Delete a provider configuration. Returns 409 if the provider is still referenced - # by routing or notifications. + # Deletes a provider configuration, which fails while routing strategies or + # templates still reference it. Update those references first. sig do params( id: String, diff --git a/rbi/courier/resources/providers/catalog.rbi b/rbi/courier/resources/providers/catalog.rbi index 7c663abf..05c49c5a 100644 --- a/rbi/courier/resources/providers/catalog.rbi +++ b/rbi/courier/resources/providers/catalog.rbi @@ -4,10 +4,8 @@ module Courier module Resources class Providers class Catalog - # Returns the catalog of available provider types with their display names, - # descriptions, and configuration schema fields (snake_case, with `type` and - # `required`). Providers with no configurable schema return only `provider`, - # `name`, and `description`. + # Returns the provider types Courier supports, each with a display name, + # description, and the configuration fields it requires. sig do params( channel: String, diff --git a/rbi/courier/resources/requests.rbi b/rbi/courier/resources/requests.rbi index 3e31f83a..bcfe1b5d 100644 --- a/rbi/courier/resources/requests.rbi +++ b/rbi/courier/resources/requests.rbi @@ -3,7 +3,8 @@ module Courier module Resources class Requests - # Archive message + # Archives a send request by its request id. Use it to remove test sends or + # superseded requests from the message list without deleting them. sig do params( request_id: String, diff --git a/rbi/courier/resources/routing_strategies.rbi b/rbi/courier/resources/routing_strategies.rbi index ecba72a7..aeff313c 100644 --- a/rbi/courier/resources/routing_strategies.rbi +++ b/rbi/courier/resources/routing_strategies.rbi @@ -14,28 +14,42 @@ module Courier providers: T.nilable(T::Hash[Symbol, Courier::MessageProvidersType::OrHash]), tags: T.nilable(T::Array[String]), + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(Courier::RoutingStrategyGetResponse) end def create( - # Human-readable name for the routing strategy. + # Body param: Human-readable name for the routing strategy. name:, - # Routing tree defining channel selection method and order. + # Body param: Routing tree defining channel selection method and order. routing:, - # Per-channel delivery configuration. Defaults to empty if omitted. + # Body param: Per-channel delivery configuration. Defaults to empty if omitted. channels: nil, - # Optional description of the routing strategy. + # Body param: Optional description of the routing strategy. description: nil, - # Per-provider delivery configuration. Defaults to empty if omitted. + # Body param: Per-provider delivery configuration. Defaults to empty if omitted. providers: nil, - # Optional tags for categorization. + # Body param: Optional tags for categorization. tags: nil, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end - # Retrieve a routing strategy by ID. Returns the full entity including routing - # content and metadata. + # Returns one routing strategy by id with its name, tags, channels, and the + # routing rules that decide provider order and fallback. sig do params( id: String, @@ -83,8 +97,8 @@ module Courier ) end - # List notification templates associated with a routing strategy. Includes - # template metadata only, not full content. + # Returns the notification templates using a routing strategy, with paging. Check + # this before changing a strategy that templates depend on. sig do params( id: String, diff --git a/rbi/courier/resources/send.rbi b/rbi/courier/resources/send.rbi index b7d36c2c..bddccd8b 100644 --- a/rbi/courier/resources/send.rbi +++ b/rbi/courier/resources/send.rbi @@ -3,17 +3,32 @@ module Courier module Resources class Send - # Send a message to one or more recipients. + # Sends a message to one or more recipients and returns a requestId. Courier + # routes it to email, SMS, push, chat, or in-app based on your rules. sig do params( message: Courier::SendMessageParams::Message::OrHash, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(Courier::Models::SendMessageResponse) end def message( - # The message property has the following primary top-level properties. They define - # the destination and content of the message. + # Body param: The message property has the following primary top-level properties. + # They define the destination and content of the message. message:, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end diff --git a/rbi/courier/resources/tenants.rbi b/rbi/courier/resources/tenants.rbi index eebe3f6d..714106c8 100644 --- a/rbi/courier/resources/tenants.rbi +++ b/rbi/courier/resources/tenants.rbi @@ -9,7 +9,8 @@ module Courier sig { returns(Courier::Resources::Tenants::Templates) } attr_reader :templates - # Get a Tenant + # Returns one tenant with its name, parent tenant id, default preferences, + # properties, and the user profile applied to its members. sig do params( tenant_id: String, @@ -23,7 +24,8 @@ module Courier ) end - # Create or Replace a Tenant + # Creates or replaces a tenant from a name, parent, brand, properties, and default + # preferences supplied in the request body. sig do params( tenant_id: String, @@ -56,7 +58,8 @@ module Courier ) end - # Get a List of Tenants + # Lists the workspace's tenants, each carrying a name, parent tenant, properties, + # and default preferences. Paged. sig do params( cursor: T.nilable(String), @@ -76,7 +79,8 @@ module Courier ) end - # Delete a Tenant + # Deletes a tenant. Its members' workspace-level profiles and preferences live + # outside the tenant and are managed separately. sig do params( tenant_id: String, @@ -90,7 +94,8 @@ module Courier ) end - # Get Users in Tenant + # Returns the users belonging to a tenant with cursor paging. Use it to see who a + # tenant-scoped send will reach. sig do params( tenant_id: String, diff --git a/rbi/courier/resources/tenants/preferences/items.rbi b/rbi/courier/resources/tenants/preferences/items.rbi index 9aee21a4..7bc774ae 100644 --- a/rbi/courier/resources/tenants/preferences/items.rbi +++ b/rbi/courier/resources/tenants/preferences/items.rbi @@ -5,7 +5,8 @@ module Courier class Tenants class Preferences class Items - # Create or Replace Default Preferences For Topic + # Sets a tenant's default opt-in status for one subscription topic, which applies + # to every member unless a user sets their own override. sig do params( topic_id: String, @@ -36,7 +37,8 @@ module Courier ) end - # Remove Default Preferences For Topic + # Removes a tenant's default preference for one subscription topic, addressed by + # tenant id and topic id. sig do params( topic_id: String, diff --git a/rbi/courier/resources/tenants/templates.rbi b/rbi/courier/resources/tenants/templates.rbi index 2e40d7e1..9126980a 100644 --- a/rbi/courier/resources/tenants/templates.rbi +++ b/rbi/courier/resources/tenants/templates.rbi @@ -7,7 +7,8 @@ module Courier sig { returns(Courier::Resources::Tenants::Templates::Versions) } attr_reader :versions - # Get a Template in Tenant + # Returns a tenant's notification template with its content, version, and created, + # updated, and published timestamps. sig do params( template_id: String, @@ -24,7 +25,8 @@ module Courier ) end - # List Templates in Tenant + # Lists a tenant's notification templates, each carrying its version and published + # timestamp. Paged. sig do params( tenant_id: String, @@ -44,12 +46,8 @@ module Courier ) end - # Deletes the tenant's notification template with the given `template_id`. - # - # Returns **204 No Content** with an empty body on success. - # - # Returns **404** if there is no template with this ID for the tenant, including a - # second `DELETE` after a successful removal. + # Deletes a tenant's notification template by id. Sends for that tenant then use + # the workspace template registered under the same id. sig do params( template_id: String, @@ -66,10 +64,8 @@ module Courier ) end - # Publishes a specific version of a notification template for a tenant. - # - # The template must already exist in the tenant's notification map. If no version - # is specified, defaults to publishing the "latest" version. + # Publishes a version of a tenant's notification template, making it the content + # that tenant's sends render from until you publish another. sig do params( template_id: String, @@ -90,13 +86,8 @@ module Courier ) end - # Creates or updates a notification template for a tenant. - # - # If the template already exists for the tenant, it will be updated (200). - # Otherwise, a new template is created (201). - # - # Optionally publishes the template immediately if the `published` flag is set to - # true. + # Creates or updates a notification template scoped to one tenant, letting a + # tenant override the content the workspace template would send. sig do params( template_id: String, diff --git a/rbi/courier/resources/tenants/templates/versions.rbi b/rbi/courier/resources/tenants/templates/versions.rbi index 2c27af33..fd3ed46c 100644 --- a/rbi/courier/resources/tenants/templates/versions.rbi +++ b/rbi/courier/resources/tenants/templates/versions.rbi @@ -5,13 +5,8 @@ module Courier class Tenants class Templates class Versions - # Fetches a specific version of a tenant template. - # - # Supports the following version formats: - # - # - `latest` - The most recent version of the template - # - `published` - The currently published version - # - `v{version}` - A specific version (e.g., "v1", "v2", "v1.0.0") + # Returns one version of a tenant template, addressed by version number or by + # latest, with its content and publish timestamp. sig do params( version: String, diff --git a/rbi/courier/resources/translations.rbi b/rbi/courier/resources/translations.rbi index 4f74baca..37310d57 100644 --- a/rbi/courier/resources/translations.rbi +++ b/rbi/courier/resources/translations.rbi @@ -3,7 +3,8 @@ module Courier module Resources class Translations - # Get translations by locale + # Returns the translation strings stored for one domain and locale, for use in + # localized notification content. sig do params( locale: String, @@ -21,7 +22,8 @@ module Courier ) end - # Update a translation + # Uploads the translation strings for one domain and locale. Courier uses them to + # render localized content for recipients in that locale. sig do params( locale: String, diff --git a/rbi/courier/resources/users/preferences.rbi b/rbi/courier/resources/users/preferences.rbi index e33a7622..4c81e4d8 100644 --- a/rbi/courier/resources/users/preferences.rbi +++ b/rbi/courier/resources/users/preferences.rbi @@ -4,7 +4,8 @@ module Courier module Resources class Users class Preferences - # Fetch all user preferences. + # Returns a user's preference overrides with paging, one entry per subscription + # topic they have set a choice for. sig do params( user_id: String, @@ -22,23 +23,8 @@ module Courier ) end - # Replace a user's complete set of preference overrides in a single request. The - # topics in the request body become the recipient's entire set of overrides: - # listed topics are created or updated, and every existing override that is not - # included in the body is reset to its topic default. Submitting an empty `topics` - # array is a valid clear-all that resets every existing override. - # - # This operation is validation-atomic (all-or-nothing): structural validation - # fails fast with a single `400`, and if any topic is semantically invalid (an - # unknown topic, a `REQUIRED` topic that cannot be opted out, or a custom routing - # request that is not available on the workspace's plan) the request returns a - # single `400` aggregating every failure in `errors` and writes nothing. On - # success it returns `200` with `items` (the complete resulting override set) and - # `deleted` (the ids of the overrides that were reset to default). - # - # Every `topic_id` in the response — in `items`, `deleted`, and any `errors` — is - # returned in Courier's canonical topic id form, regardless of the form supplied - # in the request. + # Replaces a user's entire set of preference overrides. Any topic you leave out is + # reset to its default, so send the full set rather than a subset. sig do params( user_id: String, @@ -64,23 +50,8 @@ module Courier ) end - # Additively create or update a user's preferences for one or more subscription - # topics in a single request. Only the topics included in the request body are - # created or updated; any existing overrides for topics not listed are left - # untouched. - # - # Structural validation of the request body fails fast with a single `400`. Beyond - # that, each topic is processed independently (partial-success, not - # all-or-nothing): valid topics are written and returned in `items`, while topics - # that cannot be applied are collected in `errors` with a per-topic `reason` (for - # example an unknown topic, a `REQUIRED` topic that cannot be opted out, a custom - # routing request that is not available on the workspace's plan, or a write - # failure). The request therefore returns `200` with both lists whenever the body - # is structurally valid. - # - # Every `topic_id` in the response — in both `items` and `errors` — is returned in - # Courier's canonical topic id form, regardless of the form supplied in the - # request. + # Adds or updates a user's preferences for several subscription topics at once. + # Topics you leave out keep whatever they were set to before. sig do params( user_id: String, @@ -89,6 +60,8 @@ module Courier Courier::Users::PreferenceBulkUpdateParams::Topic::OrHash ], tenant_id: T.nilable(String), + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(Courier::Models::Users::PreferenceBulkUpdateResponse) end @@ -101,13 +74,24 @@ module Courier topics:, # Query param: Update the preferences of a user for this specific tenant context. tenant_id: nil, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end - # Remove a user's preferences for a specific subscription topic, resetting the - # topic to its effective default. This operation is idempotent: deleting a - # preference that does not exist succeeds with no error. + # Removes a user's override for one subscription topic, resetting it to the + # effective default from the tenant or workspace. sig do params( topic_id: String, @@ -128,7 +112,8 @@ module Courier ) end - # Fetch user preferences for a specific subscription topic. + # Returns a user's opt-in status and channel choices for one subscription topic, + # or the effective default if they have set no override. sig do params( topic_id: String, @@ -149,7 +134,8 @@ module Courier ) end - # Update or Create user preferences for a specific subscription topic. + # Sets a user's opt-in status and channel choices for one subscription topic, + # overriding the tenant default for that topic only. sig do params( topic_id: String, diff --git a/rbi/courier/resources/users/tenants.rbi b/rbi/courier/resources/users/tenants.rbi index 6eb7592c..16d6d008 100644 --- a/rbi/courier/resources/users/tenants.rbi +++ b/rbi/courier/resources/users/tenants.rbi @@ -4,7 +4,8 @@ module Courier module Resources class Users class Tenants - # Returns a paginated list of user tenant associations. + # Returns the tenants a user belongs to, with cursor paging. A user can belong to + # many tenants, each with its own profile and preferences. sig do params( user_id: String, @@ -24,9 +25,8 @@ module Courier ) end - # This endpoint is used to add a user to multiple tenants in one call. A custom - # profile can also be supplied for each tenant. This profile will be merged with - # the user's main profile when sending to the user with that tenant. + # Adds a user to several tenants in one call, each optionally with a per-tenant + # profile that overrides their workspace profile. sig do params( user_id: String, @@ -42,10 +42,8 @@ module Courier ) end - # This endpoint is used to add a single tenant. - # - # A custom profile can also be supplied with the tenant. This profile will be - # merged with the user's main profile when sending to the user with that tenant. + # Adds a user to one tenant, optionally with a tenant-specific profile that + # overrides their workspace profile for sends in that tenant. sig do params( tenant_id: String, @@ -65,7 +63,8 @@ module Courier ) end - # Removes a user from any tenants they may have been associated with. + # Removes a user from every tenant they belong to in one call. Their + # workspace-level profile is a separate resource. sig do params( user_id: String, @@ -79,7 +78,8 @@ module Courier ) end - # Removes a user from the supplied tenant. + # Removes a user from one tenant. Their other tenant memberships and workspace + # profile are managed through separate endpoints. sig do params( tenant_id: String, diff --git a/rbi/courier/resources/users/tokens.rbi b/rbi/courier/resources/users/tokens.rbi index ef582fd7..b3453627 100644 --- a/rbi/courier/resources/users/tokens.rbi +++ b/rbi/courier/resources/users/tokens.rbi @@ -4,7 +4,8 @@ module Courier module Resources class Users class Tokens - # Get single token available for a `:token` + # Returns one device token with its provider key, status and status reason, expiry + # date, and any properties stored alongside it. sig do params( token: String, @@ -21,7 +22,8 @@ module Courier ) end - # Apply a JSON Patch (RFC 6902) to the specified token. + # Applies a JSON Patch to a device token, changing its status, expiry, or + # properties without re-registering it. sig do params( token: String, @@ -41,7 +43,8 @@ module Courier ) end - # Gets all tokens available for a :user_id + # Returns every device token registered for a user, each with its provider key, + # status, and expiry date. sig do params( user_id: String, @@ -55,7 +58,8 @@ module Courier ) end - # Delete User Token + # Deletes one device token for a user, addressed by the token value, so push sends + # no longer target that device. sig do params( token: String, @@ -72,7 +76,8 @@ module Courier ) end - # Adds multiple tokens to a user and overwrites matching existing tokens. + # Registers several device tokens for a user in one call, overwriting any stored + # token with a matching value. sig do params( user_id: String, @@ -86,7 +91,8 @@ module Courier ) end - # Adds a single token to a user and overwrites a matching existing token. + # Registers one device token for a user against a provider key, overwriting the + # token if it already exists. Push sends resolve tokens per user. sig do params( token: String, diff --git a/rbi/courier/resources/workspace_preferences.rbi b/rbi/courier/resources/workspace_preferences.rbi index b6d3dfb7..342d4887 100644 --- a/rbi/courier/resources/workspace_preferences.rbi +++ b/rbi/courier/resources/workspace_preferences.rbi @@ -6,9 +6,8 @@ module Courier sig { returns(Courier::Resources::WorkspacePreferences::Topics) } attr_reader :topics - # Create a workspace preference. The workspace preference id is generated and - # returned. Topics are created inside a workspace preference via POST - # /preferences/sections/{section_id}/topics. + # Creates a workspace preference and returns its generated id. Add subscription + # topics to it afterwards with the topics endpoint. sig do params( name: String, @@ -16,23 +15,41 @@ module Courier has_custom_routing: T.nilable(T::Boolean), routing_options: T.nilable(T::Array[Courier::ChannelClassification::OrSymbol]), + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(Courier::WorkspacePreferenceGetResponse) end def create( - # Human-readable name for the workspace preference. + # Body param: Human-readable name for the workspace preference. name:, - # Optional description shown under the section on the hosted preferences page. + # Body param: Optional description shown under the section on the hosted + # preferences page. description: nil, - # Whether the workspace preference defines custom routing for its topics. + # Body param: Whether the workspace preference defines custom routing for its + # topics. has_custom_routing: nil, - # Default channels for the workspace preference. Defaults to empty if omitted. + # Body param: Default channels for the workspace preference. Defaults to empty if + # omitted. routing_options: nil, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end - # Retrieve a workspace preference by id, including its topics. + # Returns one workspace preference by id, including its subscription topics, + # routing options, and custom routing flag. sig do params( section_id: String, @@ -46,8 +63,8 @@ module Courier ) end - # List the workspace's preferences. Each workspace preference embeds its topics. - # Scoped to the workspace of the API key. + # Returns the workspace's preferences, each embedding its subscription topics, + # routing options, and whether custom routing is allowed. sig do params(request_options: Courier::RequestOptions::OrHash).returns( Courier::WorkspacePreferenceListResponse @@ -71,25 +88,38 @@ module Courier ) end - # Publish the workspace's preferences page. Takes a snapshot of every workspace - # preference with its topics under a new published version, making the current - # state visible on the hosted preferences page (non-draft). + # Publishes the workspace preference page, snapshotting every preference and + # topic, and returns the page id and a preview URL. sig do params( brand_id: T.nilable(String), description: T.nilable(String), heading: T.nilable(String), + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(Courier::PublishPreferencesResponse) end def publish( - # Brand for the hosted page - "default" (workspace default brand), "none" (no - # brand), or a specific brand id. Defaults to "default". + # Body param: Brand for the hosted page - "default" (workspace default brand), + # "none" (no brand), or a specific brand id. Defaults to "default". brand_id: nil, - # Description shown under the heading on the hosted preferences page. + # Body param: Description shown under the heading on the hosted preferences page. description: nil, - # Heading shown at the top of the hosted preferences page. + # Body param: Heading shown at the top of the hosted preferences page. heading: nil, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end diff --git a/rbi/courier/resources/workspace_preferences/topics.rbi b/rbi/courier/resources/workspace_preferences/topics.rbi index c39b18ab..cc96036e 100644 --- a/rbi/courier/resources/workspace_preferences/topics.rbi +++ b/rbi/courier/resources/workspace_preferences/topics.rbi @@ -4,9 +4,8 @@ module Courier module Resources class WorkspacePreferences class Topics - # Create a subscription preference topic inside a workspace preference. Fails with - # 404 if the workspace preference does not exist. The topic id is generated and - # returned. + # Creates a subscription topic inside a workspace preference. The default status + # sets whether users start opted in, opted out, or required. sig do params( section_id: String, @@ -24,34 +23,51 @@ module Courier routing_options: T.nilable(T::Array[Courier::ChannelClassification::OrSymbol]), topic_data: T.nilable(T::Hash[Symbol, T.anything]), + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions::OrHash ).returns(Courier::WorkspacePreferenceTopicGetResponse) end def create( - # Id of the workspace preference to create the topic in. + # Path param: Id of the workspace preference to create the topic in. section_id, - # The default subscription status applied when a recipient has not set their own. + # Body param: The default subscription status applied when a recipient has not set + # their own. default_status:, - # Human-readable name for the preference topic. + # Body param: Human-readable name for the preference topic. name:, - # Preference controls a recipient may customize for this topic. Defaults to empty - # if omitted. + # Body param: Preference controls a recipient may customize for this topic. + # Defaults to empty if omitted. allowed_preferences: nil, - # Optional description shown under the topic on the hosted preferences page. + # Body param: Optional description shown under the topic on the hosted preferences + # page. description: nil, - # Whether to include a list-unsubscribe header on emails for this topic. + # Body param: Whether to include a list-unsubscribe header on emails for this + # topic. include_unsubscribe_header: nil, - # Default channels delivered for this topic. Defaults to empty if omitted. + # Body param: Default channels delivered for this topic. Defaults to empty if + # omitted. routing_options: nil, - # Arbitrary metadata associated with the topic. + # Body param: Arbitrary metadata associated with the topic. topic_data: nil, + # Header param: A unique key that makes this request idempotent. If Courier + # receives another request with the same `Idempotency-Key`, it returns the stored + # response from the first request without performing the operation again + # (including the original status code and any error). Use it to safely retry + # `POST` requests after network failures without risking duplicate sends. The key + # is scoped to this endpoint. + idempotency_key: nil, + # Header param: How long the idempotency key remains valid, as a Unix epoch + # timestamp in seconds or an ISO 8601 date string. Only applies when + # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the + # maximum is 1 year. + x_idempotency_expiration: nil, request_options: {} ) end - # Retrieve a topic within a workspace preference. Returns 404 if the workspace - # preference does not exist, the topic does not exist, or the topic belongs to a - # different workspace preference. + # Returns one subscription topic with its default status, routing options, allowed + # preferences, and unsubscribe header setting. sig do params( topic_id: String, @@ -68,7 +84,8 @@ module Courier ) end - # List the topics in a workspace preference. + # Returns the subscription topics inside a workspace preference, each with its + # default status and routing options. sig do params( section_id: String, @@ -82,8 +99,8 @@ module Courier ) end - # Archive a topic and remove it from its workspace preference. Same 404 rules as - # GET. + # Archives a subscription topic and removes it from its workspace preference, + # addressed by section id and topic id. sig do params( topic_id: String, diff --git a/sig/courier/client.rbs b/sig/courier/client.rbs index 071501a2..aeaa2f44 100644 --- a/sig/courier/client.rbs +++ b/sig/courier/client.rbs @@ -32,6 +32,8 @@ module Courier attr_reader lists: Courier::Resources::Lists + attr_reader inbox: Courier::Resources::Inbox + attr_reader messages: Courier::Resources::Messages attr_reader requests: Courier::Resources::Requests diff --git a/sig/courier/models.rbs b/sig/courier/models.rbs index 31b27a2c..bc49990c 100644 --- a/sig/courier/models.rbs +++ b/sig/courier/models.rbs @@ -145,6 +145,8 @@ module Courier class InboundTrackEventParams = Courier::Models::InboundTrackEventParams + module Inbox = Courier::Models::Inbox + class Intercom = Courier::Models::Intercom class IntercomRecipient = Courier::Models::IntercomRecipient diff --git a/sig/courier/models/automations/invoke_invoke_ad_hoc_params.rbs b/sig/courier/models/automations/invoke_invoke_ad_hoc_params.rbs index 6138d60d..7a18c8b0 100644 --- a/sig/courier/models/automations/invoke_invoke_ad_hoc_params.rbs +++ b/sig/courier/models/automations/invoke_invoke_ad_hoc_params.rbs @@ -8,7 +8,9 @@ module Courier data: ::Hash[Symbol, top]?, profile: ::Hash[Symbol, top]?, recipient: String?, - template: String? + template: String?, + idempotency_key: String, + x_idempotency_expiration: String } & Courier::Internal::Type::request_parameters @@ -28,6 +30,14 @@ module Courier attr_accessor template: String? + attr_reader idempotency_key: String? + + def idempotency_key=: (String) -> String + + attr_reader x_idempotency_expiration: String? + + def x_idempotency_expiration=: (String) -> String + def initialize: ( automation: Courier::Automations::InvokeInvokeAdHocParams::Automation, ?brand: String?, @@ -35,6 +45,8 @@ module Courier ?profile: ::Hash[Symbol, top]?, ?recipient: String?, ?template: String?, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> void @@ -45,6 +57,8 @@ module Courier profile: ::Hash[Symbol, top]?, recipient: String?, template: String?, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } diff --git a/sig/courier/models/automations/invoke_invoke_by_template_params.rbs b/sig/courier/models/automations/invoke_invoke_by_template_params.rbs index add8ca95..62d8127e 100644 --- a/sig/courier/models/automations/invoke_invoke_by_template_params.rbs +++ b/sig/courier/models/automations/invoke_invoke_by_template_params.rbs @@ -8,7 +8,9 @@ module Courier brand: String?, data: ::Hash[Symbol, top]?, profile: ::Hash[Symbol, top]?, - template: String? + template: String?, + idempotency_key: String, + x_idempotency_expiration: String } & Courier::Internal::Type::request_parameters @@ -28,6 +30,14 @@ module Courier attr_accessor template: String? + attr_reader idempotency_key: String? + + def idempotency_key=: (String) -> String + + attr_reader x_idempotency_expiration: String? + + def x_idempotency_expiration=: (String) -> String + def initialize: ( template_id: String, recipient: String?, @@ -35,6 +45,8 @@ module Courier ?data: ::Hash[Symbol, top]?, ?profile: ::Hash[Symbol, top]?, ?template: String?, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> void @@ -45,6 +57,8 @@ module Courier data: ::Hash[Symbol, top]?, profile: ::Hash[Symbol, top]?, template: String?, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } end diff --git a/sig/courier/models/brand_create_params.rbs b/sig/courier/models/brand_create_params.rbs index f0b9e057..eee9d83b 100644 --- a/sig/courier/models/brand_create_params.rbs +++ b/sig/courier/models/brand_create_params.rbs @@ -5,7 +5,9 @@ module Courier name: String, settings: Courier::BrandSettings, id: String?, - snippets: Courier::BrandSnippets? + snippets: Courier::BrandSnippets?, + idempotency_key: String, + x_idempotency_expiration: String } & Courier::Internal::Type::request_parameters @@ -21,11 +23,21 @@ module Courier attr_accessor snippets: Courier::BrandSnippets? + attr_reader idempotency_key: String? + + def idempotency_key=: (String) -> String + + attr_reader x_idempotency_expiration: String? + + def x_idempotency_expiration=: (String) -> String + def initialize: ( name: String, settings: Courier::BrandSettings, ?id: String?, ?snippets: Courier::BrandSnippets?, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> void @@ -34,6 +46,8 @@ module Courier settings: Courier::BrandSettings, id: String?, snippets: Courier::BrandSnippets?, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } end diff --git a/sig/courier/models/inbox/message_delete_params.rbs b/sig/courier/models/inbox/message_delete_params.rbs new file mode 100644 index 00000000..5d77c654 --- /dev/null +++ b/sig/courier/models/inbox/message_delete_params.rbs @@ -0,0 +1,25 @@ +module Courier + module Models + module Inbox + type message_delete_params = + { message_id: String } & Courier::Internal::Type::request_parameters + + class MessageDeleteParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + attr_accessor message_id: String + + def initialize: ( + message_id: String, + ?request_options: Courier::request_opts + ) -> void + + def to_hash: -> { + message_id: String, + request_options: Courier::RequestOptions + } + end + end + end +end diff --git a/sig/courier/models/inbox/message_restore_params.rbs b/sig/courier/models/inbox/message_restore_params.rbs new file mode 100644 index 00000000..e27ee8da --- /dev/null +++ b/sig/courier/models/inbox/message_restore_params.rbs @@ -0,0 +1,25 @@ +module Courier + module Models + module Inbox + type message_restore_params = + { message_id: String } & Courier::Internal::Type::request_parameters + + class MessageRestoreParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + attr_accessor message_id: String + + def initialize: ( + message_id: String, + ?request_options: Courier::request_opts + ) -> void + + def to_hash: -> { + message_id: String, + request_options: Courier::RequestOptions + } + end + end + end +end diff --git a/sig/courier/models/journey_cancel_params.rbs b/sig/courier/models/journey_cancel_params.rbs index 01516251..e13282db 100644 --- a/sig/courier/models/journey_cancel_params.rbs +++ b/sig/courier/models/journey_cancel_params.rbs @@ -1,15 +1,32 @@ module Courier module Models type journey_cancel_params = - { } & Courier::Internal::Type::request_parameters + { idempotency_key: String, x_idempotency_expiration: String } + & Courier::Internal::Type::request_parameters class JourneyCancelParams < Courier::Internal::Type::BaseModel extend Courier::Internal::Type::RequestParameters::Converter include Courier::Internal::Type::RequestParameters - def initialize: (?request_options: Courier::request_opts) -> void + attr_reader idempotency_key: String? - def to_hash: -> { request_options: Courier::RequestOptions } + def idempotency_key=: (String) -> String + + attr_reader x_idempotency_expiration: String? + + def x_idempotency_expiration=: (String) -> String + + def initialize: ( + ?idempotency_key: String, + ?x_idempotency_expiration: String, + ?request_options: Courier::request_opts + ) -> void + + def to_hash: -> { + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions + } end end end diff --git a/sig/courier/models/journey_create_params.rbs b/sig/courier/models/journey_create_params.rbs index 0e2c7fc5..766f18e5 100644 --- a/sig/courier/models/journey_create_params.rbs +++ b/sig/courier/models/journey_create_params.rbs @@ -1,15 +1,32 @@ module Courier module Models type journey_create_params = - { } & Courier::Internal::Type::request_parameters + { idempotency_key: String, x_idempotency_expiration: String } + & Courier::Internal::Type::request_parameters class JourneyCreateParams < Courier::Models::CreateJourneyRequest extend Courier::Internal::Type::RequestParameters::Converter include Courier::Internal::Type::RequestParameters - def initialize: (?request_options: Courier::request_opts) -> void + def idempotency_key: -> String? - def to_hash: -> { request_options: Courier::RequestOptions } + def idempotency_key=: (String _) -> String + + def x_idempotency_expiration: -> String? + + def x_idempotency_expiration=: (String _) -> String + + def initialize: ( + ?idempotency_key: String, + ?x_idempotency_expiration: String, + ?request_options: Courier::request_opts + ) -> void + + def to_hash: -> { + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions + } end end end diff --git a/sig/courier/models/journey_invoke_params.rbs b/sig/courier/models/journey_invoke_params.rbs index 1774a2d4..f41777d3 100644 --- a/sig/courier/models/journey_invoke_params.rbs +++ b/sig/courier/models/journey_invoke_params.rbs @@ -1,7 +1,12 @@ module Courier module Models type journey_invoke_params = - { template_id: String } & Courier::Internal::Type::request_parameters + { + template_id: String, + idempotency_key: String, + x_idempotency_expiration: String + } + & Courier::Internal::Type::request_parameters class JourneyInvokeParams < Courier::Models::JourneysInvokeRequest extend Courier::Internal::Type::RequestParameters::Converter @@ -11,13 +16,25 @@ module Courier def template_id=: (String _) -> String + def idempotency_key: -> String? + + def idempotency_key=: (String _) -> String + + def x_idempotency_expiration: -> String? + + def x_idempotency_expiration=: (String _) -> String + def initialize: ( template_id: String, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> void def to_hash: -> { template_id: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } end diff --git a/sig/courier/models/journey_publish_params.rbs b/sig/courier/models/journey_publish_params.rbs index 906e1577..1f73045f 100644 --- a/sig/courier/models/journey_publish_params.rbs +++ b/sig/courier/models/journey_publish_params.rbs @@ -1,7 +1,12 @@ module Courier module Models type journey_publish_params = - { template_id: String } & Courier::Internal::Type::request_parameters + { + template_id: String, + idempotency_key: String, + x_idempotency_expiration: String + } + & Courier::Internal::Type::request_parameters class JourneyPublishParams < Courier::Models::JourneyPublishRequest extend Courier::Internal::Type::RequestParameters::Converter @@ -11,13 +16,25 @@ module Courier def template_id=: (String _) -> String + def idempotency_key: -> String? + + def idempotency_key=: (String _) -> String + + def x_idempotency_expiration: -> String? + + def x_idempotency_expiration=: (String _) -> String + def initialize: ( template_id: String, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> void def to_hash: -> { template_id: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } end diff --git a/sig/courier/models/journeys/template_create_params.rbs b/sig/courier/models/journeys/template_create_params.rbs index 1e835b55..804f5c20 100644 --- a/sig/courier/models/journeys/template_create_params.rbs +++ b/sig/courier/models/journeys/template_create_params.rbs @@ -2,7 +2,12 @@ module Courier module Models module Journeys type template_create_params = - { template_id: String } & Courier::Internal::Type::request_parameters + { + template_id: String, + idempotency_key: String, + x_idempotency_expiration: String + } + & Courier::Internal::Type::request_parameters class TemplateCreateParams < Courier::Models::JourneyTemplateCreateRequest extend Courier::Internal::Type::RequestParameters::Converter @@ -12,13 +17,25 @@ module Courier def template_id=: (String _) -> String + def idempotency_key: -> String? + + def idempotency_key=: (String _) -> String + + def x_idempotency_expiration: -> String? + + def x_idempotency_expiration=: (String _) -> String + def initialize: ( template_id: String, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> void def to_hash: -> { template_id: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } end diff --git a/sig/courier/models/journeys/template_publish_params.rbs b/sig/courier/models/journeys/template_publish_params.rbs index a39f9b6f..661ab046 100644 --- a/sig/courier/models/journeys/template_publish_params.rbs +++ b/sig/courier/models/journeys/template_publish_params.rbs @@ -2,7 +2,12 @@ module Courier module Models module Journeys type template_publish_params = - { template_id: String, notification_id: String } + { + template_id: String, + notification_id: String, + idempotency_key: String, + x_idempotency_expiration: String + } & Courier::Internal::Type::request_parameters class TemplatePublishParams < Courier::Models::JourneyTemplatePublishRequest @@ -17,15 +22,27 @@ module Courier def notification_id=: (String _) -> String + def idempotency_key: -> String? + + def idempotency_key=: (String _) -> String + + def x_idempotency_expiration: -> String? + + def x_idempotency_expiration=: (String _) -> String + def initialize: ( template_id: String, notification_id: String, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> void def to_hash: -> { template_id: String, notification_id: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } end diff --git a/sig/courier/models/lists/subscription_add_params.rbs b/sig/courier/models/lists/subscription_add_params.rbs index cbdeece7..d23f2c34 100644 --- a/sig/courier/models/lists/subscription_add_params.rbs +++ b/sig/courier/models/lists/subscription_add_params.rbs @@ -4,7 +4,9 @@ module Courier type subscription_add_params = { list_id: String, - recipients: ::Array[Courier::PutSubscriptionsRecipient] + recipients: ::Array[Courier::PutSubscriptionsRecipient], + idempotency_key: String, + x_idempotency_expiration: String } & Courier::Internal::Type::request_parameters @@ -16,15 +18,27 @@ module Courier attr_accessor recipients: ::Array[Courier::PutSubscriptionsRecipient] + attr_reader idempotency_key: String? + + def idempotency_key=: (String) -> String + + attr_reader x_idempotency_expiration: String? + + def x_idempotency_expiration=: (String) -> String + def initialize: ( list_id: String, recipients: ::Array[Courier::PutSubscriptionsRecipient], + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> void def to_hash: -> { list_id: String, recipients: ::Array[Courier::PutSubscriptionsRecipient], + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } end diff --git a/sig/courier/models/notification_create_params.rbs b/sig/courier/models/notification_create_params.rbs index d43d8b8a..7fed8818 100644 --- a/sig/courier/models/notification_create_params.rbs +++ b/sig/courier/models/notification_create_params.rbs @@ -1,15 +1,32 @@ module Courier module Models type notification_create_params = - { } & Courier::Internal::Type::request_parameters + { idempotency_key: String, x_idempotency_expiration: String } + & Courier::Internal::Type::request_parameters class NotificationCreateParams < Courier::Models::NotificationTemplateCreateRequest extend Courier::Internal::Type::RequestParameters::Converter include Courier::Internal::Type::RequestParameters - def initialize: (?request_options: Courier::request_opts) -> void + def idempotency_key: -> String? - def to_hash: -> { request_options: Courier::RequestOptions } + def idempotency_key=: (String _) -> String + + def x_idempotency_expiration: -> String? + + def x_idempotency_expiration=: (String _) -> String + + def initialize: ( + ?idempotency_key: String, + ?x_idempotency_expiration: String, + ?request_options: Courier::request_opts + ) -> void + + def to_hash: -> { + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions + } end end end diff --git a/sig/courier/models/notification_publish_params.rbs b/sig/courier/models/notification_publish_params.rbs index e7b69aed..4f4fb5a4 100644 --- a/sig/courier/models/notification_publish_params.rbs +++ b/sig/courier/models/notification_publish_params.rbs @@ -1,7 +1,8 @@ module Courier module Models type notification_publish_params = - { id: String } & Courier::Internal::Type::request_parameters + { id: String, idempotency_key: String, x_idempotency_expiration: String } + & Courier::Internal::Type::request_parameters class NotificationPublishParams < Courier::Models::NotificationTemplatePublishRequest extend Courier::Internal::Type::RequestParameters::Converter @@ -11,12 +12,27 @@ module Courier def id=: (String _) -> String + def idempotency_key: -> String? + + def idempotency_key=: (String _) -> String + + def x_idempotency_expiration: -> String? + + def x_idempotency_expiration=: (String _) -> String + def initialize: ( id: String, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> void - def to_hash: -> { id: String, request_options: Courier::RequestOptions } + def to_hash: -> { + id: String, + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions + } end end end diff --git a/sig/courier/models/profile_create_params.rbs b/sig/courier/models/profile_create_params.rbs index fe318b69..95302f1c 100644 --- a/sig/courier/models/profile_create_params.rbs +++ b/sig/courier/models/profile_create_params.rbs @@ -1,7 +1,12 @@ module Courier module Models type profile_create_params = - { user_id: String, profile: ::Hash[Symbol, top] } + { + user_id: String, + profile: ::Hash[Symbol, top], + idempotency_key: String, + x_idempotency_expiration: String + } & Courier::Internal::Type::request_parameters class ProfileCreateParams < Courier::Internal::Type::BaseModel @@ -12,15 +17,27 @@ module Courier attr_accessor profile: ::Hash[Symbol, top] + attr_reader idempotency_key: String? + + def idempotency_key=: (String) -> String + + attr_reader x_idempotency_expiration: String? + + def x_idempotency_expiration=: (String) -> String + def initialize: ( user_id: String, profile: ::Hash[Symbol, top], + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> void def to_hash: -> { user_id: String, profile: ::Hash[Symbol, top], + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } end diff --git a/sig/courier/models/profiles/list_subscribe_params.rbs b/sig/courier/models/profiles/list_subscribe_params.rbs index ccf15123..97a06be4 100644 --- a/sig/courier/models/profiles/list_subscribe_params.rbs +++ b/sig/courier/models/profiles/list_subscribe_params.rbs @@ -4,7 +4,9 @@ module Courier type list_subscribe_params = { user_id: String, - lists: ::Array[Courier::SubscribeToListsRequestItem] + lists: ::Array[Courier::SubscribeToListsRequestItem], + idempotency_key: String, + x_idempotency_expiration: String } & Courier::Internal::Type::request_parameters @@ -16,15 +18,27 @@ module Courier attr_accessor lists: ::Array[Courier::SubscribeToListsRequestItem] + attr_reader idempotency_key: String? + + def idempotency_key=: (String) -> String + + attr_reader x_idempotency_expiration: String? + + def x_idempotency_expiration=: (String) -> String + def initialize: ( user_id: String, lists: ::Array[Courier::SubscribeToListsRequestItem], + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> void def to_hash: -> { user_id: String, lists: ::Array[Courier::SubscribeToListsRequestItem], + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } end diff --git a/sig/courier/models/provider_create_params.rbs b/sig/courier/models/provider_create_params.rbs index ca46d514..ec747c7d 100644 --- a/sig/courier/models/provider_create_params.rbs +++ b/sig/courier/models/provider_create_params.rbs @@ -5,7 +5,9 @@ module Courier provider: String, alias_: String, settings: ::Hash[Symbol, top], - title: String + title: String, + idempotency_key: String, + x_idempotency_expiration: String } & Courier::Internal::Type::request_parameters @@ -27,11 +29,21 @@ module Courier def title=: (String) -> String + attr_reader idempotency_key: String? + + def idempotency_key=: (String) -> String + + attr_reader x_idempotency_expiration: String? + + def x_idempotency_expiration=: (String) -> String + def initialize: ( provider: String, ?alias_: String, ?settings: ::Hash[Symbol, top], ?title: String, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> void @@ -40,6 +52,8 @@ module Courier alias_: String, settings: ::Hash[Symbol, top], title: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } end diff --git a/sig/courier/models/routing_strategy_create_params.rbs b/sig/courier/models/routing_strategy_create_params.rbs index 93a729cf..8ee48127 100644 --- a/sig/courier/models/routing_strategy_create_params.rbs +++ b/sig/courier/models/routing_strategy_create_params.rbs @@ -1,15 +1,32 @@ module Courier module Models type routing_strategy_create_params = - { } & Courier::Internal::Type::request_parameters + { idempotency_key: String, x_idempotency_expiration: String } + & Courier::Internal::Type::request_parameters class RoutingStrategyCreateParams < Courier::Models::RoutingStrategyCreateRequest extend Courier::Internal::Type::RequestParameters::Converter include Courier::Internal::Type::RequestParameters - def initialize: (?request_options: Courier::request_opts) -> void + def idempotency_key: -> String? - def to_hash: -> { request_options: Courier::RequestOptions } + def idempotency_key=: (String _) -> String + + def x_idempotency_expiration: -> String? + + def x_idempotency_expiration=: (String _) -> String + + def initialize: ( + ?idempotency_key: String, + ?x_idempotency_expiration: String, + ?request_options: Courier::request_opts + ) -> void + + def to_hash: -> { + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions + } end end end diff --git a/sig/courier/models/send_message_params.rbs b/sig/courier/models/send_message_params.rbs index 4caba81d..029d28b7 100644 --- a/sig/courier/models/send_message_params.rbs +++ b/sig/courier/models/send_message_params.rbs @@ -1,7 +1,11 @@ module Courier module Models type send_message_params = - { message: Courier::SendMessageParams::Message } + { + message: Courier::SendMessageParams::Message, + idempotency_key: String, + x_idempotency_expiration: String + } & Courier::Internal::Type::request_parameters class SendMessageParams < Courier::Internal::Type::BaseModel @@ -10,13 +14,25 @@ module Courier attr_accessor message: Courier::SendMessageParams::Message + attr_reader idempotency_key: String? + + def idempotency_key=: (String) -> String + + attr_reader x_idempotency_expiration: String? + + def x_idempotency_expiration=: (String) -> String + def initialize: ( message: Courier::SendMessageParams::Message, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> void def to_hash: -> { message: Courier::SendMessageParams::Message, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } diff --git a/sig/courier/models/users/preference_bulk_update_params.rbs b/sig/courier/models/users/preference_bulk_update_params.rbs index fe5a61dd..5eebc9a0 100644 --- a/sig/courier/models/users/preference_bulk_update_params.rbs +++ b/sig/courier/models/users/preference_bulk_update_params.rbs @@ -5,7 +5,9 @@ module Courier { user_id: String, topics: ::Array[Courier::Users::PreferenceBulkUpdateParams::Topic], - tenant_id: String? + tenant_id: String?, + idempotency_key: String, + x_idempotency_expiration: String } & Courier::Internal::Type::request_parameters @@ -19,10 +21,20 @@ module Courier attr_accessor tenant_id: String? + attr_reader idempotency_key: String? + + def idempotency_key=: (String) -> String + + attr_reader x_idempotency_expiration: String? + + def x_idempotency_expiration=: (String) -> String + def initialize: ( user_id: String, topics: ::Array[Courier::Users::PreferenceBulkUpdateParams::Topic], ?tenant_id: String?, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> void @@ -30,6 +42,8 @@ module Courier user_id: String, topics: ::Array[Courier::Users::PreferenceBulkUpdateParams::Topic], tenant_id: String?, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } diff --git a/sig/courier/models/workspace_preference_create_params.rbs b/sig/courier/models/workspace_preference_create_params.rbs index 33f5a37e..a72b7102 100644 --- a/sig/courier/models/workspace_preference_create_params.rbs +++ b/sig/courier/models/workspace_preference_create_params.rbs @@ -1,15 +1,32 @@ module Courier module Models type workspace_preference_create_params = - { } & Courier::Internal::Type::request_parameters + { idempotency_key: String, x_idempotency_expiration: String } + & Courier::Internal::Type::request_parameters class WorkspacePreferenceCreateParams < Courier::Models::WorkspacePreferenceCreateRequest extend Courier::Internal::Type::RequestParameters::Converter include Courier::Internal::Type::RequestParameters - def initialize: (?request_options: Courier::request_opts) -> void + def idempotency_key: -> String? - def to_hash: -> { request_options: Courier::RequestOptions } + def idempotency_key=: (String _) -> String + + def x_idempotency_expiration: -> String? + + def x_idempotency_expiration=: (String _) -> String + + def initialize: ( + ?idempotency_key: String, + ?x_idempotency_expiration: String, + ?request_options: Courier::request_opts + ) -> void + + def to_hash: -> { + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions + } end end end diff --git a/sig/courier/models/workspace_preference_publish_params.rbs b/sig/courier/models/workspace_preference_publish_params.rbs index b785a593..6ec2ae76 100644 --- a/sig/courier/models/workspace_preference_publish_params.rbs +++ b/sig/courier/models/workspace_preference_publish_params.rbs @@ -1,15 +1,32 @@ module Courier module Models type workspace_preference_publish_params = - { } & Courier::Internal::Type::request_parameters + { idempotency_key: String, x_idempotency_expiration: String } + & Courier::Internal::Type::request_parameters class WorkspacePreferencePublishParams < Courier::Models::PublishPreferencesRequest extend Courier::Internal::Type::RequestParameters::Converter include Courier::Internal::Type::RequestParameters - def initialize: (?request_options: Courier::request_opts) -> void + def idempotency_key: -> String? - def to_hash: -> { request_options: Courier::RequestOptions } + def idempotency_key=: (String _) -> String + + def x_idempotency_expiration: -> String? + + def x_idempotency_expiration=: (String _) -> String + + def initialize: ( + ?idempotency_key: String, + ?x_idempotency_expiration: String, + ?request_options: Courier::request_opts + ) -> void + + def to_hash: -> { + idempotency_key: String, + x_idempotency_expiration: String, + request_options: Courier::RequestOptions + } end end end diff --git a/sig/courier/models/workspace_preferences/topic_create_params.rbs b/sig/courier/models/workspace_preferences/topic_create_params.rbs index 92daaa05..aad23d99 100644 --- a/sig/courier/models/workspace_preferences/topic_create_params.rbs +++ b/sig/courier/models/workspace_preferences/topic_create_params.rbs @@ -2,7 +2,12 @@ module Courier module Models module WorkspacePreferences type topic_create_params = - { section_id: String } & Courier::Internal::Type::request_parameters + { + section_id: String, + idempotency_key: String, + x_idempotency_expiration: String + } + & Courier::Internal::Type::request_parameters class TopicCreateParams < Courier::Models::WorkspacePreferenceTopicCreateRequest extend Courier::Internal::Type::RequestParameters::Converter @@ -12,13 +17,25 @@ module Courier def section_id=: (String _) -> String + def idempotency_key: -> String? + + def idempotency_key=: (String _) -> String + + def x_idempotency_expiration: -> String? + + def x_idempotency_expiration=: (String _) -> String + def initialize: ( section_id: String, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> void def to_hash: -> { section_id: String, + idempotency_key: String, + x_idempotency_expiration: String, request_options: Courier::RequestOptions } end diff --git a/sig/courier/resources/automations/invoke.rbs b/sig/courier/resources/automations/invoke.rbs index 9478fc2c..e4be2925 100644 --- a/sig/courier/resources/automations/invoke.rbs +++ b/sig/courier/resources/automations/invoke.rbs @@ -9,6 +9,8 @@ module Courier ?profile: ::Hash[Symbol, top]?, ?recipient: String?, ?template: String?, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> Courier::AutomationInvokeResponse @@ -19,6 +21,8 @@ module Courier ?data: ::Hash[Symbol, top]?, ?profile: ::Hash[Symbol, top]?, ?template: String?, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> Courier::AutomationInvokeResponse diff --git a/sig/courier/resources/brands.rbs b/sig/courier/resources/brands.rbs index 159a1ee0..694b700f 100644 --- a/sig/courier/resources/brands.rbs +++ b/sig/courier/resources/brands.rbs @@ -6,6 +6,8 @@ module Courier settings: Courier::BrandSettings, ?id: String?, ?snippets: Courier::BrandSnippets?, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> Courier::Brand diff --git a/sig/courier/resources/inbox.rbs b/sig/courier/resources/inbox.rbs new file mode 100644 index 00000000..07c680c1 --- /dev/null +++ b/sig/courier/resources/inbox.rbs @@ -0,0 +1,9 @@ +module Courier + module Resources + class Inbox + attr_reader messages: Courier::Resources::Inbox::Messages + + def initialize: (client: Courier::Client) -> void + end + end +end diff --git a/sig/courier/resources/inbox/messages.rbs b/sig/courier/resources/inbox/messages.rbs new file mode 100644 index 00000000..9c2332bf --- /dev/null +++ b/sig/courier/resources/inbox/messages.rbs @@ -0,0 +1,19 @@ +module Courier + module Resources + class Inbox + class Messages + def delete: ( + String message_id, + ?request_options: Courier::request_opts + ) -> nil + + def restore: ( + String message_id, + ?request_options: Courier::request_opts + ) -> nil + + def initialize: (client: Courier::Client) -> void + end + end + end +end diff --git a/sig/courier/resources/journeys.rbs b/sig/courier/resources/journeys.rbs index 51aa4392..477123a7 100644 --- a/sig/courier/resources/journeys.rbs +++ b/sig/courier/resources/journeys.rbs @@ -8,6 +8,8 @@ module Courier nodes: ::Array[Courier::Models::journey_node], ?enabled: bool, ?state: Courier::Models::journey_state, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> Courier::JourneyResponse @@ -30,6 +32,8 @@ module Courier def cancel: ( cancel_journey_request: Courier::Models::cancel_journey_request, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> Courier::Models::cancel_journey_response @@ -38,6 +42,8 @@ module Courier ?data: ::Hash[Symbol, top], ?profile: ::Hash[Symbol, top], ?user_id: String, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> Courier::JourneysInvokeResponse @@ -49,6 +55,8 @@ module Courier def publish: ( String template_id, ?version: String, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> Courier::JourneyResponse diff --git a/sig/courier/resources/journeys/templates.rbs b/sig/courier/resources/journeys/templates.rbs index 0c0c3b62..f375fc72 100644 --- a/sig/courier/resources/journeys/templates.rbs +++ b/sig/courier/resources/journeys/templates.rbs @@ -8,6 +8,8 @@ module Courier notification: Courier::JourneyTemplateCreateRequest::Notification, ?provider_key: String, ?state: String, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> Courier::JourneyTemplateGetResponse @@ -40,6 +42,8 @@ module Courier String notification_id, template_id: String, ?version: String, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> nil diff --git a/sig/courier/resources/lists/subscriptions.rbs b/sig/courier/resources/lists/subscriptions.rbs index 0a1a67a7..79ac9f48 100644 --- a/sig/courier/resources/lists/subscriptions.rbs +++ b/sig/courier/resources/lists/subscriptions.rbs @@ -11,6 +11,8 @@ module Courier def add: ( String list_id, recipients: ::Array[Courier::PutSubscriptionsRecipient], + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> nil diff --git a/sig/courier/resources/notifications.rbs b/sig/courier/resources/notifications.rbs index c5251f5e..15cfa20f 100644 --- a/sig/courier/resources/notifications.rbs +++ b/sig/courier/resources/notifications.rbs @@ -6,6 +6,8 @@ module Courier def create: ( notification: Courier::NotificationTemplatePayload, ?state: Courier::Models::NotificationTemplateCreateRequest::state, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> Courier::NotificationTemplateResponse @@ -39,6 +41,8 @@ module Courier def publish: ( String id, ?version: String, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> nil diff --git a/sig/courier/resources/profiles.rbs b/sig/courier/resources/profiles.rbs index ee962639..ce7f81e9 100644 --- a/sig/courier/resources/profiles.rbs +++ b/sig/courier/resources/profiles.rbs @@ -6,6 +6,8 @@ module Courier def create: ( String user_id, profile: ::Hash[Symbol, top], + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> Courier::Models::ProfileCreateResponse diff --git a/sig/courier/resources/profiles/lists.rbs b/sig/courier/resources/profiles/lists.rbs index 0943c211..9939698e 100644 --- a/sig/courier/resources/profiles/lists.rbs +++ b/sig/courier/resources/profiles/lists.rbs @@ -16,6 +16,8 @@ module Courier def subscribe: ( String user_id, lists: ::Array[Courier::SubscribeToListsRequestItem], + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> Courier::Models::Profiles::ListSubscribeResponse diff --git a/sig/courier/resources/providers.rbs b/sig/courier/resources/providers.rbs index 5508d74e..384f6bf9 100644 --- a/sig/courier/resources/providers.rbs +++ b/sig/courier/resources/providers.rbs @@ -8,6 +8,8 @@ module Courier ?alias_: String, ?settings: ::Hash[Symbol, top], ?title: String, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> Courier::Provider diff --git a/sig/courier/resources/routing_strategies.rbs b/sig/courier/resources/routing_strategies.rbs index 13cf0f49..8f393aa0 100644 --- a/sig/courier/resources/routing_strategies.rbs +++ b/sig/courier/resources/routing_strategies.rbs @@ -8,6 +8,8 @@ module Courier ?description: String?, ?providers: Courier::Models::message_providers?, ?tags: ::Array[String]?, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> Courier::RoutingStrategyGetResponse diff --git a/sig/courier/resources/send.rbs b/sig/courier/resources/send.rbs index ce577627..4b52db71 100644 --- a/sig/courier/resources/send.rbs +++ b/sig/courier/resources/send.rbs @@ -3,6 +3,8 @@ module Courier class Send def message: ( message: Courier::SendMessageParams::Message, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> Courier::Models::SendMessageResponse diff --git a/sig/courier/resources/users/preferences.rbs b/sig/courier/resources/users/preferences.rbs index 3528192b..d0b79037 100644 --- a/sig/courier/resources/users/preferences.rbs +++ b/sig/courier/resources/users/preferences.rbs @@ -19,6 +19,8 @@ module Courier String user_id, topics: ::Array[Courier::Users::PreferenceBulkUpdateParams::Topic], ?tenant_id: String?, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> Courier::Models::Users::PreferenceBulkUpdateResponse diff --git a/sig/courier/resources/workspace_preferences.rbs b/sig/courier/resources/workspace_preferences.rbs index d0202113..7abf3b5f 100644 --- a/sig/courier/resources/workspace_preferences.rbs +++ b/sig/courier/resources/workspace_preferences.rbs @@ -8,6 +8,8 @@ module Courier ?description: String?, ?has_custom_routing: bool?, ?routing_options: ::Array[Courier::Models::channel_classification]?, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> Courier::WorkspacePreferenceGetResponse @@ -29,6 +31,8 @@ module Courier ?brand_id: String?, ?description: String?, ?heading: String?, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> Courier::PublishPreferencesResponse diff --git a/sig/courier/resources/workspace_preferences/topics.rbs b/sig/courier/resources/workspace_preferences/topics.rbs index 3afd9d99..34d6b68c 100644 --- a/sig/courier/resources/workspace_preferences/topics.rbs +++ b/sig/courier/resources/workspace_preferences/topics.rbs @@ -11,6 +11,8 @@ module Courier ?include_unsubscribe_header: bool?, ?routing_options: ::Array[Courier::Models::channel_classification]?, ?topic_data: ::Hash[Symbol, top]?, + ?idempotency_key: String, + ?x_idempotency_expiration: String, ?request_options: Courier::request_opts ) -> Courier::WorkspacePreferenceTopicGetResponse diff --git a/test/courier/resource_namespaces.rb b/test/courier/resource_namespaces.rb index 118f91bf..d0fe2cee 100644 --- a/test/courier/resource_namespaces.rb +++ b/test/courier/resource_namespaces.rb @@ -9,6 +9,9 @@ module Automations module Digests end + module Inbox + end + module Journeys end diff --git a/test/courier/resources/inbox/messages_test.rb b/test/courier/resources/inbox/messages_test.rb new file mode 100644 index 00000000..809d74ec --- /dev/null +++ b/test/courier/resources/inbox/messages_test.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Courier::Test::Resources::Inbox::MessagesTest < Courier::Test::ResourceTest + def test_delete + skip("Mock server tests are disabled") + + response = @courier.inbox.messages.delete("message_id") + + assert_pattern do + response => nil + end + end + + def test_restore + skip("Mock server tests are disabled") + + response = @courier.inbox.messages.restore("message_id") + + assert_pattern do + response => nil + end + end +end diff --git a/test/courier/resources/inbox_test.rb b/test/courier/resources/inbox_test.rb new file mode 100644 index 00000000..25340ee4 --- /dev/null +++ b/test/courier/resources/inbox_test.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Courier::Test::Resources::InboxTest < Courier::Test::ResourceTest +end