Class: Courier::Resources::Journeys::Templates
- Inherits:
-
Object
- Object
- Courier::Resources::Journeys::Templates
- Defined in:
- lib/courier/resources/journeys/templates.rb
Instance Method Summary collapse
-
#archive(notification_id, template_id:, request_options: {}) ⇒ nil
Archive the journey-scoped notification template.
-
#create(template_id, channel:, notification:, provider_key: nil, state: nil, request_options: {}) ⇒ Courier::Models::JourneyTemplateGetResponse
Create a notification template scoped to this journey.
-
#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
List published versions of the journey-scoped notification template, ordered most recent first.
-
#publish(notification_id, template_id:, version: nil, request_options: {}) ⇒ nil
Publish the current draft of the journey-scoped notification template as a new version.
-
#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
Replace the journey-scoped notification template draft.
-
#retrieve(notification_id, template_id:, request_options: {}) ⇒ Courier::Models::JourneyTemplateGetResponse
Fetch a journey-scoped notification template by id.
-
#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.
331 332 333 |
# File 'lib/courier/resources/journeys/templates.rb', line 331 def initialize(client:) @client = client end |
Instance Method Details
#archive(notification_id, template_id:, request_options: {}) ⇒ nil
Archive the journey-scoped notification template. Archived templates cannot be sent.
109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/courier/resources/journeys/templates.rb', line 109 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, request_options: {}) ⇒ Courier::Models::JourneyTemplateGetResponse
Create a notification template scoped to this journey. Defaults to ‘DRAFT` state; pass `state: “PUBLISHED”` to publish on create.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/courier/resources/journeys/templates.rb', line 27 def create(template_id, params) parsed, = Courier::Journeys::TemplateCreateParams.dump_request(params) @client.request( method: :post, path: ["journeys/%1$s/templates", template_id], body: parsed, 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.
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/courier/resources/journeys/templates.rb', line 83 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
List published versions of the journey-scoped notification template, ordered most recent first.
137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/courier/resources/journeys/templates.rb', line 137 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, request_options: {}) ⇒ nil
Publish the current draft of the journey-scoped notification template as a new version. Optionally roll back to a prior version by passing ‘{ “version”: “vN” }`.
168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/courier/resources/journeys/templates.rb', line 168 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 @client.request( method: :post, path: ["journeys/%1$s/templates/%2$s/publish", template_id, notification_id], body: parsed, 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.
204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/courier/resources/journeys/templates.rb', line 204 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.
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/courier/resources/journeys/templates.rb', line 239 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
Replace the journey-scoped notification template draft.
275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/courier/resources/journeys/templates.rb', line 275 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
Fetch a journey-scoped notification template by id. Pass ‘?version=draft` (default `published`) to retrieve the working draft, or `?version=vN` for a historical version.
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/courier/resources/journeys/templates.rb', line 53 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.
Retrieve the elemental content of a journey-scoped notification template. The response contains the versioned elements along with their content checksums, which can be used to detect changes between versions. Pass ‘?version=draft` (default `published`) to retrieve the working draft, or `?version=vN` for a historical version.
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'lib/courier/resources/journeys/templates.rb', line 312 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 |