Class: Posthubify::BroadcastsResource
- Inherits:
-
Object
- Object
- Posthubify::BroadcastsResource
- Defined in:
- lib/posthubify/resources/messaging.rb
Overview
Broadcast — CRUD + send/schedule/cancel + recipients (Node sdk .broadcasts).
Instance Method Summary collapse
-
#add_recipients(id, contact_ids) ⇒ Object
Add recipients (duplicates are skipped) — only draft/scheduled.
-
#cancel(id) ⇒ Object
scheduled → draft (content is preserved).
-
#create(input, idempotency_key: nil) ⇒ Object
Create a broadcast (safe retry with idempotency_key).
-
#delete(id) ⇒ Object
Delete a broadcast.
-
#get(id) ⇒ Object
A single broadcast.
-
#initialize(http) ⇒ BroadcastsResource
constructor
A new instance of BroadcastsResource.
-
#list ⇒ Object
Broadcast list.
-
#recipients(id, limit: nil, cursor: nil) ⇒ Object
Recipients: contact name + per-target status (paginated envelope).
-
#schedule(id, scheduled_at) ⇒ Object
draft → scheduled; when the time comes the server scheduler starts the send.
-
#send(id) ⇒ Object
Asynchronous (202): sending happens in the background; poll progress with get(id).
-
#update(id, input) ⇒ Object
Editable only in the draft/scheduled/failed stage.
Constructor Details
#initialize(http) ⇒ BroadcastsResource
Returns a new instance of BroadcastsResource.
338 339 340 |
# File 'lib/posthubify/resources/messaging.rb', line 338 def initialize(http) @http = http end |
Instance Method Details
#add_recipients(id, contact_ids) ⇒ Object
Add recipients (duplicates are skipped) — only draft/scheduled.
388 389 390 |
# File 'lib/posthubify/resources/messaging.rb', line 388 def add_recipients(id, contact_ids) @http.data('POST', "/broadcasts/#{id}/recipients", body: { 'contactIds' => contact_ids }) end |
#cancel(id) ⇒ Object
scheduled → draft (content is preserved).
378 379 380 |
# File 'lib/posthubify/resources/messaging.rb', line 378 def cancel(id) @http.data('POST', "/broadcasts/#{id}/cancel") end |
#create(input, idempotency_key: nil) ⇒ Object
Create a broadcast (safe retry with idempotency_key).
353 354 355 |
# File 'lib/posthubify/resources/messaging.rb', line 353 def create(input, idempotency_key: nil) @http.data('POST', '/broadcasts', body: input, idempotency_key: idempotency_key) end |
#delete(id) ⇒ Object
Delete a broadcast.
363 364 365 |
# File 'lib/posthubify/resources/messaging.rb', line 363 def delete(id) @http.data('DELETE', "/broadcasts/#{id}") end |
#get(id) ⇒ Object
A single broadcast.
348 349 350 |
# File 'lib/posthubify/resources/messaging.rb', line 348 def get(id) @http.data('GET', "/broadcasts/#{id}") end |
#list ⇒ Object
Broadcast list.
343 344 345 |
# File 'lib/posthubify/resources/messaging.rb', line 343 def list @http.data('GET', '/broadcasts') end |
#recipients(id, limit: nil, cursor: nil) ⇒ Object
Recipients: contact name + per-target status (paginated envelope).
383 384 385 |
# File 'lib/posthubify/resources/messaging.rb', line 383 def recipients(id, limit: nil, cursor: nil) @http.req('GET', "/broadcasts/#{id}/recipients", query: { 'limit' => limit, 'cursor' => cursor }) end |
#schedule(id, scheduled_at) ⇒ Object
draft → scheduled; when the time comes the server scheduler starts the send.
373 374 375 |
# File 'lib/posthubify/resources/messaging.rb', line 373 def schedule(id, scheduled_at) @http.data('POST', "/broadcasts/#{id}/schedule", body: { 'scheduledAt' => scheduled_at }) end |
#send(id) ⇒ Object
Asynchronous (202): sending happens in the background; poll progress with get(id).
368 369 370 |
# File 'lib/posthubify/resources/messaging.rb', line 368 def send(id) @http.data('POST', "/broadcasts/#{id}/send") end |
#update(id, input) ⇒ Object
Editable only in the draft/scheduled/failed stage.
358 359 360 |
# File 'lib/posthubify/resources/messaging.rb', line 358 def update(id, input) @http.data('PATCH', "/broadcasts/#{id}", body: input) end |