klaviyo_sdk 1.0.0.20220329

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +6 -0
  3. data/README.md +1121 -0
  4. data/klaviyo_sdk.gemspec +35 -0
  5. data/lib/klaviyo_sdk/api/campaigns_api.rb +717 -0
  6. data/lib/klaviyo_sdk/api/data_privacy_api.rb +86 -0
  7. data/lib/klaviyo_sdk/api/lists_segments_api.rb +1101 -0
  8. data/lib/klaviyo_sdk/api/metrics_api.rb +343 -0
  9. data/lib/klaviyo_sdk/api/profiles_api.rb +381 -0
  10. data/lib/klaviyo_sdk/api/templates_api.rb +555 -0
  11. data/lib/klaviyo_sdk/api/track_identify_api.rb +288 -0
  12. data/lib/klaviyo_sdk/api_client.rb +389 -0
  13. data/lib/klaviyo_sdk/api_error.rb +57 -0
  14. data/lib/klaviyo_sdk/configuration.rb +278 -0
  15. data/lib/klaviyo_sdk/models/campaign.rb +310 -0
  16. data/lib/klaviyo_sdk/models/check_membership_request.rb +244 -0
  17. data/lib/klaviyo_sdk/models/delete_email.rb +218 -0
  18. data/lib/klaviyo_sdk/models/delete_person.rb +218 -0
  19. data/lib/klaviyo_sdk/models/delete_phone.rb +219 -0
  20. data/lib/klaviyo_sdk/models/deprecated_get_list_response.rb +298 -0
  21. data/lib/klaviyo_sdk/models/deprecated_get_list_response_data.rb +263 -0
  22. data/lib/klaviyo_sdk/models/global_exclusion_response_data.rb +274 -0
  23. data/lib/klaviyo_sdk/models/identify_payload.rb +237 -0
  24. data/lib/klaviyo_sdk/models/identify_payload_properties.rb +327 -0
  25. data/lib/klaviyo_sdk/models/inline_object.rb +220 -0
  26. data/lib/klaviyo_sdk/models/inline_object3.rb +226 -0
  27. data/lib/klaviyo_sdk/models/inline_object4.rb +254 -0
  28. data/lib/klaviyo_sdk/models/inline_object5.rb +288 -0
  29. data/lib/klaviyo_sdk/models/metric.rb +265 -0
  30. data/lib/klaviyo_sdk/models/metric_export.rb +285 -0
  31. data/lib/klaviyo_sdk/models/metric_timeline.rb +271 -0
  32. data/lib/klaviyo_sdk/models/metric_timeline_data.rb +294 -0
  33. data/lib/klaviyo_sdk/models/person.rb +389 -0
  34. data/lib/klaviyo_sdk/models/person.rb.bak +389 -0
  35. data/lib/klaviyo_sdk/models/privacy_email.rb +218 -0
  36. data/lib/klaviyo_sdk/models/privacy_id.rb +218 -0
  37. data/lib/klaviyo_sdk/models/privacy_phone.rb +218 -0
  38. data/lib/klaviyo_sdk/models/rendered_template.rb +247 -0
  39. data/lib/klaviyo_sdk/models/template.rb +272 -0
  40. data/lib/klaviyo_sdk/models/track_payload.rb +261 -0
  41. data/lib/klaviyo_sdk/models/track_payload_customer_properties.rb +227 -0
  42. data/lib/klaviyo_sdk/models/track_payload_properties.rb +237 -0
  43. data/lib/klaviyo_sdk/version.rb +15 -0
  44. data/lib/klaviyo_sdk.rb +124 -0
  45. metadata +120 -0
