mailinator_client 1.0.6 → 1.1.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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.agent/rules/tdd.md +7 -0
  3. data/.agent/tdd-flow/skill.md +15 -0
  4. data/.env.example +25 -0
  5. data/.github/copilot-instructions.md +7 -0
  6. data/.gitignore +2 -0
  7. data/.ruby-version +1 -1
  8. data/AGENTS.md +9 -0
  9. data/AI_INSTRUCTIONS.md +205 -0
  10. data/CHANGELOG.md +65 -0
  11. data/EXAMPLES.md +11 -0
  12. data/README.md +18 -13
  13. data/ROADMAP.md +58 -0
  14. data/docs/domains.md +6 -0
  15. data/docs/rules.md +9 -6
  16. data/lib/mailinator_client/authenticators.rb +0 -22
  17. data/lib/mailinator_client/client.rb +14 -24
  18. data/lib/mailinator_client/domains.rb +5 -25
  19. data/lib/mailinator_client/error.rb +11 -25
  20. data/lib/mailinator_client/messages.rb +464 -48
  21. data/lib/mailinator_client/rules.rb +12 -28
  22. data/lib/mailinator_client/stats.rb +0 -22
  23. data/lib/mailinator_client/utils.rb +0 -22
  24. data/lib/mailinator_client/version.rb +3 -25
  25. data/lib/mailinator_client/webhooks.rb +1 -22
  26. data/lib/mailinator_client.rb +0 -22
  27. data/mailinator_client.gemspec +25 -25
  28. data/test/authenticators_api_test.rb +28 -0
  29. data/test/domains_api_test.rb +15 -0
  30. data/test/messages_api_test.rb +274 -0
  31. data/test/messages_headers_api_test.rb +30 -0
  32. data/test/messages_query_params_test.rb +76 -0
  33. data/test/messages_stream_domain_api_test.rb +39 -0
  34. data/test/messages_stream_inbox_api_test.rb +40 -0
  35. data/test/messages_summary_api_test.rb +28 -0
  36. data/test/messages_text_api_test.rb +28 -0
  37. data/test/messages_texthtml_api_test.rb +28 -0
  38. data/test/messages_textplain_api_test.rb +28 -0
  39. data/test/rules_api_test.rb +7 -0
  40. data/test/stats_api_test.rb +19 -0
  41. data/test/test_helper.rb +31 -1
  42. data/test/webhooks_api_test.rb +49 -0
  43. metadata +84 -23
  44. data/test/mailinator_client_api_test.rb +0 -246
@@ -1,25 +1,3 @@
1
- # The MIT License (MIT)
2
- #
3
- # Copyright (c) 2024 Manybrain, Inc.
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
22
-
23
1
  require "json"
24
2
 
25
3
  module MailinatorClient
@@ -31,6 +9,7 @@ module MailinatorClient
31
9
  @client = client
32
10
  end
33
11
 
12
+ # @deprecated Rules endpoints are deprecated in this client.
34
13
  # Creates a Rule. Note that in the examples, ":domain_id" can be one of your private domains.
35
14
  #
36
15
  # Authentication:
@@ -38,7 +17,7 @@ module MailinatorClient
38
17
  # access token to call this action.
39
18
  #
40
19
  # Parameters:
41
- # * {string} domainId - The Domain name or the Domain id
20
+ # * {string} domainId - The Domain name or simply 'private'
42
21
  # * {string} ruleToPost - The Rule object (https://manybrain.github.io/m8rdocs/#create-rule)
43
22
  #
44
23
  # Responses:
@@ -64,6 +43,7 @@ module MailinatorClient
64
43
  body: body)
65
44
  end
66
45
 
46
+ # @deprecated Rules endpoints are deprecated in this client.
67
47
  # Enables an existing Rule
68
48
  #
69
49
  # Authentication:
@@ -71,7 +51,7 @@ module MailinatorClient
71
51
  # access token to call this action.
72
52
  #
73
53
  # Parameters:
74
- # * {string} domainId - The Domain name or the Domain id
54
+ # * {string} domainId - The Domain name or simply 'private'
75
55
  # * {string} ruleId - The Rule id
76
56
  #
77
57
  # Responses:
@@ -95,6 +75,7 @@ module MailinatorClient
95
75
  body: body)
96
76
  end
97
77
 
78
+ # @deprecated Rules endpoints are deprecated in this client.
98
79
  # Disables an existing Rule
99
80
  #
100
81
  # Authentication:
