From 122e5984cc48c30473a81fd3003c4fd899fc1cc6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 Jul 2026 20:29:40 +0000 Subject: [PATCH 1/2] feat(broadcasts): document Broadcasts CRUD REST API (#170) Add the Broadcasts tag + 11 operations to specs/openapi.yml (list, create, retrieve, update, archive, duplicate, send, schedule, cancel, retrieve/put content) with Broadcast, BroadcastSchedule, BroadcastListResponse, Create/Update/Send/ScheduleBroadcastRequest schemas (channel enum + full error responses). Add the broadcasts resource to specs/stainless.yml and node/e2e/broadcasts.e2e.test.ts. C-19454 Co-authored-by: Claude Opus 4.8 --- .stats.yml | 8 +- lib/courier.rb | 21 +- lib/courier/client.rb | 4 + lib/courier/models.rb | 36 +++ lib/courier/models/broadcast.rb | 132 ++++++++ .../models/broadcast_archive_params.rb | 20 ++ lib/courier/models/broadcast_cancel_params.rb | 20 ++ lib/courier/models/broadcast_create_params.rb | 14 + .../models/broadcast_duplicate_params.rb | 20 ++ lib/courier/models/broadcast_list_params.rb | 30 ++ lib/courier/models/broadcast_list_response.rb | 24 ++ .../models/broadcast_put_content_params.rb | 20 ++ .../broadcast_retrieve_content_params.rb | 33 ++ .../models/broadcast_retrieve_params.rb | 20 ++ lib/courier/models/broadcast_schedule.rb | 59 ++++ .../models/broadcast_schedule_params.rb | 20 ++ lib/courier/models/broadcast_send_params.rb | 20 ++ lib/courier/models/broadcast_update_params.rb | 20 ++ .../models/create_broadcast_request.rb | 43 +++ .../models/schedule_broadcast_request.rb | 59 ++++ lib/courier/models/send_broadcast_request.rb | 39 +++ .../models/update_broadcast_request.rb | 18 ++ lib/courier/resources/broadcasts.rb | 290 ++++++++++++++++++ rbi/courier/client.rbi | 3 + rbi/courier/models.rbi | 37 +++ rbi/courier/models/broadcast.rbi | 164 ++++++++++ .../models/broadcast_archive_params.rbi | 35 +++ .../models/broadcast_cancel_params.rbi | 35 +++ .../models/broadcast_create_params.rbi | 27 ++ .../models/broadcast_duplicate_params.rbi | 35 +++ rbi/courier/models/broadcast_list_params.rbi | 54 ++++ .../models/broadcast_list_response.rbi | 39 +++ .../models/broadcast_put_content_params.rbi | 35 +++ .../broadcast_retrieve_content_params.rbi | 57 ++++ .../models/broadcast_retrieve_params.rbi | 35 +++ rbi/courier/models/broadcast_schedule.rbi | 92 ++++++ .../models/broadcast_schedule_params.rbi | 35 +++ rbi/courier/models/broadcast_send_params.rbi | 35 +++ .../models/broadcast_update_params.rbi | 35 +++ .../models/create_broadcast_request.rbi | 81 +++++ .../models/schedule_broadcast_request.rbi | 103 +++++++ rbi/courier/models/send_broadcast_request.rbi | 77 +++++ .../models/update_broadcast_request.rbi | 28 ++ rbi/courier/resources/broadcasts.rbi | 199 ++++++++++++ sig/courier/client.rbs | 2 + sig/courier/models.rbs | 36 +++ sig/courier/models/broadcast.rbs | 98 ++++++ .../models/broadcast_archive_params.rbs | 23 ++ .../models/broadcast_cancel_params.rbs | 23 ++ .../models/broadcast_create_params.rbs | 15 + .../models/broadcast_duplicate_params.rbs | 23 ++ sig/courier/models/broadcast_list_params.rbs | 30 ++ .../models/broadcast_list_response.rbs | 22 ++ .../models/broadcast_put_content_params.rbs | 25 ++ .../broadcast_retrieve_content_params.rbs | 30 ++ .../models/broadcast_retrieve_params.rbs | 23 ++ sig/courier/models/broadcast_schedule.rbs | 46 +++ .../models/broadcast_schedule_params.rbs | 25 ++ sig/courier/models/broadcast_send_params.rbs | 25 ++ .../models/broadcast_update_params.rbs | 25 ++ .../models/create_broadcast_request.rbs | 40 +++ .../models/schedule_broadcast_request.rbs | 48 +++ sig/courier/models/send_broadcast_request.rbs | 36 +++ .../models/update_broadcast_request.rbs | 13 + sig/courier/resources/broadcasts.rbs | 74 +++++ test/courier/resources/broadcasts_test.rb | 273 +++++++++++++++++ 66 files changed, 3161 insertions(+), 5 deletions(-) create mode 100644 lib/courier/models/broadcast.rb create mode 100644 lib/courier/models/broadcast_archive_params.rb create mode 100644 lib/courier/models/broadcast_cancel_params.rb create mode 100644 lib/courier/models/broadcast_create_params.rb create mode 100644 lib/courier/models/broadcast_duplicate_params.rb create mode 100644 lib/courier/models/broadcast_list_params.rb create mode 100644 lib/courier/models/broadcast_list_response.rb create mode 100644 lib/courier/models/broadcast_put_content_params.rb create mode 100644 lib/courier/models/broadcast_retrieve_content_params.rb create mode 100644 lib/courier/models/broadcast_retrieve_params.rb create mode 100644 lib/courier/models/broadcast_schedule.rb create mode 100644 lib/courier/models/broadcast_schedule_params.rb create mode 100644 lib/courier/models/broadcast_send_params.rb create mode 100644 lib/courier/models/broadcast_update_params.rb create mode 100644 lib/courier/models/create_broadcast_request.rb create mode 100644 lib/courier/models/schedule_broadcast_request.rb create mode 100644 lib/courier/models/send_broadcast_request.rb create mode 100644 lib/courier/models/update_broadcast_request.rb create mode 100644 lib/courier/resources/broadcasts.rb create mode 100644 rbi/courier/models/broadcast.rbi create mode 100644 rbi/courier/models/broadcast_archive_params.rbi create mode 100644 rbi/courier/models/broadcast_cancel_params.rbi create mode 100644 rbi/courier/models/broadcast_create_params.rbi create mode 100644 rbi/courier/models/broadcast_duplicate_params.rbi create mode 100644 rbi/courier/models/broadcast_list_params.rbi create mode 100644 rbi/courier/models/broadcast_list_response.rbi create mode 100644 rbi/courier/models/broadcast_put_content_params.rbi create mode 100644 rbi/courier/models/broadcast_retrieve_content_params.rbi create mode 100644 rbi/courier/models/broadcast_retrieve_params.rbi create mode 100644 rbi/courier/models/broadcast_schedule.rbi create mode 100644 rbi/courier/models/broadcast_schedule_params.rbi create mode 100644 rbi/courier/models/broadcast_send_params.rbi create mode 100644 rbi/courier/models/broadcast_update_params.rbi create mode 100644 rbi/courier/models/create_broadcast_request.rbi create mode 100644 rbi/courier/models/schedule_broadcast_request.rbi create mode 100644 rbi/courier/models/send_broadcast_request.rbi create mode 100644 rbi/courier/models/update_broadcast_request.rbi create mode 100644 rbi/courier/resources/broadcasts.rbi create mode 100644 sig/courier/models/broadcast.rbs create mode 100644 sig/courier/models/broadcast_archive_params.rbs create mode 100644 sig/courier/models/broadcast_cancel_params.rbs create mode 100644 sig/courier/models/broadcast_create_params.rbs create mode 100644 sig/courier/models/broadcast_duplicate_params.rbs create mode 100644 sig/courier/models/broadcast_list_params.rbs create mode 100644 sig/courier/models/broadcast_list_response.rbs create mode 100644 sig/courier/models/broadcast_put_content_params.rbs create mode 100644 sig/courier/models/broadcast_retrieve_content_params.rbs create mode 100644 sig/courier/models/broadcast_retrieve_params.rbs create mode 100644 sig/courier/models/broadcast_schedule.rbs create mode 100644 sig/courier/models/broadcast_schedule_params.rbs create mode 100644 sig/courier/models/broadcast_send_params.rbs create mode 100644 sig/courier/models/broadcast_update_params.rbs create mode 100644 sig/courier/models/create_broadcast_request.rbs create mode 100644 sig/courier/models/schedule_broadcast_request.rbs create mode 100644 sig/courier/models/send_broadcast_request.rbs create mode 100644 sig/courier/models/update_broadcast_request.rbs create mode 100644 sig/courier/resources/broadcasts.rbs create mode 100644 test/courier/resources/broadcasts_test.rb diff --git a/.stats.yml b/.stats.yml index cf69b295..29ea7c78 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 136 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier/courier-47bd7f89519b4aa68b039b9a03888b689fac9d6ee763d26be0b267bbb0b2ddaa.yml -openapi_spec_hash: 67ff63b23cbfb19beac58d6e471836d3 -config_hash: b30c4b3086cd9f3da06a63b256d8c189 +configured_endpoints: 147 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier/courier-ca32540df5bca42c8113de4004e7751b74bb440e3d73267e7cbad84dd3c3e82a.yml +openapi_spec_hash: 5576c8cf8e5be1f250b5dd1eb6d30571 +config_hash: c6cefb51165221f01d442a42ac4a13b9 diff --git a/lib/courier.rb b/lib/courier.rb index 25a28bc8..66df7490 100644 --- a/lib/courier.rb +++ b/lib/courier.rb @@ -54,6 +54,11 @@ require_relative "courier/client" require_relative "courier/models/elemental_base_node" require_relative "courier/models/brand_template" +require_relative "courier/models/create_broadcast_request" +require_relative "courier/models/notification_content_put_request" +require_relative "courier/models/schedule_broadcast_request" +require_relative "courier/models/send_broadcast_request" +require_relative "courier/models/update_broadcast_request" require_relative "courier/models/base_check" require_relative "courier/models/subscription_topic_new" require_relative "courier/models/elemental_channel_node" @@ -63,7 +68,6 @@ require_relative "courier/models/journey_publish_request" require_relative "courier/models/journey_template_create_request" require_relative "courier/models/journey_template_publish_request" -require_relative "courier/models/notification_content_put_request" require_relative "courier/models/notification_locale_put_request" require_relative "courier/models/journey_template_replace_request" require_relative "courier/models/message_details" @@ -124,6 +128,20 @@ require_relative "courier/models/brand_snippet" require_relative "courier/models/brand_snippets" require_relative "courier/models/brand_update_params" +require_relative "courier/models/broadcast" +require_relative "courier/models/broadcast_archive_params" +require_relative "courier/models/broadcast_cancel_params" +require_relative "courier/models/broadcast_create_params" +require_relative "courier/models/broadcast_duplicate_params" +require_relative "courier/models/broadcast_list_params" +require_relative "courier/models/broadcast_list_response" +require_relative "courier/models/broadcast_put_content_params" +require_relative "courier/models/broadcast_retrieve_content_params" +require_relative "courier/models/broadcast_retrieve_params" +require_relative "courier/models/broadcast_schedule" +require_relative "courier/models/broadcast_schedule_params" +require_relative "courier/models/broadcast_send_params" +require_relative "courier/models/broadcast_update_params" require_relative "courier/models/cancel_journey_response" require_relative "courier/models/channel" require_relative "courier/models/channel_classification" @@ -423,6 +441,7 @@ require_relative "courier/resources/automations" require_relative "courier/resources/automations/invoke" require_relative "courier/resources/brands" +require_relative "courier/resources/broadcasts" require_relative "courier/resources/digests" require_relative "courier/resources/digests/schedules" require_relative "courier/resources/inbound" diff --git a/lib/courier/client.rb b/lib/courier/client.rb index afb10777..3a79db27 100644 --- a/lib/courier/client.rb +++ b/lib/courier/client.rb @@ -53,6 +53,9 @@ class Client < Courier::Internal::Transport::BaseClient # @return [Courier::Resources::Journeys] attr_reader :journeys + # @return [Courier::Resources::Broadcasts] + attr_reader :broadcasts + # Manage the logos, colors, and layout that give the templates you send a # consistent look. # @return [Courier::Resources::Brands] @@ -184,6 +187,7 @@ def initialize( @auth = Courier::Resources::Auth.new(client: self) @automations = Courier::Resources::Automations.new(client: self) @journeys = Courier::Resources::Journeys.new(client: self) + @broadcasts = Courier::Resources::Broadcasts.new(client: self) @brands = Courier::Resources::Brands.new(client: self) @digests = Courier::Resources::Digests.new(client: self) @inbound = Courier::Resources::Inbound.new(client: self) diff --git a/lib/courier/models.rb b/lib/courier/models.rb index a60e69e2..202ff812 100644 --- a/lib/courier/models.rb +++ b/lib/courier/models.rb @@ -113,6 +113,34 @@ module Courier BrandUpdateParams = Courier::Models::BrandUpdateParams + Broadcast = Courier::Models::Broadcast + + BroadcastArchiveParams = Courier::Models::BroadcastArchiveParams + + BroadcastCancelParams = Courier::Models::BroadcastCancelParams + + BroadcastCreateParams = Courier::Models::BroadcastCreateParams + + BroadcastDuplicateParams = Courier::Models::BroadcastDuplicateParams + + BroadcastListParams = Courier::Models::BroadcastListParams + + BroadcastListResponse = Courier::Models::BroadcastListResponse + + BroadcastPutContentParams = Courier::Models::BroadcastPutContentParams + + BroadcastRetrieveContentParams = Courier::Models::BroadcastRetrieveContentParams + + BroadcastRetrieveParams = Courier::Models::BroadcastRetrieveParams + + BroadcastSchedule = Courier::Models::BroadcastSchedule + + BroadcastScheduleParams = Courier::Models::BroadcastScheduleParams + + BroadcastSendParams = Courier::Models::BroadcastSendParams + + BroadcastUpdateParams = Courier::Models::BroadcastUpdateParams + CancelJourneyRequest = Courier::Models::CancelJourneyRequest CancelJourneyResponse = Courier::Models::CancelJourneyResponse @@ -127,6 +155,8 @@ module Courier Check = Courier::Models::Check + CreateBroadcastRequest = Courier::Models::CreateBroadcastRequest + CreateJourneyRequest = Courier::Models::CreateJourneyRequest DefaultPreferences = Courier::Models::DefaultPreferences @@ -474,6 +504,10 @@ module Courier Rule = Courier::Models::Rule + ScheduleBroadcastRequest = Courier::Models::ScheduleBroadcastRequest + + SendBroadcastRequest = Courier::Models::SendBroadcastRequest + SendDirectMessage = Courier::Models::SendDirectMessage SendMessageParams = Courier::Models::SendMessageParams @@ -536,6 +570,8 @@ module Courier TranslationUpdateParams = Courier::Models::TranslationUpdateParams + UpdateBroadcastRequest = Courier::Models::UpdateBroadcastRequest + UserProfile = Courier::Models::UserProfile UserProfileFirebaseToken = Courier::Models::UserProfileFirebaseToken diff --git a/lib/courier/models/broadcast.rb b/lib/courier/models/broadcast.rb new file mode 100644 index 00000000..07ef7b2f --- /dev/null +++ b/lib/courier/models/broadcast.rb @@ -0,0 +1,132 @@ +# frozen_string_literal: true + +module Courier + module Models + # @see Courier::Resources::Broadcasts#create + class Broadcast < Courier::Internal::Type::BaseModel + # @!attribute id + # The broadcast ID (bst\_ prefix). + # + # @return [String] + required :id, String + + # @!attribute channel + # The broadcast's delivery channel. + # + # @return [Symbol, Courier::Models::Broadcast::Channel] + required :channel, enum: -> { Courier::Broadcast::Channel } + + # @!attribute created_at + # ISO 8601 timestamp when the broadcast was created. + # + # @return [String] + required :created_at, String + + # @!attribute created_by + # Actor that created the broadcast. + # + # @return [String] + required :created_by, String + + # @!attribute name + # Human-readable name. + # + # @return [String] + required :name, String + + # @!attribute status + # Lifecycle status of the broadcast. + # + # @return [Symbol, Courier::Models::Broadcast::Status] + required :status, enum: -> { Courier::Broadcast::Status } + + # @!attribute updated_at + # ISO 8601 timestamp of the last update. + # + # @return [String] + required :updated_at, String + + # @!attribute updated_by + # Actor that last updated the broadcast. + # + # @return [String] + required :updated_by, String + + # @!attribute archived_at + # ISO 8601 timestamp when the broadcast was archived, if archived. + # + # @return [String, nil] + optional :archived_at, String, nil?: true + + # @!attribute archived_by + # Actor that archived the broadcast, if archived. + # + # @return [String, nil] + optional :archived_by, String, nil?: true + + # @!attribute schedule + # The delivery schedule and recipient targeting for a broadcast. + # + # @return [Courier::Models::BroadcastSchedule, nil] + optional :schedule, -> { Courier::BroadcastSchedule }, nil?: true + + # @!method initialize(id:, channel:, created_at:, created_by:, name:, status:, updated_at:, updated_by:, archived_at: nil, archived_by: nil, schedule: nil) + # A broadcast — a single-channel message delivered to a known set of recipients (a + # list or audience). + # + # @param id [String] The broadcast ID (bst\_ prefix). + # + # @param channel [Symbol, Courier::Models::Broadcast::Channel] The broadcast's delivery channel. + # + # @param created_at [String] ISO 8601 timestamp when the broadcast was created. + # + # @param created_by [String] Actor that created the broadcast. + # + # @param name [String] Human-readable name. + # + # @param status [Symbol, Courier::Models::Broadcast::Status] Lifecycle status of the broadcast. + # + # @param updated_at [String] ISO 8601 timestamp of the last update. + # + # @param updated_by [String] Actor that last updated the broadcast. + # + # @param archived_at [String, nil] ISO 8601 timestamp when the broadcast was archived, if archived. + # + # @param archived_by [String, nil] Actor that archived the broadcast, if archived. + # + # @param schedule [Courier::Models::BroadcastSchedule, nil] The delivery schedule and recipient targeting for a broadcast. + + # The broadcast's delivery channel. + # + # @see Courier::Models::Broadcast#channel + module Channel + extend Courier::Internal::Type::Enum + + EMAIL = :email + SMS = :sms + PUSH = :push + INBOX = :inbox + SLACK = :slack + MSTEAMS = :msteams + + # @!method self.values + # @return [Array] + end + + # Lifecycle status of the broadcast. + # + # @see Courier::Models::Broadcast#status + module Status + extend Courier::Internal::Type::Enum + + DRAFT = :draft + SCHEDULED = :scheduled + SENDING = :sending + SENT = :sent + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/courier/models/broadcast_archive_params.rb b/lib/courier/models/broadcast_archive_params.rb new file mode 100644 index 00000000..c8a2a8ce --- /dev/null +++ b/lib/courier/models/broadcast_archive_params.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Courier + module Models + # @see Courier::Resources::Broadcasts#archive + class BroadcastArchiveParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + # @!attribute broadcast_id + # + # @return [String] + required :broadcast_id, String + + # @!method initialize(broadcast_id:, request_options: {}) + # @param broadcast_id [String] + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/courier/models/broadcast_cancel_params.rb b/lib/courier/models/broadcast_cancel_params.rb new file mode 100644 index 00000000..9c103868 --- /dev/null +++ b/lib/courier/models/broadcast_cancel_params.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Courier + module Models + # @see Courier::Resources::Broadcasts#cancel + class BroadcastCancelParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + # @!attribute broadcast_id + # + # @return [String] + required :broadcast_id, String + + # @!method initialize(broadcast_id:, request_options: {}) + # @param broadcast_id [String] + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/courier/models/broadcast_create_params.rb b/lib/courier/models/broadcast_create_params.rb new file mode 100644 index 00000000..11294818 --- /dev/null +++ b/lib/courier/models/broadcast_create_params.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Courier + module Models + # @see Courier::Resources::Broadcasts#create + class BroadcastCreateParams < Courier::Models::CreateBroadcastRequest + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/courier/models/broadcast_duplicate_params.rb b/lib/courier/models/broadcast_duplicate_params.rb new file mode 100644 index 00000000..45b3aa87 --- /dev/null +++ b/lib/courier/models/broadcast_duplicate_params.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Courier + module Models + # @see Courier::Resources::Broadcasts#duplicate + class BroadcastDuplicateParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + # @!attribute broadcast_id + # + # @return [String] + required :broadcast_id, String + + # @!method initialize(broadcast_id:, request_options: {}) + # @param broadcast_id [String] + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/courier/models/broadcast_list_params.rb b/lib/courier/models/broadcast_list_params.rb new file mode 100644 index 00000000..0b54274e --- /dev/null +++ b/lib/courier/models/broadcast_list_params.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module Courier + module Models + # @see Courier::Resources::Broadcasts#list + class BroadcastListParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + # @!attribute cursor + # Opaque pagination cursor from a previous response. Omit for the first page. + # + # @return [String, nil] + optional :cursor, String, nil?: true + + # @!attribute limit + # Maximum number of results per page. + # + # @return [Integer, nil] + optional :limit, Integer + + # @!method initialize(cursor: nil, limit: nil, request_options: {}) + # @param cursor [String, nil] Opaque pagination cursor from a previous response. Omit for the first page. + # + # @param limit [Integer] Maximum number of results per page. + # + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/courier/models/broadcast_list_response.rb b/lib/courier/models/broadcast_list_response.rb new file mode 100644 index 00000000..09e7ab62 --- /dev/null +++ b/lib/courier/models/broadcast_list_response.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Courier + module Models + # @see Courier::Resources::Broadcasts#list + class BroadcastListResponse < Courier::Internal::Type::BaseModel + # @!attribute paging + # + # @return [Courier::Models::Paging] + required :paging, -> { Courier::Paging } + + # @!attribute results + # + # @return [Array] + required :results, -> { Courier::Internal::Type::ArrayOf[Courier::Broadcast] } + + # @!method initialize(paging:, results:) + # Paginated list of broadcasts. + # + # @param paging [Courier::Models::Paging] + # @param results [Array] + end + end +end diff --git a/lib/courier/models/broadcast_put_content_params.rb b/lib/courier/models/broadcast_put_content_params.rb new file mode 100644 index 00000000..50e17f60 --- /dev/null +++ b/lib/courier/models/broadcast_put_content_params.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Courier + module Models + # @see Courier::Resources::Broadcasts#put_content + class BroadcastPutContentParams < Courier::Models::NotificationContentPutRequest + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + # @!attribute broadcast_id + # + # @return [String] + required :broadcast_id, String + + # @!method initialize(broadcast_id:, request_options: {}) + # @param broadcast_id [String] + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/courier/models/broadcast_retrieve_content_params.rb b/lib/courier/models/broadcast_retrieve_content_params.rb new file mode 100644 index 00000000..d19e1195 --- /dev/null +++ b/lib/courier/models/broadcast_retrieve_content_params.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Courier + module Models + # @see Courier::Resources::Broadcasts#retrieve_content + class BroadcastRetrieveContentParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + # @!attribute broadcast_id + # + # @return [String] + required :broadcast_id, String + + # @!attribute version + # Accepts `draft`, `published`, or a version string (e.g. `v001`). Defaults to + # `draft`. + # + # @return [String, nil] + optional :version, String + + # @!method initialize(broadcast_id:, version: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Courier::Models::BroadcastRetrieveContentParams} for more details. + # + # @param broadcast_id [String] + # + # @param version [String] Accepts `draft`, `published`, or a version string (e.g. `v001`). Defaults to `dr + # + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/courier/models/broadcast_retrieve_params.rb b/lib/courier/models/broadcast_retrieve_params.rb new file mode 100644 index 00000000..4437b787 --- /dev/null +++ b/lib/courier/models/broadcast_retrieve_params.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Courier + module Models + # @see Courier::Resources::Broadcasts#retrieve + class BroadcastRetrieveParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + # @!attribute broadcast_id + # + # @return [String] + required :broadcast_id, String + + # @!method initialize(broadcast_id:, request_options: {}) + # @param broadcast_id [String] + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/courier/models/broadcast_schedule.rb b/lib/courier/models/broadcast_schedule.rb new file mode 100644 index 00000000..98106901 --- /dev/null +++ b/lib/courier/models/broadcast_schedule.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +module Courier + module Models + class BroadcastSchedule < Courier::Internal::Type::BaseModel + # @!attribute recipient_id + # ID of the target list or audience. + # + # @return [String] + required :recipient_id, String + + # @!attribute recipient_type + # Whether the broadcast targets a list or an audience. + # + # @return [Symbol, Courier::Models::BroadcastSchedule::RecipientType] + required :recipient_type, enum: -> { Courier::BroadcastSchedule::RecipientType } + + # @!attribute scheduled_to + # Wall-clock timestamp of the scheduled send, no timezone offset (e.g. + # "2026-07-21T20:00:00"). + # + # @return [String, nil] + optional :scheduled_to, String, nil?: true + + # @!attribute timezone + # IANA timezone for the scheduled send (e.g. America/New_York). + # + # @return [String, nil] + optional :timezone, String, nil?: true + + # @!method initialize(recipient_id:, recipient_type:, scheduled_to: nil, timezone: nil) + # Some parameter documentations has been truncated, see + # {Courier::Models::BroadcastSchedule} for more details. + # + # The delivery schedule and recipient targeting for a broadcast. + # + # @param recipient_id [String] ID of the target list or audience. + # + # @param recipient_type [Symbol, Courier::Models::BroadcastSchedule::RecipientType] Whether the broadcast targets a list or an audience. + # + # @param scheduled_to [String, nil] Wall-clock timestamp of the scheduled send, no timezone offset (e.g. "2026-07-21 + # + # @param timezone [String, nil] IANA timezone for the scheduled send (e.g. America/New_York). + + # Whether the broadcast targets a list or an audience. + # + # @see Courier::Models::BroadcastSchedule#recipient_type + module RecipientType + extend Courier::Internal::Type::Enum + + LIST = :list + AUDIENCE = :audience + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/courier/models/broadcast_schedule_params.rb b/lib/courier/models/broadcast_schedule_params.rb new file mode 100644 index 00000000..01789235 --- /dev/null +++ b/lib/courier/models/broadcast_schedule_params.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Courier + module Models + # @see Courier::Resources::Broadcasts#schedule + class BroadcastScheduleParams < Courier::Models::ScheduleBroadcastRequest + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + # @!attribute broadcast_id + # + # @return [String] + required :broadcast_id, String + + # @!method initialize(broadcast_id:, request_options: {}) + # @param broadcast_id [String] + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/courier/models/broadcast_send_params.rb b/lib/courier/models/broadcast_send_params.rb new file mode 100644 index 00000000..a8239612 --- /dev/null +++ b/lib/courier/models/broadcast_send_params.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Courier + module Models + # @see Courier::Resources::Broadcasts#send_ + class BroadcastSendParams < Courier::Models::SendBroadcastRequest + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + # @!attribute broadcast_id + # + # @return [String] + required :broadcast_id, String + + # @!method initialize(broadcast_id:, request_options: {}) + # @param broadcast_id [String] + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/courier/models/broadcast_update_params.rb b/lib/courier/models/broadcast_update_params.rb new file mode 100644 index 00000000..7b40d374 --- /dev/null +++ b/lib/courier/models/broadcast_update_params.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Courier + module Models + # @see Courier::Resources::Broadcasts#update + class BroadcastUpdateParams < Courier::Models::UpdateBroadcastRequest + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + # @!attribute broadcast_id + # + # @return [String] + required :broadcast_id, String + + # @!method initialize(broadcast_id:, request_options: {}) + # @param broadcast_id [String] + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/courier/models/create_broadcast_request.rb b/lib/courier/models/create_broadcast_request.rb new file mode 100644 index 00000000..3210ecf8 --- /dev/null +++ b/lib/courier/models/create_broadcast_request.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module Courier + module Models + class CreateBroadcastRequest < Courier::Internal::Type::BaseModel + # @!attribute channel + # The single delivery channel for this broadcast. + # + # @return [Symbol, Courier::Models::CreateBroadcastRequest::Channel] + required :channel, enum: -> { Courier::CreateBroadcastRequest::Channel } + + # @!attribute name + # Human-readable name. + # + # @return [String] + required :name, String + + # @!method initialize(channel:, name:) + # Request body for creating a broadcast. + # + # @param channel [Symbol, Courier::Models::CreateBroadcastRequest::Channel] The single delivery channel for this broadcast. + # + # @param name [String] Human-readable name. + + # The single delivery channel for this broadcast. + # + # @see Courier::Models::CreateBroadcastRequest#channel + module Channel + extend Courier::Internal::Type::Enum + + EMAIL = :email + SMS = :sms + PUSH = :push + INBOX = :inbox + SLACK = :slack + MSTEAMS = :msteams + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/courier/models/schedule_broadcast_request.rb b/lib/courier/models/schedule_broadcast_request.rb new file mode 100644 index 00000000..6ef918f1 --- /dev/null +++ b/lib/courier/models/schedule_broadcast_request.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +module Courier + module Models + class ScheduleBroadcastRequest < Courier::Internal::Type::BaseModel + # @!attribute recipient_id + # ID of the target list or audience. + # + # @return [String] + required :recipient_id, String + + # @!attribute recipient_type + # Whether the broadcast targets a list or an audience. + # + # @return [Symbol, Courier::Models::ScheduleBroadcastRequest::RecipientType] + required :recipient_type, enum: -> { Courier::ScheduleBroadcastRequest::RecipientType } + + # @!attribute scheduled_to + # Wall-clock timestamp of the future send, no timezone offset (e.g. + # "2026-07-21T20:00:00"). The zone is given by `timezone`. + # + # @return [String] + required :scheduled_to, String + + # @!attribute timezone + # IANA timezone for the scheduled send (e.g. America/New_York). + # + # @return [String, nil] + optional :timezone, String + + # @!method initialize(recipient_id:, recipient_type:, scheduled_to:, timezone: nil) + # Some parameter documentations has been truncated, see + # {Courier::Models::ScheduleBroadcastRequest} for more details. + # + # Request body for scheduling a broadcast for a future send. + # + # @param recipient_id [String] ID of the target list or audience. + # + # @param recipient_type [Symbol, Courier::Models::ScheduleBroadcastRequest::RecipientType] Whether the broadcast targets a list or an audience. + # + # @param scheduled_to [String] Wall-clock timestamp of the future send, no timezone offset (e.g. "2026-07-21T20 + # + # @param timezone [String] IANA timezone for the scheduled send (e.g. America/New_York). + + # Whether the broadcast targets a list or an audience. + # + # @see Courier::Models::ScheduleBroadcastRequest#recipient_type + module RecipientType + extend Courier::Internal::Type::Enum + + LIST = :list + AUDIENCE = :audience + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/courier/models/send_broadcast_request.rb b/lib/courier/models/send_broadcast_request.rb new file mode 100644 index 00000000..caa606ab --- /dev/null +++ b/lib/courier/models/send_broadcast_request.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +module Courier + module Models + class SendBroadcastRequest < Courier::Internal::Type::BaseModel + # @!attribute recipient_id + # ID of the target list or audience. + # + # @return [String] + required :recipient_id, String + + # @!attribute recipient_type + # Whether the broadcast targets a list or an audience. + # + # @return [Symbol, Courier::Models::SendBroadcastRequest::RecipientType] + required :recipient_type, enum: -> { Courier::SendBroadcastRequest::RecipientType } + + # @!method initialize(recipient_id:, recipient_type:) + # Request body for sending a broadcast immediately. + # + # @param recipient_id [String] ID of the target list or audience. + # + # @param recipient_type [Symbol, Courier::Models::SendBroadcastRequest::RecipientType] Whether the broadcast targets a list or an audience. + + # Whether the broadcast targets a list or an audience. + # + # @see Courier::Models::SendBroadcastRequest#recipient_type + module RecipientType + extend Courier::Internal::Type::Enum + + LIST = :list + AUDIENCE = :audience + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/courier/models/update_broadcast_request.rb b/lib/courier/models/update_broadcast_request.rb new file mode 100644 index 00000000..f468d409 --- /dev/null +++ b/lib/courier/models/update_broadcast_request.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Courier + module Models + class UpdateBroadcastRequest < Courier::Internal::Type::BaseModel + # @!attribute name + # New human-readable name. + # + # @return [String] + required :name, String + + # @!method initialize(name:) + # Request body for updating a broadcast. Only the name is mutable. + # + # @param name [String] New human-readable name. + end + end +end diff --git a/lib/courier/resources/broadcasts.rb b/lib/courier/resources/broadcasts.rb new file mode 100644 index 00000000..dec6acef --- /dev/null +++ b/lib/courier/resources/broadcasts.rb @@ -0,0 +1,290 @@ +# frozen_string_literal: true + +module Courier + module Resources + class Broadcasts + # Create a broadcast. Provisions a private notification template for the broadcast + # and returns the new broadcast in the draft state. Exactly one channel is + # required. + # + # @overload create(channel:, name:, request_options: {}) + # + # @param channel [Symbol, Courier::Models::CreateBroadcastRequest::Channel] The single delivery channel for this broadcast. + # + # @param name [String] Human-readable name. + # + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Courier::Models::Broadcast] + # + # @see Courier::Models::BroadcastCreateParams + def create(params) + parsed, options = Courier::BroadcastCreateParams.dump_request(params) + @client.request( + method: :post, + path: "broadcasts", + body: parsed, + model: Courier::Broadcast, + options: options + ) + end + + # Retrieve a broadcast by ID. Archived broadcasts return 404. + # + # @overload retrieve(broadcast_id, request_options: {}) + # + # @param broadcast_id [String] + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Courier::Models::Broadcast] + # + # @see Courier::Models::BroadcastRetrieveParams + def retrieve(broadcast_id, params = {}) + @client.request( + method: :get, + path: ["broadcasts/%1$s", broadcast_id], + model: Courier::Broadcast, + options: params[:request_options] + ) + end + + # Update a broadcast's name. Content is edited via the broadcast's notification + # template, not this endpoint. + # + # @overload update(broadcast_id, name:, request_options: {}) + # + # @param broadcast_id [String] + # + # @param name [String] New human-readable name. + # + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Courier::Models::Broadcast] + # + # @see Courier::Models::BroadcastUpdateParams + def update(broadcast_id, params) + parsed, options = Courier::BroadcastUpdateParams.dump_request(params) + @client.request( + method: :put, + path: ["broadcasts/%1$s", broadcast_id], + body: parsed, + model: Courier::Broadcast, + options: options + ) + end + + # List broadcasts in your workspace. Cursor-paginated; returns broadcasts + # newest-first. + # + # @overload list(cursor: nil, limit: nil, request_options: {}) + # + # @param cursor [String, nil] Opaque pagination cursor from a previous response. Omit for the first page. + # + # @param limit [Integer] Maximum number of results per page. + # + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Courier::Models::BroadcastListResponse] + # + # @see Courier::Models::BroadcastListParams + def list(params = {}) + parsed, options = Courier::BroadcastListParams.dump_request(params) + query = Courier::Internal::Util.encode_query_params(parsed) + @client.request( + method: :get, + path: "broadcasts", + query: query, + model: Courier::BroadcastListResponse, + options: options + ) + end + + # Archive a broadcast. This is a soft delete — the archived broadcast is returned + # and no longer appears in list results. + # + # @overload archive(broadcast_id, request_options: {}) + # + # @param broadcast_id [String] + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Courier::Models::Broadcast] + # + # @see Courier::Models::BroadcastArchiveParams + def archive(broadcast_id, params = {}) + @client.request( + method: :delete, + path: ["broadcasts/%1$s", broadcast_id], + model: Courier::Broadcast, + options: params[:request_options] + ) + end + + # Cancel a broadcast's pending schedule, returning it to the draft state. Only + # valid for a scheduled broadcast. + # + # @overload cancel(broadcast_id, request_options: {}) + # + # @param broadcast_id [String] + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Courier::Models::Broadcast] + # + # @see Courier::Models::BroadcastCancelParams + def cancel(broadcast_id, params = {}) + @client.request( + method: :post, + path: ["broadcasts/%1$s/cancel", broadcast_id], + model: Courier::Broadcast, + options: params[:request_options] + ) + end + + # Duplicate a broadcast (and its template) into a new draft named "{source name} + # (copy)". + # + # @overload duplicate(broadcast_id, request_options: {}) + # + # @param broadcast_id [String] + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Courier::Models::Broadcast] + # + # @see Courier::Models::BroadcastDuplicateParams + def duplicate(broadcast_id, params = {}) + @client.request( + method: :post, + path: ["broadcasts/%1$s/duplicate", broadcast_id], + model: Courier::Broadcast, + options: params[:request_options] + ) + end + + # Author the broadcast's content by replacing the draft elemental content of its + # private notification template. The draft is published automatically when the + # broadcast is sent or scheduled. + # + # @overload put_content(broadcast_id, content:, state: nil, request_options: {}) + # + # @param broadcast_id [String] + # + # @param content [Courier::Models::NotificationContentPutRequest::Content] Elemental content payload. The server defaults `version` when omitted. + # + # @param state [Symbol, Courier::Models::NotificationTemplateState] Template state. Defaults to `DRAFT`. + # + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Courier::Models::NotificationContentMutationResponse] + # + # @see Courier::Models::BroadcastPutContentParams + def put_content(broadcast_id, params) + parsed, options = Courier::BroadcastPutContentParams.dump_request(params) + @client.request( + method: :put, + path: ["broadcasts/%1$s/content", broadcast_id], + body: parsed, + model: Courier::NotificationContentMutationResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Courier::Models::BroadcastRetrieveContentParams} for more details. + # + # Retrieve the broadcast's content — the elemental content of its private + # notification template. Defaults to the working draft, since broadcast content is + # authored as a draft until the broadcast is sent. + # + # @overload retrieve_content(broadcast_id, version: nil, request_options: {}) + # + # @param broadcast_id [String] + # + # @param version [String] Accepts `draft`, `published`, or a version string (e.g. `v001`). Defaults to `dr + # + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Courier::Models::NotificationContentGetResponse] + # + # @see Courier::Models::BroadcastRetrieveContentParams + def retrieve_content(broadcast_id, params = {}) + parsed, options = Courier::BroadcastRetrieveContentParams.dump_request(params) + query = Courier::Internal::Util.encode_query_params(parsed) + @client.request( + method: :get, + path: ["broadcasts/%1$s/content", broadcast_id], + query: query, + model: Courier::NotificationContentGetResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Courier::Models::BroadcastScheduleParams} for more details. + # + # Schedule a broadcast for a future send to a list or audience. Publishes the + # broadcast template first. Not allowed once the broadcast is sending or sent. For + # an immediate send use POST /broadcasts/{broadcastId}/send. + # + # @overload schedule(broadcast_id, recipient_id:, recipient_type:, scheduled_to:, timezone: nil, request_options: {}) + # + # @param broadcast_id [String] + # + # @param recipient_id [String] ID of the target list or audience. + # + # @param recipient_type [Symbol, Courier::Models::ScheduleBroadcastRequest::RecipientType] Whether the broadcast targets a list or an audience. + # + # @param scheduled_to [String] Wall-clock timestamp of the future send, no timezone offset (e.g. "2026-07-21T20 + # + # @param timezone [String] IANA timezone for the scheduled send (e.g. America/New_York). + # + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Courier::Models::Broadcast] + # + # @see Courier::Models::BroadcastScheduleParams + def schedule(broadcast_id, params) + parsed, options = Courier::BroadcastScheduleParams.dump_request(params) + @client.request( + method: :post, + path: ["broadcasts/%1$s/schedule", broadcast_id], + body: parsed, + model: Courier::Broadcast, + options: options + ) + end + + # Send a broadcast immediately to a list or audience. Publishes the broadcast + # template first. Not allowed once the broadcast is sending or sent. + # + # @overload send_(broadcast_id, recipient_id:, recipient_type:, request_options: {}) + # + # @param broadcast_id [String] + # + # @param recipient_id [String] ID of the target list or audience. + # + # @param recipient_type [Symbol, Courier::Models::SendBroadcastRequest::RecipientType] Whether the broadcast targets a list or an audience. + # + # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Courier::Models::Broadcast] + # + # @see Courier::Models::BroadcastSendParams + def send_(broadcast_id, params) + parsed, options = Courier::BroadcastSendParams.dump_request(params) + @client.request( + method: :post, + path: ["broadcasts/%1$s/send", broadcast_id], + body: parsed, + model: Courier::Broadcast, + options: options + ) + end + + # @api private + # + # @param client [Courier::Client] + def initialize(client:) + @client = client + end + end + end +end diff --git a/rbi/courier/client.rbi b/rbi/courier/client.rbi index 993596ed..53848d0c 100644 --- a/rbi/courier/client.rbi +++ b/rbi/courier/client.rbi @@ -48,6 +48,9 @@ module Courier sig { returns(Courier::Resources::Journeys) } attr_reader :journeys + sig { returns(Courier::Resources::Broadcasts) } + attr_reader :broadcasts + # Manage the logos, colors, and layout that give the templates you send a # consistent look. sig { returns(Courier::Resources::Brands) } diff --git a/rbi/courier/models.rbi b/rbi/courier/models.rbi index f94f9f27..b181d858 100644 --- a/rbi/courier/models.rbi +++ b/rbi/courier/models.rbi @@ -77,6 +77,35 @@ module Courier BrandUpdateParams = Courier::Models::BrandUpdateParams + Broadcast = Courier::Models::Broadcast + + BroadcastArchiveParams = Courier::Models::BroadcastArchiveParams + + BroadcastCancelParams = Courier::Models::BroadcastCancelParams + + BroadcastCreateParams = Courier::Models::BroadcastCreateParams + + BroadcastDuplicateParams = Courier::Models::BroadcastDuplicateParams + + BroadcastListParams = Courier::Models::BroadcastListParams + + BroadcastListResponse = Courier::Models::BroadcastListResponse + + BroadcastPutContentParams = Courier::Models::BroadcastPutContentParams + + BroadcastRetrieveContentParams = + Courier::Models::BroadcastRetrieveContentParams + + BroadcastRetrieveParams = Courier::Models::BroadcastRetrieveParams + + BroadcastSchedule = Courier::Models::BroadcastSchedule + + BroadcastScheduleParams = Courier::Models::BroadcastScheduleParams + + BroadcastSendParams = Courier::Models::BroadcastSendParams + + BroadcastUpdateParams = Courier::Models::BroadcastUpdateParams + CancelJourneyRequest = Courier::Models::CancelJourneyRequest CancelJourneyResponse = Courier::Models::CancelJourneyResponse @@ -91,6 +120,8 @@ module Courier Check = Courier::Models::Check + CreateBroadcastRequest = Courier::Models::CreateBroadcastRequest + CreateJourneyRequest = Courier::Models::CreateJourneyRequest DefaultPreferences = Courier::Models::DefaultPreferences @@ -452,6 +483,10 @@ module Courier Rule = Courier::Models::Rule + ScheduleBroadcastRequest = Courier::Models::ScheduleBroadcastRequest + + SendBroadcastRequest = Courier::Models::SendBroadcastRequest + SendDirectMessage = Courier::Models::SendDirectMessage SendMessageParams = Courier::Models::SendMessageParams @@ -514,6 +549,8 @@ module Courier TranslationUpdateParams = Courier::Models::TranslationUpdateParams + UpdateBroadcastRequest = Courier::Models::UpdateBroadcastRequest + UserProfile = Courier::Models::UserProfile UserProfileFirebaseToken = Courier::Models::UserProfileFirebaseToken diff --git a/rbi/courier/models/broadcast.rbi b/rbi/courier/models/broadcast.rbi new file mode 100644 index 00000000..160d0878 --- /dev/null +++ b/rbi/courier/models/broadcast.rbi @@ -0,0 +1,164 @@ +# typed: strong + +module Courier + module Models + class Broadcast < Courier::Internal::Type::BaseModel + OrHash = + T.type_alias { T.any(Courier::Broadcast, Courier::Internal::AnyHash) } + + # The broadcast ID (bst\_ prefix). + sig { returns(String) } + attr_accessor :id + + # The broadcast's delivery channel. + sig { returns(Courier::Broadcast::Channel::TaggedSymbol) } + attr_accessor :channel + + # ISO 8601 timestamp when the broadcast was created. + sig { returns(String) } + attr_accessor :created_at + + # Actor that created the broadcast. + sig { returns(String) } + attr_accessor :created_by + + # Human-readable name. + sig { returns(String) } + attr_accessor :name + + # Lifecycle status of the broadcast. + sig { returns(Courier::Broadcast::Status::TaggedSymbol) } + attr_accessor :status + + # ISO 8601 timestamp of the last update. + sig { returns(String) } + attr_accessor :updated_at + + # Actor that last updated the broadcast. + sig { returns(String) } + attr_accessor :updated_by + + # ISO 8601 timestamp when the broadcast was archived, if archived. + sig { returns(T.nilable(String)) } + attr_accessor :archived_at + + # Actor that archived the broadcast, if archived. + sig { returns(T.nilable(String)) } + attr_accessor :archived_by + + # The delivery schedule and recipient targeting for a broadcast. + sig { returns(T.nilable(Courier::BroadcastSchedule)) } + attr_reader :schedule + + sig do + params(schedule: T.nilable(Courier::BroadcastSchedule::OrHash)).void + end + attr_writer :schedule + + # A broadcast — a single-channel message delivered to a known set of recipients (a + # list or audience). + sig do + params( + id: String, + channel: Courier::Broadcast::Channel::OrSymbol, + created_at: String, + created_by: String, + name: String, + status: Courier::Broadcast::Status::OrSymbol, + updated_at: String, + updated_by: String, + archived_at: T.nilable(String), + archived_by: T.nilable(String), + schedule: T.nilable(Courier::BroadcastSchedule::OrHash) + ).returns(T.attached_class) + end + def self.new( + # The broadcast ID (bst\_ prefix). + id:, + # The broadcast's delivery channel. + channel:, + # ISO 8601 timestamp when the broadcast was created. + created_at:, + # Actor that created the broadcast. + created_by:, + # Human-readable name. + name:, + # Lifecycle status of the broadcast. + status:, + # ISO 8601 timestamp of the last update. + updated_at:, + # Actor that last updated the broadcast. + updated_by:, + # ISO 8601 timestamp when the broadcast was archived, if archived. + archived_at: nil, + # Actor that archived the broadcast, if archived. + archived_by: nil, + # The delivery schedule and recipient targeting for a broadcast. + schedule: nil + ) + end + + sig do + override.returns( + { + id: String, + channel: Courier::Broadcast::Channel::TaggedSymbol, + created_at: String, + created_by: String, + name: String, + status: Courier::Broadcast::Status::TaggedSymbol, + updated_at: String, + updated_by: String, + archived_at: T.nilable(String), + archived_by: T.nilable(String), + schedule: T.nilable(Courier::BroadcastSchedule) + } + ) + end + def to_hash + end + + # The broadcast's delivery channel. + module Channel + extend Courier::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Courier::Broadcast::Channel) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + EMAIL = T.let(:email, Courier::Broadcast::Channel::TaggedSymbol) + SMS = T.let(:sms, Courier::Broadcast::Channel::TaggedSymbol) + PUSH = T.let(:push, Courier::Broadcast::Channel::TaggedSymbol) + INBOX = T.let(:inbox, Courier::Broadcast::Channel::TaggedSymbol) + SLACK = T.let(:slack, Courier::Broadcast::Channel::TaggedSymbol) + MSTEAMS = T.let(:msteams, Courier::Broadcast::Channel::TaggedSymbol) + + sig do + override.returns(T::Array[Courier::Broadcast::Channel::TaggedSymbol]) + end + def self.values + end + end + + # Lifecycle status of the broadcast. + module Status + extend Courier::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Courier::Broadcast::Status) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + DRAFT = T.let(:draft, Courier::Broadcast::Status::TaggedSymbol) + SCHEDULED = T.let(:scheduled, Courier::Broadcast::Status::TaggedSymbol) + SENDING = T.let(:sending, Courier::Broadcast::Status::TaggedSymbol) + SENT = T.let(:sent, Courier::Broadcast::Status::TaggedSymbol) + + sig do + override.returns(T::Array[Courier::Broadcast::Status::TaggedSymbol]) + end + def self.values + end + end + end + end +end diff --git a/rbi/courier/models/broadcast_archive_params.rbi b/rbi/courier/models/broadcast_archive_params.rbi new file mode 100644 index 00000000..cbe157ec --- /dev/null +++ b/rbi/courier/models/broadcast_archive_params.rbi @@ -0,0 +1,35 @@ +# typed: strong + +module Courier + module Models + class BroadcastArchiveParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Courier::BroadcastArchiveParams, Courier::Internal::AnyHash) + end + + sig { returns(String) } + attr_accessor :broadcast_id + + sig do + params( + broadcast_id: String, + request_options: Courier::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(broadcast_id:, request_options: {}) + end + + sig do + override.returns( + { broadcast_id: String, request_options: Courier::RequestOptions } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/courier/models/broadcast_cancel_params.rbi b/rbi/courier/models/broadcast_cancel_params.rbi new file mode 100644 index 00000000..85d78642 --- /dev/null +++ b/rbi/courier/models/broadcast_cancel_params.rbi @@ -0,0 +1,35 @@ +# typed: strong + +module Courier + module Models + class BroadcastCancelParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Courier::BroadcastCancelParams, Courier::Internal::AnyHash) + end + + sig { returns(String) } + attr_accessor :broadcast_id + + sig do + params( + broadcast_id: String, + request_options: Courier::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(broadcast_id:, request_options: {}) + end + + sig do + override.returns( + { broadcast_id: String, request_options: Courier::RequestOptions } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/courier/models/broadcast_create_params.rbi b/rbi/courier/models/broadcast_create_params.rbi new file mode 100644 index 00000000..2486a63e --- /dev/null +++ b/rbi/courier/models/broadcast_create_params.rbi @@ -0,0 +1,27 @@ +# typed: strong + +module Courier + module Models + class BroadcastCreateParams < Courier::Models::CreateBroadcastRequest + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Courier::BroadcastCreateParams, Courier::Internal::AnyHash) + end + + sig do + params(request_options: Courier::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Courier::RequestOptions }) } + def to_hash + end + end + end +end diff --git a/rbi/courier/models/broadcast_duplicate_params.rbi b/rbi/courier/models/broadcast_duplicate_params.rbi new file mode 100644 index 00000000..48f8b2b9 --- /dev/null +++ b/rbi/courier/models/broadcast_duplicate_params.rbi @@ -0,0 +1,35 @@ +# typed: strong + +module Courier + module Models + class BroadcastDuplicateParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Courier::BroadcastDuplicateParams, Courier::Internal::AnyHash) + end + + sig { returns(String) } + attr_accessor :broadcast_id + + sig do + params( + broadcast_id: String, + request_options: Courier::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(broadcast_id:, request_options: {}) + end + + sig do + override.returns( + { broadcast_id: String, request_options: Courier::RequestOptions } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/courier/models/broadcast_list_params.rbi b/rbi/courier/models/broadcast_list_params.rbi new file mode 100644 index 00000000..ed2ffa4c --- /dev/null +++ b/rbi/courier/models/broadcast_list_params.rbi @@ -0,0 +1,54 @@ +# typed: strong + +module Courier + module Models + class BroadcastListParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Courier::BroadcastListParams, Courier::Internal::AnyHash) + end + + # Opaque pagination cursor from a previous response. Omit for the first page. + sig { returns(T.nilable(String)) } + attr_accessor :cursor + + # Maximum number of results per page. + sig { returns(T.nilable(Integer)) } + attr_reader :limit + + sig { params(limit: Integer).void } + attr_writer :limit + + sig do + params( + cursor: T.nilable(String), + limit: Integer, + request_options: Courier::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Opaque pagination cursor from a previous response. Omit for the first page. + cursor: nil, + # Maximum number of results per page. + limit: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + cursor: T.nilable(String), + limit: Integer, + request_options: Courier::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/courier/models/broadcast_list_response.rbi b/rbi/courier/models/broadcast_list_response.rbi new file mode 100644 index 00000000..e4a5f3b2 --- /dev/null +++ b/rbi/courier/models/broadcast_list_response.rbi @@ -0,0 +1,39 @@ +# typed: strong + +module Courier + module Models + class BroadcastListResponse < Courier::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Courier::BroadcastListResponse, Courier::Internal::AnyHash) + end + + sig { returns(Courier::Paging) } + attr_reader :paging + + sig { params(paging: Courier::Paging::OrHash).void } + attr_writer :paging + + sig { returns(T::Array[Courier::Broadcast]) } + attr_accessor :results + + # Paginated list of broadcasts. + sig do + params( + paging: Courier::Paging::OrHash, + results: T::Array[Courier::Broadcast::OrHash] + ).returns(T.attached_class) + end + def self.new(paging:, results:) + end + + sig do + override.returns( + { paging: Courier::Paging, results: T::Array[Courier::Broadcast] } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/courier/models/broadcast_put_content_params.rbi b/rbi/courier/models/broadcast_put_content_params.rbi new file mode 100644 index 00000000..906c3a2c --- /dev/null +++ b/rbi/courier/models/broadcast_put_content_params.rbi @@ -0,0 +1,35 @@ +# typed: strong + +module Courier + module Models + class BroadcastPutContentParams < Courier::Models::NotificationContentPutRequest + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Courier::BroadcastPutContentParams, Courier::Internal::AnyHash) + end + + sig { returns(String) } + attr_accessor :broadcast_id + + sig do + params( + broadcast_id: String, + request_options: Courier::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(broadcast_id:, request_options: {}) + end + + sig do + override.returns( + { broadcast_id: String, request_options: Courier::RequestOptions } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/courier/models/broadcast_retrieve_content_params.rbi b/rbi/courier/models/broadcast_retrieve_content_params.rbi new file mode 100644 index 00000000..0a29a1a2 --- /dev/null +++ b/rbi/courier/models/broadcast_retrieve_content_params.rbi @@ -0,0 +1,57 @@ +# typed: strong + +module Courier + module Models + class BroadcastRetrieveContentParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Courier::BroadcastRetrieveContentParams, + Courier::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :broadcast_id + + # Accepts `draft`, `published`, or a version string (e.g. `v001`). Defaults to + # `draft`. + sig { returns(T.nilable(String)) } + attr_reader :version + + sig { params(version: String).void } + attr_writer :version + + sig do + params( + broadcast_id: String, + version: String, + request_options: Courier::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + broadcast_id:, + # Accepts `draft`, `published`, or a version string (e.g. `v001`). Defaults to + # `draft`. + version: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + broadcast_id: String, + version: String, + request_options: Courier::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/courier/models/broadcast_retrieve_params.rbi b/rbi/courier/models/broadcast_retrieve_params.rbi new file mode 100644 index 00000000..4a6194f3 --- /dev/null +++ b/rbi/courier/models/broadcast_retrieve_params.rbi @@ -0,0 +1,35 @@ +# typed: strong + +module Courier + module Models + class BroadcastRetrieveParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Courier::BroadcastRetrieveParams, Courier::Internal::AnyHash) + end + + sig { returns(String) } + attr_accessor :broadcast_id + + sig do + params( + broadcast_id: String, + request_options: Courier::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(broadcast_id:, request_options: {}) + end + + sig do + override.returns( + { broadcast_id: String, request_options: Courier::RequestOptions } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/courier/models/broadcast_schedule.rbi b/rbi/courier/models/broadcast_schedule.rbi new file mode 100644 index 00000000..5eb14eb3 --- /dev/null +++ b/rbi/courier/models/broadcast_schedule.rbi @@ -0,0 +1,92 @@ +# typed: strong + +module Courier + module Models + class BroadcastSchedule < Courier::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Courier::BroadcastSchedule, Courier::Internal::AnyHash) + end + + # ID of the target list or audience. + sig { returns(String) } + attr_accessor :recipient_id + + # Whether the broadcast targets a list or an audience. + sig { returns(Courier::BroadcastSchedule::RecipientType::TaggedSymbol) } + attr_accessor :recipient_type + + # Wall-clock timestamp of the scheduled send, no timezone offset (e.g. + # "2026-07-21T20:00:00"). + sig { returns(T.nilable(String)) } + attr_accessor :scheduled_to + + # IANA timezone for the scheduled send (e.g. America/New_York). + sig { returns(T.nilable(String)) } + attr_accessor :timezone + + # The delivery schedule and recipient targeting for a broadcast. + sig do + params( + recipient_id: String, + recipient_type: Courier::BroadcastSchedule::RecipientType::OrSymbol, + scheduled_to: T.nilable(String), + timezone: T.nilable(String) + ).returns(T.attached_class) + end + def self.new( + # ID of the target list or audience. + recipient_id:, + # Whether the broadcast targets a list or an audience. + recipient_type:, + # Wall-clock timestamp of the scheduled send, no timezone offset (e.g. + # "2026-07-21T20:00:00"). + scheduled_to: nil, + # IANA timezone for the scheduled send (e.g. America/New_York). + timezone: nil + ) + end + + sig do + override.returns( + { + recipient_id: String, + recipient_type: + Courier::BroadcastSchedule::RecipientType::TaggedSymbol, + scheduled_to: T.nilable(String), + timezone: T.nilable(String) + } + ) + end + def to_hash + end + + # Whether the broadcast targets a list or an audience. + module RecipientType + extend Courier::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Courier::BroadcastSchedule::RecipientType) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + LIST = + T.let(:list, Courier::BroadcastSchedule::RecipientType::TaggedSymbol) + AUDIENCE = + T.let( + :audience, + Courier::BroadcastSchedule::RecipientType::TaggedSymbol + ) + + sig do + override.returns( + T::Array[Courier::BroadcastSchedule::RecipientType::TaggedSymbol] + ) + end + def self.values + end + end + end + end +end diff --git a/rbi/courier/models/broadcast_schedule_params.rbi b/rbi/courier/models/broadcast_schedule_params.rbi new file mode 100644 index 00000000..41584798 --- /dev/null +++ b/rbi/courier/models/broadcast_schedule_params.rbi @@ -0,0 +1,35 @@ +# typed: strong + +module Courier + module Models + class BroadcastScheduleParams < Courier::Models::ScheduleBroadcastRequest + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Courier::BroadcastScheduleParams, Courier::Internal::AnyHash) + end + + sig { returns(String) } + attr_accessor :broadcast_id + + sig do + params( + broadcast_id: String, + request_options: Courier::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(broadcast_id:, request_options: {}) + end + + sig do + override.returns( + { broadcast_id: String, request_options: Courier::RequestOptions } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/courier/models/broadcast_send_params.rbi b/rbi/courier/models/broadcast_send_params.rbi new file mode 100644 index 00000000..9ac79a75 --- /dev/null +++ b/rbi/courier/models/broadcast_send_params.rbi @@ -0,0 +1,35 @@ +# typed: strong + +module Courier + module Models + class BroadcastSendParams < Courier::Models::SendBroadcastRequest + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Courier::BroadcastSendParams, Courier::Internal::AnyHash) + end + + sig { returns(String) } + attr_accessor :broadcast_id + + sig do + params( + broadcast_id: String, + request_options: Courier::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(broadcast_id:, request_options: {}) + end + + sig do + override.returns( + { broadcast_id: String, request_options: Courier::RequestOptions } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/courier/models/broadcast_update_params.rbi b/rbi/courier/models/broadcast_update_params.rbi new file mode 100644 index 00000000..8d643371 --- /dev/null +++ b/rbi/courier/models/broadcast_update_params.rbi @@ -0,0 +1,35 @@ +# typed: strong + +module Courier + module Models + class BroadcastUpdateParams < Courier::Models::UpdateBroadcastRequest + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Courier::BroadcastUpdateParams, Courier::Internal::AnyHash) + end + + sig { returns(String) } + attr_accessor :broadcast_id + + sig do + params( + broadcast_id: String, + request_options: Courier::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(broadcast_id:, request_options: {}) + end + + sig do + override.returns( + { broadcast_id: String, request_options: Courier::RequestOptions } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/courier/models/create_broadcast_request.rbi b/rbi/courier/models/create_broadcast_request.rbi new file mode 100644 index 00000000..8afb41e9 --- /dev/null +++ b/rbi/courier/models/create_broadcast_request.rbi @@ -0,0 +1,81 @@ +# typed: strong + +module Courier + module Models + class CreateBroadcastRequest < Courier::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Courier::CreateBroadcastRequest, Courier::Internal::AnyHash) + end + + # The single delivery channel for this broadcast. + sig { returns(Courier::CreateBroadcastRequest::Channel::OrSymbol) } + attr_accessor :channel + + # Human-readable name. + sig { returns(String) } + attr_accessor :name + + # Request body for creating a broadcast. + sig do + params( + channel: Courier::CreateBroadcastRequest::Channel::OrSymbol, + name: String + ).returns(T.attached_class) + end + def self.new( + # The single delivery channel for this broadcast. + channel:, + # Human-readable name. + name: + ) + end + + sig do + override.returns( + { + channel: Courier::CreateBroadcastRequest::Channel::OrSymbol, + name: String + } + ) + end + def to_hash + end + + # The single delivery channel for this broadcast. + module Channel + extend Courier::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Courier::CreateBroadcastRequest::Channel) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + EMAIL = + T.let(:email, Courier::CreateBroadcastRequest::Channel::TaggedSymbol) + SMS = + T.let(:sms, Courier::CreateBroadcastRequest::Channel::TaggedSymbol) + PUSH = + T.let(:push, Courier::CreateBroadcastRequest::Channel::TaggedSymbol) + INBOX = + T.let(:inbox, Courier::CreateBroadcastRequest::Channel::TaggedSymbol) + SLACK = + T.let(:slack, Courier::CreateBroadcastRequest::Channel::TaggedSymbol) + MSTEAMS = + T.let( + :msteams, + Courier::CreateBroadcastRequest::Channel::TaggedSymbol + ) + + sig do + override.returns( + T::Array[Courier::CreateBroadcastRequest::Channel::TaggedSymbol] + ) + end + def self.values + end + end + end + end +end diff --git a/rbi/courier/models/schedule_broadcast_request.rbi b/rbi/courier/models/schedule_broadcast_request.rbi new file mode 100644 index 00000000..69f7bbb6 --- /dev/null +++ b/rbi/courier/models/schedule_broadcast_request.rbi @@ -0,0 +1,103 @@ +# typed: strong + +module Courier + module Models + class ScheduleBroadcastRequest < Courier::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Courier::ScheduleBroadcastRequest, Courier::Internal::AnyHash) + end + + # ID of the target list or audience. + sig { returns(String) } + attr_accessor :recipient_id + + # Whether the broadcast targets a list or an audience. + sig do + returns(Courier::ScheduleBroadcastRequest::RecipientType::OrSymbol) + end + attr_accessor :recipient_type + + # Wall-clock timestamp of the future send, no timezone offset (e.g. + # "2026-07-21T20:00:00"). The zone is given by `timezone`. + sig { returns(String) } + attr_accessor :scheduled_to + + # IANA timezone for the scheduled send (e.g. America/New_York). + sig { returns(T.nilable(String)) } + attr_reader :timezone + + sig { params(timezone: String).void } + attr_writer :timezone + + # Request body for scheduling a broadcast for a future send. + sig do + params( + recipient_id: String, + recipient_type: + Courier::ScheduleBroadcastRequest::RecipientType::OrSymbol, + scheduled_to: String, + timezone: String + ).returns(T.attached_class) + end + def self.new( + # ID of the target list or audience. + recipient_id:, + # Whether the broadcast targets a list or an audience. + recipient_type:, + # Wall-clock timestamp of the future send, no timezone offset (e.g. + # "2026-07-21T20:00:00"). The zone is given by `timezone`. + scheduled_to:, + # IANA timezone for the scheduled send (e.g. America/New_York). + timezone: nil + ) + end + + sig do + override.returns( + { + recipient_id: String, + recipient_type: + Courier::ScheduleBroadcastRequest::RecipientType::OrSymbol, + scheduled_to: String, + timezone: String + } + ) + end + def to_hash + end + + # Whether the broadcast targets a list or an audience. + module RecipientType + extend Courier::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Courier::ScheduleBroadcastRequest::RecipientType) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + LIST = + T.let( + :list, + Courier::ScheduleBroadcastRequest::RecipientType::TaggedSymbol + ) + AUDIENCE = + T.let( + :audience, + Courier::ScheduleBroadcastRequest::RecipientType::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Courier::ScheduleBroadcastRequest::RecipientType::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end +end diff --git a/rbi/courier/models/send_broadcast_request.rbi b/rbi/courier/models/send_broadcast_request.rbi new file mode 100644 index 00000000..7495a924 --- /dev/null +++ b/rbi/courier/models/send_broadcast_request.rbi @@ -0,0 +1,77 @@ +# typed: strong + +module Courier + module Models + class SendBroadcastRequest < Courier::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Courier::SendBroadcastRequest, Courier::Internal::AnyHash) + end + + # ID of the target list or audience. + sig { returns(String) } + attr_accessor :recipient_id + + # Whether the broadcast targets a list or an audience. + sig { returns(Courier::SendBroadcastRequest::RecipientType::OrSymbol) } + attr_accessor :recipient_type + + # Request body for sending a broadcast immediately. + sig do + params( + recipient_id: String, + recipient_type: Courier::SendBroadcastRequest::RecipientType::OrSymbol + ).returns(T.attached_class) + end + def self.new( + # ID of the target list or audience. + recipient_id:, + # Whether the broadcast targets a list or an audience. + recipient_type: + ) + end + + sig do + override.returns( + { + recipient_id: String, + recipient_type: + Courier::SendBroadcastRequest::RecipientType::OrSymbol + } + ) + end + def to_hash + end + + # Whether the broadcast targets a list or an audience. + module RecipientType + extend Courier::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Courier::SendBroadcastRequest::RecipientType) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + LIST = + T.let( + :list, + Courier::SendBroadcastRequest::RecipientType::TaggedSymbol + ) + AUDIENCE = + T.let( + :audience, + Courier::SendBroadcastRequest::RecipientType::TaggedSymbol + ) + + sig do + override.returns( + T::Array[Courier::SendBroadcastRequest::RecipientType::TaggedSymbol] + ) + end + def self.values + end + end + end + end +end diff --git a/rbi/courier/models/update_broadcast_request.rbi b/rbi/courier/models/update_broadcast_request.rbi new file mode 100644 index 00000000..08eb3196 --- /dev/null +++ b/rbi/courier/models/update_broadcast_request.rbi @@ -0,0 +1,28 @@ +# typed: strong + +module Courier + module Models + class UpdateBroadcastRequest < Courier::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Courier::UpdateBroadcastRequest, Courier::Internal::AnyHash) + end + + # New human-readable name. + sig { returns(String) } + attr_accessor :name + + # Request body for updating a broadcast. Only the name is mutable. + sig { params(name: String).returns(T.attached_class) } + def self.new( + # New human-readable name. + name: + ) + end + + sig { override.returns({ name: String }) } + def to_hash + end + end + end +end diff --git a/rbi/courier/resources/broadcasts.rbi b/rbi/courier/resources/broadcasts.rbi new file mode 100644 index 00000000..16abc589 --- /dev/null +++ b/rbi/courier/resources/broadcasts.rbi @@ -0,0 +1,199 @@ +# typed: strong + +module Courier + module Resources + class Broadcasts + # Create a broadcast. Provisions a private notification template for the broadcast + # and returns the new broadcast in the draft state. Exactly one channel is + # required. + sig do + params( + channel: Courier::CreateBroadcastRequest::Channel::OrSymbol, + name: String, + request_options: Courier::RequestOptions::OrHash + ).returns(Courier::Broadcast) + end + def create( + # The single delivery channel for this broadcast. + channel:, + # Human-readable name. + name:, + request_options: {} + ) + end + + # Retrieve a broadcast by ID. Archived broadcasts return 404. + sig do + params( + broadcast_id: String, + request_options: Courier::RequestOptions::OrHash + ).returns(Courier::Broadcast) + end + def retrieve(broadcast_id, request_options: {}) + end + + # Update a broadcast's name. Content is edited via the broadcast's notification + # template, not this endpoint. + sig do + params( + broadcast_id: String, + name: String, + request_options: Courier::RequestOptions::OrHash + ).returns(Courier::Broadcast) + end + def update( + broadcast_id, + # New human-readable name. + name:, + request_options: {} + ) + end + + # List broadcasts in your workspace. Cursor-paginated; returns broadcasts + # newest-first. + sig do + params( + cursor: T.nilable(String), + limit: Integer, + request_options: Courier::RequestOptions::OrHash + ).returns(Courier::BroadcastListResponse) + end + def list( + # Opaque pagination cursor from a previous response. Omit for the first page. + cursor: nil, + # Maximum number of results per page. + limit: nil, + request_options: {} + ) + end + + # Archive a broadcast. This is a soft delete — the archived broadcast is returned + # and no longer appears in list results. + sig do + params( + broadcast_id: String, + request_options: Courier::RequestOptions::OrHash + ).returns(Courier::Broadcast) + end + def archive(broadcast_id, request_options: {}) + end + + # Cancel a broadcast's pending schedule, returning it to the draft state. Only + # valid for a scheduled broadcast. + sig do + params( + broadcast_id: String, + request_options: Courier::RequestOptions::OrHash + ).returns(Courier::Broadcast) + end + def cancel(broadcast_id, request_options: {}) + end + + # Duplicate a broadcast (and its template) into a new draft named "{source name} + # (copy)". + sig do + params( + broadcast_id: String, + request_options: Courier::RequestOptions::OrHash + ).returns(Courier::Broadcast) + end + def duplicate(broadcast_id, request_options: {}) + end + + # Author the broadcast's content by replacing the draft elemental content of its + # private notification template. The draft is published automatically when the + # broadcast is sent or scheduled. + sig do + params( + broadcast_id: String, + content: Courier::NotificationContentPutRequest::Content::OrHash, + state: Courier::NotificationTemplateState::OrSymbol, + request_options: Courier::RequestOptions::OrHash + ).returns(Courier::NotificationContentMutationResponse) + end + def put_content( + broadcast_id, + # Elemental content payload. The server defaults `version` when omitted. + content:, + # Template state. Defaults to `DRAFT`. + state: nil, + request_options: {} + ) + end + + # Retrieve the broadcast's content — the elemental content of its private + # notification template. Defaults to the working draft, since broadcast content is + # authored as a draft until the broadcast is sent. + sig do + params( + broadcast_id: String, + version: String, + request_options: Courier::RequestOptions::OrHash + ).returns(Courier::NotificationContentGetResponse) + end + def retrieve_content( + broadcast_id, + # Accepts `draft`, `published`, or a version string (e.g. `v001`). Defaults to + # `draft`. + version: nil, + request_options: {} + ) + end + + # Schedule a broadcast for a future send to a list or audience. Publishes the + # broadcast template first. Not allowed once the broadcast is sending or sent. For + # an immediate send use POST /broadcasts/{broadcastId}/send. + sig do + params( + broadcast_id: String, + recipient_id: String, + recipient_type: + Courier::ScheduleBroadcastRequest::RecipientType::OrSymbol, + scheduled_to: String, + timezone: String, + request_options: Courier::RequestOptions::OrHash + ).returns(Courier::Broadcast) + end + def schedule( + broadcast_id, + # ID of the target list or audience. + recipient_id:, + # Whether the broadcast targets a list or an audience. + recipient_type:, + # Wall-clock timestamp of the future send, no timezone offset (e.g. + # "2026-07-21T20:00:00"). The zone is given by `timezone`. + scheduled_to:, + # IANA timezone for the scheduled send (e.g. America/New_York). + timezone: nil, + request_options: {} + ) + end + + # Send a broadcast immediately to a list or audience. Publishes the broadcast + # template first. Not allowed once the broadcast is sending or sent. + sig do + params( + broadcast_id: String, + recipient_id: String, + recipient_type: + Courier::SendBroadcastRequest::RecipientType::OrSymbol, + request_options: Courier::RequestOptions::OrHash + ).returns(Courier::Broadcast) + end + def send_( + broadcast_id, + # ID of the target list or audience. + recipient_id:, + # Whether the broadcast targets a list or an audience. + recipient_type:, + request_options: {} + ) + end + + # @api private + sig { params(client: Courier::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end +end diff --git a/sig/courier/client.rbs b/sig/courier/client.rbs index aeaa2f44..dcfd0c7b 100644 --- a/sig/courier/client.rbs +++ b/sig/courier/client.rbs @@ -24,6 +24,8 @@ module Courier attr_reader journeys: Courier::Resources::Journeys + attr_reader broadcasts: Courier::Resources::Broadcasts + attr_reader brands: Courier::Resources::Brands attr_reader digests: Courier::Resources::Digests diff --git a/sig/courier/models.rbs b/sig/courier/models.rbs index bc49990c..7e2010c7 100644 --- a/sig/courier/models.rbs +++ b/sig/courier/models.rbs @@ -73,6 +73,34 @@ module Courier class BrandUpdateParams = Courier::Models::BrandUpdateParams + class Broadcast = Courier::Models::Broadcast + + class BroadcastArchiveParams = Courier::Models::BroadcastArchiveParams + + class BroadcastCancelParams = Courier::Models::BroadcastCancelParams + + class BroadcastCreateParams = Courier::Models::BroadcastCreateParams + + class BroadcastDuplicateParams = Courier::Models::BroadcastDuplicateParams + + class BroadcastListParams = Courier::Models::BroadcastListParams + + class BroadcastListResponse = Courier::Models::BroadcastListResponse + + class BroadcastPutContentParams = Courier::Models::BroadcastPutContentParams + + class BroadcastRetrieveContentParams = Courier::Models::BroadcastRetrieveContentParams + + class BroadcastRetrieveParams = Courier::Models::BroadcastRetrieveParams + + class BroadcastSchedule = Courier::Models::BroadcastSchedule + + class BroadcastScheduleParams = Courier::Models::BroadcastScheduleParams + + class BroadcastSendParams = Courier::Models::BroadcastSendParams + + class BroadcastUpdateParams = Courier::Models::BroadcastUpdateParams + module CancelJourneyRequest = Courier::Models::CancelJourneyRequest module CancelJourneyResponse = Courier::Models::CancelJourneyResponse @@ -87,6 +115,8 @@ module Courier class Check = Courier::Models::Check + class CreateBroadcastRequest = Courier::Models::CreateBroadcastRequest + class CreateJourneyRequest = Courier::Models::CreateJourneyRequest class DefaultPreferences = Courier::Models::DefaultPreferences @@ -431,6 +461,10 @@ module Courier class Rule = Courier::Models::Rule + class ScheduleBroadcastRequest = Courier::Models::ScheduleBroadcastRequest + + class SendBroadcastRequest = Courier::Models::SendBroadcastRequest + class SendDirectMessage = Courier::Models::SendDirectMessage class SendMessageParams = Courier::Models::SendMessageParams @@ -493,6 +527,8 @@ module Courier class TranslationUpdateParams = Courier::Models::TranslationUpdateParams + class UpdateBroadcastRequest = Courier::Models::UpdateBroadcastRequest + class UserProfile = Courier::Models::UserProfile module UserProfileFirebaseToken = Courier::Models::UserProfileFirebaseToken diff --git a/sig/courier/models/broadcast.rbs b/sig/courier/models/broadcast.rbs new file mode 100644 index 00000000..c2793da9 --- /dev/null +++ b/sig/courier/models/broadcast.rbs @@ -0,0 +1,98 @@ +module Courier + module Models + type broadcast = + { + id: String, + channel: Courier::Models::Broadcast::channel, + created_at: String, + created_by: String, + name: String, + status: Courier::Models::Broadcast::status, + updated_at: String, + updated_by: String, + archived_at: String?, + archived_by: String?, + schedule: Courier::BroadcastSchedule? + } + + class Broadcast < Courier::Internal::Type::BaseModel + attr_accessor id: String + + attr_accessor channel: Courier::Models::Broadcast::channel + + attr_accessor created_at: String + + attr_accessor created_by: String + + attr_accessor name: String + + attr_accessor status: Courier::Models::Broadcast::status + + attr_accessor updated_at: String + + attr_accessor updated_by: String + + attr_accessor archived_at: String? + + attr_accessor archived_by: String? + + attr_accessor schedule: Courier::BroadcastSchedule? + + def initialize: ( + id: String, + channel: Courier::Models::Broadcast::channel, + created_at: String, + created_by: String, + name: String, + status: Courier::Models::Broadcast::status, + updated_at: String, + updated_by: String, + ?archived_at: String?, + ?archived_by: String?, + ?schedule: Courier::BroadcastSchedule? + ) -> void + + def to_hash: -> { + id: String, + channel: Courier::Models::Broadcast::channel, + created_at: String, + created_by: String, + name: String, + status: Courier::Models::Broadcast::status, + updated_at: String, + updated_by: String, + archived_at: String?, + archived_by: String?, + schedule: Courier::BroadcastSchedule? + } + + type channel = :email | :sms | :push | :inbox | :slack | :msteams + + module Channel + extend Courier::Internal::Type::Enum + + EMAIL: :email + SMS: :sms + PUSH: :push + INBOX: :inbox + SLACK: :slack + MSTEAMS: :msteams + + def self?.values: -> ::Array[Courier::Models::Broadcast::channel] + end + + type status = :draft | :scheduled | :sending | :sent + + module Status + extend Courier::Internal::Type::Enum + + DRAFT: :draft + SCHEDULED: :scheduled + SENDING: :sending + SENT: :sent + + def self?.values: -> ::Array[Courier::Models::Broadcast::status] + end + end + end +end diff --git a/sig/courier/models/broadcast_archive_params.rbs b/sig/courier/models/broadcast_archive_params.rbs new file mode 100644 index 00000000..185037e0 --- /dev/null +++ b/sig/courier/models/broadcast_archive_params.rbs @@ -0,0 +1,23 @@ +module Courier + module Models + type broadcast_archive_params = + { broadcast_id: String } & Courier::Internal::Type::request_parameters + + class BroadcastArchiveParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + attr_accessor broadcast_id: String + + def initialize: ( + broadcast_id: String, + ?request_options: Courier::request_opts + ) -> void + + def to_hash: -> { + broadcast_id: String, + request_options: Courier::RequestOptions + } + end + end +end diff --git a/sig/courier/models/broadcast_cancel_params.rbs b/sig/courier/models/broadcast_cancel_params.rbs new file mode 100644 index 00000000..8c8b4b5d --- /dev/null +++ b/sig/courier/models/broadcast_cancel_params.rbs @@ -0,0 +1,23 @@ +module Courier + module Models + type broadcast_cancel_params = + { broadcast_id: String } & Courier::Internal::Type::request_parameters + + class BroadcastCancelParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + attr_accessor broadcast_id: String + + def initialize: ( + broadcast_id: String, + ?request_options: Courier::request_opts + ) -> void + + def to_hash: -> { + broadcast_id: String, + request_options: Courier::RequestOptions + } + end + end +end diff --git a/sig/courier/models/broadcast_create_params.rbs b/sig/courier/models/broadcast_create_params.rbs new file mode 100644 index 00000000..c7e7d645 --- /dev/null +++ b/sig/courier/models/broadcast_create_params.rbs @@ -0,0 +1,15 @@ +module Courier + module Models + type broadcast_create_params = + { } & Courier::Internal::Type::request_parameters + + class BroadcastCreateParams < Courier::Models::CreateBroadcastRequest + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + def initialize: (?request_options: Courier::request_opts) -> void + + def to_hash: -> { request_options: Courier::RequestOptions } + end + end +end diff --git a/sig/courier/models/broadcast_duplicate_params.rbs b/sig/courier/models/broadcast_duplicate_params.rbs new file mode 100644 index 00000000..55b71790 --- /dev/null +++ b/sig/courier/models/broadcast_duplicate_params.rbs @@ -0,0 +1,23 @@ +module Courier + module Models + type broadcast_duplicate_params = + { broadcast_id: String } & Courier::Internal::Type::request_parameters + + class BroadcastDuplicateParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + attr_accessor broadcast_id: String + + def initialize: ( + broadcast_id: String, + ?request_options: Courier::request_opts + ) -> void + + def to_hash: -> { + broadcast_id: String, + request_options: Courier::RequestOptions + } + end + end +end diff --git a/sig/courier/models/broadcast_list_params.rbs b/sig/courier/models/broadcast_list_params.rbs new file mode 100644 index 00000000..39b6bfe8 --- /dev/null +++ b/sig/courier/models/broadcast_list_params.rbs @@ -0,0 +1,30 @@ +module Courier + module Models + type broadcast_list_params = + { cursor: String?, limit: Integer } + & Courier::Internal::Type::request_parameters + + class BroadcastListParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + attr_accessor cursor: String? + + attr_reader limit: Integer? + + def limit=: (Integer) -> Integer + + def initialize: ( + ?cursor: String?, + ?limit: Integer, + ?request_options: Courier::request_opts + ) -> void + + def to_hash: -> { + cursor: String?, + limit: Integer, + request_options: Courier::RequestOptions + } + end + end +end diff --git a/sig/courier/models/broadcast_list_response.rbs b/sig/courier/models/broadcast_list_response.rbs new file mode 100644 index 00000000..0028e259 --- /dev/null +++ b/sig/courier/models/broadcast_list_response.rbs @@ -0,0 +1,22 @@ +module Courier + module Models + type broadcast_list_response = + { paging: Courier::Paging, results: ::Array[Courier::Broadcast] } + + class BroadcastListResponse < Courier::Internal::Type::BaseModel + attr_accessor paging: Courier::Paging + + attr_accessor results: ::Array[Courier::Broadcast] + + def initialize: ( + paging: Courier::Paging, + results: ::Array[Courier::Broadcast] + ) -> void + + def to_hash: -> { + paging: Courier::Paging, + results: ::Array[Courier::Broadcast] + } + end + end +end diff --git a/sig/courier/models/broadcast_put_content_params.rbs b/sig/courier/models/broadcast_put_content_params.rbs new file mode 100644 index 00000000..1c0b6a20 --- /dev/null +++ b/sig/courier/models/broadcast_put_content_params.rbs @@ -0,0 +1,25 @@ +module Courier + module Models + type broadcast_put_content_params = + { broadcast_id: String } & Courier::Internal::Type::request_parameters + + class BroadcastPutContentParams < Courier::Models::NotificationContentPutRequest + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + def broadcast_id: -> String + + def broadcast_id=: (String _) -> String + + def initialize: ( + broadcast_id: String, + ?request_options: Courier::request_opts + ) -> void + + def to_hash: -> { + broadcast_id: String, + request_options: Courier::RequestOptions + } + end + end +end diff --git a/sig/courier/models/broadcast_retrieve_content_params.rbs b/sig/courier/models/broadcast_retrieve_content_params.rbs new file mode 100644 index 00000000..e176afe2 --- /dev/null +++ b/sig/courier/models/broadcast_retrieve_content_params.rbs @@ -0,0 +1,30 @@ +module Courier + module Models + type broadcast_retrieve_content_params = + { broadcast_id: String, version: String } + & Courier::Internal::Type::request_parameters + + class BroadcastRetrieveContentParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + attr_accessor broadcast_id: String + + attr_reader version: String? + + def version=: (String) -> String + + def initialize: ( + broadcast_id: String, + ?version: String, + ?request_options: Courier::request_opts + ) -> void + + def to_hash: -> { + broadcast_id: String, + version: String, + request_options: Courier::RequestOptions + } + end + end +end diff --git a/sig/courier/models/broadcast_retrieve_params.rbs b/sig/courier/models/broadcast_retrieve_params.rbs new file mode 100644 index 00000000..bffa81fc --- /dev/null +++ b/sig/courier/models/broadcast_retrieve_params.rbs @@ -0,0 +1,23 @@ +module Courier + module Models + type broadcast_retrieve_params = + { broadcast_id: String } & Courier::Internal::Type::request_parameters + + class BroadcastRetrieveParams < Courier::Internal::Type::BaseModel + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + attr_accessor broadcast_id: String + + def initialize: ( + broadcast_id: String, + ?request_options: Courier::request_opts + ) -> void + + def to_hash: -> { + broadcast_id: String, + request_options: Courier::RequestOptions + } + end + end +end diff --git a/sig/courier/models/broadcast_schedule.rbs b/sig/courier/models/broadcast_schedule.rbs new file mode 100644 index 00000000..36a9bd02 --- /dev/null +++ b/sig/courier/models/broadcast_schedule.rbs @@ -0,0 +1,46 @@ +module Courier + module Models + type broadcast_schedule = + { + recipient_id: String, + recipient_type: Courier::Models::BroadcastSchedule::recipient_type, + scheduled_to: String?, + timezone: String? + } + + class BroadcastSchedule < Courier::Internal::Type::BaseModel + attr_accessor recipient_id: String + + attr_accessor recipient_type: Courier::Models::BroadcastSchedule::recipient_type + + attr_accessor scheduled_to: String? + + attr_accessor timezone: String? + + def initialize: ( + recipient_id: String, + recipient_type: Courier::Models::BroadcastSchedule::recipient_type, + ?scheduled_to: String?, + ?timezone: String? + ) -> void + + def to_hash: -> { + recipient_id: String, + recipient_type: Courier::Models::BroadcastSchedule::recipient_type, + scheduled_to: String?, + timezone: String? + } + + type recipient_type = :list | :audience + + module RecipientType + extend Courier::Internal::Type::Enum + + LIST: :list + AUDIENCE: :audience + + def self?.values: -> ::Array[Courier::Models::BroadcastSchedule::recipient_type] + end + end + end +end diff --git a/sig/courier/models/broadcast_schedule_params.rbs b/sig/courier/models/broadcast_schedule_params.rbs new file mode 100644 index 00000000..bb21a23b --- /dev/null +++ b/sig/courier/models/broadcast_schedule_params.rbs @@ -0,0 +1,25 @@ +module Courier + module Models + type broadcast_schedule_params = + { broadcast_id: String } & Courier::Internal::Type::request_parameters + + class BroadcastScheduleParams < Courier::Models::ScheduleBroadcastRequest + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + def broadcast_id: -> String + + def broadcast_id=: (String _) -> String + + def initialize: ( + broadcast_id: String, + ?request_options: Courier::request_opts + ) -> void + + def to_hash: -> { + broadcast_id: String, + request_options: Courier::RequestOptions + } + end + end +end diff --git a/sig/courier/models/broadcast_send_params.rbs b/sig/courier/models/broadcast_send_params.rbs new file mode 100644 index 00000000..79c80f9f --- /dev/null +++ b/sig/courier/models/broadcast_send_params.rbs @@ -0,0 +1,25 @@ +module Courier + module Models + type broadcast_send_params = + { broadcast_id: String } & Courier::Internal::Type::request_parameters + + class BroadcastSendParams < Courier::Models::SendBroadcastRequest + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + def broadcast_id: -> String + + def broadcast_id=: (String _) -> String + + def initialize: ( + broadcast_id: String, + ?request_options: Courier::request_opts + ) -> void + + def to_hash: -> { + broadcast_id: String, + request_options: Courier::RequestOptions + } + end + end +end diff --git a/sig/courier/models/broadcast_update_params.rbs b/sig/courier/models/broadcast_update_params.rbs new file mode 100644 index 00000000..99a955a0 --- /dev/null +++ b/sig/courier/models/broadcast_update_params.rbs @@ -0,0 +1,25 @@ +module Courier + module Models + type broadcast_update_params = + { broadcast_id: String } & Courier::Internal::Type::request_parameters + + class BroadcastUpdateParams < Courier::Models::UpdateBroadcastRequest + extend Courier::Internal::Type::RequestParameters::Converter + include Courier::Internal::Type::RequestParameters + + def broadcast_id: -> String + + def broadcast_id=: (String _) -> String + + def initialize: ( + broadcast_id: String, + ?request_options: Courier::request_opts + ) -> void + + def to_hash: -> { + broadcast_id: String, + request_options: Courier::RequestOptions + } + end + end +end diff --git a/sig/courier/models/create_broadcast_request.rbs b/sig/courier/models/create_broadcast_request.rbs new file mode 100644 index 00000000..184020ac --- /dev/null +++ b/sig/courier/models/create_broadcast_request.rbs @@ -0,0 +1,40 @@ +module Courier + module Models + type create_broadcast_request = + { + channel: Courier::Models::CreateBroadcastRequest::channel, + name: String + } + + class CreateBroadcastRequest < Courier::Internal::Type::BaseModel + attr_accessor channel: Courier::Models::CreateBroadcastRequest::channel + + attr_accessor name: String + + def initialize: ( + channel: Courier::Models::CreateBroadcastRequest::channel, + name: String + ) -> void + + def to_hash: -> { + channel: Courier::Models::CreateBroadcastRequest::channel, + name: String + } + + type channel = :email | :sms | :push | :inbox | :slack | :msteams + + module Channel + extend Courier::Internal::Type::Enum + + EMAIL: :email + SMS: :sms + PUSH: :push + INBOX: :inbox + SLACK: :slack + MSTEAMS: :msteams + + def self?.values: -> ::Array[Courier::Models::CreateBroadcastRequest::channel] + end + end + end +end diff --git a/sig/courier/models/schedule_broadcast_request.rbs b/sig/courier/models/schedule_broadcast_request.rbs new file mode 100644 index 00000000..2f93fae3 --- /dev/null +++ b/sig/courier/models/schedule_broadcast_request.rbs @@ -0,0 +1,48 @@ +module Courier + module Models + type schedule_broadcast_request = + { + recipient_id: String, + recipient_type: Courier::Models::ScheduleBroadcastRequest::recipient_type, + scheduled_to: String, + timezone: String + } + + class ScheduleBroadcastRequest < Courier::Internal::Type::BaseModel + attr_accessor recipient_id: String + + attr_accessor recipient_type: Courier::Models::ScheduleBroadcastRequest::recipient_type + + attr_accessor scheduled_to: String + + attr_reader timezone: String? + + def timezone=: (String) -> String + + def initialize: ( + recipient_id: String, + recipient_type: Courier::Models::ScheduleBroadcastRequest::recipient_type, + scheduled_to: String, + ?timezone: String + ) -> void + + def to_hash: -> { + recipient_id: String, + recipient_type: Courier::Models::ScheduleBroadcastRequest::recipient_type, + scheduled_to: String, + timezone: String + } + + type recipient_type = :list | :audience + + module RecipientType + extend Courier::Internal::Type::Enum + + LIST: :list + AUDIENCE: :audience + + def self?.values: -> ::Array[Courier::Models::ScheduleBroadcastRequest::recipient_type] + end + end + end +end diff --git a/sig/courier/models/send_broadcast_request.rbs b/sig/courier/models/send_broadcast_request.rbs new file mode 100644 index 00000000..c5b1523d --- /dev/null +++ b/sig/courier/models/send_broadcast_request.rbs @@ -0,0 +1,36 @@ +module Courier + module Models + type send_broadcast_request = + { + recipient_id: String, + recipient_type: Courier::Models::SendBroadcastRequest::recipient_type + } + + class SendBroadcastRequest < Courier::Internal::Type::BaseModel + attr_accessor recipient_id: String + + attr_accessor recipient_type: Courier::Models::SendBroadcastRequest::recipient_type + + def initialize: ( + recipient_id: String, + recipient_type: Courier::Models::SendBroadcastRequest::recipient_type + ) -> void + + def to_hash: -> { + recipient_id: String, + recipient_type: Courier::Models::SendBroadcastRequest::recipient_type + } + + type recipient_type = :list | :audience + + module RecipientType + extend Courier::Internal::Type::Enum + + LIST: :list + AUDIENCE: :audience + + def self?.values: -> ::Array[Courier::Models::SendBroadcastRequest::recipient_type] + end + end + end +end diff --git a/sig/courier/models/update_broadcast_request.rbs b/sig/courier/models/update_broadcast_request.rbs new file mode 100644 index 00000000..2442c0d9 --- /dev/null +++ b/sig/courier/models/update_broadcast_request.rbs @@ -0,0 +1,13 @@ +module Courier + module Models + type update_broadcast_request = { name: String } + + class UpdateBroadcastRequest < Courier::Internal::Type::BaseModel + attr_accessor name: String + + def initialize: (name: String) -> void + + def to_hash: -> { name: String } + end + end +end diff --git a/sig/courier/resources/broadcasts.rbs b/sig/courier/resources/broadcasts.rbs new file mode 100644 index 00000000..27bd4da6 --- /dev/null +++ b/sig/courier/resources/broadcasts.rbs @@ -0,0 +1,74 @@ +module Courier + module Resources + class Broadcasts + def create: ( + channel: Courier::Models::CreateBroadcastRequest::channel, + name: String, + ?request_options: Courier::request_opts + ) -> Courier::Broadcast + + def retrieve: ( + String broadcast_id, + ?request_options: Courier::request_opts + ) -> Courier::Broadcast + + def update: ( + String broadcast_id, + name: String, + ?request_options: Courier::request_opts + ) -> Courier::Broadcast + + def list: ( + ?cursor: String?, + ?limit: Integer, + ?request_options: Courier::request_opts + ) -> Courier::BroadcastListResponse + + def archive: ( + String broadcast_id, + ?request_options: Courier::request_opts + ) -> Courier::Broadcast + + def cancel: ( + String broadcast_id, + ?request_options: Courier::request_opts + ) -> Courier::Broadcast + + def duplicate: ( + String broadcast_id, + ?request_options: Courier::request_opts + ) -> Courier::Broadcast + + def put_content: ( + String broadcast_id, + content: Courier::NotificationContentPutRequest::Content, + ?state: Courier::Models::notification_template_state, + ?request_options: Courier::request_opts + ) -> Courier::NotificationContentMutationResponse + + def retrieve_content: ( + String broadcast_id, + ?version: String, + ?request_options: Courier::request_opts + ) -> Courier::NotificationContentGetResponse + + def schedule: ( + String broadcast_id, + recipient_id: String, + recipient_type: Courier::Models::ScheduleBroadcastRequest::recipient_type, + scheduled_to: String, + ?timezone: String, + ?request_options: Courier::request_opts + ) -> Courier::Broadcast + + def send_: ( + String broadcast_id, + recipient_id: String, + recipient_type: Courier::Models::SendBroadcastRequest::recipient_type, + ?request_options: Courier::request_opts + ) -> Courier::Broadcast + + def initialize: (client: Courier::Client) -> void + end + end +end diff --git a/test/courier/resources/broadcasts_test.rb b/test/courier/resources/broadcasts_test.rb new file mode 100644 index 00000000..71525feb --- /dev/null +++ b/test/courier/resources/broadcasts_test.rb @@ -0,0 +1,273 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Courier::Test::Resources::BroadcastsTest < Courier::Test::ResourceTest + def test_create_required_params + skip("Mock server tests are disabled") + + response = @courier.broadcasts.create(channel: :email, name: "Spring Sale Announcement") + + assert_pattern do + response => Courier::Broadcast + end + + assert_pattern do + response => { + id: String, + channel: Courier::Broadcast::Channel, + created_at: String, + created_by: String, + name: String, + status: Courier::Broadcast::Status, + updated_at: String, + updated_by: String, + archived_at: String | nil, + archived_by: String | nil, + schedule: Courier::BroadcastSchedule | nil + } + end + end + + def test_retrieve + skip("Mock server tests are disabled") + + response = @courier.broadcasts.retrieve("broadcastId") + + assert_pattern do + response => Courier::Broadcast + end + + assert_pattern do + response => { + id: String, + channel: Courier::Broadcast::Channel, + created_at: String, + created_by: String, + name: String, + status: Courier::Broadcast::Status, + updated_at: String, + updated_by: String, + archived_at: String | nil, + archived_by: String | nil, + schedule: Courier::BroadcastSchedule | nil + } + end + end + + def test_update_required_params + skip("Mock server tests are disabled") + + response = @courier.broadcasts.update("broadcastId", name: "Spring Sale Announcement (v2)") + + assert_pattern do + response => Courier::Broadcast + end + + assert_pattern do + response => { + id: String, + channel: Courier::Broadcast::Channel, + created_at: String, + created_by: String, + name: String, + status: Courier::Broadcast::Status, + updated_at: String, + updated_by: String, + archived_at: String | nil, + archived_by: String | nil, + schedule: Courier::BroadcastSchedule | nil + } + end + end + + def test_list + skip("Mock server tests are disabled") + + response = @courier.broadcasts.list + + assert_pattern do + response => Courier::BroadcastListResponse + end + + assert_pattern do + response => { + paging: Courier::Paging, + results: ^(Courier::Internal::Type::ArrayOf[Courier::Broadcast]) + } + end + end + + def test_archive + skip("Mock server tests are disabled") + + response = @courier.broadcasts.archive("broadcastId") + + assert_pattern do + response => Courier::Broadcast + end + + assert_pattern do + response => { + id: String, + channel: Courier::Broadcast::Channel, + created_at: String, + created_by: String, + name: String, + status: Courier::Broadcast::Status, + updated_at: String, + updated_by: String, + archived_at: String | nil, + archived_by: String | nil, + schedule: Courier::BroadcastSchedule | nil + } + end + end + + def test_cancel + skip("Mock server tests are disabled") + + response = @courier.broadcasts.cancel("broadcastId") + + assert_pattern do + response => Courier::Broadcast + end + + assert_pattern do + response => { + id: String, + channel: Courier::Broadcast::Channel, + created_at: String, + created_by: String, + name: String, + status: Courier::Broadcast::Status, + updated_at: String, + updated_by: String, + archived_at: String | nil, + archived_by: String | nil, + schedule: Courier::BroadcastSchedule | nil + } + end + end + + def test_duplicate + skip("Mock server tests are disabled") + + response = @courier.broadcasts.duplicate("broadcastId") + + assert_pattern do + response => Courier::Broadcast + end + + assert_pattern do + response => { + id: String, + channel: Courier::Broadcast::Channel, + created_at: String, + created_by: String, + name: String, + status: Courier::Broadcast::Status, + updated_at: String, + updated_by: String, + archived_at: String | nil, + archived_by: String | nil, + schedule: Courier::BroadcastSchedule | nil + } + end + end + + def test_put_content_required_params + skip("Mock server tests are disabled") + + response = @courier.broadcasts.put_content("broadcastId", content: {elements: [{}, {}]}) + + assert_pattern do + response => Courier::NotificationContentMutationResponse + end + + assert_pattern do + response => { + id: String, + elements: ^(Courier::Internal::Type::ArrayOf[Courier::NotificationContentMutationResponse::Element]), + state: Courier::NotificationTemplateState, + version: String + } + end + end + + def test_retrieve_content + skip("Mock server tests are disabled") + + response = @courier.broadcasts.retrieve_content("broadcastId") + + assert_pattern do + response => Courier::NotificationContentGetResponse + end + + assert_pattern do + response => { + elements: ^(Courier::Internal::Type::ArrayOf[Courier::ElementWithChecksums]), + version: String + } + end + end + + def test_schedule_required_params + skip("Mock server tests are disabled") + + response = + @courier.broadcasts.schedule( + "broadcastId", + recipient_id: "aud_01kx4h2jdafq8bk9amzvy6hbv0", + recipient_type: :audience, + scheduled_to: "2026-08-01T15:00:00" + ) + + assert_pattern do + response => Courier::Broadcast + end + + assert_pattern do + response => { + id: String, + channel: Courier::Broadcast::Channel, + created_at: String, + created_by: String, + name: String, + status: Courier::Broadcast::Status, + updated_at: String, + updated_by: String, + archived_at: String | nil, + archived_by: String | nil, + schedule: Courier::BroadcastSchedule | nil + } + end + end + + def test_send__required_params + skip("Mock server tests are disabled") + + response = + @courier.broadcasts.send_("broadcastId", recipient_id: "cool-customers", recipient_type: :list) + + assert_pattern do + response => Courier::Broadcast + end + + assert_pattern do + response => { + id: String, + channel: Courier::Broadcast::Channel, + created_at: String, + created_by: String, + name: String, + status: Courier::Broadcast::Status, + updated_at: String, + updated_by: String, + archived_at: String | nil, + archived_by: String | nil, + schedule: Courier::BroadcastSchedule | nil + } + end + end +end From 85b7149e9a9c4b217953d7d959ec150251daa9c9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 Jul 2026 20:30:03 +0000 Subject: [PATCH 2/2] release: 4.23.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ Gemfile.lock | 2 +- lib/courier/version.rb | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index c032d311..69e5aa20 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.22.0" + ".": "4.23.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 140288ab..4604d966 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 4.23.0 (2026-07-29) + +Full Changelog: [v4.22.0...v4.23.0](https://github.com/trycourier/courier-ruby/compare/v4.22.0...v4.23.0) + +### Features + +* **broadcasts:** document Broadcasts CRUD REST API ([#170](https://github.com/trycourier/courier-ruby/issues/170)) ([122e598](https://github.com/trycourier/courier-ruby/commit/122e5984cc48c30473a81fd3003c4fd899fc1cc6)) + ## 4.22.0 (2026-07-29) Full Changelog: [v4.21.0...v4.22.0](https://github.com/trycourier/courier-ruby/compare/v4.21.0...v4.22.0) diff --git a/Gemfile.lock b/Gemfile.lock index dee5cfef..a56a027c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: . specs: - trycourier (4.22.0) + trycourier (4.23.0) cgi connection_pool diff --git a/lib/courier/version.rb b/lib/courier/version.rb index 6d6c6fda..b8f333e7 100644 --- a/lib/courier/version.rb +++ b/lib/courier/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Courier - VERSION = "4.22.0" + VERSION = "4.23.0" end