mailtrap 2.14.0 → 2.16.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: c0e9b68ca02cc19cc2c9800b4ea92a41082f50e71a79c1df11be822007e462f0
4
- data.tar.gz: 426de0d20a602d9e792eb71a1fb8d7bfcf5d9b449d5159cff16c1b7e1ac2bb7c
3
+ metadata.gz: 5a727114a65c3b0d37de9dcc946d8e5d7d0c5c786b408844c4d399b9ae8caa32
4
+ data.tar.gz: 0ca0ebb87fe19a6d1a59268da9ba4b5f7cbe5c85224236764aa94dad103d6dc7
5
5
  SHA512:
6
- metadata.gz: ca735c6afbeca23e39833447203a8988ba07b4cce4e926d78580c4efb8978b51d96afadeaf60975169d2ed44a32be47b1236a803351b9c98c66aa50a7cd8f2dd
7
- data.tar.gz: defd7a908427006d002903ffe24d286ee7f15fcd2de28497056f2c9b0bf9fabfa1a0c471bb1d4f31ecae5ca8dab272001ce55f5ace461eac7dc5ed18eb8a1740
6
+ metadata.gz: b3b319869ad41f336475b58a86ef8d2b4c4e13979ae740690b5b4f95429b0094b0387ea7e1cde605085735e61bcc710af7c2424a7a7b44144c7db9fedb265ebd
7
+ data.tar.gz: 3d93fccceadcf06720feda85ff17ff2278df6f1a93f6b734e14e57f7a4d843b77cda69f88c350290f415474920a70c63056a6446265cba1e0d56c2601c7ffd02
data/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## [2.16.0] - 2026-08-31
2
+
3
+ ## What's Changed
4
+ * MT-23076: support expires_at for api token create and reset by @oshchyhol in https://github.com/mailtrap/mailtrap-ruby/pull/122
5
+ * MT-23762: redact api token values from VCR cassettes by @oshchyhol in https://github.com/mailtrap/mailtrap-ruby/pull/125
6
+
7
+ ## New Contributors
8
+ * @oshchyhol made their first contribution in https://github.com/mailtrap/mailtrap-ruby/pull/122
9
+
10
+ **Full Changelog**: https://github.com/mailtrap/mailtrap-ruby/compare/v2.15.0...v2.16.0
11
+
12
+ ## [2.15.0] - 2026-08-28
13
+
14
+ ## What's Changed
15
+ * Accept all sending domain update options by @mklocek in https://github.com/mailtrap/mailtrap-ruby/pull/126
16
+ * Add tracking opt-outs and create-suppression endpoints by @mklocek in https://github.com/mailtrap/mailtrap-ruby/pull/127
17
+
18
+
19
+ **Full Changelog**: https://github.com/mailtrap/mailtrap-ruby/compare/v2.14.0...v2.15.0
20
+
1
21
  ## [2.14.0] - 2026-08-14
2
22
 
3
23
  ## What's Changed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mailtrap (2.14.0)
4
+ mailtrap (2.16.0)
5
5
  base64
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -179,6 +179,8 @@ Email API:
179
179
  - Sending Stats API – [`stats_api.rb`](examples/stats_api.rb)
180
180
  - Email Logs API – [`email_logs_api.rb`](examples/email_logs_api.rb)
181
181
  - Webhooks API – [`webhooks_api.rb`](examples/webhooks_api.rb)
182
+ - Suppressions API – [`suppressions_api.rb`](examples/suppressions_api.rb)
183
+ - Tracking Opt-outs API – [`tracking_opt_outs_api.rb`](examples/tracking_opt_outs_api.rb)
182
184
 
183
185
  Email Sandbox (Testing):
184
186
 
@@ -206,7 +208,9 @@ General:
206
208
 
207
209
  - Accounts API – [`accounts_api.rb`](examples/accounts_api.rb)
208
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)
209
212
  - Billing API – [`billing_api.rb`](examples/billing_api.rb)
213
+ - Permissions API – [`permissions_api.rb`](examples/permissions_api.rb)
210
214
  - Templates API – [`email_templates_api.rb`](examples/email_templates_api.rb)
211
215
  - Action Mailer – [`action_mailer.rb`](examples/action_mailer.rb)
212
216
  - Verifying webhook signatures – [`webhooks_signature_verification.ru`](examples/webhooks_signature_verification.ru)
