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
-
#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.
144 145 146 147 |
# File 'lib/courier/resources/tenants/templates.rb', line 144 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
#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.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/courier/resources/tenants/templates.rb', line 85 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.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/courier/resources/tenants/templates.rb', line 126 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 |