Class: Courier::Resources::Broadcasts
- Inherits:
-
Object
- Object
- Courier::Resources::Broadcasts
- Defined in:
- lib/courier/resources/broadcasts.rb,
sig/courier/resources/broadcasts.rbs
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.
285 286 287 |
# File 'lib/courier/resources/broadcasts.rb', line 285 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.
113 114 115 116 117 118 119 120 |
# File 'lib/courier/resources/broadcasts.rb', line 113 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.
133 134 135 136 137 138 139 140 |
# File 'lib/courier/resources/broadcasts.rb', line 133 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.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/courier/resources/broadcasts.rb', line 21 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)".
153 154 155 156 157 158 159 160 |
# File 'lib/courier/resources/broadcasts.rb', line 153 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.
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/courier/resources/broadcasts.rb', line 90 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.
179 180 181 182 183 184 185 186 187 188 |
# File 'lib/courier/resources/broadcasts.rb', line 179 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.
42 43 44 45 46 47 48 49 |
# File 'lib/courier/resources/broadcasts.rb', line 42 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.
208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/courier/resources/broadcasts.rb', line 208 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.
244 245 246 247 248 249 250 251 252 253 |
# File 'lib/courier/resources/broadcasts.rb', line 244 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.
271 272 273 274 275 276 277 278 279 280 |
# File 'lib/courier/resources/broadcasts.rb', line 271 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.
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/courier/resources/broadcasts.rb', line 65 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 |