Class: ClerkHttpClient::EmailSMSTemplatesApi

Inherits:
Object
  • Object
show all
Defined in:
lib/clerk-http-client/api/email_sms_templates_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ EmailSMSTemplatesApi

Returns a new instance of EmailSMSTemplatesApi.



19
20
21
# File 'lib/clerk-http-client/api/email_sms_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/clerk-http-client/api/email_sms_templates_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#all(template_type, opts = {}) ⇒ Array<Template>

List all templates Returns a list of all templates. The templates are returned sorted by position.

Parameters:

  • template_type (String)

    The type of templates to list (email or SMS)

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

    the optional parameters

Returns:



104
105
106
107
# File 'lib/clerk-http-client/api/email_sms_templates_api.rb', line 104

def all(template_type, opts = {})
  data, _status_code, _headers = all_with_http_info(template_type, opts)
  data
end

#all_with_http_info(template_type, opts = {}) ⇒ Array<(Array<Template>, Integer, Hash)>

List all templates Returns a list of all templates. The templates are returned sorted by position. GET array

Parameters:

  • template_type (String)

    The type of templates to list (email or SMS)

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

    the optional parameters

Returns:

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

    Array<Template> data, response status code and response headers



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
161
162
163
164
165
166
# File 'lib/clerk-http-client/api/email_sms_templates_api.rb', line 115

