Class: Sentdm::Resources::Templates
- Inherits:
-
Object
- Object
- Sentdm::Resources::Templates
- Defined in:
- lib/sentdm/resources/templates.rb
Overview
Manage message templates with variable substitution
Instance Method Summary collapse
-
#create(category: nil, creation_source: nil, definition: nil, language: nil, submit_for_review: nil, test_mode: nil, idempotency_key: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseTemplate
Some parameter documentations has been truncated, see Models::TemplateCreateParams for more details.
-
#delete(id, delete_from_meta: nil, test_mode: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::TemplateDeleteParams for more details.
-
#initialize(client:) ⇒ Templates
constructor
private
A new instance of Templates.
-
#list(page:, page_size:, category: nil, search: nil, status: nil, request_options: {}) ⇒ Sentdm::Models::TemplateListResponse
Retrieves a paginated list of message templates for the authenticated customer.
-
#retrieve(id, request_options: {}) ⇒ Sentdm::Models::APIResponseTemplate
Retrieves a specific template by its ID.
-
#update(id, category: nil, definition: nil, language: nil, name: nil, submit_for_review: nil, test_mode: nil, idempotency_key: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseTemplate
Some parameter documentations has been truncated, see Models::TemplateUpdateParams for more details.
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.
177 178 179 |
# File 'lib/sentdm/resources/templates.rb', line 177 def initialize(client:) @client = client end |
Instance Method Details
#create(category: nil, creation_source: nil, definition: nil, language: nil, submit_for_review: nil, test_mode: nil, idempotency_key: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseTemplate
Some parameter documentations has been truncated, see Models::TemplateCreateParams for more details.
Creates a new message template with header, body, footer, and buttons. The template can be submitted for review immediately or saved as draft for later submission.
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/sentdm/resources/templates.rb', line 35 def create(params = {}) parsed, = Sentdm::TemplateCreateParams.dump_request(params) header_params = {idempotency_key: "idempotency-key"} @client.request( method: :post, path: "v3/templates", headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Sentdm::APIResponseTemplate, options: ) end |
#delete(id, delete_from_meta: nil, test_mode: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::TemplateDeleteParams for more details.
Deletes a template by ID. Optionally, you can also delete the template from WhatsApp/Meta by setting delete_from_meta=true.
162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/sentdm/resources/templates.rb', line 162 def delete(id, params = {}) parsed, = Sentdm::TemplateDeleteParams.dump_request(params) @client.request( method: :delete, path: ["v3/templates/%1$s", id], headers: {"content-type" => "*/*"}, body: parsed, model: NilClass, options: ) end |
#list(page:, page_size:, category: nil, search: nil, status: nil, request_options: {}) ⇒ Sentdm::Models::TemplateListResponse
Retrieves a paginated list of message templates for the authenticated customer. Supports filtering by status, category, and search term.
131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/sentdm/resources/templates.rb', line 131 def list(params) parsed, = Sentdm::TemplateListParams.dump_request(params) query = Sentdm::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "v3/templates", query: query.transform_keys(page_size: "pageSize"), model: Sentdm::Models::TemplateListResponse, options: ) end |
#retrieve(id, request_options: {}) ⇒ Sentdm::Models::APIResponseTemplate
Retrieves a specific template by its ID. Returns template details including name, category, language, status, and definition.
60 61 62 63 64 65 66 67 |
# File 'lib/sentdm/resources/templates.rb', line 60 def retrieve(id, params = {}) @client.request( method: :get, path: ["v3/templates/%1$s", id], model: Sentdm::APIResponseTemplate, options: params[:request_options] ) end |
#update(id, category: nil, definition: nil, language: nil, name: nil, submit_for_review: nil, test_mode: nil, idempotency_key: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseTemplate
Some parameter documentations has been truncated, see Models::TemplateUpdateParams for more details.
Updates an existing template’s name, category, language, definition, or submits it for review.
98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/sentdm/resources/templates.rb', line 98 def update(id, params = {}) parsed, = Sentdm::TemplateUpdateParams.dump_request(params) header_params = {idempotency_key: "idempotency-key"} @client.request( method: :put, path: ["v3/templates/%1$s", id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Sentdm::APIResponseTemplate, options: ) end |