Class: KlaviyoAPI::TemplatesApi

Inherits:
Object
  • Object
show all
Defined in:
lib/klaviyo-api-sdk/api/templates_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ TemplatesApi

Returns a new instance of TemplatesApi.



19
20
21
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_template(template_create_query, opts = {}) ⇒ Hash<String, Object>

Create Template Create a new custom HTML template. If there are 1,000 or more templates in an account, creation will fail as there is a limit of 1,000 templates that can be created via the API. Request specific fields using [sparse fieldsets](developers.klaviyo.com/en/reference/api_overview#sparse-fieldsets).
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `template:write`

Parameters:

  • template_create_query (TemplateCreateQuery)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Hash<String, Object>)


27
28
29
30
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 27

def create_template(template_create_query, opts = {})
  data, _status_code, _headers = create_template_with_http_info(template_create_query, opts)
  data
end

#create_template_clone(template_clone_query, opts = {}) ⇒ Hash<String, Object>

Create Template Clone Create a clone of a template with the given template ID.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `template:write`

Parameters:

  • template_clone_query (TemplateCloneQuery)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Hash<String, Object>)


97
98
99
100
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 97

def create_template_clone(template_clone_query, opts = {})
  data, _status_code, _headers = create_template_clone_with_http_info(template_clone_query, opts)
  data
end

#create_template_clone_with_http_info(template_clone_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Create Template Clone Create a clone of a template with the given template ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;template:write&#x60;

Parameters:

  • template_clone_query (TemplateCloneQuery)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 107

