Class: Courier::Resources::Tenants::Templates
- Inherits:
-
Object
- Object
- Courier::Resources::Tenants::Templates
- Defined in:
- lib/courier/resources/tenants/templates.rb,
lib/courier/resources/tenants/templates/versions.rb,
sig/courier/resources/tenants/templates.rbs,
sig/courier/resources/tenants/templates/versions.rbs
Overview
Manage the templates and template versions scoped to a single tenant, including the ones authored in the embedded designer.
Defined Under Namespace
Classes: Versions
Instance Attribute Summary collapse
-
#versions ⇒ Courier::Resources::Tenants::Templates::Versions
readonly
Manage the templates and template versions scoped to a single tenant, including the ones authored in the embedded designer.
Instance Method Summary collapse
-
#delete(template_id, tenant_id:, request_options: {}) ⇒ nil
Deletes a tenant's notification template by id.
-
#initialize(client:) ⇒ Templates
constructor
private
A new instance of Templates.
-
#list(tenant_id, cursor: nil, limit: nil, request_options: {}) ⇒ Courier::Models::Tenants::TemplateListResponse
Lists a tenant's notification templates, each carrying its version and published timestamp.
-
#publish(template_id, tenant_id:, version: nil, request_options: {}) ⇒ Courier::Models::PostTenantTemplatePublishResponse
Some parameter documentations has been truncated, see Models::Tenants::TemplatePublishParams for more details.
-
#replace(template_id, tenant_id:, template:, published: nil, request_options: {}) ⇒ Courier::Models::PutTenantTemplateResponse
Some parameter documentations has been truncated, see Models::Tenants::TemplateReplaceParams for more details.
-
#retrieve(template_id, tenant_id:, request_options: {}) ⇒ Courier::Models::BaseTemplateTenantAssociation
Returns a tenant's notification template with its content, version, and created, updated, and published timestamps.
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.
181 182 183 184 |
# File 'lib/courier/resources/tenants/templates.rb', line 181 def initialize(client:) @client = client @versions = Courier::Resources::Tenants::Templates::Versions.new(client: client) end |
Instance Attribute Details
#versions ⇒ Courier::Resources::Tenants::Templates::Versions (readonly)
Manage the templates and template versions scoped to a single tenant, including the ones authored in the embedded designer.
12 13 14 |
# File 'lib/courier/resources/tenants/templates.rb', line 12 def versions @versions end |
Instance Method Details
#delete(template_id, tenant_id:, request_options: {}) ⇒ nil
Deletes a tenant's notification template by id. Sends for that tenant then use the workspace template registered under the same id.
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/courier/resources/tenants/templates.rb', line 84 def delete(template_id, params) parsed, = Courier::Tenants::TemplateDeleteParams.dump_request(params) tenant_id = parsed.delete(:tenant_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :delete, path: ["tenants/%1$s/templates/%2$s", tenant_id, template_id], model: NilClass, options: ) end |
#list(tenant_id, cursor: nil, limit: nil, request_options: {}) ⇒ Courier::Models::Tenants::TemplateListResponse
Lists a tenant's notification templates, each carrying its version and published timestamp. Paged.
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/courier/resources/tenants/templates.rb', line 58 def list(tenant_id, params = {}) parsed, = Courier::Tenants::TemplateListParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["tenants/%1$s/templates", tenant_id], query: query, model: Courier::Models::Tenants::TemplateListResponse, options: ) end |
#publish(template_id, tenant_id:, version: nil, request_options: {}) ⇒ Courier::Models::PostTenantTemplatePublishResponse
Some parameter documentations has been truncated, see Models::Tenants::TemplatePublishParams for more details.
Publishes a version of a tenant's notification template, making it the content that tenant's sends render from until you publish another.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/courier/resources/tenants/templates.rb', line 117 def publish(template_id, params) parsed, = Courier::Tenants::TemplatePublishParams.dump_request(params) tenant_id = parsed.delete(:tenant_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :post, path: ["tenants/%1$s/templates/%2$s/publish", tenant_id, template_id], body: parsed, model: Courier::PostTenantTemplatePublishResponse, options: ) end |
#replace(template_id, tenant_id:, template:, published: nil, request_options: {}) ⇒ Courier::Models::PutTenantTemplateResponse
Some parameter documentations has been truncated, see Models::Tenants::TemplateReplaceParams for more details.
Creates or updates a notification template scoped to one tenant, letting a tenant override the content the workspace template would send.
This is an upsert: it creates when the tenant has no template under
template_id, and updates when it does. On the create half, content must place
its elements inside a channel block —
{ "type": "channel", "channel": "email", "elements": [...] } — or the request
returns 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, as is the { title, body } shorthand, which has
no elements to wrap. Updates are not checked, so tenant templates already stored
without a wrapper stay editable.
163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/courier/resources/tenants/templates.rb', line 163 def replace(template_id, params) parsed, = Courier::Tenants::TemplateReplaceParams.dump_request(params) tenant_id = parsed.delete(:tenant_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :put, path: ["tenants/%1$s/templates/%2$s", tenant_id, template_id], body: parsed, model: Courier::PutTenantTemplateResponse, options: ) end |
#retrieve(template_id, tenant_id:, request_options: {}) ⇒ Courier::Models::BaseTemplateTenantAssociation
Returns a tenant's notification template with its content, version, and created, updated, and published timestamps.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/courier/resources/tenants/templates.rb', line 28 def retrieve(template_id, params) parsed, = Courier::Tenants::TemplateRetrieveParams.dump_request(params) tenant_id = parsed.delete(:tenant_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :get, path: ["tenants/%1$s/templates/%2$s", tenant_id, template_id], model: Courier::BaseTemplateTenantAssociation, options: ) end |