@@ -0,0 +1,555 @@
1
+ =begin
2
+ #Klaviyo API
3
+
4
+ #Empowering creators to own their destiny
5
+
6
+ The version of the OpenAPI document: 2022.03.29
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.4.0
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module Client
16
+ class TemplatesApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Clone Template
23
+ # Creates a copy of a given template with a new name.
24
+ # @param template_id [String]
25
+ # @param name [String] The new name of the email template.
26
+ # @param [Hash] opts the optional parameters
27
+ # @return [Template]
28
+ def clone_template(template_id, name, opts = {})
29
+ data, _status_code, _headers = clone_template_with_http_info(template_id, name, opts)
30
+ data
31
+ end
32
+
33
+ # Clone Template
34
+ # Creates a copy of a given template with a new name.
35
+ # @param template_id [String]
36
+ # @param name [String] The new name of the email template.
37
+ # @param [Hash] opts the optional parameters
38
+ # @return [Array<(Template, Integer, Hash)>] Template data, response status code and response headers
39
+ def clone_template_with_http_info(template_id, name, opts = {})
40
+ if @api_client.config.debugging
41
+ @api_client.config.logger.debug 'Calling API: TemplatesApi.clone_template ...'
42
+ end
43
+ # verify the required parameter 'template_id' is set
44
+ if @api_client.config.client_side_validation && template_id.nil?
45
+ fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplatesApi.clone_template"
46
+ end
47
+ # verify the required parameter 'name' is set
48
+ if @api_client.config.client_side_validation && name.nil?
49
+ fail ArgumentError, "Missing the required parameter 'name' when calling TemplatesApi.clone_template"
50
+ end
51
+ # resource path
52
+ local_var_path = '/v1/email-template/{template_id}/clone'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))
53
+
54
+ # query parameters
55
+ query_params = opts[:query_params] || {}
56
+
57
+ # header parameters
58
+ header_params = opts[:header_params] || {}
59
+ # HTTP header 'Accept' (if needed)
60
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
61
+ # HTTP header 'Content-Type'
62
+ content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
63
+ if !content_type.nil?
64
+ header_params['Content-Type'] = content_type
65
+ end
66
+
67
+ # form parameters
68
+ form_params = opts[:form_params] || {}
69
+ form_params['name'] = name
70
+
71
+ # http body (model)
72
+ post_body = opts[:body]
73
+
74
+ # return_type
75
+ return_type = opts[:debug_return_type] || 'Template'
76
+
77
+ # auth_names
78
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
79
+
80
+ new_options = opts.merge(
81
+ :operation => :"TemplatesApi.clone_template",
82
+ :header_params => header_params,
83
+ :query_params => query_params,
84
+ :form_params => form_params,
85
+ :body => post_body,
86
+ :auth_names => auth_names,
87
+ :return_type => return_type
88
+ )
89
+
90
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
91
+ if @api_client.config.debugging
92
+ @api_client.config.logger.debug "API called: TemplatesApi#clone_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
93
+ end
94
+ return data, status_code, headers
95
+ end
96
+
97
+ # Create New Template
98
+ # Creates a new email template.
99
+ # @param name [String] The name of the email template.
100
+ # @param html [String]
101
+ # @param [Hash] opts the optional parameters
102
+ # @return [Template]
103
+ def create_template(name, html, opts = {})
104
+ data, _status_code, _headers = create_template_with_http_info(name, html, opts)
105
+ data
106
+ end
107
+
108
+ # Create New Template
109
+ # Creates a new email template.
110
+ # @param name [String] The name of the email template.
111
+ # @param html [String]
112
+ # @param [Hash] opts the optional parameters
113
+ # @return [Array<(Template, Integer, Hash)>] Template data, response status code and response headers
114
+ def create_template_with_http_info(name, html, opts = {})
115
+ if @api_client.config.debugging
116
+ @api_client.config.logger.debug 'Calling API: TemplatesApi.create_template ...'
117
+ end
118
+ # verify the required parameter 'name' is set
119
+ if @api_client.config.client_side_validation && name.nil?
120
+ fail ArgumentError, "Missing the required parameter 'name' when calling TemplatesApi.create_template"
121
+ end
122
+ # verify the required parameter 'html' is set
123
+ if @api_client.config.client_side_validation && html.nil?
124
+ fail ArgumentError, "Missing the required parameter 'html' when calling TemplatesApi.create_template"
125
+ end
126
+ # resource path
127
+ local_var_path = '/v1/email-templates'
128
+
129
+ # query parameters
130
+ query_params = opts[:query_params] || {}
131
+
132
+ # header parameters
133
+ header_params = opts[:header_params] || {}
134
+ # HTTP header 'Accept' (if needed)
135
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
136
+ # HTTP header 'Content-Type'
137
+ content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
138
+ if !content_type.nil?
139
+ header_params['Content-Type'] = content_type
140
+ end
141
+
142
+ # form parameters
143
+ form_params = opts[:form_params] || {}
144
+ form_params['name'] = name
145
+ form_params['html'] = html
146
+
147
+ # http body (model)
148
+ post_body = opts[:body]
149
+
150
+ # return_type
151
+ return_type = opts[:debug_return_type] || 'Template'
152
+
153
+ # auth_names
154
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
155
+
156
+ new_options = opts.merge(
157
+ :operation => :"TemplatesApi.create_template",
158
+ :header_params => header_params,
159
+ :query_params => query_params,
160
+ :form_params => form_params,
161
+ :body => post_body,
162
+ :auth_names => auth_names,
163
+ :return_type => return_type
164
+ )
165
+
166
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
167
+ if @api_client.config.debugging
168
+ @api_client.config.logger.debug "API called: TemplatesApi#create_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
169
+ end
170
+ return data, status_code, headers
171
+ end
172
+
173
+ # Delete Template
174
+ # Deletes a given template.
175
+ # @param template_id [String]
176
+ # @param [Hash] opts the optional parameters
177
+ # @return [Hash<String, Object>]
178
+ def delete_template(template_id, opts = {})
179
+ data, _status_code, _headers = delete_template_with_http_info(template_id, opts)
180
+ data
181
+ end
182
+
183
+ # Delete Template
184
+ # Deletes a given template.
185
+ # @param template_id [String]
186
+ # @param [Hash] opts the optional parameters
187
+ # @return [Array<(Hash<String, Object>, Integer, Hash)>] Hash<String, Object> data, response status code and response headers
188
+ def delete_template_with_http_info(template_id, opts = {})
189
+ if @api_client.config.debugging
190
+ @api_client.config.logger.debug 'Calling API: TemplatesApi.delete_template ...'
191
+ end
192
+ # verify the required parameter 'template_id' is set
193
+ if @api_client.config.client_side_validation && template_id.nil?
194
+ fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplatesApi.delete_template"
195
+ end
196
+ # resource path
197
+ local_var_path = '/v1/email-template/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))
198
+
199
+ # query parameters
200
+ query_params = opts[:query_params] || {}
201
+
202
+ # header parameters
203
+ header_params = opts[:header_params] || {}
204
+ # HTTP header 'Accept' (if needed)
205
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
206
+
207
+ # form parameters
208
+ form_params = opts[:form_params] || {}
209
+
210
+ # http body (model)
211
+ post_body = opts[:body]
212
+
213
+ # return_type
214
+ return_type = opts[:debug_return_type] || 'Hash<String, Object>'
215
+
216
+ # auth_names
217
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
218
+
219
+ new_options = opts.merge(
220
+ :operation => :"TemplatesApi.delete_template",
221
+ :header_params => header_params,
222
+ :query_params => query_params,
223
+ :form_params => form_params,
224
+ :body => post_body,
225
+ :auth_names => auth_names,
226
+ :return_type => return_type
227
+ )
228
+
229
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
230
+ if @api_client.config.debugging
231
+ @api_client.config.logger.debug "API called: TemplatesApi#delete_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
232
+ end
233
+ return data, status_code, headers
234
+ end
235
+
236
+ # Get All Templates
237
+ # Returns a list of all the email templates you've created. The templates are returned in sorted order by `name`.
238
+ # @param [Hash] opts the optional parameters
239
+ # @option opts [Integer] :page For pagination, which page of results to return. Default &#x3D; 0 (default to 0)
240
+ # @option opts [Integer] :count For pagination, the number of results to return. Max &#x3D; 100 (default to 50)
241
+ # @return [Hash<String, Object>]
242
+ def get_templates(opts = {})
243
+ data, _status_code, _headers = get_templates_with_http_info(opts)
244
+ data
245
+ end
246
+
247
+ # Get All Templates
248
+ # Returns a list of all the email templates you&#39;ve created. The templates are returned in sorted order by &#x60;name&#x60;.
249
+ # @param [Hash] opts the optional parameters
250
+ # @option opts [Integer] :page For pagination, which page of results to return. Default &#x3D; 0
251
+ # @option opts [Integer] :count For pagination, the number of results to return. Max &#x3D; 100
252
+ # @return [Array<(Hash<String, Object>, Integer, Hash)>] Hash<String, Object> data, response status code and response headers
253
+ def get_templates_with_http_info(opts = {})
254
+ if @api_client.config.debugging
255
+ @api_client.config.logger.debug 'Calling API: TemplatesApi.get_templates ...'
256
+ end
257
+ if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 0
258
+ fail ArgumentError, 'invalid value for "opts[:"page"]" when calling TemplatesApi.get_templates, must be greater than or equal to 0.'
259
+ end
260
+
261
+ if @api_client.config.client_side_validation && !opts[:'count'].nil? && opts[:'count'] > 100
262
+ fail ArgumentError, 'invalid value for "opts[:"count"]" when calling TemplatesApi.get_templates, must be smaller than or equal to 100.'
263
+ end
264
+
265
+ if @api_client.config.client_side_validation && !opts[:'count'].nil? && opts[:'count'] < 1
266
+ fail ArgumentError, 'invalid value for "opts[:"count"]" when calling TemplatesApi.get_templates, must be greater than or equal to 1.'
267
+ end
268
+
269
+ # resource path
270
+ local_var_path = '/v1/email-templates'
271
+
272
+ # query parameters
273
+ query_params = opts[:query_params] || {}
274
+ query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
275
+ query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil?
276
+
277
+ # header parameters
278
+ header_params = opts[:header_params] || {}
279
+ # HTTP header 'Accept' (if needed)
280
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
281
+
282
+ # form parameters
283
+ form_params = opts[:form_params] || {}
284
+
285
+ # http body (model)
286
+ post_body = opts[:body]
287
+
288
+ # return_type
289
+ return_type = opts[:debug_return_type] || 'Hash<String, Object>'
290
+
291
+ # auth_names
292
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
293
+
294
+ new_options = opts.merge(
295
+ :operation => :"TemplatesApi.get_templates",
296
+ :header_params => header_params,
297
+ :query_params => query_params,
298
+ :form_params => form_params,
299
+ :body => post_body,
300
+ :auth_names => auth_names,
301
+ :return_type => return_type
302
+ )
303
+
304
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
305
+ if @api_client.config.debugging
306
+ @api_client.config.logger.debug "API called: TemplatesApi#get_templates\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
307
+ end
308
+ return data, status_code, headers
309
+ end
310
+
311
+ # Render Template
312
+ # Renders the specified template with the provided data and return HTML and text versions of the email.
313
+ # @param template_id [String]
314
+ # @param [Hash] opts the optional parameters
315
+ # @option opts [String] :context This is the context your email template will be rendered with. Email templates are rendered with contexts in a similar manner to how Django templates are rendered. This means that nested template variables can be referenced via dot notation and template variables without corresponding context values are treated as falsy and output nothing. (default to '{ \"name\" : \"George Washington\", \"state\" : \"VA\" }')
316
+ # @return [RenderedTemplate]
317
+ def render_template(template_id, opts = {})
318
+ data, _status_code, _headers = render_template_with_http_info(template_id, opts)
319
+ data
320
+ end
321
+
322
+ # Render Template
323
+ # Renders the specified template with the provided data and return HTML and text versions of the email.
324
+ # @param template_id [String]
325
+ # @param [Hash] opts the optional parameters
326
+ # @option opts [String] :context This is the context your email template will be rendered with. Email templates are rendered with contexts in a similar manner to how Django templates are rendered. This means that nested template variables can be referenced via dot notation and template variables without corresponding context values are treated as falsy and output nothing.
327
+ # @return [Array<(RenderedTemplate, Integer, Hash)>] RenderedTemplate data, response status code and response headers
328
+ def render_template_with_http_info(template_id, opts = {})
329
+ if @api_client.config.debugging
330
+ @api_client.config.logger.debug 'Calling API: TemplatesApi.render_template ...'
331
+ end
332
+ # verify the required parameter 'template_id' is set
333
+ if @api_client.config.client_side_validation && template_id.nil?
334
+ fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplatesApi.render_template"
335
+ end
336
+ # resource path
337
+ local_var_path = '/v1/email-template/{template_id}/render'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))
338
+
339
+ # query parameters
340
+ query_params = opts[:query_params] || {}
341
+
342
+ # header parameters
343
+ header_params = opts[:header_params] || {}
344
+ # HTTP header 'Accept' (if needed)
345
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
346
+ # HTTP header 'Content-Type'
347
+ content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
348
+ if !content_type.nil?
349
+ header_params['Content-Type'] = content_type
350
+ end
351
+
352
+ # form parameters
353
+ form_params = opts[:form_params] || {}
354
+ form_params['context'] = opts[:'context'] if !opts[:'context'].nil?
355
+
356
+ # http body (model)
357
+ post_body = opts[:body]
358
+
359
+ # return_type
360
+ return_type = opts[:debug_return_type] || 'RenderedTemplate'
361
+
362
+ # auth_names
363
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
364
+
365
+ new_options = opts.merge(
366
+ :operation => :"TemplatesApi.render_template",
367
+ :header_params => header_params,
368
+ :query_params => query_params,
369
+ :form_params => form_params,
370
+ :body => post_body,
371
+ :auth_names => auth_names,
372
+ :return_type => return_type
373
+ )
374
+
375
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
376
+ if @api_client.config.debugging
377
+ @api_client.config.logger.debug "API called: TemplatesApi#render_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
378
+ end
379
+ return data, status_code, headers
380
+ end
381
+
382
+ # Render and Send Template
383
+ # Renders the specified template with the provided data and send the contents in an email via the service specified. This API is intended to test templates only, and is rate limited to the following thresholds: 100/hour, 1,000/day.
384
+ # @param template_id [String]
385
+ # @param from_email [String]
386
+ # @param from_name [String]
387
+ # @param subject [String]
388
+ # @param to [String] **Mixed**. string, or JSON encoded array of objects with \\\&quot;email\\\&quot; and \\\&quot;name\\\&quot; keys. &#x60;abraham.lincoln@klaviyo.com&#x60; OR &#x60;[{\\\&quot;name\\\&quot;:\\\&quot;Abraham Lincoln\\\&quot;,\\\&quot;email\\\&quot;:\\\&quot;abraham.lincoln@klaviyo.com\\\&quot;}]&#x60;
389
+ # @param [Hash] opts the optional parameters
390
+ # @option opts [String] :context Optional, JSON object. This is the context your email template will be rendered with. Email templates are rendered with contexts in a similar manner to how Django templates are rendered. This means that nested template variables can be referenced via dot notation and template variables without corresponding context values are treated as falsy and output nothing. ex: &#x60;{ \\\&quot;name\\\&quot; : \\\&quot;George Washington\\\&quot;, \\\&quot;state\\\&quot; : \\\&quot;VA\\\&quot; }&#x60; (default to '{ \"name\" : \"George Washington\", \"state\" : \"VA\" }')
391
+ # @return [RenderedTemplate]
392
+ def send_template(template_id, from_email, from_name, subject, to, opts = {})
393
+ data, _status_code, _headers = send_template_with_http_info(template_id, from_email, from_name, subject, to, opts)
394
+ data
395
+ end
396
+
397
+ # Render and Send Template
398
+ # Renders the specified template with the provided data and send the contents in an email via the service specified. This API is intended to test templates only, and is rate limited to the following thresholds: 100/hour, 1,000/day.
399
+ # @param template_id [String]
400
+ # @param from_email [String]
401
+ # @param from_name [String]
402
+ # @param subject [String]
403
+ # @param to [String] **Mixed**. string, or JSON encoded array of objects with \\\&quot;email\\\&quot; and \\\&quot;name\\\&quot; keys. &#x60;abraham.lincoln@klaviyo.com&#x60; OR &#x60;[{\\\&quot;name\\\&quot;:\\\&quot;Abraham Lincoln\\\&quot;,\\\&quot;email\\\&quot;:\\\&quot;abraham.lincoln@klaviyo.com\\\&quot;}]&#x60;
404
+ # @param [Hash] opts the optional parameters
405
+ # @option opts [String] :context Optional, JSON object. This is the context your email template will be rendered with. Email templates are rendered with contexts in a similar manner to how Django templates are rendered. This means that nested template variables can be referenced via dot notation and template variables without corresponding context values are treated as falsy and output nothing. ex: &#x60;{ \\\&quot;name\\\&quot; : \\\&quot;George Washington\\\&quot;, \\\&quot;state\\\&quot; : \\\&quot;VA\\\&quot; }&#x60;
406
+ # @return [Array<(RenderedTemplate, Integer, Hash)>] RenderedTemplate data, response status code and response headers
407
+ def send_template_with_http_info(template_id, from_email, from_name, subject, to, opts = {})
408
+ if @api_client.config.debugging
409
+ @api_client.config.logger.debug 'Calling API: TemplatesApi.send_template ...'
410
+ end
411
+ # verify the required parameter 'template_id' is set
412
+ if @api_client.config.client_side_validation && template_id.nil?
413
+ fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplatesApi.send_template"
414
+ end
415
+ # verify the required parameter 'from_email' is set
416
+ if @api_client.config.client_side_validation && from_email.nil?
417
+ fail ArgumentError, "Missing the required parameter 'from_email' when calling TemplatesApi.send_template"
418
+ end
419
+ # verify the required parameter 'from_name' is set
420
+ if @api_client.config.client_side_validation && from_name.nil?
421
+ fail ArgumentError, "Missing the required parameter 'from_name' when calling TemplatesApi.send_template"
422
+ end
423
+ # verify the required parameter 'subject' is set
424
+ if @api_client.config.client_side_validation && subject.nil?
425
+ fail ArgumentError, "Missing the required parameter 'subject' when calling TemplatesApi.send_template"
426
+ end
427
+ # verify the required parameter 'to' is set
428
+ if @api_client.config.client_side_validation && to.nil?
429
+ fail ArgumentError, "Missing the required parameter 'to' when calling TemplatesApi.send_template"
430
+ end
431
+ # resource path
432
+ local_var_path = '/v1/email-template/{template_id}/send'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))
433
+
434
+ # query parameters
435
+ query_params = opts[:query_params] || {}
436
+
437
+ # header parameters
438
+ header_params = opts[:header_params] || {}
439
+ # HTTP header 'Accept' (if needed)
440
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
441
+ # HTTP header 'Content-Type'
442
+ content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
443
+ if !content_type.nil?
444
+ header_params['Content-Type'] = content_type
445
+ end
446
+
447
+ # form parameters
448
+ form_params = opts[:form_params] || {}
449
+ form_params['from_email'] = from_email
450
+ form_params['from_name'] = from_name
451
+ form_params['subject'] = subject
452
+ form_params['to'] = to
453
+ form_params['context'] = opts[:'context'] if !opts[:'context'].nil?
454
+
455
+ # http body (model)
456
+ post_body = opts[:body]
457
+
458
+ # return_type
459
+ return_type = opts[:debug_return_type] || 'RenderedTemplate'
460
+
461
+ # auth_names
462
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
463
+
464
+ new_options = opts.merge(
465
+ :operation => :"TemplatesApi.send_template",
466
+ :header_params => header_params,
467
+ :query_params => query_params,
468
+ :form_params => form_params,
469
+ :body => post_body,
470
+ :auth_names => auth_names,
471
+ :return_type => return_type
472
+ )
473
+
474
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
475
+ if @api_client.config.debugging
476
+ @api_client.config.logger.debug "API called: TemplatesApi#send_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
477
+ end
478
+ return data, status_code, headers
479
+ end
480
+
481
+ # Update Template
482
+ # Updates the name and/or HTML content of a template. Only updates imported HTML templates; does not currently update drag & drop templates.
483
+ # @param template_id [String]
484
+ # @param [Hash] opts the optional parameters
485
+ # @option opts [String] :name The new name of the email template.
486
+ # @option opts [String] :html The new HTML content for this template.
487
+ # @return [Template]
488
+ def update_template(template_id, opts = {})
489
+ data, _status_code, _headers = update_template_with_http_info(template_id, opts)
490
+ data
491
+ end
492
+
493
+ # Update Template
494
+ # Updates the name and/or HTML content of a template. Only updates imported HTML templates; does not currently update drag &amp; drop templates.
495
+ # @param template_id [String]
496
+ # @param [Hash] opts the optional parameters
497
+ # @option opts [String] :name The new name of the email template.
498
+ # @option opts [String] :html The new HTML content for this template.
499
+ # @return [Array<(Template, Integer, Hash)>] Template data, response status code and response headers
500
+ def update_template_with_http_info(template_id, opts = {})
501
+ if @api_client.config.debugging
502
+ @api_client.config.logger.debug 'Calling API: TemplatesApi.update_template ...'
503
+ end
504
+ # verify the required parameter 'template_id' is set
505
+ if @api_client.config.client_side_validation && template_id.nil?
506
+ fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplatesApi.update_template"
507
+ end
508
+ # resource path
509
+ local_var_path = '/v1/email-template/{template_id}'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))
510
+
511
+ # query parameters
512
+ query_params = opts[:query_params] || {}
513
+
514
+ # header parameters
515
+ header_params = opts[:header_params] || {}
516
+ # HTTP header 'Accept' (if needed)
517
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
518
+ # HTTP header 'Content-Type'
519
+ content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
520
+ if !content_type.nil?
521
+ header_params['Content-Type'] = content_type
522
+ end
523
+
524
+ # form parameters
525
+ form_params = opts[:form_params] || {}
526
+ form_params['name'] = opts[:'name'] if !opts[:'name'].nil?
527
+ form_params['html'] = opts[:'html'] if !opts[:'html'].nil?
528
+
529
+ # http body (model)
530
+ post_body = opts[:body]
531
+
532
+ # return_type
533
+ return_type = opts[:debug_return_type] || 'Template'
534
+
535
+ # auth_names
536
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
537
+
538
+ new_options = opts.merge(
539
+ :operation => :"TemplatesApi.update_template",
540
+ :header_params => header_params,
541
+ :query_params => query_params,
542
+ :form_params => form_params,
543
+ :body => post_body,
544
+ :auth_names => auth_names,
545
+ :return_type => return_type
546
+ )
547
+
548
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
549
+ if @api_client.config.debugging
550
+ @api_client.config.logger.debug "API called: TemplatesApi#update_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
551
+ end
552
+ return data, status_code, headers
553
+ end
554
+ end
555
+ end