mailtrap 2.16.0 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/lib/mailtrap/template.rb +36 -0
- data/lib/mailtrap/templates_api.rb +91 -0
- data/lib/mailtrap/version.rb +1 -1
- data/lib/mailtrap.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cf895b774a80d6579230f2629793150d13be0648536b9c88524f6149ae39feb9
|
|
4
|
+
data.tar.gz: 50169e072e02c1509a9da6b7b933ad8fe1b6b6d219f50771696d3f5f62cc4674
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7da15a7343f680b071be20f34f3223582351e66de800600d48c84afd46ee78d9dad96220fb9885f4498f0d62617cb35b16a0957169d3e79639d071509177c52d
|
|
7
|
+
data.tar.gz: 4c4a95c0fdbf908287f60e6ae15ff0332a24ee35e217643f80664a6ef379d80216902335c4d7b8108c05301f3f7e46e39ef232f1293e1ee70a9edc41533a0334
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## [2.17.0] - 2026-10-07
|
|
2
|
+
|
|
3
|
+
## What's Changed
|
|
4
|
+
* Add TemplatesAPI for the paginated /api/templates endpoints by @izikaj in https://github.com/mailtrap/mailtrap-ruby/pull/133
|
|
5
|
+
|
|
6
|
+
## New Contributors
|
|
7
|
+
* @izikaj made their first contribution in https://github.com/mailtrap/mailtrap-ruby/pull/133
|
|
8
|
+
|
|
9
|
+
**Full Changelog**: https://github.com/mailtrap/mailtrap-ruby/compare/v2.16.0...v2.17.0
|
|
10
|
+
|
|
1
11
|
## [2.16.0] - 2026-08-31
|
|
2
12
|
|
|
3
13
|
## What's Changed
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -211,7 +211,8 @@ General:
|
|
|
211
211
|
- API Tokens API – [`api_tokens_api.rb`](examples/api_tokens_api.rb)
|
|
212
212
|
- Billing API – [`billing_api.rb`](examples/billing_api.rb)
|
|
213
213
|
- Permissions API – [`permissions_api.rb`](examples/permissions_api.rb)
|
|
214
|
-
- Templates API – [`
|
|
214
|
+
- Templates API (experimental) – [`templates_api.rb`](examples/templates_api.rb)
|
|
215
|
+
- Email Templates API – [`email_templates_api.rb`](examples/email_templates_api.rb)
|
|
215
216
|
- Action Mailer – [`action_mailer.rb`](examples/action_mailer.rb)
|
|
216
217
|
- Verifying webhook signatures – [`webhooks_signature_verification.ru`](examples/webhooks_signature_verification.ru)
|
|
217
218
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailtrap
|
|
4
|
+
# Data Transfer Object for Template
|
|
5
|
+
# @attr_reader id [Integer] The template ID
|
|
6
|
+
# @attr_reader uuid [String] The template UUID
|
|
7
|
+
# @attr_reader name [String] The template name
|
|
8
|
+
# @attr_reader subject [String] The email subject
|
|
9
|
+
# @attr_reader category [String] The template category
|
|
10
|
+
# @attr_reader body_html [String] The HTML content
|
|
11
|
+
# @attr_reader body_text [String] The plain text content
|
|
12
|
+
# @attr_reader created_at [String] The creation timestamp
|
|
13
|
+
# @attr_reader updated_at [String] The last update timestamp
|
|
14
|
+
Template = Struct.new(
|
|
15
|
+
:id,
|
|
16
|
+
:uuid,
|
|
17
|
+
:name,
|
|
18
|
+
:subject,
|
|
19
|
+
:category,
|
|
20
|
+
:body_html,
|
|
21
|
+
:body_text,
|
|
22
|
+
:created_at,
|
|
23
|
+
:updated_at,
|
|
24
|
+
keyword_init: true
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
# Response from listing templates (paginated)
|
|
28
|
+
# @attr_reader data [Array<Template>] Page of templates
|
|
29
|
+
# @attr_reader pagination [Hash] Page-token pagination metadata
|
|
30
|
+
# (+token+, +prev_token+, +next_token+, +first_url+, +prev_url+, +current_url+, +next_url+)
|
|
31
|
+
TemplatesListResponse = Struct.new(
|
|
32
|
+
:data,
|
|
33
|
+
:pagination,
|
|
34
|
+
keyword_init: true
|
|
35
|
+
)
|
|
36
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'base_api'
|
|
4
|
+
require_relative 'template'
|
|
5
|
+
|
|
6
|
+
module Mailtrap
|
|
7
|
+
# @note Experimental: the +/api/templates+ endpoints may change their request and response
|
|
8
|
+
# shapes before general availability.
|
|
9
|
+
class TemplatesAPI
|
|
10
|
+
include BaseAPI
|
|
11
|
+
|
|
12
|
+
self.supported_options = %i[name subject category body_html body_text]
|
|
13
|
+
|
|
14
|
+
self.response_class = Template
|
|
15
|
+
|
|
16
|
+
# Lists templates for the account, one page at a time. Unlike {EmailTemplatesAPI#list}, it does
|
|
17
|
+
# not return every template: pass +pagination[:next_token]+ with the same +per_page+ to get the
|
|
18
|
+
# next page.
|
|
19
|
+
# @param per_page [Integer, nil] Number of templates per page (max 100, default 50)
|
|
20
|
+
# @param token [Integer, nil] Page number to retrieve (page-token pagination, default 1)
|
|
21
|
+
# @return [TemplatesListResponse] The page of templates and pagination metadata
|
|
22
|
+
# @!macro api_errors
|
|
23
|
+
def list(per_page: nil, token: nil)
|
|
24
|
+
query_params = {}
|
|
25
|
+
query_params[:per_page] = per_page unless per_page.nil?
|
|
26
|
+
query_params[:token] = token unless token.nil?
|
|
27
|
+
|
|
28
|
+
response = client.get(base_path, query_params)
|
|
29
|
+
|
|
30
|
+
TemplatesListResponse.new(
|
|
31
|
+
data: Array(response[:data]).map { |item| build_entity(item, response_class) },
|
|
32
|
+
pagination: response[:pagination]
|
|
33
|
+
)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Retrieves a specific template
|
|
37
|
+
# @param template_id [Integer] The template ID
|
|
38
|
+
# @return [Template] Template object
|
|
39
|
+
# @!macro api_errors
|
|
40
|
+
def get(template_id)
|
|
41
|
+
base_get(template_id)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Creates a new template
|
|
45
|
+
# @param [Hash] options The parameters to create
|
|
46
|
+
# @option options [String] :name The template name (required)
|
|
47
|
+
# @option options [String] :subject The email subject (required)
|
|
48
|
+
# @option options [String] :category The template category (required)
|
|
49
|
+
# @option options [String, nil] :body_html The HTML content. Default: nil.
|
|
50
|
+
# @option options [String, nil] :body_text The plain text content. Default: nil.
|
|
51
|
+
# @return [Template] Created template object
|
|
52
|
+
# @!macro api_errors
|
|
53
|
+
# @raise [ArgumentError] If invalid options are provided
|
|
54
|
+
def create(options)
|
|
55
|
+
base_create(options)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Updates an existing template. Only the provided attributes are changed.
|
|
59
|
+
# @param template_id [Integer] The template ID
|
|
60
|
+
# @param [Hash] options The parameters to update
|
|
61
|
+
# @option options [String] :name The template name
|
|
62
|
+
# @option options [String] :subject The email subject
|
|
63
|
+
# @option options [String] :category The template category
|
|
64
|
+
# @option options [String, nil] :body_html The HTML content
|
|
65
|
+
# @option options [String, nil] :body_text The plain text content
|
|
66
|
+
# @return [Template] Updated template object
|
|
67
|
+
# @!macro api_errors
|
|
68
|
+
# @raise [ArgumentError] If invalid options are provided
|
|
69
|
+
def update(template_id, options)
|
|
70
|
+
base_update(template_id, options)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Deletes a template
|
|
74
|
+
# @param template_id [Integer] The template ID
|
|
75
|
+
# @return [nil]
|
|
76
|
+
# @!macro api_errors
|
|
77
|
+
def delete(template_id)
|
|
78
|
+
base_delete(template_id)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
private
|
|
82
|
+
|
|
83
|
+
def base_path
|
|
84
|
+
"/api/accounts/#{account_id}/templates"
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def handle_response(response)
|
|
88
|
+
build_entity(response[:data], response_class)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
data/lib/mailtrap/version.rb
CHANGED
data/lib/mailtrap.rb
CHANGED
|
@@ -11,6 +11,7 @@ require_relative 'mailtrap/permissions_api'
|
|
|
11
11
|
require_relative 'mailtrap/sub_accounts_api'
|
|
12
12
|
require_relative 'mailtrap/billing_api'
|
|
13
13
|
require_relative 'mailtrap/email_templates_api'
|
|
14
|
+
require_relative 'mailtrap/templates_api'
|
|
14
15
|
require_relative 'mailtrap/contacts_api'
|
|
15
16
|
require_relative 'mailtrap/contact_lists_api'
|
|
16
17
|
require_relative 'mailtrap/contact_fields_api'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mailtrap
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.17.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Railsware Products Studio LLC
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|
|
@@ -117,6 +117,8 @@ files:
|
|
|
117
117
|
- lib/mailtrap/sub_accounts_api.rb
|
|
118
118
|
- lib/mailtrap/suppression.rb
|
|
119
119
|
- lib/mailtrap/suppressions_api.rb
|
|
120
|
+
- lib/mailtrap/template.rb
|
|
121
|
+
- lib/mailtrap/templates_api.rb
|
|
120
122
|
- lib/mailtrap/tracking_opt_out.rb
|
|
121
123
|
- lib/mailtrap/tracking_opt_outs_api.rb
|
|
122
124
|
- lib/mailtrap/tracking_opt_outs_list_response.rb
|