mailinator_client 1.0.3 → 1.0.5
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/LICENSE +1 -1
- data/README.md +13 -1
- data/docs/authenticators.md +71 -0
- data/docs/domains.md +26 -0
- data/docs/messages.md +170 -14
- data/docs/webhooks.md +125 -0
- data/lib/mailinator_client/authenticators.rb +165 -0
- data/lib/mailinator_client/client.rb +12 -2
- data/lib/mailinator_client/domains.rb +60 -1
- data/lib/mailinator_client/error.rb +1 -1
- data/lib/mailinator_client/messages.rb +327 -16
- data/lib/mailinator_client/rules.rb +1 -1
- data/lib/mailinator_client/stats.rb +1 -1
- data/lib/mailinator_client/utils.rb +1 -1
- data/lib/mailinator_client/version.rb +2 -2
- data/lib/mailinator_client/webhooks.rb +281 -0
- data/lib/mailinator_client.rb +3 -1
- data/test/mailinator_client_api_test.rb +125 -25
- metadata +7 -3
@@ -0,0 +1,281 @@
|
|
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
|
+
require "json"
|
24
|
+
|
25
|
+
module MailinatorClient
|
26
|
+
|
27
|
+
# Class containing all the actions for the Webhooks Resource
|
28
|
+
class Webhooks
|
29
|
+
|
30
|
+
def initialize(client)
|
31
|
+
@client = client
|
32
|
+
end
|
33
|
+
|
34
|
+
# This command will deliver the message to the :to inbox that was set into request object
|
35
|
+
#
|
36
|
+
# Parameters:
|
37
|
+
# * {string} webhook - The Webhook object
|
38
|
+
#
|
39
|
+
# Responses:
|
40
|
+
# * PublicWebhookResponse (https://manybrain.github.io/m8rdocs/#public-webhook)
|
41
|
+
def public_webhook(params = {})
|
42
|
+
query_params = {}
|
43
|
+
headers = {}
|
44
|
+
body = nil
|
45
|
+
|
46
|
+
raise ArgumentError.new("webhook is required") unless params.has_key?(:webhook)
|
47
|
+
|
48
|
+
body = params[:webhook] if params.has_key?(:webhook)
|
49
|
+
|
50
|
+
path = "/domains/public/webhook"
|
51
|
+
|
52
|
+
response = @client.request(
|
53
|
+
method: :post,
|
54
|
+
path: path,
|
55
|
+
query: query_params,
|
56
|
+
headers: headers,
|
57
|
+
body: body)
|
58
|
+
end
|
59
|
+
|
60
|
+
# This command will deliver the message to the :inbox inbox
|
61
|
+
# Note that if the Mailinator system cannot determine the destination inbox via the URL or a "to" field in the payload, the message will be rejected.
|
62
|
+
# If the message contains a "from" and "subject" field, these will be visible on the inbox page.
|
63
|
+
#
|
64
|
+
# Parameters:
|
65
|
+
# * {string} inbox - inbox
|
66
|
+
# * {string} webhook - The Webhook object
|
67
|
+
#
|
68
|
+
# Responses:
|
69
|
+
# * PublicWebhookResponse (https://manybrain.github.io/m8rdocs/#public-inbox-webhook)
|
70
|
+
def public_inbox_webhook(params = {})
|
71
|
+
query_params = {}
|
72
|
+
headers = {}
|
73
|
+
body = nil
|
74
|
+
|
75
|
+
raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
|
76
|
+
raise ArgumentError.new("webhook is required") unless params.has_key?(:webhook)
|
77
|
+
|
78
|
+
body = params[:webhook] if params.has_key?(:webhook)
|
79
|
+
|
80
|
+
path = "/domains/public/webhook/#{params[:inbox]}"
|
81
|
+
|
82
|
+
response = @client.request(
|
83
|
+
method: :post,
|
84
|
+
path: path,
|
85
|
+
query: query_params,
|
86
|
+
headers: headers,
|
87
|
+
body: body)
|
88
|
+
end
|
89
|
+
|
90
|
+
# If you have a Twilio account which receives incoming SMS messages. You may direct those messages through this facility to inject those messages into the Mailinator system.
|
91
|
+
#
|
92
|
+
# Parameters:
|
93
|
+
# * {string} customService - custom service name
|
94
|
+
# * {string} webhook - The Webhook object
|
95
|
+
#
|
96
|
+
# Responses:
|
97
|
+
# * PublicWebhookResponse (https://manybrain.github.io/m8rdocs/#public-custom-service-webhook)
|
98
|
+
def public_custom_service_webhook(params = {})
|
99
|
+
query_params = {}
|
100
|
+
headers = {}
|
101
|
+
body = nil
|
102
|
+
|
103
|
+
raise ArgumentError.new("customService is required") unless params.has_key?(:customService)
|
104
|
+
raise ArgumentError.new("webhook is required") unless params.has_key?(:webhook)
|
105
|
+
|
106
|
+
body = params[:webhook] if params.has_key?(:webhook)
|
107
|
+
|
108
|
+
path = "/domains/public/#{params[:customService]}"
|
109
|
+
|
110
|
+
response = @client.request(
|
111
|
+
method: :post,
|
112
|
+
path: path,
|
113
|
+
query: query_params,
|
114
|
+
headers: headers,
|
115
|
+
body: body)
|
116
|
+
end
|
117
|
+
|
118
|
+
# The SMS message will arrive in the Public Mailinator inbox corresponding to the Twilio Phone Number. (only the digits, if a plus sign precedes the number it will be removed)
|
119
|
+
# If you wish the message to arrive in a different inbox, you may append the destination inbox to the URL.
|
120
|
+
#
|
121
|
+
# Parameters:
|
122
|
+
# * {string} inbox - inbox
|
123
|
+
# * {string} customService - custom service name
|
124
|
+
# * {string} webhook - The Webhook object
|
125
|
+
#
|
126
|
+
# Responses:
|
127
|
+
# * PublicWebhookResponse (https://manybrain.github.io/m8rdocs/#public-custom-service-inbox-webhook)
|
128
|
+
def public_custom_service_inbox_webhook(params = {})
|
129
|
+
query_params = {}
|
130
|
+
headers = {}
|
131
|
+
body = nil
|
132
|
+
|
133
|
+
raise ArgumentError.new("customService is required") unless params.has_key?(:customService)
|
134
|
+
raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
|
135
|
+
raise ArgumentError.new("webhook is required") unless params.has_key?(:webhook)
|
136
|
+
|
137
|
+
body = params[:webhook] if params.has_key?(:webhook)
|
138
|
+
|
139
|
+
path = "/domains/public/#{params[:customService]}/#{params[:inbox]}"
|
140
|
+
|
141
|
+
response = @client.request(
|
142
|
+
method: :post,
|
143
|
+
path: path,
|
144
|
+
query: query_params,
|
145
|
+
headers: headers,
|
146
|
+
body: body)
|
147
|
+
end
|
148
|
+
|
149
|
+
# This command will Webhook messages into your Private Domain
|
150
|
+
# The incoming Webhook will arrive in the inbox designated by the "to" field in the incoming request payload.
|
151
|
+
# Webhooks into your Private System do NOT use your regular API Token.
|
152
|
+
# This is because a typical use case is to enter the Webhook URL into 3rd-party systems(i.e.Twilio, Zapier, IFTTT, etc) and you should never give out your API Token.
|
153
|
+
# Check your Team Settings where you can create "Webhook Tokens" designed for this purpose.
|
154
|
+
#
|
155
|
+
# Parameters:
|
156
|
+
# * {string} whToken - webhook token
|
157
|
+
# * {string} webhook - The Webhook object
|
158
|
+
#
|
159
|
+
# Responses:
|
160
|
+
# * PrivateWebhookResponse (https://manybrain.github.io/m8rdocs/#private-webhook)
|
161
|
+
def private_webhook(params = {})
|
162
|
+
query_params = {}
|
163
|
+
headers = {}
|
164
|
+
body = nil
|
165
|
+
|
166
|
+
raise ArgumentError.new("whToken is required") unless params.has_key?(:whToken)
|
167
|
+
raise ArgumentError.new("webhook is required") unless params.has_key?(:webhook)
|
168
|
+
|
169
|
+
body = params[:webhook] if params.has_key?(:webhook)
|
170
|
+
|
171
|
+
path = "/domains/#{params[:whToken]}/webhook"
|
172
|
+
|
173
|
+
response = @client.request(
|
174
|
+
method: :post,
|
175
|
+
path: path,
|
176
|
+
query: query_params,
|
177
|
+
headers: headers,
|
178
|
+
body: body)
|
179
|
+
end
|
180
|
+
|
181
|
+
# This command will deliver the message to the :inbox inbox
|
182
|
+
# Incoming Webhooks are delivered to Mailinator inboxes and from that point onward are not notably different than other messages in the system (i.e. emails).
|
183
|
+
# As normal, Mailinator will list all messages in the Inbox page and via the Inbox API calls.
|
184
|
+
# If the incoming JSON payload does not contain a "from" or "subject", then dummy values will be inserted in these fields.
|
185
|
+
# You may retrieve such messages via the Web Interface, the API, or the Rule System
|
186
|
+
#
|
187
|
+
# Parameters:
|
188
|
+
# * {string} whToken - webhook token
|
189
|
+
# * {string} inbox - inbox
|
190
|
+
# * {string} webhook - The Webhook object
|
191
|
+
#
|
192
|
+
# Responses:
|
193
|
+
# * PrivateWebhookResponse (https://manybrain.github.io/m8rdocs/#private-inbox-webhook)
|
194
|
+
def private_inbox_webhook(params = {})
|
195
|
+
query_params = {}
|
196
|
+
headers = {}
|
197
|
+
body = nil
|
198
|
+
|
199
|
+
raise ArgumentError.new("whToken is required") unless params.has_key?(:whToken)
|
200
|
+
raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
|
201
|
+
raise ArgumentError.new("webhook is required") unless params.has_key?(:webhook)
|
202
|
+
|
203
|
+
body = params[:webhook] if params.has_key?(:webhook)
|
204
|
+
|
205
|
+
path = "/domains/#{params[:whToken]}/webhook/#{params[:inbox]}"
|
206
|
+
|
207
|
+
response = @client.request(
|
208
|
+
method: :post,
|
209
|
+
path: path,
|
210
|
+
query: query_params,
|
211
|
+
headers: headers,
|
212
|
+
body: body)
|
213
|
+
end
|
214
|
+
|
215
|
+
# If you have a Twilio account which receives incoming SMS messages. You may direct those messages through this facility to inject those messages into the Mailinator system.
|
216
|
+
# Mailinator intends to apply specific mappings for certain services that commonly publish webhooks.
|
217
|
+
# If you test incoming Messages to SMS numbers via Twilio, you may use this endpoint to correctly map "to", "from", and "subject" of those messages to the Mailinator system.By default, the destination inbox is the Twilio phone number.
|
218
|
+
#
|
219
|
+
# Parameters:
|
220
|
+
# * {string} whToken - webhook token
|
221
|
+
# * {string} customService - custom service name
|
222
|
+
# * {string} webhook - The Webhook object
|
223
|
+
#
|
224
|
+
# Responses:
|
225
|
+
# * PrivateWebhookResponse (https://manybrain.github.io/m8rdocs/#private-custom-service-webhook)
|
226
|
+
def private_custom_service_webhook(params = {})
|
227
|
+
query_params = {}
|
228
|
+
headers = {}
|
229
|
+
body = nil
|
230
|
+
|
231
|
+
raise ArgumentError.new("whToken is required") unless params.has_key?(:whToken)
|
232
|
+
raise ArgumentError.new("customService is required") unless params.has_key?(:customService)
|
233
|
+
raise ArgumentError.new("webhook is required") unless params.has_key?(:webhook)
|
234
|
+
|
235
|
+
body = params[:webhook] if params.has_key?(:webhook)
|
236
|
+
|
237
|
+
path = "/domains/#{params[:whToken]}/#{params[:customService]}"
|
238
|
+
|
239
|
+
response = @client.request(
|
240
|
+
method: :post,
|
241
|
+
path: path,
|
242
|
+
query: query_params,
|
243
|
+
headers: headers,
|
244
|
+
body: body)
|
245
|
+
end
|
246
|
+
|
247
|
+
# The SMS message will arrive in the Private Mailinator inbox corresponding to the Twilio Phone Number. (only the digits, if a plus sign precedes the number it will be removed)
|
248
|
+
# If you wish the message to arrive in a different inbox, you may append the destination inbox to the URL.
|
249
|
+
#
|
250
|
+
# Parameters:
|
251
|
+
# * {string} whToken - webhook token
|
252
|
+
# * {string} inbox - inbox
|
253
|
+
# * {string} customService - custom service name
|
254
|
+
# * {string} webhook - The Webhook object
|
255
|
+
#
|
256
|
+
# Responses:
|
257
|
+
# * PrivateWebhookResponse (https://manybrain.github.io/m8rdocs/#private-custom-service-inbox-webhook)
|
258
|
+
def private_custom_service_inbox_webhook(params = {})
|
259
|
+
query_params = {}
|
260
|
+
headers = {}
|
261
|
+
body = nil
|
262
|
+
|
263
|
+
raise ArgumentError.new("whToken is required") unless params.has_key?(:whToken)
|
264
|
+
raise ArgumentError.new("customService is required") unless params.has_key?(:customService)
|
265
|
+
raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
|
266
|
+
raise ArgumentError.new("webhook is required") unless params.has_key?(:webhook)
|
267
|
+
|
268
|
+
body = params[:webhook] if params.has_key?(:webhook)
|
269
|
+
|
270
|
+
path = "/domains/#{params[:whToken]}/#{params[:customService]}/#{params[:inbox]}"
|
271
|
+
|
272
|
+
response = @client.request(
|
273
|
+
method: :post,
|
274
|
+
path: path,
|
275
|
+
query: query_params,
|
276
|
+
headers: headers,
|
277
|
+
body: body)
|
278
|
+
end
|
279
|
+
|
280
|
+
end
|
281
|
+
end
|
data/lib/mailinator_client.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c)
|
3
|
+
# Copyright (c) 2024 Manybrain, Inc.
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -23,10 +23,12 @@
|
|
23
23
|
require_relative "mailinator_client/version"
|
24
24
|
require_relative "mailinator_client/error"
|
25
25
|
require_relative "mailinator_client/utils"
|
26
|
+
require_relative "mailinator_client/authenticators"
|
26
27
|
require_relative "mailinator_client/domains"
|
27
28
|
require_relative "mailinator_client/stats"
|
28
29
|
require_relative "mailinator_client/messages"
|
29
30
|
require_relative "mailinator_client/rules"
|
31
|
+
require_relative "mailinator_client/webhooks"
|
30
32
|
require_relative "mailinator_client/client"
|
31
33
|
|
32
34
|
module MailinatorClient
|
@@ -11,12 +11,33 @@ class MailinatorClientApiTest < MiniTest::Test
|
|
11
11
|
@messageIdWithAttachment = "MAILINATOR_TEST_MESSAGE_WITH_ATTACHMENT_ID"
|
12
12
|
@attachmentId = "MAILINATOR_TEST_ATTACHMENT_ID"
|
13
13
|
@deleteDomain = "MAILINATOR_TEST_DELETE_DOMAIN"
|
14
|
+
@webhookTokenPrivateDomain= "MAILINATOR_TEST_WEBHOOKTOKEN_PRIVATEDOMAIN"
|
15
|
+
@webhookTokenCustomService = "MAILINATOR_TEST_WEBHOOKTOKEN_CUSTOMSERVICE"
|
16
|
+
@authSecret = "MAILINATOR_TEST_AUTH_SECRET"
|
17
|
+
@authId = "MAILINATOR_TEST_AUTH_ID"
|
18
|
+
@webhookInbox = "MAILINATOR_TEST_WEBHOOK_INBOX"
|
19
|
+
@webhookCustomService = "MAILINATOR_TEST_WEBHOOK_CUSTOMSERVICE"
|
14
20
|
end
|
15
21
|
|
16
22
|
it "should correctly do manipulation with mailinator data" do
|
17
23
|
|
18
24
|
client = MailinatorClient::Client.new(auth_token: @auth_token)
|
19
25
|
|
26
|
+
response = client.authenticators.instant_totp_2fa_code(totpSecretKey: @authSecret)
|
27
|
+
assert response != nil, "Expected instant totp 2fa code response to not be nil"
|
28
|
+
|
29
|
+
response = client.authenticators.get_authenticators()
|
30
|
+
assert response != nil, "Expected get authenticators response to not be nil"
|
31
|
+
|
32
|
+
response = client.authenticators.get_authenticators_by_id(id: @authId)
|
33
|
+
assert response != nil, "Expected get authenticators by id response to not be nil"
|
34
|
+
|
35
|
+
response = client.authenticators.get_authenticator()
|
36
|
+
assert response != nil, "Expected get authenticator response to not be nil"
|
37
|
+
|
38
|
+
response = client.authenticators.get_authenticator_by_id(id: @authId)
|
39
|
+
assert response != nil, "Expected get authenticator by id response to not be nil"
|
40
|
+
|
20
41
|
response = client.domains.get_domains
|
21
42
|
assert response != nil, "Expected get domains response to not be nil"
|
22
43
|
assert response["domains"] != nil, "Expected response domains to not be nil"
|
@@ -24,13 +45,24 @@ class MailinatorClientApiTest < MiniTest::Test
|
|
24
45
|
@domainId = @domain["_id"]
|
25
46
|
@domainName = @domain["name"]
|
26
47
|
|
27
|
-
response = client.domains.get_domain(domainId:@
|
48
|
+
response = client.domains.get_domain(domainId:@domainName)
|
28
49
|
assert response != nil, "Expected get domain response to not be nil"
|
29
50
|
|
51
|
+
@domainNameToAdd = "testruby.testinator.com"
|
52
|
+
|
53
|
+
response = client.domains.create_domain(domainId:@domainNameToAdd)
|
54
|
+
assert response != nil, "Expected create domain response to not be nil"
|
55
|
+
#assert response["status"] == "ok", "Expected create domain response to be ok"
|
56
|
+
|
57
|
+
response = client.domains.delete_domain(domainId:@domainNameToAdd)
|
58
|
+
assert response != nil, "Expected delete domain response to not be nil"
|
59
|
+
#assert response["status"] == "ok", "Expected delete domain response to be ok"
|
60
|
+
|
61
|
+
random_string = SecureRandom.hex(4)
|
30
62
|
ruleToPost = {
|
31
|
-
name: "
|
63
|
+
name: "RuleName_RubyTest_#{random_string}",
|
32
64
|
priority: 15,
|
33
|
-
description: "
|
65
|
+
description: "Description_RubyTest_#{random_string}",
|
34
66
|
conditions: [
|
35
67
|
{
|
36
68
|
operation: "PREFIX",
|
@@ -52,54 +84,94 @@ class MailinatorClientApiTest < MiniTest::Test
|
|
52
84
|
]
|
53
85
|
}
|
54
86
|
|
55
|
-
response = client.rules.create_rule(domainId:@
|
87
|
+
response = client.rules.create_rule(domainId:@domainName, ruleToPost: ruleToPost)
|
56
88
|
assert response != nil, "Expected get create rule response to not be nil"
|
57
89
|
assert response["_id"] != nil, "Expected response rule id to not be nil"
|
58
90
|
|
59
|
-
response = client.rules.get_all_rules(domainId:@
|
91
|
+
response = client.rules.get_all_rules(domainId:@domainName)
|
60
92
|
assert response != nil, "Expected get all rules response to not be nil"
|
61
93
|
assert response["rules"] != nil, "Expected response rules to not be nil"
|
62
94
|
@rule = response["rules"][0]
|
63
95
|
@ruleId = @rule["_id"]
|
64
96
|
|
65
|
-
response = client.rules.enable_rule(domainId:@
|
97
|
+
response = client.rules.enable_rule(domainId:@domainName, ruleId: @ruleId)
|
66
98
|
assert response != nil, "Expected enable rule response to not be nil"
|
67
99
|
assert response["status"] == "ok", "Expected enable rule response to be ok"
|
68
100
|
|
69
|
-
response = client.rules.disable_rule(domainId:@
|
101
|
+
response = client.rules.disable_rule(domainId:@domainName, ruleId: @ruleId)
|
70
102
|
assert response != nil, "Expected disable rule response to not be nil"
|
71
103
|
assert response["status"] == "ok", "Expected disable rule response to be ok"
|
72
104
|
|
73
|
-
response = client.rules.get_rule(domainId:@
|
105
|
+
response = client.rules.get_rule(domainId:@domainName, ruleId: @ruleId)
|
74
106
|
assert response != nil, "Expected disable rule response to not be nil"
|
75
|
-
assert response["_id"] != nil, "Expected get rule response to not be nil"
|
107
|
+
assert response["_id"] != nil, "Expected get rule response id to not be nil"
|
76
108
|
|
77
109
|
response = client.rules.delete_rule(domainId:@deleteDomain, ruleId: @ruleId)
|
78
110
|
assert response != nil, "Expected delete rule response to not be nil"
|
79
111
|
assert response["status"] == "ok", "Expected delete rule response to be ok"
|
80
112
|
|
113
|
+
messageToPost = {
|
114
|
+
subject:"Testing ruby message",
|
115
|
+
from:"test_email_ruby@test.com",
|
116
|
+
text:"I love Ruby!"
|
117
|
+
}
|
118
|
+
response = client.messages.post_message(domain:@domainName, inbox: @inboxAll, messageToPost: messageToPost)
|
119
|
+
assert response != nil, "Expected post message response to not be nil"
|
120
|
+
assert response["status"] == "ok", "Expected post message response to be ok"
|
121
|
+
|
81
122
|
response = client.messages.fetch_inbox(domain:@domainName, inbox: @inboxAll, skip: 0, limit: 50, sort: "ascending", decodeSubject: false)
|
82
123
|
assert response != nil, "Expected fetch inbox response to not be nil"
|
83
124
|
assert response["msgs"] != nil, "Expected response fetch inbox messages to not be nil"
|
84
125
|
@message = response["msgs"][0]
|
85
126
|
@messageId = @message["id"]
|
86
127
|
|
87
|
-
response = client.messages.
|
128
|
+
response = client.messages.fetch_inbox_message(domain:@domainName, inbox: @inboxAll, messageId: @messageId)
|
129
|
+
assert response != nil, "Expected fetch inbox message response to not be nil"
|
130
|
+
|
131
|
+
response = client.messages.fetch_message(domain:@domainName, messageId: @messageId)
|
88
132
|
assert response != nil, "Expected fetch message response to not be nil"
|
89
133
|
|
90
|
-
response = client.messages.fetch_sms_message(domain:@domainName,
|
134
|
+
response = client.messages.fetch_sms_message(domain:@domainName, teamSmsNumber: @teamSMSNumber)
|
91
135
|
assert response != nil, "Expected fetch sms message response to not be nil"
|
92
136
|
|
93
|
-
response = client.messages.
|
94
|
-
assert response != nil, "Expected fetch attachments response to not be nil"
|
137
|
+
response = client.messages.fetch_inbox_message_attachments(domain:@domainName, inbox: @inbox, messageId: @messageIdWithAttachment)
|
138
|
+
assert response != nil, "Expected fetch inbox message attachments response to not be nil"
|
139
|
+
|
140
|
+
response = client.messages.fetch_message_attachments(domain:@domainName, messageId: @messageIdWithAttachment)
|
141
|
+
assert response != nil, "Expected fetch message attachments response to not be nil"
|
95
142
|
|
96
|
-
response = client.messages.
|
97
|
-
assert response != nil, "Expected fetch attachment response to not be nil"
|
143
|
+
response = client.messages.fetch_inbox_message_attachment(domain:@domainName, inbox: @inbox, messageId: @messageIdWithAttachment, attachmentId: @attachmentId)
|
144
|
+
assert response != nil, "Expected fetch inbox message attachment response to not be nil"
|
98
145
|
|
99
|
-
response = client.messages.
|
146
|
+
response = client.messages.fetch_message_attachment(domain:@domainName, messageId: @messageIdWithAttachment, attachmentId: @attachmentId)
|
147
|
+
assert response != nil, "Expected fetch message attachment response to not be nil"
|
148
|
+
|
149
|
+
response = client.messages.fetch_message_links(domain:@domainName, messageId: @messageId)
|
100
150
|
assert response != nil, "Expected fetch message links response to not be nil"
|
101
151
|
assert response["links"] != nil, "Expected fetch message links links response to not be nil"
|
152
|
+
|
153
|
+
response = client.messages.fetch_inbox_message_links(domain:@domainName, inbox: @inboxAll, messageId: @messageId)
|
154
|
+
assert response != nil, "Expected fetch inbox message links response to not be nil"
|
155
|
+
assert response["links"] != nil, "Expected fetch inbox message links links response to not be nil"
|
102
156
|
|
157
|
+
response = client.messages.fetch_message_smtp_log(domain:@domainName, messageId: @messageId)
|
158
|
+
assert response != nil, "Expected fetch message smtp log response to not be nil"
|
159
|
+
|
160
|
+
response = client.messages.fetch_inbox_message_smtp_log(domain:@domainName, inbox: @inboxAll, messageId: @messageId)
|
161
|
+
assert response != nil, "Expected fetch inbox message smtp log response to not be nil"
|
162
|
+
|
163
|
+
response = client.messages.fetch_message_raw(domain:@domainName, messageId: @messageId)
|
164
|
+
assert response != nil, "Expected fetch message raw response to not be nil"
|
165
|
+
|
166
|
+
response = client.messages.fetch_inbox_message_raw(domain:@domainName, inbox: @inboxAll, messageId: @messageId)
|
167
|
+
assert response != nil, "Expected fetch inbox message raw response to not be nil"
|
168
|
+
|
169
|
+
response = client.messages.fetch_latest_messages(domain:@domainName)
|
170
|
+
assert response != nil, "Expected fetch latest messages response to not be nil"
|
171
|
+
|
172
|
+
response = client.messages.fetch_latest_inbox_messages(domain:@domainName, inbox: @inboxAll)
|
173
|
+
assert response != nil, "Expected fetch latest inbox message response to not be nil"
|
174
|
+
|
103
175
|
response = client.messages.delete_message(domain:@deleteDomain, inbox: @inbox, messageId: @messageId)
|
104
176
|
assert response != nil, "Expected delete message response to not be nil"
|
105
177
|
assert response["status"] == "ok", "Expected delete message response to be ok"
|
@@ -112,21 +184,49 @@ class MailinatorClientApiTest < MiniTest::Test
|
|
112
184
|
assert response != nil, "Expected delete all domain messages response to not be nil"
|
113
185
|
assert response["status"] == "ok", "Expected delete all domain messages response to be ok"
|
114
186
|
|
115
|
-
messageToPost = {
|
116
|
-
subject:"Testing ruby message",
|
117
|
-
from:"test_email_ruby@test.com",
|
118
|
-
text:"I love Ruby!"
|
119
|
-
}
|
120
|
-
response = client.messages.inject_message(domain:@domainName, inbox: @inboxAll, messageToPost: messageToPost)
|
121
|
-
assert response != nil, "Expected inject message response to not be nil"
|
122
|
-
assert response["status"] == "ok", "Expected inject message response to be ok"
|
123
|
-
|
124
187
|
response = client.stats.get_team_stats
|
125
188
|
assert response != nil, "Expected response to not be nil"
|
126
189
|
assert response["stats"] != nil, "Expected response stats to not be nil"
|
127
190
|
|
128
191
|
response = client.stats.get_team
|
129
192
|
assert response != nil, "Expected response to not be nil"
|
193
|
+
|
194
|
+
webhook = {
|
195
|
+
from:"MyMailinatorRubyTest",
|
196
|
+
subject:"testing message",
|
197
|
+
text:"hello world",
|
198
|
+
to:"jack"
|
199
|
+
}
|
200
|
+
|
201
|
+
clientWithoutAuthToken = MailinatorClient::Client.new()
|
202
|
+
response = clientWithoutAuthToken.webhooks.public_webhook(webhook:webhook)
|
203
|
+
assert response != nil, "Expected public webhook response to not be nil"
|
204
|
+
assert response["status"] == "ok", "Expected public webhook response to be ok"
|
205
|
+
|
206
|
+
response = clientWithoutAuthToken.webhooks.public_inbox_webhook(inbox: @webhookInbox, webhook:webhook)
|
207
|
+
assert response != nil, "Expected public inbox webhook response to not be nil"
|
208
|
+
assert response["status"] == "ok", "Expected public inbox webhook response to be ok"
|
209
|
+
|
210
|
+
response = clientWithoutAuthToken.webhooks.public_custom_service_webhook(customService: @webhookCustomService, webhook:webhook)
|
211
|
+
#assert response != nil, "Expected public custom service webhook response to not be nil"
|
212
|
+
|
213
|
+
response = clientWithoutAuthToken.webhooks.public_custom_service_inbox_webhook(customService: @webhookCustomService, inbox: @webhookInbox, webhook:webhook)
|
214
|
+
#assert response != nil, "Expected public custom service inbox webhook response to not be nil"
|
215
|
+
|
216
|
+
response = clientWithoutAuthToken.webhooks.private_webhook(whToken: @webhookTokenPrivateDomain, webhook:webhook)
|
217
|
+
assert response != nil, "Expected private webhook status response to not be nil"
|
218
|
+
assert response["status"] == "ok", "Expected private webhook response to be ok"
|
219
|
+
|
220
|
+
response = clientWithoutAuthToken.webhooks.private_inbox_webhook(whToken: @webhookTokenPrivateDomain, inbox: @webhookInbox, webhook:webhook)
|
221
|
+
assert response != nil, "Expected private inbox webhook response to not be nil"
|
222
|
+
assert response["status"] == "ok", "Expected private inbox webhook response to be ok"
|
223
|
+
|
224
|
+
response = clientWithoutAuthToken.webhooks.private_custom_service_webhook(whToken: @webhookTokenPrivateDomain, customService: @webhookCustomService, webhook:webhook)
|
225
|
+
#assert response != nil, "Expected private custom service webhook response to not be nil"
|
226
|
+
|
227
|
+
response = clientWithoutAuthToken.webhooks.private_custom_service_inbox_webhook(whToken: @webhookTokenPrivateDomain, customService: @webhookCustomService, inbox: @webhookInbox, webhook:webhook)
|
228
|
+
#assert response != nil, "Expected private custom service inbox webhook response to not be nil"
|
229
|
+
|
130
230
|
end
|
131
231
|
end
|
132
232
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailinator_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marian Melnychuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -81,11 +81,14 @@ files:
|
|
81
81
|
- LICENSE
|
82
82
|
- README.md
|
83
83
|
- Rakefile
|
84
|
+
- docs/authenticators.md
|
84
85
|
- docs/domains.md
|
85
86
|
- docs/messages.md
|
86
87
|
- docs/rules.md
|
87
88
|
- docs/stats.md
|
89
|
+
- docs/webhooks.md
|
88
90
|
- lib/mailinator_client.rb
|
91
|
+
- lib/mailinator_client/authenticators.rb
|
89
92
|
- lib/mailinator_client/client.rb
|
90
93
|
- lib/mailinator_client/domains.rb
|
91
94
|
- lib/mailinator_client/error.rb
|
@@ -94,6 +97,7 @@ files:
|
|
94
97
|
- lib/mailinator_client/stats.rb
|
95
98
|
- lib/mailinator_client/utils.rb
|
96
99
|
- lib/mailinator_client/version.rb
|
100
|
+
- lib/mailinator_client/webhooks.rb
|
97
101
|
- mailinator_client.gemspec
|
98
102
|
- test/mailinator_client_api_test.rb
|
99
103
|
- test/test_helper.rb
|
@@ -116,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
120
|
- !ruby/object:Gem::Version
|
117
121
|
version: '0'
|
118
122
|
requirements: []
|
119
|
-
rubygems_version: 3.
|
123
|
+
rubygems_version: 3.3.3
|
120
124
|
signing_key:
|
121
125
|
specification_version: 4
|
122
126
|
summary: Provides a simple ruby wrapper around the Mailinator REST API
|