Class: Telnyx::Resources::EmailTemplates
- Inherits:
-
Object
- Object
- Telnyx::Resources::EmailTemplates
- Defined in:
- lib/telnyx/resources/email_templates.rb,
sig/telnyx/resources/email_templates.rbs
Overview
Create, list, retrieve, update, delete, and render Liquid email templates.
Instance Method Summary collapse
-
#create(name:, html_body: nil, subject: nil, text_body: nil, variables: nil, idempotency_key: nil, request_options: {}) ⇒ Telnyx::Models::EmailTemplateResponse
Some parameter documentations has been truncated, see Models::EmailTemplateCreateParams for more details.
-
#delete(id, request_options: {}) ⇒ nil
Delete an email template.
-
#initialize(client:) ⇒ EmailTemplates
constructor
private
A new instance of EmailTemplates.
-
#list(page_cursor: nil, page_size: nil, request_options: {}) ⇒ Telnyx::Models::EmailTemplateListResponse
Some parameter documentations has been truncated, see Models::EmailTemplateListParams for more details.
-
#render(id, template_variables: nil, request_options: {}) ⇒ Telnyx::Models::EmailTemplateRenderResponse
Some parameter documentations has been truncated, see Models::EmailTemplateRenderParams for more details.
-
#replace(id, html_body: nil, name: nil, subject: nil, text_body: nil, variables: nil, request_options: {}) ⇒ Telnyx::Models::EmailTemplateResponse
Replaces template fields.
-
#retrieve(id, request_options: {}) ⇒ Telnyx::Models::EmailTemplateResponse
Get an email template.
-
#update(id, html_body: nil, name: nil, subject: nil, text_body: nil, variables: nil, request_options: {}) ⇒ Telnyx::Models::EmailTemplateResponse
Updates one or more template fields.
Constructor Details
#initialize(client:) ⇒ EmailTemplates
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 EmailTemplates.
208 209 210 |
# File 'lib/telnyx/resources/email_templates.rb', line 208 def initialize(client:) @client = client end |
Instance Method Details
#create(name:, html_body: nil, subject: nil, text_body: nil, variables: nil, idempotency_key: nil, request_options: {}) ⇒ Telnyx::Models::EmailTemplateResponse
Some parameter documentations has been truncated, see Models::EmailTemplateCreateParams for more details.
Creates a Liquid email template. Variables are auto-extracted when omitted.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/telnyx/resources/email_templates.rb', line 31 def create(params) parsed, = Telnyx::EmailTemplateCreateParams.dump_request(params) header_params = {idempotency_key: "idempotency-key"} @client.request( method: :post, path: "email_templates", headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Telnyx::EmailTemplateResponse, options: ) end |
#delete(id, request_options: {}) ⇒ nil
Delete an email template
135 136 137 138 139 140 141 142 |
# File 'lib/telnyx/resources/email_templates.rb', line 135 def delete(id, params = {}) @client.request( method: :delete, path: ["email_templates/%1$s", id], model: NilClass, options: params[:request_options] ) end |
#list(page_cursor: nil, page_size: nil, request_options: {}) ⇒ Telnyx::Models::EmailTemplateListResponse
Some parameter documentations has been truncated, see Models::EmailTemplateListParams for more details.
Lists templates sorted newest first by created_at desc, id desc.
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/telnyx/resources/email_templates.rb', line 112 def list(params = {}) parsed, = Telnyx::EmailTemplateListParams.dump_request(params) query = Telnyx::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "email_templates", query: query, model: Telnyx::Models::EmailTemplateListResponse, options: ) end |
#render(id, template_variables: nil, request_options: {}) ⇒ Telnyx::Models::EmailTemplateRenderResponse
Some parameter documentations has been truncated, see Models::EmailTemplateRenderParams for more details.
Renders a template using the provided Liquid variables. Missing
template_variables defaults to {}.
161 162 163 164 165 166 167 168 169 170 |
# File 'lib/telnyx/resources/email_templates.rb', line 161 def render(id, params = {}) parsed, = Telnyx::EmailTemplateRenderParams.dump_request(params) @client.request( method: :post, path: ["email_templates/%1$s/render", id], body: parsed, model: Telnyx::Models::EmailTemplateRenderResponse, options: ) end |
#replace(id, html_body: nil, name: nil, subject: nil, text_body: nil, variables: nil, request_options: {}) ⇒ Telnyx::Models::EmailTemplateResponse
Replaces template fields. Behaves identically to PATCH; provided for compatibility with Phoenix resource routes.
194 195 196 197 198 199 200 201 202 203 |
# File 'lib/telnyx/resources/email_templates.rb', line 194 def replace(id, params = {}) parsed, = Telnyx::EmailTemplateReplaceParams.dump_request(params) @client.request( method: :put, path: ["email_templates/%1$s", id], body: parsed, model: Telnyx::EmailTemplateResponse, options: ) end |
#retrieve(id, request_options: {}) ⇒ Telnyx::Models::EmailTemplateResponse
Get an email template
55 56 57 58 59 60 61 62 |
# File 'lib/telnyx/resources/email_templates.rb', line 55 def retrieve(id, params = {}) @client.request( method: :get, path: ["email_templates/%1$s", id], model: Telnyx::EmailTemplateResponse, options: params[:request_options] ) end |
#update(id, html_body: nil, name: nil, subject: nil, text_body: nil, variables: nil, request_options: {}) ⇒ Telnyx::Models::EmailTemplateResponse
Updates one or more template fields.
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/telnyx/resources/email_templates.rb', line 85 def update(id, params = {}) parsed, = Telnyx::EmailTemplateUpdateParams.dump_request(params) @client.request( method: :patch, path: ["email_templates/%1$s", id], body: parsed, model: Telnyx::EmailTemplateResponse, options: ) end |