def create_template_clone_with_http_info(template_clone_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.create_template_clone ...'
  end
  # verify the required parameter 'template_clone_query' is set
  if @api_client.config.client_side_validation && template_clone_query.nil?
    fail ArgumentError, "Missing the required parameter 'template_clone_query' when calling TemplatesApi.create_template_clone"
  end
  # resource path
  local_var_path = '/api/template-clone/'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(template_clone_query)

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key']

  new_options = opts.merge(
    :operation => :"TemplatesApi.create_template_clone",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#create_template_clone\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_template_render(template_render_query, opts = {}) ⇒ Hash<String, Object>

Create Template Render Render a template with the given template ID and context attribute. Returns the HTML and plain text versions of the email template. **Request body parameters** (nested under ‘attributes`): * `return_fields`: Request specific fields using [sparse fieldsets](developers.klaviyo.com/en/reference/api_overview#sparse-fieldsets). * `context`: This is the context your email template will be rendered with. You must pass in a `context` object as a JSON object. Email templates are rendered with contexts in a similar manner to Django templates. Nested template variables can be referenced via dot notation. Template variables without corresponding `context` values are treated as `FALSE` and output nothing. Ex. `{ "name" : "George Washington", "state" : "VA" }`
*Rate limits*:
Burst: `3/s`
Steady: `60/m` Scopes: `templates:read`

Parameters:

  • template_render_query (TemplateRenderQuery)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Hash<String, Object>)


167
168
169
170
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 167

def create_template_render(template_render_query, opts = {})
  data, _status_code, _headers = create_template_render_with_http_info(template_render_query, opts)
  data
end

#create_template_render_with_http_info(template_render_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Create Template Render Render a template with the given template ID and context attribute. Returns the HTML and plain text versions of the email template. **Request body parameters** (nested under &#x60;attributes&#x60;): * &#x60;return_fields&#x60;: Request specific fields using [sparse fieldsets](developers.klaviyo.com/en/reference/api_overview#sparse-fieldsets). * &#x60;context&#x60;: This is the context your email template will be rendered with. You must pass in a &#x60;context&#x60; object as a JSON object. Email templates are rendered with contexts in a similar manner to Django templates. Nested template variables can be referenced via dot notation. Template variables without corresponding &#x60;context&#x60; values are treated as &#x60;FALSE&#x60; and output nothing. Ex. &#x60;{ &quot;name&quot; : &quot;George Washington&quot;, &quot;state&quot; : &quot;VA&quot; }&#x60;&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;3/s&#x60;&lt;br&gt;Steady: &#x60;60/m&#x60; Scopes: &#x60;templates:read&#x60;

Parameters:

  • template_render_query (TemplateRenderQuery)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 177

def create_template_render_with_http_info(template_render_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.create_template_render ...'
  end
  # verify the required parameter 'template_render_query' is set
  if @api_client.config.client_side_validation && template_render_query.nil?
    fail ArgumentError, "Missing the required parameter 'template_render_query' when calling TemplatesApi.create_template_render"
  end
  # resource path
  local_var_path = '/api/template-render/'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(template_render_query)

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key']

  new_options = opts.merge(
    :operation => :"TemplatesApi.create_template_render",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#create_template_render\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_template_with_http_info(template_create_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Create Template Create a new custom HTML template. If there are 1,000 or more templates in an account, creation will fail as there is a limit of 1,000 templates that can be created via the API. Request specific fields using [sparse fieldsets](developers.klaviyo.com/en/reference/api_overview#sparse-fieldsets).&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;template:write&#x60;

Parameters:

  • template_create_query (TemplateCreateQuery)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 37

def create_template_with_http_info(template_create_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.create_template ...'
  end
  # verify the required parameter 'template_create_query' is set
  if @api_client.config.client_side_validation && template_create_query.nil?
    fail ArgumentError, "Missing the required parameter 'template_create_query' when calling TemplatesApi.create_template"
  end
  # resource path
  local_var_path = '/api/templates/'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(template_create_query)

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key']

  new_options = opts.merge(
    :operation => :"TemplatesApi.create_template",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#create_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_template(id, opts = {}) ⇒ nil

Delete Template Delete a template with the given template ID.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `template:write`

Parameters:

  • id (String)

    The ID of template

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


237
238
239
240
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 237

def delete_template(id, opts = {})
  delete_template_with_http_info(id, opts)
  nil
end

#delete_template_with_http_info(id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Delete Template Delete a template with the given template ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;template:write&#x60;

Parameters:

  • id (String)

    The ID of template

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 247

def delete_template_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.delete_template ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling TemplatesApi.delete_template"
  end
  # resource path
  local_var_path = '/api/templates/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key']

  new_options = opts.merge(
    :operation => :"TemplatesApi.delete_template",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#delete_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_template(id, opts = {}) ⇒ Hash<String, Object>

Get Template Get a template with the given template ID.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `templates:read`

Parameters:

  • id (String)

    The ID of template

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


303
304
305
306
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 303

def get_template(id, opts = {})
  data, _status_code, _headers = get_template_with_http_info(id, opts)
  data
end

#get_template_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Get Template Get a template with the given template ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;templates:read&#x60;

Parameters:

  • id (String)

    The ID of template

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 314

def get_template_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.get_template ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling TemplatesApi.get_template"
  end
  allowable_values = ["name", "editor_type", "html", "text", "created", "updated"]
  if @api_client.config.client_side_validation && opts[:'fields_template'] && !opts[:'fields_template'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_template\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/templates/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[template]'] = @api_client.build_collection_param(opts[:'fields_template'], :csv) if !opts[:'fields_template'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key']

  new_options = opts.merge(
    :operation => :"TemplatesApi.get_template",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#get_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_templates(opts = {}) ⇒ Hash<String, Object>

Get Templates Get all templates in an account. Filter to request a subset of all templates. Templates can be sorted by the following fields, in ascending and descending order: ‘id`, `name`, `created`, `updated` Returns a maximum of 10 results per page.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` Scopes: `templates:read`

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


377
378
379
380
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 377

def get_templates(opts = {})
  data, _status_code, _headers = get_templates_with_http_info(opts)
  data
end

#get_templates_with_http_info(opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Get Templates Get all templates in an account. Filter to request a subset of all templates. Templates can be sorted by the following fields, in ascending and descending order: &#x60;id&#x60;, &#x60;name&#x60;, &#x60;created&#x60;, &#x60;updated&#x60; Returns a maximum of 10 results per page.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;templates:read&#x60;

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 390

def get_templates_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.get_templates ...'
  end
  allowable_values = ["name", "editor_type", "html", "text", "created", "updated"]
  if @api_client.config.client_side_validation && opts[:'fields_template'] && !opts[:'fields_template'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_template\", must include one of #{allowable_values}"
  end
  allowable_values = ["created", "-created", "id", "-id", "name", "-name", "updated", "-updated"]
  if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
    fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/templates/'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[template]'] = @api_client.build_collection_param(opts[:'fields_template'], :csv) if !opts[:'fields_template'].nil?
  query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?
  query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key']

  new_options = opts.merge(
    :operation => :"TemplatesApi.get_templates",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#get_templates\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_template(id, template_update_query, opts = {}) ⇒ Hash<String, Object>

Update Template Update a template with the given template ID. Does not currently update drag & drop templates.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `template:write`

Parameters:

  • id (String)

    The ID of template

  • template_update_query (TemplateUpdateQuery)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Hash<String, Object>)


454
455
456
457
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 454

def update_template(id, template_update_query, opts = {})
  data, _status_code, _headers = update_template_with_http_info(id, template_update_query, opts)
  data
end

#update_template_with_http_info(id, template_update_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Update Template Update a template with the given template ID. Does not currently update drag &amp; drop templates.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;template:write&#x60;

Parameters:

  • id (String)

    The ID of template

  • template_update_query (TemplateUpdateQuery)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
# File 'lib/klaviyo-api-sdk/api/templates_api.rb', line 465

def update_template_with_http_info(id, template_update_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.update_template ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling TemplatesApi.update_template"
  end
  # verify the required parameter 'template_update_query' is set
  if @api_client.config.client_side_validation && template_update_query.nil?
    fail ArgumentError, "Missing the required parameter 'template_update_query' when calling TemplatesApi.update_template"
  end
  # resource path
  local_var_path = '/api/templates/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(template_update_query)

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key']

  new_options = opts.merge(
    :operation => :"TemplatesApi.update_template",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#update_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end