Class: Zavudev::Resources::Broadcasts

Inherits:
Object
  • Object
show all
Defined in:
lib/zavudev/resources/broadcasts.rb,
lib/zavudev/resources/broadcasts/contacts.rb,
sig/zavudev/resources/broadcasts.rbs,
sig/zavudev/resources/broadcasts/contacts.rbs

Defined Under Namespace

Classes: Contacts

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Parameters:



312
313
314
315
# File 'lib/zavudev/resources/broadcasts.rb', line 312

def initialize(client:)
  @client = client
  @contacts = Zavudev::Resources::Broadcasts::Contacts.new(client: client)
end

Instance Attribute Details

#contacts ⇒ Zavudev::Resources::Broadcasts::Contacts (readonly)



7
8
9
# File 'lib/zavudev/resources/broadcasts.rb', line 7

def contacts
  @contacts
end

Instance Method Details

#cancel(broadcast_id, request_options: {}) ⇒ Zavudev::Models::BroadcastCancelResponse

Cancel a broadcast. Pending contacts will be skipped, but already queued messages may still be delivered.

Parameters:

Returns:

See Also:



162
163
164
165
166
167
168
169
# File 'lib/zavudev/resources/broadcasts.rb', line 162

def cancel(broadcast_id, params = {})
  @client.request(
    method: :post,
    path: ["v1/broadcasts/%1$s/cancel", broadcast_id],
    model: Zavudev::Models::BroadcastCancelResponse,
    options: params[:request_options]
  )
end

#create(channel:, name:, content: nil, email_html_body: nil, email_subject: nil, idempotency_key: nil, message_type: nil, metadata: nil, scheduled_at: nil, sender_id: nil, text: nil, request_options: {}) ⇒ Zavudev::Models::BroadcastCreateResponse

Create a new broadcast campaign. Add contacts after creation, then send.

Parameters:

  • channel (Symbol, Zavudev::Models::BroadcastChannel) —

    Broadcast delivery channel. Use 'smart' for per-contact intelligent routing.

  • name (String) —

    Name of the broadcast campaign.

  • content (Zavudev::Models::BroadcastContent) —

    Content for non-text broadcast message types.

  • email_html_body (String) —

    HTML body for email broadcasts.

  • email_subject (String) —

    Email subject line. Required for email broadcasts.

  • idempotency_key (String) —

    Idempotency key to prevent duplicate broadcasts.

  • message_type (Symbol, Zavudev::Models::BroadcastMessageType) —

    Type of message for broadcast.

  • metadata (Hash{Symbol=>String})
  • scheduled_at (Time) —

    Schedule the broadcast for future delivery.

  • sender_id (String) —

    Sender profile ID. Uses default sender if omitted.

  • text (String) —

    Text content or caption. Supports template variables: {name}, {1}, etc.

  • request_options (Zavudev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



40
41
42
43
44
45
46
47
48
49
# File 'lib/zavudev/resources/broadcasts.rb', line 40

def create(params)
  parsed, options = Zavudev::BroadcastCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/broadcasts",
    body: parsed,
    model: Zavudev::Models::BroadcastCreateResponse,
    options: options
  )
end

#delete(broadcast_id, request_options: {}) ⇒ nil

Delete a broadcast in draft status.

Parameters:

Returns:

  • (nil)

See Also:



142
143
144
145
146
147
148
149
# File 'lib/zavudev/resources/broadcasts.rb', line 142

def delete(broadcast_id, params = {})
  @client.request(
    method: :delete,
    path: ["v1/broadcasts/%1$s", broadcast_id],
    model: NilClass,
    options: params[:request_options]
  )
end

#escalate_review(broadcast_id, request_options: {}) ⇒ Zavudev::Models::BroadcastEscalateReviewResponse

Request manual review by the Zavu team for a rejected broadcast. Use this after automated review rejection if you believe the content is legitimate.

Parameters:

Returns:

See Also:



182
183
184
185
186
187
188
189
# File 'lib/zavudev/resources/broadcasts.rb', line 182

def escalate_review(broadcast_id, params = {})
  @client.request(
    method: :post,
    path: ["v1/broadcasts/%1$s/escalate", broadcast_id],
    model: Zavudev::Models::BroadcastEscalateReviewResponse,
    options: params[:request_options]
  )
end

#list(cursor: nil, limit: nil, status: nil, request_options: {}) ⇒ Zavudev::Internal::Cursor<Zavudev::Models::Broadcast>

List broadcasts for this project.

Parameters:

Returns:

See Also:



119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/zavudev/resources/broadcasts.rb', line 119

def list(params = {})
  parsed, options = Zavudev::BroadcastListParams.dump_request(params)
  query = Zavudev::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "v1/broadcasts",
    query: query,
    page: Zavudev::Internal::Cursor,
    model: Zavudev::Broadcast,
    options: options
  )
end

#progress(broadcast_id, request_options: {}) ⇒ Zavudev::Models::BroadcastProgress

Get real-time progress of a broadcast including delivery counts and estimated completion time.

Parameters:

Returns:

See Also:



202
203
204
205
206
207
208
209
# File 'lib/zavudev/resources/broadcasts.rb', line 202

