Class: Zavudev::Resources::Broadcasts

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

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:



286
287
288
289
# File 'lib/zavudev/resources/broadcasts.rb', line 286

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

Instance Attribute Details

#contactsZavudev::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. Broadcasts go through automated AI content review before sending. If the review passes, the broadcast proceeds. If rejected, use PATCH to edit content, then call POST /retry-review. 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:



272
273
274
275
276
277
278
279
280
281
# File 'lib/zavudev/resources/broadcasts.rb', line 272

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