Class: MailSlurpClient::TemplateControllerApi

Inherits:
Object
  • Object
show all
Defined in:
lib/mailslurp_client/api/template_controller_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ TemplateControllerApi

Returns a new instance of TemplateControllerApi.



19
20
21
# File 'lib/mailslurp_client/api/template_controller_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/mailslurp_client/api/template_controller_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_template(create_template_options, opts = {}) ⇒ TemplateDto

Create a Template Create an email template with variables for use with templated transactional emails.

Parameters:

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

    the optional parameters

Returns:



27
28
29
30
# File 'lib/mailslurp_client/api/template_controller_api.rb', line 27

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

#create_template_with_http_info(create_template_options, opts = {}) ⇒ Array<(TemplateDto, Integer, Hash)>

Create a Template Create an email template with variables for use with templated transactional emails.

Parameters:

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

    the optional parameters

Returns:

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

    TemplateDto 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
# File 'lib/mailslurp_client/api/template_controller_api.rb', line 37

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

  # 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(['*/*'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

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

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

  # return_type
  return_type = opts[:return_type] || 'TemplateDto' 

  # auth_names
  auth_names = opts[:auth_names] || ['API_KEY']

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

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

Delete email template Delete template

Parameters:

  • template_id (String)

    Template ID

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

    the optional parameters

Returns:

  • (nil)


91
92
93
94
# File 'lib/mailslurp_client/api/template_controller_api.rb', line 91

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

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

Delete email template Delete template

Parameters:

  • template_id (String)

    Template ID

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



101
102
103
104
105
106
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
# File 'lib/mailslurp_client/api/template_controller_api.rb', line 101

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

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

  # header parameters
  header_params = opts[:header_params] || {}

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

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

  # return_type
  return_type = opts[:return_type] 

  # auth_names
  auth_names = opts[:auth_names] || ['API_KEY']

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

#get_all_templates(opts = {}) ⇒ PageTemplateProjection

List templates Get all templates in paginated format

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    Optional page index in list pagination (default to 0)

  • :size (Integer)

    Optional page size in list pagination (default to 20)

  • :sort (String)

    Optional createdAt sort direction ASC or DESC (default to 'ASC')

  • :since (DateTime)

    Filter by created at after the given timestamp

  • :before (DateTime)

    Filter by created at before the given timestamp

Returns:



155
156
157
158
# File 'lib/mailslurp_client/api/template_controller_api.rb', line 155

def get_all_templates(opts = {})
  data, _status_code, _headers = get_all_templates_with_http_info(opts)
  data
end

#get_all_templates_with_http_info(opts = {}) ⇒ Array<(PageTemplateProjection, Integer, Hash)>

List templates Get all templates in paginated format

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    Optional page index in list pagination

  • :size (Integer)

    Optional page size in list pagination

  • :sort (String)

    Optional createdAt sort direction ASC or DESC

  • :since (DateTime)

    Filter by created at after the given timestamp

  • :before (DateTime)

    Filter by created at before the given timestamp

Returns:

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

    PageTemplateProjection data, response status code and response headers



169
170
171
172
173
174
175
176
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
# File 'lib/mailslurp_client/api/template_controller_api.rb', line 169

def get_all_templates_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplateControllerApi.get_all_templates ...'
  end
  allowable_values = ["ASC", "DESC"]
  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 = '/templates/paginated'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'since'] = opts[:'since'] if !opts[:'since'].nil?
  query_params[:'before'] = opts[:'before'] if !opts[:'before'].nil?

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

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

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

  # return_type
  return_type = opts[:return_type] || 'PageTemplateProjection' 

  # auth_names
  auth_names = opts[:auth_names] || ['API_KEY']

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

#get_template(template_id, opts = {}) ⇒ TemplateDto

Get template Get email template

Parameters:

  • template_id (String)

    Template ID

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

    the optional parameters

Returns:



226
227
228
229
# File 'lib/mailslurp_client/api/template_controller_api.rb', line 226

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

#get_template_preview_html(template_id, opts = {}) ⇒ String

Get template preview HTML Get email template preview with passed template variables in HTML format for browsers. Pass template variables as query params.

Parameters:

  • template_id (String)

    Template ID

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

    the optional parameters

Returns:

  • (String)


288
289
290
291
# File 'lib/mailslurp_client/api/template_controller_api.rb', line 288

def get_template_preview_html(template_id, opts = {})
  data, _status_code, _headers = get_template_preview_html_with_http_info(template_id, opts)
  data
end

#get_template_preview_html_with_http_info(template_id, opts = {}) ⇒ Array<(String, Integer, Hash)>

Get template preview HTML Get email template preview with passed template variables in HTML format for browsers. Pass template variables as query params.

Parameters:

  • template_id (String)

    Template ID

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

    the optional parameters

Returns:

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

    String data, response status code and response headers



298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
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
# File 'lib/mailslurp_client/api/template_controller_api.rb', line 298

