Class: Courier::Resources::Broadcasts
- Inherits:
-
Object
- Object
- Courier::Resources::Broadcasts
- Defined in:
- lib/courier/resources/broadcasts.rb,
sig/courier/resources/broadcasts.rbs
Overview
Create a one-off send to a list or audience, author its content, then send it immediately or schedule it for later.
Instance Method Summary collapse
-
#archive(broadcast_id, request_options: {}) ⇒ Courier::Models::Broadcast
Archive a broadcast.
-
#cancel(broadcast_id, request_options: {}) ⇒ Courier::Models::Broadcast
Cancel a broadcast's pending schedule, returning it to the draft state.
-
#create(channel:, name:, request_options: {}) ⇒ Courier::Models::Broadcast
Create a broadcast.
-
#duplicate(broadcast_id, request_options: {}) ⇒ Courier::Models::Broadcast
Some parameter documentations has been truncated, see Models::BroadcastDuplicateParams for more details.
-
#initialize(client:) ⇒ Broadcasts
constructor
private
A new instance of Broadcasts.
-
#list(cursor: nil, limit: nil, request_options: {}) ⇒ Courier::Models::BroadcastListResponse
List broadcasts in your workspace.
-
#put_content(broadcast_id, content:, state: nil, request_options: {}) ⇒ Courier::Models::NotificationContentMutationResponse
Author the broadcast's content by replacing the draft elemental content of its private notification template.
-
#retrieve(broadcast_id, request_options: {}) ⇒ Courier::Models::Broadcast
Retrieve a broadcast by ID.
-
#retrieve_content(broadcast_id, version: nil, request_options: {}) ⇒ Courier::Models::NotificationContentGetResponse
Some parameter documentations has been truncated, see Models::BroadcastRetrieveContentParams for more details.
-
#schedule(broadcast_id, recipient_id:, recipient_type:, scheduled_to:, timezone: nil, request_options: {}) ⇒ Courier::Models::Broadcast
Some parameter documentations has been truncated, see Models::BroadcastScheduleParams for more details.
-
#send_(broadcast_id, recipient_id:, recipient_type:, request_options: {}) ⇒ Courier::Models::Broadcast
Send a broadcast immediately to a list or audience.
-
#update(broadcast_id, name:, request_options: {}) ⇒ Courier::Models::Broadcast
Update a broadcast's name.
Constructor Details
#initialize(client:) ⇒ Broadcasts
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Broadcasts.
294 295 296 |
# File 'lib/courier/resources/broadcasts.rb', line 294 def initialize(client:) @client = client end |
Instance Method Details
#archive(broadcast_id, request_options: {}) ⇒ Courier::Models::Broadcast
Archive a broadcast. This is a soft delete — the archived broadcast is returned and no longer appears in list results.
117 118 119 120 121 122 123 124 |
# File 'lib/courier/resources/broadcasts.rb', line 117 def archive(broadcast_id, params = {}) @client.request( method: :delete, path: ["broadcasts/%1$s", broadcast_id], model: Courier::Broadcast, options: params[:request_options] ) end |
#cancel(broadcast_id, request_options: {}) ⇒ Courier::Models::Broadcast
Cancel a broadcast's pending schedule, returning it to the draft state. Only valid for a scheduled broadcast.
138 139 140 141 142 143 144 145 |
# File 'lib/courier/resources/broadcasts.rb', line 138 def cancel(broadcast_id, params = {}) @client.request( method: :post, path: ["broadcasts/%1$s/cancel", broadcast_id], model: Courier::Broadcast, options: params[:request_options] ) end |
#create(channel:, name:, request_options: {}) ⇒ Courier::Models::Broadcast
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.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/courier/resources/broadcasts.rb', line 23 def create(params) parsed, = Courier::BroadcastCreateParams.dump_request(params) @client.request( method: :post, path: "broadcasts", body: parsed, model: Courier::Broadcast, options: ) end |
#duplicate(broadcast_id, request_options: {}) ⇒ Courier::Models::Broadcast
Some parameter documentations has been truncated, see Models::BroadcastDuplicateParams for more details.
Duplicate a broadcast (and its template) into a new draft named "name (copy)".
162 163 164 165 166 167 168 169 |
# File 'lib/courier/resources/broadcasts.rb', line 162 def duplicate(broadcast_id, params = {}) @client.request( method: :post, path: ["broadcasts/%1$s/duplicate", broadcast_id], model: Courier::Broadcast, options: params[:request_options] ) end |
#list(cursor: nil, limit: nil, request_options: {}) ⇒ Courier::Models::BroadcastListResponse
List broadcasts in your workspace. Cursor-paginated; returns broadcasts newest-first.
93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/courier/resources/broadcasts.rb', line 93 def list(params = {}) parsed, = 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: ) end |
#put_content(broadcast_id, content:, state: nil, request_options: {}) ⇒ Courier::Models::NotificationContentMutationResponse
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.
188 189 190 191 192 193 194 195 196 197 |
# File 'lib/courier/resources/broadcasts.rb', line 188 def put_content(broadcast_id, params) parsed, = Courier::BroadcastPutContentParams.dump_request(params) @client.request( method: :put, path: ["broadcasts/%1$s/content", broadcast_id], body: parsed, model: Courier::NotificationContentMutationResponse, options: ) end |
#retrieve(broadcast_id, request_options: {}) ⇒ Courier::Models::Broadcast
Retrieve a broadcast by ID. Archived broadcasts return 404.
45 46 47 48 49 50 51 52 |
# File 'lib/courier/resources/broadcasts.rb', line 45 def retrieve(broadcast_id, params = {}) @client.request( method: :get, path: ["broadcasts/%1$s", broadcast_id], model: Courier::Broadcast, options: params[:request_options] ) end |
#retrieve_content(broadcast_id, version: nil, request_options: {}) ⇒ Courier::Models::NotificationContentGetResponse
Some parameter documentations has been truncated, see 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.
217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/courier/resources/broadcasts.rb', line 217 def retrieve_content(broadcast_id, params = {}) parsed, = 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: ) end |
#schedule(broadcast_id, recipient_id:, recipient_type:, scheduled_to:, timezone: nil, request_options: {}) ⇒ Courier::Models::Broadcast
Some parameter documentations has been truncated, see 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.
253 254 255 256 257 258 259 260 261 262 |
# File 'lib/courier/resources/broadcasts.rb', line 253 def schedule(broadcast_id, params) parsed, = Courier::BroadcastScheduleParams.dump_request(params) @client.request( method: :post, path: ["broadcasts/%1$s/schedule", broadcast_id], body: parsed, model: Courier::Broadcast, options: ) end |
#send_(broadcast_id, recipient_id:, recipient_type:, request_options: {}) ⇒ Courier::Models::Broadcast
Send a broadcast immediately to a list or audience. Publishes the broadcast template first. Not allowed once the broadcast is sending or sent.
280 281 282 283 284 285 286 287 288 289 |
# File 'lib/courier/resources/broadcasts.rb', line 280 def send_(broadcast_id, params) parsed, = Courier::BroadcastSendParams.dump_request(params) @client.request( method: :post, path: ["broadcasts/%1$s/send", broadcast_id], body: parsed, model: Courier::Broadcast, options: ) end |
#update(broadcast_id, name:, request_options: {}) ⇒ Courier::Models::Broadcast
Update a broadcast's name. Content is edited via the broadcast's notification template, not this endpoint.
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/courier/resources/broadcasts.rb', line 68 def update(broadcast_id, params) parsed, = Courier::BroadcastUpdateParams.dump_request(params) @client.request( method: :put, path: ["broadcasts/%1$s", broadcast_id], body: parsed, model: Courier::Broadcast, options: ) end |