@@ -7,8 +7,6 @@ module Mailtrap
7
7
  class AccountAccessesAPI
8
8
  include BaseAPI
9
9
 
10
- attr_reader :account_id
11
-
12
10
  self.response_class = AccountAccess
13
11
 
14
12
  # Retrieves a list of account accesses with optional filtering by domain, inbox, or project IDs
@@ -9,8 +9,6 @@ module Mailtrap
9
9
 
10
10
  self.response_class = Account
11
11
 
12
- attr_reader :client
13
-
14
12
  # @param client [Mailtrap::Client] The client instance
15
13
  # @raise [ArgumentError] If account_id is nil
16
14
  def initialize(client = Mailtrap::Client.new)
@@ -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
 
@@ -22,8 +22,6 @@ module Mailtrap
22
22
 
23
23
  self.response_class = EmailCampaign
24
24
 
25
- attr_reader :client
26
-
27
25
  # @param client [Mailtrap::Client] The client instance
28
26
  def initialize(client = Mailtrap::Client.new)
29
27
  @client = client
@@ -10,7 +10,6 @@ module Mailtrap
10
10
  self.supported_options = %i[name]
11
11
  self.response_class = InboundFolder
12
12
 
13
- # Inbound is scoped to the token's account, so no account_id is required.
14
13
  # @param client [Mailtrap::Client] The client instance
15
14
  def initialize(client = Mailtrap::Client.new)
16
15
  @client = client
@@ -12,7 +12,6 @@ module Mailtrap
12
12
  CREATE_OPTIONS = %i[name domain_id].freeze
13
13
  UPDATE_OPTIONS = %i[name].freeze
14
14
 
15
- # Inbound is scoped to the token's account, so no account_id is required.
16
15
  # @param client [Mailtrap::Client] The client instance
17
16
  def initialize(client = Mailtrap::Client.new)
18
17
  @client = client
@@ -14,7 +14,6 @@ module Mailtrap
14
14
 
15
15
  SEND_OPTIONS = %i[from to cc bcc reply_to text html category attachments headers custom_variables].freeze
16
16
 
17
- # Inbound is scoped to the token's account, so no account_id is required.
18
17
  # @param client [Mailtrap::Client] The client instance
19
18
  def initialize(client = Mailtrap::Client.new)
20
19
  @client = client
@@ -12,7 +12,6 @@ module Mailtrap
12
12
 
13
13
  self.response_class = InboundThread
14
14
 
15
- # Inbound is scoped to the token's account, so no account_id is required.
16
15
  # @param client [Mailtrap::Client] The client instance
17
16
  def initialize(client = Mailtrap::Client.new)
18
17
  @client = client
@@ -7,7 +7,7 @@ module Mailtrap
7
7
  class SandboxAttachmentsAPI
8
8
  include BaseAPI
9
9
 
10
- attr_reader :account_id, :inbox_id, :sandbox_message_id, :client
10
+ attr_reader :inbox_id, :sandbox_message_id
11
11
 
12
12
  self.response_class = SandboxAttachment
13
13
 
@@ -7,7 +7,7 @@ module Mailtrap
7
7
  class SandboxMessagesAPI
8
8
  include BaseAPI
9
9
 
10
- attr_reader :account_id, :inbox_id, :client
10
+ attr_reader :inbox_id
11
11
 
12
12
  self.supported_options = %i[is_read]
13
13
 
@@ -12,6 +12,7 @@ module Mailtrap
12
12
  # @attr_reader dns_records [Array] The DNS records for the sending domain
13
13
  # @attr_reader open_tracking_enabled [Boolean] Whether open tracking is enabled
14
14
  # @attr_reader click_tracking_enabled [Boolean] Whether click tracking is enabled
15
+ # @attr_reader tracking_opt_out_enabled [Boolean] Whether the tracking opt-out link is enabled
15
16
  # @attr_reader auto_unsubscribe_link_enabled [Boolean] Whether auto unsubscribe link is enabled
16
17
  # @attr_reader custom_domain_tracking_enabled [Boolean] Whether custom domain tracking is enabled
17
18
  # @attr_reader health_alerts_enabled [Boolean] Whether health alerts are enabled
@@ -31,6 +32,7 @@ module Mailtrap
31
32
  :dns_records,
32
33
  :open_tracking_enabled,
33
34
  :click_tracking_enabled,
