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
Defined Under Namespace
Classes: Versions
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#delete(template_id, tenant_id:, request_options: {}) ⇒ nil
Deletes the tenant’s notification template with the given ‘template_id`.
-
#initialize(client:) ⇒ Templates
constructor
private
A new instance of Templates.
-
#list(tenant_id, cursor: nil, limit: nil, request_options: {}) ⇒ Courier::Models::Tenants::TemplateListResponse
List Templates in Tenant.
-
#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
Get a Template in Tenant.
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.
176 177 178 179 |
# File 'lib/courier/resources/tenants/templates.rb', line 176 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)
8 9 10 |
# File 'lib/courier/resources/tenants/templates.rb', line 8 def versions @versions end |
Instance Method Details
#delete(template_id, tenant_id:, request_options: {}) ⇒ nil
Deletes the tenant’s notification template with the given ‘template_id`.
Returns **204 No Content** with an empty body on success.
Returns 404 if there is no template with this ID for the tenant, including a second ‘DELETE` after a successful removal.
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/courier/resources/tenants/templates.rb', line 82 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
List Templates in Tenant
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/courier/resources/tenants/templates.rb', line 52 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 specific version of a notification template for a tenant.
The template must already exist in the tenant’s notification map. If no version is specified, defaults to publishing the “latest” version.
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 for a tenant.
If the template already exists for the tenant, it will be updated (200). Otherwise, a new template is created (201).
Optionally publishes the template immediately if the ‘published` flag is set to true.
158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/courier/resources/tenants/templates.rb', line 158 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
Get a Template in Tenant
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/courier/resources/tenants/templates.rb', line 23 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 |