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.
349 350 351 |
# File 'lib/courier/resources/journeys/templates.rb', line 349 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.
120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/courier/resources/journeys/templates.rb', line 120 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.
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/courier/resources/journeys/templates.rb', line 36 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.
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/courier/resources/journeys/templates.rb', line 94 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.
148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/courier/resources/journeys/templates.rb', line 148 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.
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/courier/resources/journeys/templates.rb', line 185 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.
224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/courier/resources/journeys/templates.rb', line 224 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.
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/courier/resources/journeys/templates.rb', line 259 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.
296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/courier/resources/journeys/templates.rb', line 296 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.
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/courier/resources/journeys/templates.rb', line 64 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.
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
# File 'lib/courier/resources/journeys/templates.rb', line 330 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 |