mailtrap 2.19.0 → 2.20.1
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 +17 -0
- data/Gemfile.lock +1 -1
- data/README.md +41 -7
- data/lib/mailtrap/account_accesses_api.rb +2 -2
- data/lib/mailtrap/action_mailer/delivery_method.rb +13 -2
- data/lib/mailtrap/base_api.rb +6 -0
- data/lib/mailtrap/billing_usage.rb +1 -1
- data/lib/mailtrap/client.rb +23 -9
- data/lib/mailtrap/company_info.rb +1 -1
- data/lib/mailtrap/company_info_api.rb +14 -14
- data/lib/mailtrap/deprecation.rb +37 -0
- data/lib/mailtrap/domain.rb +48 -0
- data/lib/mailtrap/domains_api.rb +88 -0
- data/lib/mailtrap/email_campaign.rb +3 -3
- data/lib/mailtrap/email_campaigns_api.rb +4 -4
- data/lib/mailtrap/email_log_message.rb +1 -1
- data/lib/mailtrap/inbound_inbox.rb +1 -1
- data/lib/mailtrap/inbox.rb +5 -53
- data/lib/mailtrap/inboxes_api.rb +7 -108
- data/lib/mailtrap/marketing_stats_api.rb +1 -1
- data/lib/mailtrap/project.rb +1 -1
- data/lib/mailtrap/projects_api.rb +2 -2
- data/lib/mailtrap/sandbox.rb +57 -0
- data/lib/mailtrap/sandbox_attachments_api.rb +15 -7
- data/lib/mailtrap/sandbox_message.rb +1 -1
- data/lib/mailtrap/sandbox_messages_api.rb +16 -8
- data/lib/mailtrap/sandboxes_api.rb +117 -0
- data/lib/mailtrap/sending_domain.rb +5 -44
- data/lib/mailtrap/sending_domains_api.rb +7 -80
- data/lib/mailtrap/stats_api.rb +5 -5
- data/lib/mailtrap/sub_accounts_api.rb +13 -0
- data/lib/mailtrap/tracking_opt_out.rb +1 -1
- data/lib/mailtrap/tracking_opt_outs_api.rb +2 -2
- data/lib/mailtrap/version.rb +1 -1
- data/lib/mailtrap/webhook.rb +1 -1
- data/lib/mailtrap/webhooks_api.rb +1 -1
- data/lib/mailtrap.rb +2 -0
- metadata +7 -3
- data/mailtrap.gemspec +0 -34
data/lib/mailtrap/inboxes_api.rb
CHANGED
|
@@ -1,116 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative '
|
|
3
|
+
require_relative 'deprecation'
|
|
4
|
+
require_relative 'sandboxes_api'
|
|
4
5
|
require_relative 'inbox'
|
|
5
6
|
|
|
6
7
|
module Mailtrap
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
# Lists all Inboxes for the account
|
|
14
|
-
# @return [Array<Inbox>] Array of Inboxes
|
|
15
|
-
# @!macro api_errors
|
|
16
|
-
def list
|
|
17
|
-
base_list
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# Retrieves a specific inbox
|
|
21
|
-
# @param inbox_id [Integer] The inbox identifier
|
|
22
|
-
# @return [Inbox] Inbox object
|
|
23
|
-
# @!macro api_errors
|
|
24
|
-
def get(inbox_id)
|
|
25
|
-
base_get(inbox_id)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# Creates a new inbox
|
|
29
|
-
# @param [Hash] options The parameters to create
|
|
30
|
-
# @option options [String] :name The inbox name
|
|
31
|
-
# @return [Inbox] Created inbox object
|
|
32
|
-
# @!macro api_errors
|
|
33
|
-
# @raise [ArgumentError] If invalid options are provided
|
|
34
|
-
def create(options)
|
|
35
|
-
validate_options!(options, supported_options + [:project_id])
|
|
36
|
-
response = client.post("/api/accounts/#{account_id}/projects/#{options[:project_id]}/inboxes",
|
|
37
|
-
wrap_request(options))
|
|
38
|
-
handle_response(response)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Deletes an inbox
|
|
42
|
-
# @param inbox_id [Integer] The Inbox identifier
|
|
43
|
-
# @return nil
|
|
44
|
-
# @!macro api_errors
|
|
45
|
-
def delete(inbox_id)
|
|
46
|
-
base_delete(inbox_id)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# Updates an existing Inbox
|
|
50
|
-
# @param inbox_id [Integer] The Inbox identifier
|
|
51
|
-
# @param [Hash] options The parameters to update
|
|
52
|
-
# @option options [String] :name The inbox name
|
|
53
|
-
# @option options [String] :email_username The inbox email username
|
|
54
|
-
# @return [Inbox] Updated Inbox object
|
|
55
|
-
# @!macro api_errors
|
|
56
|
-
# @raise [ArgumentError] If invalid options are provided
|
|
57
|
-
def update(inbox_id, options)
|
|
58
|
-
base_update(inbox_id, options, supported_options + [:email_username])
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
# Delete all messages (emails) from Inbox
|
|
62
|
-
# @param inbox_id [Integer] The Inbox identifier
|
|
63
|
-
# @return [Inbox] Updated Inbox object
|
|
64
|
-
# @!macro api_errors
|
|
65
|
-
def clean(inbox_id)
|
|
66
|
-
response = client.patch("#{base_path}/#{inbox_id}/clean")
|
|
67
|
-
handle_response(response)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
# Mark all messages in the inbox as read
|
|
71
|
-
# @param inbox_id [Integer] The Inbox identifier
|
|
72
|
-
# @return [Inbox] Updated Inbox object
|
|
73
|
-
# @!macro api_errors
|
|
74
|
-
def mark_as_read(inbox_id)
|
|
75
|
-
response = client.patch("#{base_path}/#{inbox_id}/all_read")
|
|
76
|
-
handle_response(response)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
# Reset SMTP credentials of the inbox
|
|
80
|
-
# @param inbox_id [Integer] The Inbox identifier
|
|
81
|
-
# @return [Inbox] Updated Inbox object
|
|
82
|
-
# @!macro api_errors
|
|
83
|
-
def reset_credentials(inbox_id)
|
|
84
|
-
response = client.patch("#{base_path}/#{inbox_id}/reset_credentials")
|
|
85
|
-
handle_response(response)
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
# Turn the email address of the inbox on/off
|
|
89
|
-
# @param inbox_id [Integer] The Inbox identifier
|
|
90
|
-
# @return [Inbox] Updated Inbox object
|
|
91
|
-
# @!macro api_errors
|
|
92
|
-
def toggle_email_username(inbox_id)
|
|
93
|
-
response = client.patch("#{base_path}/#{inbox_id}/toggle_email_username")
|
|
94
|
-
handle_response(response)
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
# Reset username of email address per inbox
|
|
98
|
-
# @param inbox_id [Integer] The Inbox identifier
|
|
99
|
-
# @return [Inbox] Updated Inbox object
|
|
100
|
-
# @!macro api_errors
|
|
101
|
-
def reset_email_username(inbox_id)
|
|
102
|
-
response = client.patch("#{base_path}/#{inbox_id}/reset_email_username")
|
|
103
|
-
handle_response(response)
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
private
|
|
107
|
-
|
|
108
|
-
def wrap_request(options)
|
|
109
|
-
{ inbox: options }
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def base_path
|
|
113
|
-
"/api/accounts/#{account_id}/inboxes"
|
|
8
|
+
# @deprecated Use {SandboxesAPI} instead.
|
|
9
|
+
class InboxesAPI < SandboxesAPI
|
|
10
|
+
def initialize(*)
|
|
11
|
+
Deprecation.warn('Mailtrap::InboxesAPI', 'Mailtrap::SandboxesAPI')
|
|
12
|
+
super
|
|
114
13
|
end
|
|
115
14
|
end
|
|
116
15
|
end
|
|
@@ -18,7 +18,7 @@ module Mailtrap
|
|
|
18
18
|
# as Email Marketing > Stats Overview in the app. Email API/SMTP traffic is reported by {StatsAPI}.
|
|
19
19
|
# @param start_date [String, Date, Time] Start of the period, inclusive (required)
|
|
20
20
|
# @param end_date [String, Date, Time] End of the period, inclusive (required)
|
|
21
|
-
# @param sending_domain_ids [Array<Integer>] Filter by
|
|
21
|
+
# @param sending_domain_ids [Array<Integer>] Filter by domain IDs
|
|
22
22
|
# @param sources [Array<String>] Filter by source: +campaigns+ or +automations+;
|
|
23
23
|
# omit it, or pass both, to include campaigns and automations together
|
|
24
24
|
# @param email_service_providers [Array<String>] Filter by recipient email service providers
|
data/lib/mailtrap/project.rb
CHANGED
|
@@ -6,7 +6,7 @@ module Mailtrap
|
|
|
6
6
|
# @attr_reader id [Integer] The project ID
|
|
7
7
|
# @attr_reader name [String] The project name
|
|
8
8
|
# @attr_reader share_links [Hash] Admin and viewer share links
|
|
9
|
-
# @attr_reader inboxes [Array<Mailtrap::
|
|
9
|
+
# @attr_reader inboxes [Array<Mailtrap::Sandbox>] Array of the project's sandboxes
|
|
10
10
|
# @attr_reader permissions [Hash] List of permissions
|
|
11
11
|
#
|
|
12
12
|
Project = Struct.new(
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative 'base_api'
|
|
4
4
|
require_relative 'project'
|
|
5
|
-
require_relative '
|
|
5
|
+
require_relative 'sandbox'
|
|
6
6
|
|
|
7
7
|
module Mailtrap
|
|
8
8
|
class ProjectsAPI
|
|
@@ -60,7 +60,7 @@ module Mailtrap
|
|
|
60
60
|
def handle_response(response)
|
|
61
61
|
build_entity(
|
|
62
62
|
response.merge(
|
|
63
|
-
inboxes: response[:inboxes]&.map { |
|
|
63
|
+
inboxes: response[:inboxes]&.map { |sandbox| build_entity(sandbox, Mailtrap::Sandbox) }
|
|
64
64
|
),
|
|
65
65
|
response_class
|
|
66
66
|
)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailtrap
|
|
4
|
+
# Data Transfer Object for Sandbox
|
|
5
|
+
# @see https://api-docs.mailtrap.io/docs/mailtrap-api-docs/ee252e413d78a-create-project
|
|
6
|
+
# @attr_reader id [Integer] The sandbox ID
|
|
7
|
+
# @attr_reader name [String] The sandbox name
|
|
8
|
+
# @attr_reader username [String] The sandbox username
|
|
9
|
+
# @attr_reader password [String, nil] The sandbox password
|
|
10
|
+
# @attr_reader max_size [Integer] The maximum sandbox size in MB
|
|
11
|
+
# @attr_reader status [String] The sandbox status
|
|
12
|
+
# @attr_reader email_username [String] The email username
|
|
13
|
+
# @attr_reader email_username_enabled [Boolean] Whether the email username is enabled
|
|
14
|
+
# @attr_reader sent_messages_count [Integer] The count of sent messages
|
|
15
|
+
# @attr_reader forwarded_messages_count [Integer] The count of forwarded messages
|
|
16
|
+
# @attr_reader used [Boolean] Whether the sandbox has been used
|
|
17
|
+
# @attr_reader forward_from_email_address [String] The forwarding email address
|
|
18
|
+
# @attr_reader project_id [Integer] The associated project ID
|
|
19
|
+
# @attr_reader domain [String] The sandbox domain
|
|
20
|
+
# @attr_reader pop3_domain [String] The POP3 domain
|
|
21
|
+
# @attr_reader email_domain [String] The email domain
|
|
22
|
+
# @attr_reader api_domain [String] The API domain
|
|
23
|
+
# @attr_reader emails_count [Integer] The total number of emails
|
|
24
|
+
# @attr_reader emails_unread_count [Integer] The number of unread emails
|
|
25
|
+
# @attr_reader last_message_sent_at [String, nil] The timestamp of the last sent message
|
|
26
|
+
# @attr_reader smtp_ports [Array<Integer>] The list of SMTP ports
|
|
27
|
+
# @attr_reader pop3_ports [Array<Integer>] The list of POP3 ports
|
|
28
|
+
# @attr_reader max_message_size [Integer] The maximum message size in bytes
|
|
29
|
+
# @attr_reader permissions [Hash] List of permissions
|
|
30
|
+
Sandbox = Struct.new(
|
|
31
|
+
:id,
|
|
32
|
+
:name,
|
|
33
|
+
:username,
|
|
34
|
+
:password,
|
|
35
|
+
:max_size,
|
|
36
|
+
:status,
|
|
37
|
+
:email_username,
|
|
38
|
+
:email_username_enabled,
|
|
39
|
+
:sent_messages_count,
|
|
40
|
+
:forwarded_messages_count,
|
|
41
|
+
:used,
|
|
42
|
+
:forward_from_email_address,
|
|
43
|
+
:project_id,
|
|
44
|
+
:domain,
|
|
45
|
+
:pop3_domain,
|
|
46
|
+
:email_domain,
|
|
47
|
+
:api_domain,
|
|
48
|
+
:emails_count,
|
|
49
|
+
:emails_unread_count,
|
|
50
|
+
:last_message_sent_at,
|
|
51
|
+
:smtp_ports,
|
|
52
|
+
:pop3_ports,
|
|
53
|
+
:max_message_size,
|
|
54
|
+
:permissions,
|
|
55
|
+
keyword_init: true
|
|
56
|
+
)
|
|
57
|
+
end
|
|
@@ -1,32 +1,40 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative 'base_api'
|
|
4
|
+
require_relative 'deprecation'
|
|
4
5
|
require_relative 'sandbox_attachment'
|
|
5
6
|
|
|
6
7
|
module Mailtrap
|
|
7
8
|
class SandboxAttachmentsAPI
|
|
8
9
|
include BaseAPI
|
|
9
10
|
|
|
10
|
-
attr_reader :
|
|
11
|
+
attr_reader :sandbox_id, :sandbox_message_id
|
|
11
12
|
|
|
12
13
|
self.response_class = SandboxAttachment
|
|
13
14
|
|
|
14
15
|
# @param account_id [Integer] The account ID
|
|
15
|
-
# @param
|
|
16
|
+
# @param sandbox_id [Integer] The sandbox ID
|
|
16
17
|
# @param sandbox_message_id [Integer] The message ID
|
|
17
18
|
# @param client [Mailtrap::Client] The client instance
|
|
18
19
|
# @raise [ArgumentError] If account_id is nil
|
|
19
|
-
# @raise [ArgumentError] If
|
|
20
|
-
def initialize(account_id,
|
|
21
|
-
raise ArgumentError, '
|
|
20
|
+
# @raise [ArgumentError] If sandbox_id is nil
|
|
21
|
+
def initialize(account_id, sandbox_id, sandbox_message_id, client = Mailtrap::Client.new)
|
|
22
|
+
raise ArgumentError, 'sandbox_id is required' if sandbox_id.nil?
|
|
22
23
|
raise ArgumentError, 'sandbox_message_id is required' if sandbox_message_id.nil?
|
|
23
24
|
|
|
24
|
-
@
|
|
25
|
+
@sandbox_id = sandbox_id
|
|
25
26
|
@sandbox_message_id = sandbox_message_id
|
|
26
27
|
|
|
27
28
|
super(account_id, client)
|
|
28
29
|
end
|
|
29
30
|
|
|
31
|
+
# @deprecated Use {#sandbox_id} instead.
|
|
32
|
+
# @return [Integer] The sandbox ID
|
|
33
|
+
def inbox_id
|
|
34
|
+
Deprecation.warn('Mailtrap::SandboxAttachmentsAPI#inbox_id', 'Mailtrap::SandboxAttachmentsAPI#sandbox_id')
|
|
35
|
+
sandbox_id
|
|
36
|
+
end
|
|
37
|
+
|
|
30
38
|
# Retrieves a specific sandbox attachment
|
|
31
39
|
# @param sandbox_attachment_id [Integer] The sandbox attachment ID
|
|
32
40
|
# @return [SandboxAttachment] Sandbox attachment object
|
|
@@ -45,7 +53,7 @@ module Mailtrap
|
|
|
45
53
|
private
|
|
46
54
|
|
|
47
55
|
def base_path
|
|
48
|
-
"/api/accounts/#{account_id}/inboxes/#{
|
|
56
|
+
"/api/accounts/#{account_id}/inboxes/#{sandbox_id}/messages/#{sandbox_message_id}/attachments"
|
|
49
57
|
end
|
|
50
58
|
end
|
|
51
59
|
end
|
|
@@ -4,7 +4,7 @@ module Mailtrap
|
|
|
4
4
|
# Data Transfer Object for Sandbox Message
|
|
5
5
|
# @see https://docs.mailtrap.io/developers/email-sandbox/email-sandbox-api/messages
|
|
6
6
|
# @attr_reader id [Integer] The message ID
|
|
7
|
-
# @attr_reader inbox_id [Integer] The
|
|
7
|
+
# @attr_reader inbox_id [Integer] The sandbox ID
|
|
8
8
|
# @attr_reader subject [String] The message subject
|
|
9
9
|
# @attr_reader sent_at [String] The timestamp when the message was sent
|
|
10
10
|
# @attr_reader from_email [String] The sender's email address
|
|
@@ -1,32 +1,40 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative 'base_api'
|
|
4
|
+
require_relative 'deprecation'
|
|
4
5
|
require_relative 'sandbox_message'
|
|
5
6
|
|
|
6
7
|
module Mailtrap
|
|
7
8
|
class SandboxMessagesAPI
|
|
8
9
|
include BaseAPI
|
|
9
10
|
|
|
10
|
-
attr_reader :
|
|
11
|
+
attr_reader :sandbox_id
|
|
11
12
|
|
|
12
13
|
self.supported_options = %i[is_read]
|
|
13
14
|
|
|
14
15
|
self.response_class = SandboxMessage
|
|
15
16
|
|
|
16
17
|
# @param account_id [Integer] The account ID
|
|
17
|
-
# @param
|
|
18
|
+
# @param sandbox_id [Integer] The sandbox ID
|
|
18
19
|
# @param client [Mailtrap::Client] The client instance
|
|
19
20
|
# @raise [ArgumentError] If account_id is nil
|
|
20
|
-
# @raise [ArgumentError] If
|
|
21
|
-
def initialize(account_id,
|
|
22
|
-
raise ArgumentError, '
|
|
21
|
+
# @raise [ArgumentError] If sandbox_id is nil
|
|
22
|
+
def initialize(account_id, sandbox_id, client = Mailtrap::Client.new)
|
|
23
|
+
raise ArgumentError, 'sandbox_id is required' if sandbox_id.nil?
|
|
23
24
|
|
|
24
|
-
@
|
|
25
|
+
@sandbox_id = sandbox_id
|
|
25
26
|
|
|
26
27
|
super(account_id, client)
|
|
27
28
|
end
|
|
28
29
|
|
|
29
|
-
#
|
|
30
|
+
# @deprecated Use {#sandbox_id} instead.
|
|
31
|
+
# @return [Integer] The sandbox ID
|
|
32
|
+
def inbox_id
|
|
33
|
+
Deprecation.warn('Mailtrap::SandboxMessagesAPI#inbox_id', 'Mailtrap::SandboxMessagesAPI#sandbox_id')
|
|
34
|
+
sandbox_id
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Retrieves a specific sandbox message
|
|
30
38
|
# @param message_id [Integer] The sandbox message ID
|
|
31
39
|
# @return [SandboxMessage] Sandbox message object
|
|
32
40
|
# @!macro api_errors
|
|
@@ -165,7 +173,7 @@ module Mailtrap
|
|
|
165
173
|
private
|
|
166
174
|
|
|
167
175
|
def base_path
|
|
168
|
-
"/api/accounts/#{account_id}/inboxes/#{
|
|
176
|
+
"/api/accounts/#{account_id}/inboxes/#{sandbox_id}/messages"
|
|
169
177
|
end
|
|
170
178
|
|
|
171
179
|
def wrap_request(options)
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'base_api'
|
|
4
|
+
require_relative 'sandbox'
|
|
5
|
+
|
|
6
|
+
module Mailtrap
|
|
7
|
+
class SandboxesAPI
|
|
8
|
+
include BaseAPI
|
|
9
|
+
|
|
10
|
+
self.supported_options = %i[name]
|
|
11
|
+
self.response_class = Sandbox
|
|
12
|
+
|
|
13
|
+
# Lists all sandboxes for the account
|
|
14
|
+
# @return [Array<Sandbox>] Array of sandboxes
|
|
15
|
+
# @!macro api_errors
|
|
16
|
+
def list
|
|
17
|
+
base_list
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Retrieves a specific sandbox
|
|
21
|
+
# @param sandbox_id [Integer] The sandbox identifier
|
|
22
|
+
# @return [Sandbox] Sandbox object
|
|
23
|
+
# @!macro api_errors
|
|
24
|
+
def get(sandbox_id)
|
|
25
|
+
base_get(sandbox_id)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Creates a new sandbox
|
|
29
|
+
# @param [Hash] options The parameters to create
|
|
30
|
+
# @option options [String] :name The sandbox name
|
|
31
|
+
# @option options [Integer] :project_id The project ID. Required.
|
|
32
|
+
# @return [Sandbox] Created sandbox object
|
|
33
|
+
# @!macro api_errors
|
|
34
|
+
# @raise [ArgumentError] If invalid options are provided
|
|
35
|
+
def create(options)
|
|
36
|
+
validate_options!(options, supported_options + [:project_id])
|
|
37
|
+
response = client.post("/api/accounts/#{account_id}/projects/#{options[:project_id]}/inboxes",
|
|
38
|
+
wrap_request(options))
|
|
39
|
+
handle_response(response)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Deletes a sandbox
|
|
43
|
+
# @param sandbox_id [Integer] The sandbox identifier
|
|
44
|
+
# @return [Hash, nil] Deleted sandbox data, or nil when the API returns no content
|
|
45
|
+
# @!macro api_errors
|
|
46
|
+
def delete(sandbox_id)
|
|
47
|
+
base_delete(sandbox_id)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Updates an existing sandbox
|
|
51
|
+
# @param sandbox_id [Integer] The sandbox identifier
|
|
52
|
+
# @param [Hash] options The parameters to update
|
|
53
|
+
# @option options [String] :name The sandbox name
|
|
54
|
+
# @option options [String] :email_username The sandbox email username
|
|
55
|
+
# @return [Sandbox] Updated sandbox object
|
|
56
|
+
# @!macro api_errors
|
|
57
|
+
# @raise [ArgumentError] If invalid options are provided
|
|
58
|
+
def update(sandbox_id, options)
|
|
59
|
+
base_update(sandbox_id, options, supported_options + [:email_username])
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Delete all messages (emails) from the sandbox
|
|
63
|
+
# @param sandbox_id [Integer] The sandbox identifier
|
|
64
|
+
# @return [Sandbox] Updated sandbox object
|
|
65
|
+
# @!macro api_errors
|
|
66
|
+
def clean(sandbox_id)
|
|
67
|
+
response = client.patch("#{base_path}/#{sandbox_id}/clean")
|
|
68
|
+
handle_response(response)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Mark all messages in the sandbox as read
|
|
72
|
+
# @param sandbox_id [Integer] The sandbox identifier
|
|
73
|
+
# @return [Sandbox] Updated sandbox object
|
|
74
|
+
# @!macro api_errors
|
|
75
|
+
def mark_as_read(sandbox_id)
|
|
76
|
+
response = client.patch("#{base_path}/#{sandbox_id}/all_read")
|
|
77
|
+
handle_response(response)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Reset SMTP credentials of the sandbox
|
|
81
|
+
# @param sandbox_id [Integer] The sandbox identifier
|
|
82
|
+
# @return [Sandbox] Updated sandbox object
|
|
83
|
+
# @!macro api_errors
|
|
84
|
+
def reset_credentials(sandbox_id)
|
|
85
|
+
response = client.patch("#{base_path}/#{sandbox_id}/reset_credentials")
|
|
86
|
+
handle_response(response)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Turn the email address of the sandbox on/off
|
|
90
|
+
# @param sandbox_id [Integer] The sandbox identifier
|
|
91
|
+
# @return [Sandbox] Updated sandbox object
|
|
92
|
+
# @!macro api_errors
|
|
93
|
+
def toggle_email_username(sandbox_id)
|
|
94
|
+
response = client.patch("#{base_path}/#{sandbox_id}/toggle_email_username")
|
|
95
|
+
handle_response(response)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Reset username of email address per sandbox
|
|
99
|
+
# @param sandbox_id [Integer] The sandbox identifier
|
|
100
|
+
# @return [Sandbox] Updated sandbox object
|
|
101
|
+
# @!macro api_errors
|
|
102
|
+
def reset_email_username(sandbox_id)
|
|
103
|
+
response = client.patch("#{base_path}/#{sandbox_id}/reset_email_username")
|
|
104
|
+
handle_response(response)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
private
|
|
108
|
+
|
|
109
|
+
def wrap_request(options)
|
|
110
|
+
{ inbox: options }
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def base_path
|
|
114
|
+
"/api/accounts/#{account_id}/inboxes"
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -1,48 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative 'domain'
|
|
4
|
+
|
|
3
5
|
module Mailtrap
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
# @attr_reader domain_name [String] The sending domain name
|
|
8
|
-
# @attr_reader demo [Boolean] Whether the sending domain is a demo domain
|
|
9
|
-
# @attr_reader compliance_status [String] The compliance status of the sending domain
|
|
10
|
-
# @attr_reader dns_verified [Boolean] Whether the DNS records are verified
|
|
11
|
-
# @attr_reader dns_verified_at [String, nil] The timestamp when DNS was verified
|
|
12
|
-
# @attr_reader dns_records [Array] The DNS records for the sending domain
|
|
13
|
-
# @attr_reader open_tracking_enabled [Boolean] Whether open tracking is enabled
|
|
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
|
|
16
|
-
# @attr_reader auto_unsubscribe_link_enabled [Boolean] Whether auto unsubscribe link is enabled
|
|
17
|
-
# @attr_reader custom_domain_tracking_enabled [Boolean] Whether custom domain tracking is enabled
|
|
18
|
-
# @attr_reader health_alerts_enabled [Boolean] Whether health alerts are enabled
|
|
19
|
-
# @attr_reader critical_alerts_enabled [Boolean] Whether critical alerts are enabled
|
|
20
|
-
# @attr_reader alert_recipient_email [String, nil] The email address for alert recipients
|
|
21
|
-
# @attr_reader inbound_enabled [Boolean] Whether inbound email is enabled for this domain
|
|
22
|
-
# @attr_reader inbound_verified [Boolean] Whether the domain's inbound MX records are verified
|
|
23
|
-
# @attr_reader permissions [Hash] The permissions for the sending domain
|
|
24
|
-
#
|
|
25
|
-
SendingDomain = Struct.new(
|
|
26
|
-
:id,
|
|
27
|
-
:domain_name,
|
|
28
|
-
:demo,
|
|
29
|
-
:compliance_status,
|
|
30
|
-
:dns_verified,
|
|
31
|
-
:dns_verified_at,
|
|
32
|
-
:dns_records,
|
|
33
|
-
:open_tracking_enabled,
|
|
34
|
-
:click_tracking_enabled,
|
|
35
|
-
:tracking_opt_out_enabled,
|
|
36
|
-
:auto_unsubscribe_link_enabled,
|
|
37
|
-
:custom_domain_tracking_enabled,
|
|
38
|
-
:health_alerts_enabled,
|
|
39
|
-
:critical_alerts_enabled,
|
|
40
|
-
:alert_recipient_email,
|
|
41
|
-
:inbound_enabled,
|
|
42
|
-
:inbound_verified,
|
|
43
|
-
:permissions,
|
|
44
|
-
:created_at,
|
|
45
|
-
:updated_at,
|
|
46
|
-
keyword_init: true
|
|
47
|
-
)
|
|
6
|
+
# @deprecated Use {Domain} instead.
|
|
7
|
+
SendingDomain = Domain
|
|
8
|
+
deprecate_constant :SendingDomain
|
|
48
9
|
end
|
|
@@ -1,88 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative '
|
|
3
|
+
require_relative 'deprecation'
|
|
4
|
+
require_relative 'domains_api'
|
|
4
5
|
require_relative 'sending_domain'
|
|
5
6
|
|
|
6
7
|
module Mailtrap
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
click_tracking_enabled
|
|
13
|
-
tracking_opt_out_enabled
|
|
14
|
-
auto_unsubscribe_link_enabled
|
|
15
|
-
inbound_enabled
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
self.response_class = SendingDomain
|
|
19
|
-
|
|
20
|
-
# Lists all sending domains for the account
|
|
21
|
-
# @return [Array<SendingDomain>] Array of sending domains
|
|
22
|
-
# @!macro api_errors
|
|
23
|
-
def list
|
|
24
|
-
response = client.get(base_path)
|
|
25
|
-
response[:data].map { |item| handle_response(item) }
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# Retrieves a specific sending domain
|
|
29
|
-
# @param domain_id [Integer] The sending domain ID
|
|
30
|
-
# @return [SendingDomain] Sending domain object
|
|
31
|
-
# @!macro api_errors
|
|
32
|
-
def get(domain_id)
|
|
33
|
-
base_get(domain_id)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# Creates a new sending domain
|
|
37
|
-
# @param [Hash] options The parameters to create
|
|
38
|
-
# @option options [String] :domain_name The sending domain name
|
|
39
|
-
# @return [SendingDomain] Created sending domain
|
|
40
|
-
# @!macro api_errors
|
|
41
|
-
# @raise [ArgumentError] If invalid options are provided
|
|
42
|
-
def create(options)
|
|
43
|
-
base_create(options, %i[domain_name])
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
# Deletes a sending domain
|
|
47
|
-
# @param domain_id [Integer] The sending domain ID
|
|
48
|
-
# @return nil
|
|
49
|
-
# @!macro api_errors
|
|
50
|
-
def delete(domain_id)
|
|
51
|
-
base_delete(domain_id)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# Updates configuration settings for a sending domain
|
|
55
|
-
# @param domain_id [Integer] The sending domain ID
|
|
56
|
-
# @param [Hash] options The parameters to update
|
|
57
|
-
# @option options [Boolean] :open_tracking_enabled Enable open tracking for emails sent from this domain
|
|
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
|
|
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
|
|
62
|
-
# @return [SendingDomain] Updated sending domain
|
|
63
|
-
# @!macro api_errors
|
|
64
|
-
# @raise [ArgumentError] If invalid options are provided
|
|
65
|
-
def update(domain_id, options)
|
|
66
|
-
base_update(domain_id, options)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# Email DNS configuration instructions for the sending domain
|
|
70
|
-
# @param domain_id [Integer] The sending domain ID
|
|
71
|
-
# @param email [String] The email for instructions
|
|
72
|
-
# @return nil
|
|
73
|
-
# @!macro api_errors
|
|
74
|
-
def send_setup_instructions(domain_id, email:)
|
|
75
|
-
client.post("#{base_path}/#{domain_id}/send_setup_instructions", email:)
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
private
|
|
79
|
-
|
|
80
|
-
def base_path
|
|
81
|
-
"/api/accounts/#{account_id}/sending_domains"
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def wrap_request(options)
|
|
85
|
-
{ sending_domain: options }
|
|
8
|
+
# @deprecated Use {DomainsAPI} instead.
|
|
9
|
+
class SendingDomainsAPI < DomainsAPI
|
|
10
|
+
def initialize(*)
|
|
11
|
+
Deprecation.warn('Mailtrap::SendingDomainsAPI', 'Mailtrap::DomainsAPI')
|
|
12
|
+
super
|
|
86
13
|
end
|
|
87
14
|
end
|
|
88
15
|
end
|
data/lib/mailtrap/stats_api.rb
CHANGED
|
@@ -20,7 +20,7 @@ module Mailtrap
|
|
|
20
20
|
# Get aggregated sending stats
|
|
21
21
|
# @param start_date [String, Date, Time] Start date for the stats period (required)
|
|
22
22
|
# @param end_date [String, Date, Time] End date for the stats period (required)
|
|
23
|
-
# @param sending_domain_ids [Array<Integer>] Filter by
|
|
23
|
+
# @param sending_domain_ids [Array<Integer>] Filter by domain IDs
|
|
24
24
|
# @param sending_streams [Array<String>] Filter by sending streams
|
|
25
25
|
# @param categories [Array<String>] Filter by categories
|
|
26
26
|
# @param email_service_providers [Array<String>] Filter by email service providers
|
|
@@ -39,7 +39,7 @@ module Mailtrap
|
|
|
39
39
|
# Get sending stats grouped by domain
|
|
40
40
|
# @param start_date [String, Date, Time] Start date for the stats period (required)
|
|
41
41
|
# @param end_date [String, Date, Time] End date for the stats period (required)
|
|
42
|
-
# @param sending_domain_ids [Array<Integer>] Filter by
|
|
42
|
+
# @param sending_domain_ids [Array<Integer>] Filter by domain IDs
|
|
43
43
|
# @param sending_streams [Array<String>] Filter by sending streams
|
|
44
44
|
# @param categories [Array<String>] Filter by categories
|
|
45
45
|
# @param email_service_providers [Array<String>] Filter by email service providers
|
|
@@ -54,7 +54,7 @@ module Mailtrap
|
|
|
54
54
|
# Get sending stats grouped by category
|
|
55
55
|
# @param start_date [String, Date, Time] Start date for the stats period (required)
|
|
56
56
|
# @param end_date [String, Date, Time] End date for the stats period (required)
|
|
57
|
-
# @param sending_domain_ids [Array<Integer>] Filter by
|
|
57
|
+
# @param sending_domain_ids [Array<Integer>] Filter by domain IDs
|
|
58
58
|
# @param sending_streams [Array<String>] Filter by sending streams
|
|
59
59
|
# @param categories [Array<String>] Filter by categories
|
|
60
60
|
# @param email_service_providers [Array<String>] Filter by email service providers
|
|
@@ -69,7 +69,7 @@ module Mailtrap
|
|
|
69
69
|
# Get sending stats grouped by email service provider
|
|
70
70
|
# @param start_date [String, Date, Time] Start date for the stats period (required)
|
|
71
71
|
# @param end_date [String, Date, Time] End date for the stats period (required)
|
|
72
|
-
# @param sending_domain_ids [Array<Integer>] Filter by
|
|
72
|
+
# @param sending_domain_ids [Array<Integer>] Filter by domain IDs
|
|
73
73
|
# @param sending_streams [Array<String>] Filter by sending streams
|
|
74
74
|
# @param categories [Array<String>] Filter by categories
|
|
75
75
|
# @param email_service_providers [Array<String>] Filter by email service providers
|
|
@@ -84,7 +84,7 @@ module Mailtrap
|
|
|
84
84
|
# Get sending stats grouped by date
|
|
85
85
|
# @param start_date [String, Date, Time] Start date for the stats period (required)
|
|
86
86
|
# @param end_date [String, Date, Time] End date for the stats period (required)
|
|
87
|
-
# @param sending_domain_ids [Array<Integer>] Filter by
|
|
87
|
+
# @param sending_domain_ids [Array<Integer>] Filter by domain IDs
|
|
88
88
|
# @param sending_streams [Array<String>] Filter by sending streams
|
|
89
89
|
# @param categories [Array<String>] Filter by categories
|
|
90
90
|
# @param email_service_providers [Array<String>] Filter by email service providers
|
|
@@ -40,6 +40,19 @@ module Mailtrap
|
|
|
40
40
|
base_create(options)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
+
# Permanently deletes a sub account under the organization
|
|
44
|
+
#
|
|
45
|
+
# Requires organization admin permissions. The deletion is permanent
|
|
46
|
+
# and removes all data of the sub account. Deleting the last sub account also deletes the organization.
|
|
47
|
+
# A repeated call for the same sub account returns a 404 error.
|
|
48
|
+
# Rate limit: 10 requests per minute per organization.
|
|
49
|
+
# @param sub_account_id [Integer] The sub account ID
|
|
50
|
+
# @return nil
|
|
51
|
+
# @!macro api_errors
|
|
52
|
+
def delete(sub_account_id)
|
|
53
|
+
base_delete(sub_account_id)
|
|
54
|
+
end
|
|
55
|
+
|
|
43
56
|
private
|
|
44
57
|
|
|
45
58
|
def base_path
|