def progress(broadcast_id, params = {})
  @client.request(
    method: :get,
    path: ["v1/broadcasts/%1$s/progress", broadcast_id],
    model: Zavudev::BroadcastProgress,
    options: params[:request_options]
  )
end

#reschedule(broadcast_id, scheduled_at:, request_options: {}) ⇒ Zavudev::Models::BroadcastRescheduleResponse

Update the scheduled time for a broadcast. The broadcast must be in scheduled status.

Parameters:

  • broadcast_id (String)
  • scheduled_at (Time) —

    New scheduled time for the broadcast.

  • request_options (Zavudev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



225
226
227
228
229
230
231
232
233
234
# File 'lib/zavudev/resources/broadcasts.rb', line 225

def reschedule(broadcast_id, params)
  parsed, options = Zavudev::BroadcastRescheduleParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["v1/broadcasts/%1$s/schedule", broadcast_id],
    body: parsed,
    model: Zavudev::Models::BroadcastRescheduleResponse,
    options: options
  )
end

#retrieve(broadcast_id, request_options: {}) ⇒ Zavudev::Models::BroadcastRetrieveResponse

Get broadcast

Parameters:

Returns:

See Also:



61
62
63
64
65
66
67
68
# File 'lib/zavudev/resources/broadcasts.rb', line 61

def retrieve(broadcast_id, params = {})
  @client.request(
    method: :get,
    path: ["v1/broadcasts/%1$s", broadcast_id],
    model: Zavudev::Models::BroadcastRetrieveResponse,
    options: params[:request_options]
  )
end

#retry_review(broadcast_id, request_options: {}) ⇒ Zavudev::Models::BroadcastRetryReviewResponse

Resubmit a rejected broadcast for AI review after editing content. Maximum 3 review attempts allowed per broadcast.

Parameters:

Returns:

See Also:



247
248
249
250
251
252
253
254
# File 'lib/zavudev/resources/broadcasts.rb', line 247

def retry_review(broadcast_id, params = {})
  @client.request(
    method: :post,
    path: ["v1/broadcasts/%1$s/retry-review", broadcast_id],
    model: Zavudev::Models::BroadcastRetryReviewResponse,
    options: params[:request_options]
  )
end

#send_(broadcast_id, scheduled_at: nil, request_options: {}) ⇒ Zavudev::Models::BroadcastSendResponse

Start sending the broadcast immediately or schedule for later.

The account must be past the unverified level to send, except on WhatsApp. An account that has verified nothing is refused with 403 and code kyc_required on every channel other than whatsapp. Any one of these lifts it: identity verification (KYC), a saved payment method, a settled deposit, or a paid plan. Business verification (KYB) is not required to broadcast; it gates 10DLC registration only. A whatsapp broadcast is exempt: it can only be built on a template, and Meta vets the business and the content when it approves that template, so an unapproved template is refused instead. smart is not exempt, since it can route a contact to SMS or email. Drafts can be created, edited and kept without any check. Every send path (dashboard, API and CLI) enforces the same rule.

Daily ceilings apply per recipient. Each message a broadcast sends counts against the channel's daily ceiling (see POST /v1/messages). Once the ceiling is reached, the remaining recipients are marked failed with errorCode DAILY_LIMIT_EXCEEDED; they are not retried the next day.

Review depends on the channel, and cannot be bypassed. A draft is submitted to automated content review here; it does not go straight out. A WhatsApp broadcast built on a Meta-approved template skips review (Meta already vetted the content) and begins sending. An email broadcast sends as soon as the automated review passes. Every other channel moves to pending_admin_review and waits for a person. If the review rejects it, use PATCH to edit the content then call POST /retry-review.

Calling this on a broadcast that is already approved or scheduled sends or reschedules it directly, since it has already been reviewed. Reserves the estimated cost from your balance.

Parameters:

  • broadcast_id (String)
  • scheduled_at (Time) —

    Schedule for future delivery. Omit to send immediately.

  • request_options (Zavudev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



298
299
300
301
302
303
304
305
306
307
# File 'lib/zavudev/resources/broadcasts.rb', line 298

def send_(broadcast_id, params = {})
  parsed, options = Zavudev::BroadcastSendParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/broadcasts/%1$s/send", broadcast_id],
    body: parsed,
    model: Zavudev::Models::BroadcastSendResponse,
    options: options
  )
end

#update(broadcast_id, content: nil, email_html_body: nil, email_subject: nil, metadata: nil, name: nil, text: nil, request_options: {}) ⇒ Zavudev::Models::BroadcastUpdateResponse

Update a broadcast in draft status.

Parameters:

  • broadcast_id (String)
  • content (Zavudev::Models::BroadcastContent) —

    Content for non-text broadcast message types.

  • email_html_body (String)
  • email_subject (String)
  • metadata (Hash{Symbol=>String})
  • name (String)
  • text (String)
  • request_options (Zavudev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



93
94
95
96
97
98
99
100
101
102
# File 'lib/zavudev/resources/broadcasts.rb', line 93

def update(broadcast_id, params = {})
  parsed, options = Zavudev::BroadcastUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["v1/broadcasts/%1$s", broadcast_id],
    body: parsed,
    model: Zavudev::Models::BroadcastUpdateResponse,
    options: options
  )
end