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, sandbox: nil, submit_for_review: nil, idempotency_key: nil, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseTemplate
Some parameter documentations has been truncated, see Models::TemplateCreateParams for more details.
-
#delete(id, delete_from_meta: nil, sandbox: nil, x_profile_id: 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, is_welcome_playground: nil, search: nil, status: nil, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::TemplateListResponse
Some parameter documentations has been truncated, see Models::TemplateListParams for more details.
-
#retrieve(id, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseTemplate
Some parameter documentations has been truncated, see Models::TemplateRetrieveParams for more details.
-
#update(id, category: nil, definition: nil, language: nil, name: nil, sandbox: nil, submit_for_review: nil, idempotency_key: nil, x_profile_id: 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.
200 201 202 |
# File 'lib/sentdm/resources/templates.rb', line 200 def initialize(client:) @client = client end |
Instance Method Details
#create(category: nil, creation_source: nil, definition: nil, language: nil, sandbox: nil, submit_for_review: nil, idempotency_key: nil, x_profile_id: 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.
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/sentdm/resources/templates.rb', line 37 def create(params = {}) parsed, = Sentdm::TemplateCreateParams.dump_request(params) header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"} @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, sandbox: nil, x_profile_id: 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.
184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/sentdm/resources/templates.rb', line 184 def delete(id, params = {}) parsed, = Sentdm::TemplateDeleteParams.dump_request(params) header_params = {x_profile_id: "x-profile-id"} @client.request( method: :delete, path: ["v3/templates/%1$s", id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: NilClass, options: ) end |
#list(page:, page_size:, category: nil, is_welcome_playground: nil, search: nil, status: nil, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::TemplateListResponse
Some parameter documentations has been truncated, see Models::TemplateListParams for more details.
Retrieves a paginated list of message templates for the authenticated customer. Supports filtering by status, category, and search term.
149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/sentdm/resources/templates.rb', line 149 def list(params) query_params = [:page, :page_size, :category, :is_welcome_playground, :search, :status] parsed, = Sentdm::TemplateListParams.dump_request(params) query = Sentdm::Internal::Util.encode_query_params(parsed.slice(*query_params)) @client.request( method: :get, path: "v3/templates", query: query, headers: parsed.except(*query_params).transform_keys(x_profile_id: "x-profile-id"), model: Sentdm::Models::TemplateListResponse, options: ) end |
#retrieve(id, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseTemplate
Some parameter documentations has been truncated, see Models::TemplateRetrieveParams for more details.
Retrieves a specific template by its ID. Returns template details including name, category, language, status, and definition.
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/sentdm/resources/templates.rb', line 67 def retrieve(id, params = {}) parsed, = Sentdm::TemplateRetrieveParams.dump_request(params) @client.request( method: :get, path: ["v3/templates/%1$s", id], headers: parsed.transform_keys(x_profile_id: "x-profile-id"), model: Sentdm::APIResponseTemplate, options: ) end |
#update(id, category: nil, definition: nil, language: nil, name: nil, sandbox: nil, submit_for_review: nil, idempotency_key: nil, x_profile_id: 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.
109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/sentdm/resources/templates.rb', line 109 def update(id, params = {}) parsed, = Sentdm::TemplateUpdateParams.dump_request(params) header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"} @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 |