35
+ :tracking_opt_out_enabled,
34
36
  :auto_unsubscribe_link_enabled,
35
37
  :custom_domain_tracking_enabled,
36
38
  :health_alerts_enabled,
@@ -7,7 +7,13 @@ module Mailtrap
7
7
  class SendingDomainsAPI
8
8
  include BaseAPI
9
9
 
10
- self.supported_options = %i[open_tracking_enabled click_tracking_enabled auto_unsubscribe_link_enabled]
10
+ self.supported_options = %i[
11
+ open_tracking_enabled
12
+ click_tracking_enabled
13
+ tracking_opt_out_enabled
14
+ auto_unsubscribe_link_enabled
15
+ inbound_enabled
16
+ ]
11
17
 
12
18
  self.response_class = SendingDomain
13
19
 
@@ -50,7 +56,9 @@ module Mailtrap
50
56
  # @param [Hash] options The parameters to update
51
57
  # @option options [Boolean] :open_tracking_enabled Enable open tracking for emails sent from this domain
52
58
  # @option options [Boolean] :click_tracking_enabled Enable click tracking for links in emails sent from this domain
59
+ # @option options [Boolean] :tracking_opt_out_enabled Enable the tracking opt-out link in tracked emails
53
60
  # @option options [Boolean] :auto_unsubscribe_link_enabled Automatically add an unsubscribe link to emails
61
+ # @option options [Boolean] :inbound_enabled Enable inbound email for this domain
54
62
  # @return [SendingDomain] Updated sending domain
55
63
  # @!macro api_errors
56
64
  # @raise [ArgumentError] If invalid options are provided
@@ -7,6 +7,8 @@ module Mailtrap
7
7
  class SuppressionsAPI
8
8
  include BaseAPI
9
9
 
10
+ self.supported_options = %i[email domain_id sending_stream type].freeze
11
+
10
12
  self.response_class = Suppression
11
13
 
12
14
  # Lists all suppressions for the account
@@ -20,12 +22,28 @@ module Mailtrap
20
22
  base_list(query_params)
21
23
  end
22
24
 
25
+ # Adds an email address to the account's suppression list
26
+ # @param [Hash] options The suppression attributes
27
+ # @option options [String] :email Email address to suppress
28
+ # @option options [Integer] :domain_id ID of the domain to suppress this email for
29
+ # @option options [String] :sending_stream The sending stream to suppress for: "transactional" or "bulk"
30
+ # @option options [String] :type Reason for the suppression, defaults to "manual import" when omitted
31
+ # @return [Suppression] Created suppression
32
+ # @!macro api_errors
33
+ # @raise [ArgumentError] If invalid options are provided
34
+ def create(options)
35
+ validate_options!(options, supported_options)
36
+ response = client.post(base_path, options)
37
+ build_entity(response[:data], Suppression)
38
+ end
39
+
23
40
  # Deletes a suppression
24
41
  # @param suppression_id [String] The suppression UUID
25
- # @return nil
42
+ # @return [Suppression] The deleted suppression
26
43
  # @!macro api_errors
27
44
  def delete(suppression_id)
28
- client.delete("#{base_path}/#{suppression_id}")
45
+ response = client.delete("#{base_path}/#{suppression_id}")
46
+ build_entity(response, Suppression)
29
47
  end
30
48
 
