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.
-
#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.
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.
218 219 220 |
# File 'lib/courier/resources/journeys/templates.rb', line 218 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 |
#replace(notification_id, template_id:, notification:, state: nil, request_options: {}) ⇒ Courier::Models::JourneyTemplateGetResponse
Replace the journey-scoped notification template draft.
200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/courier/resources/journeys/templates.rb', line 200 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 |