Class: Mailtrap::TemplatesAPI
- Inherits:
-
Object
- Object
- Mailtrap::TemplatesAPI
- Includes:
- BaseAPI
- Defined in:
- lib/mailtrap/templates_api.rb
Overview
Note:
Experimental: the /api/templates endpoints may change their request and response
shapes before general availability.
Instance Attribute Summary
Attributes included from BaseAPI
Instance Method Summary collapse
-
#create(options) ⇒ Template
Creates a new template.
-
#delete(template_id) ⇒ nil
Deletes a template.
-
#get(template_id) ⇒ Template
Retrieves a specific template.
-
#list(per_page: nil, token: nil) ⇒ TemplatesListResponse
Lists templates for the account, one page at a time.
-
#update(template_id, options) ⇒ Template
Updates an existing template.
Methods included from BaseAPI
Instance Method Details
#create(options) ⇒ Template
Creates a new template
54 55 56 |
# File 'lib/mailtrap/templates_api.rb', line 54 def create() base_create() end |
#delete(template_id) ⇒ nil
Deletes a template
77 78 79 |
# File 'lib/mailtrap/templates_api.rb', line 77 def delete(template_id) base_delete(template_id) end |
#get(template_id) ⇒ Template
Retrieves a specific template
40 41 42 |
# File 'lib/mailtrap/templates_api.rb', line 40 def get(template_id) base_get(template_id) end |
#list(per_page: nil, token: nil) ⇒ TemplatesListResponse
Lists templates for the account, one page at a time. Unlike EmailTemplatesAPI#list, it does
not return every template: pass pagination[:next_token] with the same per_page to get the
next page.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mailtrap/templates_api.rb', line 23 def list(per_page: nil, token: nil) query_params = {} query_params[:per_page] = per_page unless per_page.nil? query_params[:token] = token unless token.nil? response = client.get(base_path, query_params) TemplatesListResponse.new( data: Array(response[:data]).map { |item| build_entity(item, response_class) }, pagination: response[:pagination] ) end |
#update(template_id, options) ⇒ Template
Updates an existing template. Only the provided attributes are changed.
69 70 71 |
# File 'lib/mailtrap/templates_api.rb', line 69 def update(template_id, ) base_update(template_id, ) end |