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
Duplicate a broadcast (and its template) into a new draft named "name (copy)".
-
#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.
287 288 289 |
# File 'lib/courier/resources/broadcasts.rb', line 287 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.
115 116 117 118 119 120 121 122 |
# File 'lib/courier/resources/broadcasts.rb', line 115 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.
135 136 137 138 139 140 141 142 |
# File 'lib/courier/resources/broadcasts.rb', line 135 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
Duplicate a broadcast (and its template) into a new draft named "name (copy)".
155 156 157 158 159 160 161 162 |
# File 'lib/courier/resources/broadcasts.rb', line 155 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.
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/courier/resources/broadcasts.rb', line 92 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.
181 182 183 184 185 186 187 188 189 190 |
# File 'lib/courier/resources/broadcasts.rb', line 181 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.
44 45 46 47 48 49 50 51 |
# File 'lib/courier/resources/broadcasts.rb', line 44 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.
210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/courier/resources/broadcasts.rb', line 210 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.
246 247 248 249 250 251 252 253 254 255 |
# File 'lib/courier/resources/broadcasts.rb', line 246 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.
273 274 275 276 277 278 279 280 281 282 |
# File 'lib/courier/resources/broadcasts.rb', line 273 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.
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/courier/resources/broadcasts.rb', line 67 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 |