Class: Courier::Resources::Journeys::Templates
- Inherits:
-
Object
- Object
- Courier::Resources::Journeys::Templates
- Defined in:
- lib/courier/resources/journeys/templates.rb,
sig/courier/resources/journeys/templates.rbs
Overview
Build, version, publish, invoke, and cancel multi-step notification workflows, along with the templates scoped to them.
Instance Method Summary collapse
-
#archive(notification_id, template_id:, request_options: {}) ⇒ nil
Archives one journey's notification template, preventing further sends.
-
#create(template_id, channel:, notification:, provider_key: nil, state: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::JourneyTemplateGetResponse
Some parameter documentations has been truncated, see Models::Journeys::TemplateCreateParams for more details.
-
#initialize(client:) ⇒ Templates
constructor
private
A new instance of Templates.
-
#list(template_id, cursor: nil, limit: nil, request_options: {}) ⇒ Courier::Models::JourneyTemplateListResponse
List notification templates scoped to this journey.
-
#list_versions(notification_id, template_id:, request_options: {}) ⇒ Courier::Models::NotificationTemplateVersionListResponse
Lists the published versions of a template that belongs to a journey, most recent first.
-
#publish(notification_id, template_id:, version: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Journeys::TemplatePublishParams for more details.
-
#put_content(notification_id, template_id:, content:, state: nil, request_options: {}) ⇒ Courier::Models::NotificationContentMutationResponse
Some parameter documentations has been truncated, see Models::Journeys::TemplatePutContentParams for more details.
-
#put_locale(locale_id, template_id:, notification_id:, elements:, state: nil, request_options: {}) ⇒ Courier::Models::NotificationContentMutationResponse
Set locale-specific content overrides for a journey-scoped notification template.
-
#replace(notification_id, template_id:, notification:, state: nil, request_options: {}) ⇒ Courier::Models::JourneyTemplateGetResponse
Replaces the draft content of one journey's notification template.
-
#retrieve(notification_id, template_id:, request_options: {}) ⇒ Courier::Models::JourneyTemplateGetResponse
Returns a journey's own notification template with its name, brand, subscription topic, and content.
-
#retrieve_content(notification_id, template_id:, version: nil, request_options: {}) ⇒ Courier::Models::NotificationContentGetResponse
Some parameter documentations has been truncated, see Models::Journeys::TemplateRetrieveContentParams for more details.
Constructor Details
#initialize(client:) ⇒ Templates
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 Templates.
356 357 358 |
# File 'lib/courier/resources/journeys/templates.rb', line 356 def initialize(client:) @client = client end |
Instance Method Details
#archive(notification_id, template_id:, request_options: {}) ⇒ nil
Archives one journey's notification template, preventing further sends. Detach any send node referencing it beforehand.
127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/courier/resources/journeys/templates.rb', line 127 def archive(notification_id, params) parsed, = Courier::Journeys::TemplateArchiveParams.dump_request(params) template_id = parsed.delete(:template_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :delete, path: ["journeys/%1$s/templates/%2$s", template_id, notification_id], model: NilClass, options: ) end |
#create(template_id, channel:, notification:, provider_key: nil, state: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::JourneyTemplateGetResponse
Some parameter documentations has been truncated, see Models::Journeys::TemplateCreateParams for more details.
Create a notification template scoped to this journey. Defaults to DRAFT
state; pass state: "PUBLISHED" to publish on create.
The content tree must contain exactly one channel block whose channel matches
the channel on the request — a journey-scoped template carries a single
channel. Top-level elements, or a block for a different channel, return 400.
The template designer renders only the channel block matching the tab it draws,
so content stored without one cannot be opened. An empty elements array is
accepted.
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/courier/resources/journeys/templates.rb', line 43 def create(template_id, params) parsed, = Courier::Journeys::TemplateCreateParams.dump_request(params) header_params = {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: ["journeys/%1$s/templates", template_id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Courier::JourneyTemplateGetResponse, options: ) end |
#list(template_id, cursor: nil, limit: nil, request_options: {}) ⇒ Courier::Models::JourneyTemplateListResponse
List notification templates scoped to this journey. Journey-scoped notification
templates can only be referenced from send nodes within the same journey.
101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/courier/resources/journeys/templates.rb', line 101 def list(template_id, params = {}) parsed, = Courier::Journeys::TemplateListParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["journeys/%1$s/templates", template_id], query: query, model: Courier::JourneyTemplateListResponse, options: ) end |
#list_versions(notification_id, template_id:, request_options: {}) ⇒ Courier::Models::NotificationTemplateVersionListResponse
Lists the published versions of a template that belongs to a journey, most recent first. Paged by cursor.
155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/courier/resources/journeys/templates.rb', line 155 def list_versions(notification_id, params) parsed, = Courier::Journeys::TemplateListVersionsParams.dump_request(params) template_id = parsed.delete(:template_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :get, path: ["journeys/%1$s/templates/%2$s/versions", template_id, notification_id], model: Courier::NotificationTemplateVersionListResponse, options: ) end |
#publish(notification_id, template_id:, version: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Journeys::TemplatePublishParams for more details.
Publishes a journey-scoped template's draft as a new version. Pass a version instead to roll back the template to an earlier publish.
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/courier/resources/journeys/templates.rb', line 192 def publish(notification_id, params) parsed, = Courier::Journeys::TemplatePublishParams.dump_request(params) template_id = parsed.delete(:template_id) do raise ArgumentError.new("missing required path argument #{_1}") end header_params = {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: ["journeys/%1$s/templates/%2$s/publish", template_id, notification_id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: NilClass, options: ) end |
#put_content(notification_id, template_id:, content:, state: nil, request_options: {}) ⇒ Courier::Models::NotificationContentMutationResponse
Some parameter documentations has been truncated, see Models::Journeys::TemplatePutContentParams for more details.
Replace the elemental content of a journey-scoped notification template. Overwrites all elements in the template draft with the provided content.
231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/courier/resources/journeys/templates.rb', line 231 def put_content(notification_id, params) parsed, = Courier::Journeys::TemplatePutContentParams.dump_request(params) template_id = parsed.delete(:template_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :put, path: ["journeys/%1$s/templates/%2$s/content", template_id, notification_id], body: parsed, model: Courier::NotificationContentMutationResponse, options: ) end |
#put_locale(locale_id, template_id:, notification_id:, elements:, state: nil, request_options: {}) ⇒ Courier::Models::NotificationContentMutationResponse
Set locale-specific content overrides for a journey-scoped notification template. Each element override must reference an existing element by ID.
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/courier/resources/journeys/templates.rb', line 266 def put_locale(locale_id, params) parsed, = Courier::Journeys::TemplatePutLocaleParams.dump_request(params) template_id = parsed.delete(:template_id) do raise ArgumentError.new("missing required path argument #{_1}") end notification_id = parsed.delete(:notification_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :put, path: ["journeys/%1$s/templates/%2$s/locales/%3$s", template_id, notification_id, locale_id], body: parsed, model: Courier::NotificationContentMutationResponse, options: ) end |
#replace(notification_id, template_id:, notification:, state: nil, request_options: {}) ⇒ Courier::Models::JourneyTemplateGetResponse
Replaces the draft content of one journey's notification template. Publish it before send nodes referencing it render the change.
303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'lib/courier/resources/journeys/templates.rb', line 303 def replace(notification_id, params) parsed, = Courier::Journeys::TemplateReplaceParams.dump_request(params) template_id = parsed.delete(:template_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :put, path: ["journeys/%1$s/templates/%2$s", template_id, notification_id], body: parsed, model: Courier::JourneyTemplateGetResponse, options: ) end |
#retrieve(notification_id, template_id:, request_options: {}) ⇒ Courier::Models::JourneyTemplateGetResponse
Returns a journey's own notification template with its name, brand, subscription topic, and content. Defaults to the published version.
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/courier/resources/journeys/templates.rb', line 71 def retrieve(notification_id, params) parsed, = Courier::Journeys::TemplateRetrieveParams.dump_request(params) template_id = parsed.delete(:template_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :get, path: ["journeys/%1$s/templates/%2$s", template_id, notification_id], model: Courier::JourneyTemplateGetResponse, options: ) end |
#retrieve_content(notification_id, template_id:, version: nil, request_options: {}) ⇒ Courier::Models::NotificationContentGetResponse
Some parameter documentations has been truncated, see Models::Journeys::TemplateRetrieveContentParams for more details.
Returns the Elemental elements and version of a journey-scoped template's content. Compare versions to see what changed between publishes.
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/courier/resources/journeys/templates.rb', line 337 def retrieve_content(notification_id, params) parsed, = Courier::Journeys::TemplateRetrieveContentParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) template_id = parsed.delete(:template_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :get, path: ["journeys/%1$s/templates/%2$s/content", template_id, notification_id], query: query, model: Courier::NotificationContentGetResponse, options: ) end |