def get_template_preview_html_with_http_info(template_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplateControllerApi.get_template_preview_html ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateControllerApi.get_template_preview_html"
  end
  # resource path
  local_var_path = '/templates/{templateId}/preview/html'.sub('{' + 'templateId' + '}', CGI.escape(template_id.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(['text/html;charset=utf-8', 'text/html'])

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

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

  # return_type
  return_type = opts[:return_type] || 'String' 

  # auth_names
  auth_names = opts[:auth_names] || ['API_KEY']

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

#get_template_preview_json(template_id, opts = {}) ⇒ TemplatePreview

Get template preview Json Get email template preview with passed template variables in JSON format. Pass template variables as query params.

Parameters:

  • template_id (String)

    Template ID

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

    the optional parameters

Returns:



350
351
352
353
# File 'lib/mailslurp_client/api/template_controller_api.rb', line 350

def get_template_preview_json(template_id, opts = {})
  data, _status_code, _headers = get_template_preview_json_with_http_info(template_id, opts)
  data
end

#get_template_preview_json_with_http_info(template_id, opts = {}) ⇒ Array<(TemplatePreview, Integer, Hash)>

Get template preview Json Get email template preview with passed template variables in JSON format. Pass template variables as query params.

Parameters:

  • template_id (String)

    Template ID

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

    the optional parameters

Returns:

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

    TemplatePreview data, response status code and response headers



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
404
405
# File 'lib/mailslurp_client/api/template_controller_api.rb', line 360

def get_template_preview_json_with_http_info(template_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplateControllerApi.get_template_preview_json ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateControllerApi.get_template_preview_json"
  end
  # resource path
  local_var_path = '/templates/{templateId}/preview/json'.sub('{' + 'templateId' + '}', CGI.escape(template_id.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(['*/*'])

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

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

  # return_type
  return_type = opts[:return_type] || 'TemplatePreview' 

  # auth_names
  auth_names = opts[:auth_names] || ['API_KEY']

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

#get_template_with_http_info(template_id, opts = {}) ⇒ Array<(TemplateDto, Integer, Hash)>

Get template Get email template

Parameters:

  • template_id (String)

    Template ID

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

    the optional parameters

Returns:

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

    TemplateDto data, response status code and response headers



236
237
238
239
240
241
242
243
244
245
246
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
# File 'lib/mailslurp_client/api/template_controller_api.rb', line 236

def get_template_with_http_info(template_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplateControllerApi.get_template ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateControllerApi.get_template"
  end
  # resource path
  local_var_path = '/templates/{templateId}'.sub('{' + 'templateId' + '}', CGI.escape(template_id.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(['*/*'])

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

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

  # return_type
  return_type = opts[:return_type] || 'TemplateDto' 

  # auth_names
  auth_names = opts[:auth_names] || ['API_KEY']

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

#get_templates(opts = {}) ⇒ Array<TemplateProjection>

List templates Get all templates

Parameters:

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

    the optional parameters

Returns:



411
412
413
414
# File 'lib/mailslurp_client/api/template_controller_api.rb', line 411

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

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

List templates Get all templates

Parameters:

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

    the optional parameters

Returns:

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

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



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
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
# File 'lib/mailslurp_client/api/template_controller_api.rb', line 420

def get_templates_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplateControllerApi.get_templates ...'
  end
  # resource path
  local_var_path = '/templates'

  # 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(['*/*'])

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

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

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

  # auth_names
  auth_names = opts[:auth_names] || ['API_KEY']

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

#update_template(template_id, create_template_options, opts = {}) ⇒ TemplateDto

Update template Update email template

Parameters:

  • template_id (String)

    Template ID

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

    the optional parameters

Returns:



469
470
471
472
# File 'lib/mailslurp_client/api/template_controller_api.rb', line 469

def update_template(template_id, create_template_options, opts = {})
  data, _status_code, _headers = update_template_with_http_info(template_id, create_template_options, opts)
  data
end

#update_template_with_http_info(template_id, create_template_options, opts = {}) ⇒ Array<(TemplateDto, Integer, Hash)>

Update template Update email template

Parameters:

  • template_id (String)

    Template ID

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

    the optional parameters

Returns:

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

    TemplateDto data, response status code and response headers



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
523
524
525
526
527
528
529
530
531
# File 'lib/mailslurp_client/api/template_controller_api.rb', line 480

def update_template_with_http_info(template_id, create_template_options, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplateControllerApi.update_template ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplateControllerApi.update_template"
  end
  # verify the required parameter 'create_template_options' is set
  if @api_client.config.client_side_validation && create_template_options.nil?
    fail ArgumentError, "Missing the required parameter 'create_template_options' when calling TemplateControllerApi.update_template"
  end
  # resource path
  local_var_path = '/templates/{templateId}'.sub('{' + 'templateId' + '}', CGI.escape(template_id.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(['*/*'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

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

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

  # return_type
  return_type = opts[:return_type] || 'TemplateDto' 

  # auth_names
  auth_names = opts[:auth_names] || ['API_KEY']

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