Class: Mailkube::Resources::ScheduledEmailBatches

Inherits:
Object
  • Object
show all
Defined in:
lib/mailkube/resources/scheduled_emails.rb,
sig/mailkube/resources/scheduled_emails.rbs

Overview

Batch operations, reached as client.scheduled_emails.batches.

A sibling resource sharing the enclosing namespace's transport, not a method group: the wire has a scheduled-emails/batches/{id} sub-path, so the SDK has a sub-namespace. A update_batch suffix would flatten a structure the API actually has.

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ ScheduledEmailBatches

Returns a new instance of ScheduledEmailBatches.

Parameters:

  • transport (#request_json)

    the transport performing this resource's requests.

  • (_JsonTransport)


12
13
14
15
# File 'lib/mailkube/resources/scheduled_emails.rb', line 12

def initialize(transport)
  @transport = transport
  freeze
end

Instance Method Details

#cancel(batch_id) ⇒ ScheduledEmailBatchCancel

Cancel every pending email in a batch.

An unknown batch is a no-op reporting a count of 0 rather than a 404, so a count of 0 is not a failure.

Parameters:

  • batch_id (String)

    the batch label.

  • (String)

Returns:

Raises:

  • (APIError)

    on any non-2xx response.



37
38
39
# File 'lib/mailkube/resources/scheduled_emails.rb', line 37

def cancel(batch_id)
  ScheduledEmailBatchCancel.from(@transport.request_json(ScheduledEmailRequests.batch_cancel(batch_id)))
end

#update(batch_id, scheduled_at:) ⇒ ScheduledEmailBatchUpdate

Reschedule every pending email in a batch.

Parameters:

  • batch_id (String)

    the batch label.

  • scheduled_at (Time, String)

    the new due time, in the future and within the plan's scheduling horizon. ISO-8601 with an offset, or a Time.

  • (String)
  • scheduled_at: (Time, String)

Returns:

Raises:

  • (APIError)

    on any non-2xx response.



24
25
26
27
# File 'lib/mailkube/resources/scheduled_emails.rb', line 24

def update(batch_id, scheduled_at:)
  body = { "scheduled_at" => Serialization.to_iso(scheduled_at) }
  ScheduledEmailBatchUpdate.from(@transport.request_json(ScheduledEmailRequests.batch_update(batch_id, body)))
end