@@ -102,7 +83,7 @@ module MailinatorClient
102
83
  # access token to call this action.
103
84
  #
104
85
  # Parameters:
105
- # * {string} domainId - The Domain name or the Domain id
86
+ # * {string} domainId - The Domain name or simply 'private'
106
87
  # * {string} ruleId - The Rule id
107
88
  #
108
89
  # Responses:
@@ -126,6 +107,7 @@ module MailinatorClient
126
107
  body: body)
127
108
  end
128
109
 
110
+ # @deprecated Rules endpoints are deprecated in this client.
129
111
  # Fetches all Rules for a Domain.
130
112
  #
131
113
  # Authentication:
@@ -133,7 +115,7 @@ module MailinatorClient
133
115
  # access token to call this action.
134
116
  #
135
117
  # Parameters:
136
- # * {string} domainId - The Domain name or the Domain id
118
+ # * {string} domainId - The Domain name or simply 'private'
137
119
  #
138
120
  # Responses:
139
121
  # * Collection of rules (https://manybrain.github.io/m8rdocs/#get-all-rules)
@@ -155,6 +137,7 @@ module MailinatorClient
155
137
  body: body)
156
138
  end
157
139
 
140
+ # @deprecated Rules endpoints are deprecated in this client.
158
141
  # Fetches a specific rule for a Domain.
159
142
  #
160
143
  # Authentication:
@@ -162,7 +145,7 @@ module MailinatorClient
162
145
  # access token to call this action.
163
146
  #
164
147
  # Parameters:
165
- # * {string} domainId - The Domain name or the Domain id
148
+ # * {string} domainId - The Domain name or simply 'private'
166
149
  # * {string} ruleId - The Domain name or the Rule id
167
150
  #
168
151
  # Responses:
@@ -186,6 +169,7 @@ module MailinatorClient
186
169
  body: body)
187
170
  end
188
171
 
172
+ # @deprecated Rules endpoints are deprecated in this client.
189
173
  # Deletes a specific rule for a Domain.
190
174
  #
191
175
  # Authentication:
@@ -193,7 +177,7 @@ module MailinatorClient
193
177
  # access token to call this action.
194
178
  #
195
179
  # Parameters:
196
- # * {string} domainId - The Domain name or the Domain id
180
+ # * {string} domainId - The Domain name or simply 'private'
197
181
  # * {string} ruleId - The Rule id
198
182
  #
199
183
  # Responses:
@@ -1,25 +1,3 @@
1
- # The MIT License (MIT)
2
- #
3
- # Copyright (c) 2024 Manybrain, Inc.
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
22
-
23
1
  require "json"
24
2
 
25
3
  module MailinatorClient
@@ -1,25 +1,3 @@
1
- # The MIT License (MIT)
2
- #
3
- # Copyright (c) 2024 Manybrain, Inc.
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
22
-
23
1
  module MailinatorClient
24
2
  class Utils
25
3
  def self.symbolize_hash_keys(hash)
@@ -1,25 +1,3 @@
1
- # The MIT License (MIT)
2
- #
3
- # Copyright (c) 2024 Manybrain, Inc.
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
22
-
23
- module MailinatorClient
24
- VERSION = "1.0.6"
25
- end
1
+ module MailinatorClient
2
+ VERSION = "1.1.0"
3
+ end
@@ -1,25 +1,3 @@
1
- # The MIT License (MIT)
2
- #
3
- # Copyright (c) 2024 Manybrain, Inc.
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
22
-
23
1
  require "json"
24
2
 
25
3
  module MailinatorClient
@@ -51,6 +29,7 @@ module MailinatorClient
51
29
  raise ArgumentError.new("whToken is required") unless params.has_key?(:whToken)
52
30
  raise ArgumentError.new("webhook is required") unless params.has_key?(:webhook)
53
31
 
32
+ body = params[:webhook] if params.has_key?(:webhook)
54
33
  query_params[:whtoken] = params[:whToken] if params.has_key?(:whToken)
55
34
 
56
35
  path = "/domains/private/webhook"
@@ -1,25 +1,3 @@
1
- # The MIT License (MIT)
2
- #
3
- # Copyright (c) 2024 Manybrain, Inc.
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
22
-
23
1
  require_relative "mailinator_client/version"
24
2
  require_relative "mailinator_client/error"
25
3
  require_relative "mailinator_client/utils"
