mailtrap 2.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba78e8e22574eb5404c0e4d14f5a4ad764dabc559a3fd58bc0ae9ba46a49ea3f
4
- data.tar.gz: da43055430599e2f496fc794fb145bacb7d589785b2387f6296ed978db57c4ac
3
+ metadata.gz: cf895b774a80d6579230f2629793150d13be0648536b9c88524f6149ae39feb9
4
+ data.tar.gz: 50169e072e02c1509a9da6b7b933ad8fe1b6b6d219f50771696d3f5f62cc4674
5
5
  SHA512:
6
- metadata.gz: 7e5eb305e76d483f99711da0d2c913b1fdab00c8010bd55b697171284bd712d78545096dd5af9ffeab6886c06518b8c8f515edf42cf0b3e41dab4d98f7265a5b
7
- data.tar.gz: e9c400428a9e86678a2b6fd6c6ef6ddbada0726ecfac29e9b254021b6a9f9143f912e81f6ba967084fa94c16c4ac19aaaa7e01699ad98a31ef4d3e934d37cd9d
6
+ metadata.gz: 7da15a7343f680b071be20f34f3223582351e66de800600d48c84afd46ee78d9dad96220fb9885f4498f0d62617cb35b16a0957169d3e79639d071509177c52d
7
+ data.tar.gz: 4c4a95c0fdbf908287f60e6ae15ff0332a24ee35e217643f80664a6ef379d80216902335c4d7b8108c05301f3f7e46e39ef232f1293e1ee70a9edc41533a0334
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
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
+
11
+ ## [2.16.0] - 2026-08-31
12
+
13
+ ## What's Changed
14
+ * MT-23076: support expires_at for api token create and reset by @oshchyhol in https://github.com/mailtrap/mailtrap-ruby/pull/122
15
+ * MT-23762: redact api token values from VCR cassettes by @oshchyhol in https://github.com/mailtrap/mailtrap-ruby/pull/125
16
+
17
+ ## New Contributors
18
+ * @oshchyhol made their first contribution in https://github.com/mailtrap/mailtrap-ruby/pull/122
19
+
20
+ **Full Changelog**: https://github.com/mailtrap/mailtrap-ruby/compare/v2.15.0...v2.16.0
21
+
1
22
  ## [2.15.0] - 2026-08-28
2
23
 
3
24
  ## What's Changed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mailtrap (2.15.0)
4
+ mailtrap (2.17.0)
5
5
  base64
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -208,8 +208,11 @@ General:
208
208
 
209
209
  - Accounts API – [`accounts_api.rb`](examples/accounts_api.rb)
210
210
  - Account Accesses API – [`account_accesses_api.rb`](examples/account_accesses_api.rb)
211
+ - API Tokens API – [`api_tokens_api.rb`](examples/api_tokens_api.rb)
211
212
  - Billing API – [`billing_api.rb`](examples/billing_api.rb)
212
- - Templates API – [`email_templates_api.rb`](examples/email_templates_api.rb)
213
+ - Permissions API – [`permissions_api.rb`](examples/permissions_api.rb)
214
+ - Templates API (experimental) – [`templates_api.rb`](examples/templates_api.rb)
215
+ - Email Templates API – [`email_templates_api.rb`](examples/email_templates_api.rb)
213
216
  - Action Mailer – [`action_mailer.rb`](examples/action_mailer.rb)
214
217
  - Verifying webhook signatures – [`webhooks_signature_verification.ru`](examples/webhooks_signature_verification.ru)
215
218
 
@@ -7,7 +7,7 @@ module Mailtrap
7
7
  class ApiTokensAPI
8
8
  include BaseAPI
9
9
 
10
- self.supported_options = %i[name resources].freeze
10
+ self.supported_options = %i[name expires_at resources].freeze
11
11
 
12
12
  self.response_class = ApiToken
13
13
 
@@ -30,6 +30,9 @@ module Mailtrap
30
30
  # Creates a new API token. The full `token` value is returned ONLY ONCE — store it securely.
31
31
  # @param [Hash] options The parameters to create
32
32
  # @option options [String] :name Display name for the token
33
+ # @option options [String, nil] :expires_at Optional token expiration as an ISO 8601 date-time.
34
+ # Omit for the server default (a 1-year default is being rolled out). Pass explicit nil for
35
+ # a token that never expires. Past or more-than-5-years-ahead values are rejected with 422
33
36
  # @option options [Array<Hash>] :resources Permissions to assign
34
37
  # - `{ resource_type:, resource_id:, access_level: }`
35
38
  # @return [ApiToken] Created token (full `token` value populated)
@@ -43,10 +46,17 @@ module Mailtrap
43
46
  # The old token stops working after a short grace period. The new `token` value is
44
47
  # returned ONLY ONCE — store it securely
45
48
  # @param token_id [Integer] The API token ID
49
+ # @param [Hash] options The reset parameters
50
+ # @option options [String, nil] :expires_at Optional token expiration as an ISO 8601 date-time.
51
+ # Omit for the server default (a 1-year default is being rolled out). Pass explicit nil for
52
+ # a token that never expires. Past or more-than-5-years-ahead values are rejected with 422
46
53
  # @return [ApiToken] New token (full `token` value populated)
47
54
  # @!macro api_errors
48
- def reset(token_id)
49
- response = client.post("#{base_path}/#{token_id}/reset")
55
+ # @raise [ArgumentError] If invalid options are provided
56
+ def reset(token_id, options = {})
57
+ validate_options!(options, %i[expires_at])
58
+ # An empty hash must not be sent as a body — the endpoint historically takes no body
59
+ response = client.post("#{base_path}/#{token_id}/reset", options.empty? ? nil : options)
50
60
  handle_response(response)
51
61
  end
52
62
 
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mailtrap
4
- VERSION = '2.15.0'
4
+ VERSION = '2.17.0'
5
5
  end
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.15.0
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-08-28 00:00:00.000000000 Z
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