Class: Courier::Resources::Notifications::Previews::Runs
- Inherits:
-
Object
- Object
- Courier::Resources::Notifications::Previews::Runs
- Defined in:
- lib/courier/resources/notifications/previews/runs.rb,
sig/courier/resources/notifications/previews/runs.rbs
Overview
Render a template's email content on real email clients and read back the screenshots, so you can check how it looks before you send it.
Instance Method Summary collapse
-
#create(id, data: nil, device_ids: nil, device_set_id: nil, locale: nil, template_version: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::Notifications::Previews::PreviewRun
Some parameter documentations has been truncated, see Models::Notifications::Previews::RunCreateParams for more details.
-
#initialize(client:) ⇒ Runs
constructor
private
A new instance of Runs.
-
#list(id, cursor: nil, limit: nil, request_options: {}) ⇒ Courier::Models::Notifications::Previews::PreviewRunListResponse
List this template's preview runs, newest first.
-
#retrieve(preview_run_id, id:, request_options: {}) ⇒ Courier::Models::Notifications::Previews::PreviewRunDetail
Some parameter documentations has been truncated, see Models::Notifications::Previews::RunRetrieveParams for more details.
Constructor Details
#initialize(client:) ⇒ Runs
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 Runs.
141 142 143 |
# File 'lib/courier/resources/notifications/previews/runs.rb', line 141 def initialize(client:) @client = client end |
Instance Method Details
#create(id, data: nil, device_ids: nil, device_set_id: nil, locale: nil, template_version: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::Notifications::Previews::PreviewRun
Some parameter documentations has been truncated, see Models::Notifications::Previews::RunCreateParams for more details.
Render this template's email content on each of the requested devices.
Returns as soon as the run exists and its render is queued — the screenshots are
produced asynchronously. Poll
GET /notifications/{id}/previews/runs/{previewRunId} until every result
reaches a terminal status.
Name the devices either with device_set_id, for a saved set, or with
device_ids, for a one-off list. Exactly one of the two is required. Inline
device_ids must be ids listed by GET /previews/devices; any other id is a
422, refused before the run exists or is billed.
A template that does not exist is a 404. One that exists but cannot be previewed
— not a Design Studio template, no email channel, or no such template_version
— is a 422, also refused before the run exists or is billed.
Preview runs are a metered add-on. A workspace without it, or with its billing suspended, receives a 402.
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/courier/resources/notifications/previews/runs.rb', line 55 def create(id, params = {}) parsed, = Courier::Notifications::Previews::RunCreateParams.dump_request(params) header_params = {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: ["notifications/%1$s/previews/runs", id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Courier::Notifications::Previews::PreviewRun, options: ) end |
#list(id, cursor: nil, limit: nil, request_options: {}) ⇒ Courier::Models::Notifications::Previews::PreviewRunListResponse
List this template's preview runs, newest first. Cursor-paginated.
A template that does not exist is a 404, the same as every other
/notifications/{id} route.
126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/courier/resources/notifications/previews/runs.rb', line 126 def list(id, params = {}) parsed, = Courier::Notifications::Previews::RunListParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["notifications/%1$s/previews/runs", id], query: query, model: Courier::Notifications::Previews::PreviewRunListResponse, options: ) end |
#retrieve(preview_run_id, id:, request_options: {}) ⇒ Courier::Models::Notifications::Previews::PreviewRunDetail
Some parameter documentations has been truncated, see Models::Notifications::Previews::RunRetrieveParams for more details.
Retrieve one of this template's preview runs together with its per-device results.
A run is only readable under the template it previewed: under any other template it is a 404, the same as a run that does not exist.
thumbnail_url and screenshot_url are short-lived signed URLs, re-signed on
every read. Fetch them now rather than storing them. Both are null until
Courier's own copy of the image exists, which is what status: COMPLETED on a
result means.
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/courier/resources/notifications/previews/runs.rb', line 94 def retrieve(preview_run_id, params) parsed, = Courier::Notifications::Previews::RunRetrieveParams.dump_request(params) id = parsed.delete(:id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :get, path: ["notifications/%1$s/previews/runs/%2$s", id, preview_run_id], model: Courier::Notifications::Previews::PreviewRunDetail, options: ) end |