@@ -1,25 +1,25 @@
1
- $LOAD_PATH.push(File.expand_path("../lib", __FILE__))
2
- require "mailinator_client/version"
3
-
4
- Gem::Specification.new do |gem|
5
- gem.name = "mailinator_client"
6
- gem.authors = ["Marian Melnychuk"]
7
- gem.email = ["marian.melnychuk@gmail.com"]
8
- gem.summary = %q{Provides a simple ruby wrapper around the Mailinator REST API}
9
- gem.description = %q{Easily use the Mailinator through its REST API with Ruby}
10
- gem.homepage = "https://github.com/manybrain/mailinator-ruby-client"
11
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
- gem.files = `git ls-files`.split("\n")
13
- gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
- gem.require_paths = ["lib"]
15
- gem.version = MailinatorClient::VERSION
16
- gem.licenses = ["MIT"]
17
-
18
- gem.required_ruby_version = ">= 2.1"
19
-
20
- gem.add_dependency "httparty", "~> 0.21.0"
21
-
22
- gem.add_development_dependency "minitest", "~> 5.9"
23
- gem.add_development_dependency "rake", "~> 12"
24
- gem.add_development_dependency "webmock", "~> 2.3"
25
- end
1
+ $LOAD_PATH.push(File.expand_path("../lib", __FILE__))
2
+ require "mailinator_client/version"
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "mailinator_client"
6
+ gem.authors = ["Manybrain, LLC"]
7
+ gem.email = ["support@manybrain.com"]
8
+ gem.summary = %q{Provides a simple ruby wrapper around the Mailinator REST API}
9
+ gem.description = %q{Easily use the Mailinator through its REST API with Ruby}
10
+ gem.homepage = "https://github.com/manybrain/mailinator-ruby-client"
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.require_paths = ["lib"]
15
+ gem.version = MailinatorClient::VERSION
16
+ gem.licenses = ["MIT"]
17
+
18
+ gem.required_ruby_version = ">= 2.1"
19
+
20
+ gem.add_dependency "httparty", ">= 0.21", "< 0.22"
21
+
22
+ gem.add_development_dependency "minitest", ">= 5.25", "< 7.0"
23
+ gem.add_development_dependency "rake", ">= 13.0", "< 14.0"
24
+ gem.add_development_dependency "webmock", ">= 3.26", "< 4.0"
25
+ end
@@ -0,0 +1,28 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/test_helper")
2
+
3
+ class AuthenticatorsApiTest < Minitest::Test
4
+ def test_authenticators_endpoints
5
+ require_env!(
6
+ "MAILINATOR_TEST_API_TOKEN",
7
+ "MAILINATOR_TEST_AUTH_SECRET",
8
+ "MAILINATOR_TEST_AUTH_ID"
9
+ )
10
+
11
+ client = integration_client
12
+
13
+ response = client.authenticators.instant_totp_2fa_code(totpSecretKey: ENV["MAILINATOR_TEST_AUTH_SECRET"])
14
+ assert response != nil, "Expected instant totp 2fa code response to not be nil"
15
+
16
+ response = client.authenticators.get_authenticators()
17
+ assert response != nil, "Expected get authenticators response to not be nil"
18
+
19
+ response = client.authenticators.get_authenticators_by_id(id: ENV["MAILINATOR_TEST_AUTH_ID"])
20
+ assert response != nil, "Expected get authenticators by id response to not be nil"
21
+
22
+ response = client.authenticators.get_authenticator()
23
+ assert response != nil, "Expected get authenticator response to not be nil"
24
+
25
+ response = client.authenticators.get_authenticator_by_id(id: ENV["MAILINATOR_TEST_AUTH_ID"])
26
+ assert response != nil, "Expected get authenticator by id response to not be nil"
27
+ end
28
+ end
@@ -0,0 +1,15 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/test_helper")
2
+
3
+ class DomainsApiTest < Minitest::Test
4
+ def test_domains_endpoints
5
+ require_env!("MAILINATOR_TEST_API_TOKEN")
6
+
7
+ client = integration_client
8
+ domain_name = first_domain_name(client)
9
+
10
+ response = client.domains.get_domain(domainId: domain_name)
11
+ assert response != nil, "Expected get domain response to not be nil"
12
+
13
+ skip("Skipping deprecated endpoints: domains.create_domain / domains.delete_domain")
14
+ end
15
+ end
@@ -0,0 +1,274 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/test_helper")
2
+
3
+ class MessagesApiTest < Minitest::Test
4
+ def setup
5
+ super
6
+ @client = integration_client
7
+ @domain_name = first_domain_name(@client)
8
+ @inbox_all = "*"
9
+ end
10
+
11
+ def test_post_message_seed
12
+ require_env!("MAILINATOR_TEST_API_TOKEN")
13
+
14
+ response = @client.messages.post_message(
15
+ domain: @domain_name,
16
+ inbox: @inbox_all,
17
+ messageToPost: {
18
+ subject: "Testing ruby message",
19
+ from: "test_email_ruby@test.com",
20
+ text: "I love Ruby!"
21
+ }
22
+ )
23
+
24
+ assert response != nil, "Expected post message response to not be nil"
25
+ assert response["status"] == "ok", "Expected post message response to be ok"
26
+ end
27
+
28
+ def test_fetch_inbox_basic
29
+ require_env!("MAILINATOR_TEST_API_TOKEN")
30
+
31
+ response = @client.messages.fetch_inbox(
32
+ domain: @domain_name,
33
+ inbox: @inbox_all,
34
+ skip: 0,
35
+ limit: 1,
36
+ sort: "ascending",
37
+ decodeSubject: false
38
+ )
39
+
40
+ assert response != nil, "Expected fetch inbox response to not be nil"
41
+ assert response["msgs"] != nil, "Expected response fetch inbox messages to not be nil"
42
+ end
43
+
44
+ def test_fetch_inbox_cursor
45
+ require_env!("MAILINATOR_TEST_API_TOKEN")
46
+
47
+ response = @client.messages.fetch_inbox(
48
+ domain: @domain_name,
49
+ inbox: @inbox_all,
50
+ skip: 0,
51
+ limit: 1,
52
+ sort: "ascending",
53
+ decodeSubject: false
54
+ )
55
+ cursor = response["cursor"]
56
+
57
+ response = @client.messages.fetch_inbox(
58
+ domain: @domain_name,
59
+ inbox: @inbox_all,
60
+ limit: 1,
61
+ cursor: cursor
62
+ )
63
+
64
+ assert response != nil, "Expected fetch inbox response to not be nil"
65
+ assert response["msgs"] != nil, "Expected response fetch inbox messages to not be nil"
66
+ end
67
+
68
+ def test_fetch_inbox_full
69
+ require_env!("MAILINATOR_TEST_API_TOKEN")
70
+
71
+ response = @client.messages.fetch_inbox(
72
+ domain: @domain_name,
73
+ inbox: @inbox_all,
74
+ limit: 1,
75
+ full: true
76
+ )
77
+
78
+ assert response != nil, "Expected fetch inbox response to not be nil"
79
+ assert response["msgs"] != nil, "Expected response fetch inbox messages to not be nil"
80
+ end
81
+
82
+ def test_fetch_inbox_delete
83
+ require_env!("MAILINATOR_TEST_API_TOKEN")
84
+
85
+ response = @client.messages.fetch_inbox(
86
+ domain: @domain_name,
87
+ inbox: @inbox_all,
88
+ limit: 1,
89
+ delete: "1m"
90
+ )
91
+
92
+ assert response != nil, "Expected fetch inbox response to not be nil"
93
+ assert response["msgs"] != nil, "Expected response fetch inbox messages to not be nil"
94
+ end
95
+
96
+ def test_fetch_inbox_wait
97
+ require_env!("MAILINATOR_TEST_API_TOKEN")
98
+
99
+ response = @client.messages.fetch_inbox(
100
+ domain: @domain_name,
101
+ inbox: @inbox_all,
102
+ limit: 1,
103
+ wait: "1m"
104
+ )
105
+
106
+ assert response != nil, "Expected fetch inbox response to not be nil"
107
+ assert response["msgs"] != nil, "Expected response fetch inbox messages to not be nil"
108
+ end
109
+
110
+ def test_fetch_message_variants
111
+ require_env!("MAILINATOR_TEST_API_TOKEN")
112
+
113
+ response = @client.messages.fetch_inbox(
114
+ domain: @domain_name,
115
+ inbox: @inbox_all,
116
+ skip: 0,
117
+ limit: 1,
118
+ sort: "ascending",
119
+ decodeSubject: false
120
+ )
121
+ message_id = response["msgs"][0]["id"]
122
+
123
+ response = @client.messages.fetch_inbox_message(
124
+ domain: @domain_name,
125
+ inbox: @inbox_all,
126
+ messageId: message_id
127
+ )
128
+ assert response != nil, "Expected fetch inbox message response to not be nil"
129
+
130
+ response = @client.messages.fetch_message(domain: @domain_name, messageId: message_id)
131
+ assert response != nil, "Expected fetch message response to not be nil"
132
+
133
+ response = @client.messages.fetch_message(domain: @domain_name, messageId: message_id, delete: "10s")
134
+ assert response != nil, "Expected fetch message response to not be nil"
135
+ end
136
+
137
+ def test_fetch_sms_message
138
+ require_env!("MAILINATOR_TEST_API_TOKEN", "MAILINATOR_TEST_PHONE_NUMBER")
139
+
140
+ response = @client.messages.fetch_sms_message(
141
+ domain: @domain_name,
142
+ teamSmsNumber: ENV["MAILINATOR_TEST_PHONE_NUMBER"]
143
+ )
144
+
145
+ assert response != nil, "Expected fetch sms message response to not be nil"
146
+ end
147
+
148
+ def test_attachment_list_and_download
149
+ require_env!(
150
+ "MAILINATOR_TEST_API_TOKEN",
151
+ "MAILINATOR_TEST_INBOX",
152
+ "MAILINATOR_TEST_MESSAGE_WITH_ATTACHMENT_ID"
153
+ )
154
+
155
+ response = @client.messages.fetch_inbox_message_attachments(
156
+ domain: @domain_name,
157
+ inbox: ENV["MAILINATOR_TEST_INBOX"],
158
+ messageId: ENV["MAILINATOR_TEST_MESSAGE_WITH_ATTACHMENT_ID"]
159
+ )
160
+ assert response != nil, "Expected fetch inbox message attachments response to not be nil"
161
+ attachments = response["attachments"]
162
+ assert attachments != nil, "Expected attachments list in fetch inbox message attachments response"
163
+ assert_kind_of(Array, attachments, "Expected attachments to be an array")
164
+ assert !attachments.empty?, "Expected at least one attachment for MAILINATOR_TEST_MESSAGE_WITH_ATTACHMENT_ID"
165
+ attachment = attachments[0]
166
+ attachment_id = attachment["id"] || attachment["attachmentId"] || attachment["attachment_id"] || attachment["name"] || attachment["filename"]
167
+ assert attachment_id != nil, "Expected attachment to include an id or name field"
168
+
169
+ response = @client.messages.fetch_message_attachments(
170
+ domain: @domain_name,
171
+ messageId: ENV["MAILINATOR_TEST_MESSAGE_WITH_ATTACHMENT_ID"]
172
+ )
173
+ assert response != nil, "Expected fetch message attachments response to not be nil"
174
+
175
+ response = @client.messages.fetch_inbox_message_attachment(
176
+ domain: @domain_name,
177
+ inbox: ENV["MAILINATOR_TEST_INBOX"],
178
+ messageId: ENV["MAILINATOR_TEST_MESSAGE_WITH_ATTACHMENT_ID"],
179
+ attachmentId: attachment_id
180
+ )
181
+ assert response != nil, "Expected fetch inbox message attachment response to not be nil"
182
+
183
+ response = @client.messages.fetch_message_attachment(
184
+ domain: @domain_name,
185
+ messageId: ENV["MAILINATOR_TEST_MESSAGE_WITH_ATTACHMENT_ID"],
186
+ attachmentId: attachment_id
187
+ )
188
+ assert response != nil, "Expected fetch message attachment response to not be nil"
189
+ end
190
+
191
+ def test_links_and_logs
192
+ require_env!("MAILINATOR_TEST_API_TOKEN")
193
+
194
+ response = @client.messages.fetch_inbox(
195
+ domain: @domain_name,
196
+ inbox: @inbox_all,
197
+ skip: 0,
198
+ limit: 1,
199
+ sort: "ascending",
200
+ decodeSubject: false
201
+ )
202
+ message_id = response["msgs"][0]["id"]
203
+
204
+ response = @client.messages.fetch_message_links_full(domain: @domain_name, messageId: message_id)
205
+ assert response != nil, "Expected fetch message links full response to not be nil"
206
+ assert response["links"] != nil, "Expected fetch message links links full response to not be nil"
207
+
208
+ response = @client.messages.fetch_message_links(domain: @domain_name, messageId: message_id)
209
+ assert response != nil, "Expected fetch message links response to not be nil"
210
+ assert response["links"] != nil, "Expected fetch message links links response to not be nil"
211
+
212
+ response = @client.messages.fetch_inbox_message_links(domain: @domain_name, inbox: @inbox_all, messageId: message_id)
213
+ assert response != nil, "Expected fetch inbox message links response to not be nil"
214
+ assert response["links"] != nil, "Expected fetch inbox message links links response to not be nil"
215
+
216
+ response = @client.messages.fetch_message_smtp_log(domain: @domain_name, messageId: message_id)
217
+ assert response != nil, "Expected fetch message smtp log response to not be nil"
218
+
219
+ response = @client.messages.fetch_inbox_message_smtp_log(domain: @domain_name, inbox: @inbox_all, messageId: message_id)
220
+ assert response != nil, "Expected fetch inbox message smtp log response to not be nil"
221
+ end
222
+
223
+ def test_raw_message_variants
224
+ require_env!("MAILINATOR_TEST_API_TOKEN")
225
+
226
+ response = @client.messages.fetch_inbox(
227
+ domain: @domain_name,
228
+ inbox: @inbox_all,
229
+ skip: 0,
230
+ limit: 1,
231
+ sort: "ascending",
232
+ decodeSubject: false
233
+ )
234
+ message_id = response["msgs"][0]["id"]
235
+
236
+ response = @client.messages.fetch_message_raw(domain: @domain_name, messageId: message_id)
237
+ assert response != nil, "Expected fetch message raw response to not be nil"
238
+
239
+ response = @client.messages.fetch_inbox_message_raw(domain: @domain_name, inbox: @inbox_all, messageId: message_id)
240
+ assert response != nil, "Expected fetch inbox message raw response to not be nil"
241
+ end
242
+
243
+ def test_delete_domain_flows
244
+ require_env!("MAILINATOR_TEST_API_TOKEN")
245
+
246
+ delete_domain = ENV["MAILINATOR_TEST_DELETE_DOMAIN"]
247
+ if delete_domain.to_s.strip.empty?
248
+ warn "Skipping delete-domain checks: MAILINATOR_TEST_DELETE_DOMAIN is not set"
249
+ return
250
+ end
251
+
252
+ response = @client.messages.fetch_inbox(
253
+ domain: @domain_name,
254
+ inbox: @inbox_all,
255
+ skip: 0,
256
+ limit: 1,
257
+ sort: "ascending",
258
+ decodeSubject: false
259
+ )
260
+ message_id = response["msgs"][0]["id"]
261
+
262
+ response = @client.messages.delete_message(domain: delete_domain, inbox: ENV["MAILINATOR_TEST_INBOX"], messageId: message_id)
263
+ assert response != nil, "Expected delete message response to not be nil"
264
+ assert response["status"] == "ok", "Expected delete message response to be ok"
265
+
266
+ response = @client.messages.delete_all_inbox_messages(domain: delete_domain, inbox: ENV["MAILINATOR_TEST_INBOX"])
267
+ assert response != nil, "Expected delete all inbox messages response to not be nil"
268
+ assert response["status"] == "ok", "Expected delete all inbox messages response to be ok"
269
+
270
+ response = @client.messages.delete_all_domain_messages(domain: delete_domain)
271
+ assert response != nil, "Expected delete all domain messages response to not be nil"
272
+ assert response["status"] == "ok", "Expected delete all domain messages response to be ok"
273
+ end
274
+ end
@@ -0,0 +1,30 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/test_helper")
2
+
3
+ class MessagesHeadersApiTest < Minitest::Test
4
+ def test_fetch_message_headers_endpoint
5
+ require_env!(
6
+ "MAILINATOR_TEST_API_TOKEN",
7
+ "MAILINATOR_TEST_MESSAGE_WITH_ATTACHMENT_ID"
8
+ )
9
+
10
+ client = integration_client
11
+ domain_name = ENV["MAILINATOR_TEST_DOMAIN"].to_s.strip
12
+ domain_name = first_domain_name(client) if domain_name.empty?
13
+
14
+ response = client.messages.fetch_message_headers(
15
+ domain: domain_name,
16
+ messageId: ENV["MAILINATOR_TEST_MESSAGE_WITH_ATTACHMENT_ID"]
17
+ ) rescue begin
18
+ e = $!
19
+ if e.is_a?(MailinatorClient::ResponseError)
20
+ flunk "Expected HTTP 200 from message headers endpoint, got HTTP #{e.code}"
21
+ end
22
+ raise
23
+ end
24
+
25
+ assert_kind_of(Hash, response, "Expected message headers response to be a JSON object")
26
+ assert_equal(["headers"], response.keys.sort, "Expected only the headers property")
27
+ assert response["headers"].is_a?(Hash), "Expected headers to be a JSON object"
28
+ assert response["headers"]["subject"] != nil, "Expected headers.subject to not be nil"
29
+ end
30
+ end