mailtrap 2.14.0 → 2.15.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: ba78e8e22574eb5404c0e4d14f5a4ad764dabc559a3fd58bc0ae9ba46a49ea3f
4
+ data.tar.gz: da43055430599e2f496fc794fb145bacb7d589785b2387f6296ed978db57c4ac
5
5
  SHA512:
6
- metadata.gz: ca735c6afbeca23e39833447203a8988ba07b4cce4e926d78580c4efb8978b51d96afadeaf60975169d2ed44a32be47b1236a803351b9c98c66aa50a7cd8f2dd
7
- data.tar.gz: defd7a908427006d002903ffe24d286ee7f15fcd2de28497056f2c9b0bf9fabfa1a0c471bb1d4f31ecae5ca8dab272001ce55f5ace461eac7dc5ed18eb8a1740
6
+ metadata.gz: 7e5eb305e76d483f99711da0d2c913b1fdab00c8010bd55b697171284bd712d78545096dd5af9ffeab6886c06518b8c8f515edf42cf0b3e41dab4d98f7265a5b
7
+ data.tar.gz: e9c400428a9e86678a2b6fd6c6ef6ddbada0726ecfac29e9b254021b6a9f9143f912e81f6ba967084fa94c16c4ac19aaaa7e01699ad98a31ef4d3e934d37cd9d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [2.15.0] - 2026-08-28
2
+
3
+ ## What's Changed
4
+ * Accept all sending domain update options by @mklocek in https://github.com/mailtrap/mailtrap-ruby/pull/126
5
+ * Add tracking opt-outs and create-suppression endpoints by @mklocek in https://github.com/mailtrap/mailtrap-ruby/pull/127
6
+
7
+
8
+ **Full Changelog**: https://github.com/mailtrap/mailtrap-ruby/compare/v2.14.0...v2.15.0
9
+
1
10
  ## [2.14.0] - 2026-08-14
2
11
 
3
12
  ## 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.15.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
 
@@ -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)
@@ -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.15.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.15.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-28 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