def all_with_http_info(template_type, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: EmailSMSTemplatesApi.get_template_list ...'
  end
  # verify the required parameter 'template_type' is set
  if @api_client.config.client_side_validation && template_type.nil?
    fail ArgumentError, "Missing the required parameter 'template_type' when calling EmailSMSTemplatesApi.get_template_list"
  end
  # verify enum value
  allowable_values = ["email", "sms"]
  if @api_client.config.client_side_validation && !allowable_values.include?(template_type)
    fail ArgumentError, "invalid value for \"template_type\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/templates/{template_type}'.sub('{' + 'template_type' + '}', CGI.escape(template_type.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

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

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

  # return_type
  return_type = opts[:debug_return_type] || 'Array<Template>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"EmailSMSTemplatesApi.get_template_list",
    :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: EmailSMSTemplatesApi#get_template_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#find(template_type, slug, opts = {}) ⇒ Template

Retrieve a template Returns the details of a template

Parameters:

  • template_type (String)

    The type of templates to retrieve (email or SMS)

  • slug (String)

    The slug (i.e. machine-friendly name) of the template to retrieve

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

    the optional parameters

Returns:



29
30
31
32
# File 'lib/clerk-http-client/api/email_sms_templates_api.rb', line 29

def find(template_type, slug, opts = {})
  data, _status_code, _headers = find_with_http_info(template_type, slug, opts)
  data
end

#find_with_http_info(template_type, slug, opts = {}) ⇒ Array<(Template, Integer, Hash)>

Retrieve a template Returns the details of a template GET

Parameters:

  • template_type (String)

    The type of templates to retrieve (email or SMS)

  • slug (String)

    The slug (i.e. machine-friendly name) of the template to retrieve

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

    the optional parameters

Returns:

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

    Template data, response status code and response headers



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
91
92
93
94
95
96
# File 'lib/clerk-http-client/api/email_sms_templates_api.rb', line 41

def find_with_http_info(template_type, slug, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: EmailSMSTemplatesApi.get_template ...'
  end
  # verify the required parameter 'template_type' is set
  if @api_client.config.client_side_validation && template_type.nil?
    fail ArgumentError, "Missing the required parameter 'template_type' when calling EmailSMSTemplatesApi.get_template"
  end
  # verify enum value
  allowable_values = ["email", "sms"]
  if @api_client.config.client_side_validation && !allowable_values.include?(template_type)
    fail ArgumentError, "invalid value for \"template_type\", must be one of #{allowable_values}"
  end
  # verify the required parameter 'slug' is set
  if @api_client.config.client_side_validation && slug.nil?
    fail ArgumentError, "Missing the required parameter 'slug' when calling EmailSMSTemplatesApi.get_template"
  end
  # resource path
  local_var_path = '/templates/{template_type}/{slug}'.sub('{' + 'template_type' + '}', CGI.escape(template_type.to_s)).sub('{' + 'slug' + '}', CGI.escape(slug.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

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

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

  # return_type
  return_type = opts[:debug_return_type] || 'Template'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"EmailSMSTemplatesApi.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: EmailSMSTemplatesApi#get_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#preview(template_type, slug, opts = {}) ⇒ Object

Preview changes to a template Returns a preview of a template for a given template_type, slug and body

Parameters:

  • template_type (String)

    The type of template to preview

  • slug (String)

    The slug of the template to preview

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Object)


176
177
178
179
# File 'lib/clerk-http-client/api/email_sms_templates_api.rb', line 176

def preview(template_type, slug, opts = {})
  data, _status_code, _headers = preview_with_http_info(template_type, slug, opts)
  data
end

#preview_with_http_info(template_type, slug, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Preview changes to a template Returns a preview of a template for a given template_type, slug and body POST

Parameters:

  • template_type (String)

    The type of template to preview

  • slug (String)

    The slug of the template to preview

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

    the optional parameters

Options Hash (opts):

Returns:

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

    Object data, response status code and response headers



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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/clerk-http-client/api/email_sms_templates_api.rb', line 189

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

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # 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(opts[:'preview_template_request'])

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"EmailSMSTemplatesApi.preview_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: EmailSMSTemplatesApi#preview_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#revert(template_type, slug, opts = {}) ⇒ Template

Revert a template Reverts an updated template to its default state

Parameters:

  • template_type (String)

    The type of template to revert

  • slug (String)

    The slug of the template to revert

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

    the optional parameters

Returns:



253
254
255
256
# File 'lib/clerk-http-client/api/email_sms_templates_api.rb', line 253

def revert(template_type, slug, opts = {})
  data, _status_code, _headers = revert_with_http_info(template_type, slug, opts)
  data
end

#revert_with_http_info(template_type, slug, opts = {}) ⇒ Array<(Template, Integer, Hash)>

Revert a template Reverts an updated template to its default state POST

Parameters:

  • template_type (String)

    The type of template to revert

  • slug (String)

    The slug of the template to revert

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

    the optional parameters

Returns:

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

    Template data, response status code and response headers



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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/clerk-http-client/api/email_sms_templates_api.rb', line 265

def revert_with_http_info(template_type, slug, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: EmailSMSTemplatesApi.revert_template ...'
  end
  # verify the required parameter 'template_type' is set
  if @api_client.config.client_side_validation && template_type.nil?
    fail ArgumentError, "Missing the required parameter 'template_type' when calling EmailSMSTemplatesApi.revert_template"
  end
  # verify enum value
  allowable_values = ["email", "sms"]
  if @api_client.config.client_side_validation && !allowable_values.include?(template_type)
    fail ArgumentError, "invalid value for \"template_type\", must be one of #{allowable_values}"
  end
  # verify the required parameter 'slug' is set
  if @api_client.config.client_side_validation && slug.nil?
    fail ArgumentError, "Missing the required parameter 'slug' when calling EmailSMSTemplatesApi.revert_template"
  end
  # resource path
  local_var_path = '/templates/{template_type}/{slug}/revert'.sub('{' + 'template_type' + '}', CGI.escape(template_type.to_s)).sub('{' + 'slug' + '}', CGI.escape(slug.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

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

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

  # return_type
  return_type = opts[:debug_return_type] || 'Template'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"EmailSMSTemplatesApi.revert_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: EmailSMSTemplatesApi#revert_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#toggle_delivery(template_type, slug, opts = {}) ⇒ Template

Toggle the delivery by Clerk for a template of a given type and slug Toggles the delivery by Clerk for a template of a given type and slug. If disabled, Clerk will not deliver the resulting email or SMS. The app developer will need to listen to the ‘email.created` or `sms.created` webhooks in order to handle delivery themselves.

Parameters:

  • template_type (String)

    The type of template to toggle delivery for

  • slug (String)

    The slug of the template for which to toggle delivery

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

    the optional parameters

Options Hash (opts):

Returns:



330
331
332
333
# File 'lib/clerk-http-client/api/email_sms_templates_api.rb', line 330

def toggle_delivery(template_type, slug, opts = {})
  data, _status_code, _headers = toggle_delivery_with_http_info(template_type, slug, opts)
  data
end

#toggle_delivery_with_http_info(template_type, slug, opts = {}) ⇒ Array<(Template, Integer, Hash)>

Toggle the delivery by Clerk for a template of a given type and slug Toggles the delivery by Clerk for a template of a given type and slug. If disabled, Clerk will not deliver the resulting email or SMS. The app developer will need to listen to the &#x60;email.created&#x60; or &#x60;sms.created&#x60; webhooks in order to handle delivery themselves. POST

Parameters:

  • template_type (String)

    The type of template to toggle delivery for

  • slug (String)

    The slug of the template for which to toggle delivery

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

    the optional parameters

Options Hash (opts):

Returns:

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

    Template data, response status code and response headers



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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/clerk-http-client/api/email_sms_templates_api.rb', line 343

def toggle_delivery_with_http_info(template_type, slug, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: EmailSMSTemplatesApi.toggle_template_delivery ...'
  end
  # verify the required parameter 'template_type' is set
  if @api_client.config.client_side_validation && template_type.nil?
    fail ArgumentError, "Missing the required parameter 'template_type' when calling EmailSMSTemplatesApi.toggle_template_delivery"
  end
  # verify enum value
  allowable_values = ["email", "sms"]
  if @api_client.config.client_side_validation && !allowable_values.include?(template_type)
    fail ArgumentError, "invalid value for \"template_type\", must be one of #{allowable_values}"
  end
  # verify the required parameter 'slug' is set
  if @api_client.config.client_side_validation && slug.nil?
    fail ArgumentError, "Missing the required parameter 'slug' when calling EmailSMSTemplatesApi.toggle_template_delivery"
  end
  # resource path
  local_var_path = '/templates/{template_type}/{slug}/toggle_delivery'.sub('{' + 'template_type' + '}', CGI.escape(template_type.to_s)).sub('{' + 'slug' + '}', CGI.escape(slug.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # 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(opts[:'toggle_template_delivery_request'])

  # return_type
  return_type = opts[:debug_return_type] || 'Template'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"EmailSMSTemplatesApi.toggle_template_delivery",
    :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: EmailSMSTemplatesApi#toggle_template_delivery\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update(template_type, slug, opts = {}) ⇒ Template

Update a template for a given type and slug Updates the existing template of the given type and slug

Parameters:

  • template_type (String)

    The type of template to update

  • slug (String)

    The slug of the template to update

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

    the optional parameters

Options Hash (opts):

Returns:



413
414
415
416
# File 'lib/clerk-http-client/api/email_sms_templates_api.rb', line 413

def update(template_type, slug, opts = {})
  data, _status_code, _headers = update_with_http_info(template_type, slug, opts)
  data
end

#update_with_http_info(template_type, slug, opts = {}) ⇒ Array<(Template, Integer, Hash)>

Update a template for a given type and slug Updates the existing template of the given type and slug PUT

Parameters:

  • template_type (String)

    The type of template to update

  • slug (String)

    The slug of the template to update

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

    the optional parameters

Options Hash (opts):

Returns:

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

    Template data, response status code and response headers



426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
# File 'lib/clerk-http-client/api/email_sms_templates_api.rb', line 426

def update_with_http_info(template_type, slug, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: EmailSMSTemplatesApi.upsert_template ...'
  end
  # verify the required parameter 'template_type' is set
  if @api_client.config.client_side_validation && template_type.nil?
    fail ArgumentError, "Missing the required parameter 'template_type' when calling EmailSMSTemplatesApi.upsert_template"
  end
  # verify enum value
  allowable_values = ["email", "sms"]
  if @api_client.config.client_side_validation && !allowable_values.include?(template_type)
    fail ArgumentError, "invalid value for \"template_type\", must be one of #{allowable_values}"
  end
  # verify the required parameter 'slug' is set
  if @api_client.config.client_side_validation && slug.nil?
    fail ArgumentError, "Missing the required parameter 'slug' when calling EmailSMSTemplatesApi.upsert_template"
  end
  # resource path
  local_var_path = '/templates/{template_type}/{slug}'.sub('{' + 'template_type' + '}', CGI.escape(template_type.to_s)).sub('{' + 'slug' + '}', CGI.escape(slug.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # 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(opts[:'upsert_template_request'])

  # return_type
  return_type = opts[:debug_return_type] || 'Template'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"EmailSMSTemplatesApi.upsert_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(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: EmailSMSTemplatesApi#upsert_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end