31
49
  private
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mailtrap
4
+ # Data Transfer Object for Tracking Opt-out
5
+ # @see https://docs.mailtrap.io/developers/management/tracking-opt-outs
6
+ # @attr_reader id [String] The tracking opt-out UUID
7
+ # @attr_reader email [String] The email address opted out of tracking
8
+ # @attr_reader created_at [String] The creation timestamp
9
+ # @attr_reader domain_name [String, nil] Sending domain the tracking opt-out applies to
10
+ TrackingOptOut = Struct.new(
11
+ :id,
12
+ :email,
13
+ :created_at,
14
+ :domain_name,
15
+ keyword_init: true
16
+ )
17
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base_api'
4
+ require_relative 'tracking_opt_out'
5
+ require_relative 'tracking_opt_outs_list_response'
6
+
7
+ module Mailtrap
8
+ class TrackingOptOutsAPI
9
+ include BaseAPI
10
+
11
+ self.supported_options = %i[email domain_id].freeze
12
+
13
+ self.response_class = TrackingOptOut
14
+
15
+ # @param client [Mailtrap::Client] The client instance
16
+ def initialize(client = Mailtrap::Client.new)
17
+ @client = client
18
+ end
19
+
20
+ # Lists email addresses that have opted out of open and click tracking
21
+ # @param email [String, nil] Filter by exact email address (case-insensitive)
22
+ # @param start_time [String, nil] Only opt-outs created at or after this ISO 8601 timestamp
23
+ # @param end_time [String, nil] Only opt-outs created at or before this ISO 8601 timestamp
24
+ # @param last_id [String, nil] Cursor from the previous response's +last_id+ for the next page
25
+ # @return [TrackingOptOutsListResponse] The page of tracking opt-outs and the next cursor
26
+ # @!macro api_errors
27
+ def list(email: nil, start_time: nil, end_time: nil, last_id: nil)
28
+ query_params = {}
29
+ query_params[:email] = email unless email.nil?
30
+ query_params[:start_time] = start_time unless start_time.nil?
31
+ query_params[:end_time] = end_time unless end_time.nil?
32
+ query_params[:last_id] = last_id unless last_id.nil?
33
+
34
+ response = client.get(base_path, query_params)
35
+
36
+ TrackingOptOutsListResponse.new(
37
+ data: Array(response[:data]).map { |item| build_entity(item, TrackingOptOut) },
38
+ last_id: response[:last_id]
39
+ )
40
+ end
41
+
42
+ # Adds an email address to the tracking opt-out list for a sending domain
43
+ # @param [Hash] options The tracking opt-out attributes
44
+ # @option options [String] :email Email address to opt out of tracking
45
+ # @option options [Integer] :domain_id ID of the sending domain the opt-out applies to
46
+ # @return [TrackingOptOut] Created tracking opt-out
47
+ # @!macro api_errors
48
+ # @raise [ArgumentError] If invalid options are provided
49
+ def create(options)
50
+ validate_options!(options, supported_options)
51
+ response = client.post(base_path, options)
52
+ build_entity(response[:data], TrackingOptOut)
53
+ end
54
+
55
+ # Removes an email address from the tracking opt-out list
56
+ # @param tracking_opt_out_id [String] The tracking opt-out UUID
57
+ # @return [TrackingOptOut] The deleted tracking opt-out
58
+ # @!macro api_errors
59
+ def delete(tracking_opt_out_id)
60
+ response = client.delete("#{base_path}/#{tracking_opt_out_id}")
61
+ build_entity(response, TrackingOptOut)
62
+ end
63
+
64
+ private
65
+
66
+ def base_path
67
+ '/api/tracking_opt_outs'
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mailtrap
4
+ # Data Transfer Object for a paginated list of tracking opt-outs
5
+ # @see https://docs.mailtrap.io/developers/management/tracking-opt-outs
6
+ # @attr_reader data [Array<TrackingOptOut>] The tracking opt-outs on this page
7
+ # @attr_reader last_id [String, nil] Cursor for the next page, or nil if this is the last page
8
+ TrackingOptOutsListResponse = Struct.new(
9
+ :data,
10
+ :last_id,
11
+ keyword_init: true
12
+ )
13
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mailtrap
4
- VERSION = '2.14.0'
4
+ VERSION = '2.16.0'
5
5
  end
data/lib/mailtrap.rb CHANGED
@@ -18,6 +18,7 @@ require_relative 'mailtrap/contact_imports_api'
18
18
  require_relative 'mailtrap/contact_exports_api'
19
19
  require_relative 'mailtrap/contact_events_api'
20
20
  require_relative 'mailtrap/suppressions_api'
21
+ require_relative 'mailtrap/tracking_opt_outs_api'
21
22
  require_relative 'mailtrap/email_campaigns_api'
22
23
  require_relative 'mailtrap/sending_domains_api'
23
24
  require_relative 'mailtrap/company_info_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.14.0
4
+ version: 2.16.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-17 00:00:00.000000000 Z
11
+ date: 2026-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -117,6 +117,9 @@ 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/tracking_opt_out.rb
121
+ - lib/mailtrap/tracking_opt_outs_api.rb
122
+ - lib/mailtrap/tracking_opt_outs_list_response.rb
120
123
  - lib/mailtrap/version.rb
121
124
  - lib/mailtrap/webhook.rb
122
125
  - lib/mailtrap/webhooks.rb