mailinator_client 1.0.4 → 1.0.6
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/docs/authenticators.md +71 -0
- data/docs/messages.md +21 -2
- data/docs/stats.md +13 -0
- data/docs/webhooks.md +69 -0
- data/lib/mailinator_client/authenticators.rb +165 -0
- data/lib/mailinator_client/client.rb +3 -1
- data/lib/mailinator_client/messages.rb +46 -4
- data/lib/mailinator_client/stats.rb +26 -3
- data/lib/mailinator_client/version.rb +1 -1
- data/lib/mailinator_client/webhooks.rb +172 -0
- data/test/mailinator_client_api_test.rb +28 -14
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d61079f915251b975bf65147de21720b5fb852cc9c7bf332b1683180c0dfaec2
|
4
|
+
data.tar.gz: 10a01b3d925703e33ac2b9273bd3c47d3e25488e0ae432fa39e8e758a9a97d48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae1050498f67e632586b7ff037d9f37785119370819012c872a49aa30012cd02edd5e5715cf6979b3353442b4599d14f05797727c20792790f5903f942223a6a
|
7
|
+
data.tar.gz: a782fc068b13f790c1974c48542435b73ce270edcec4f6087fe366e97c7e6cf7a3590a45d1b1fe3598de2c200d1d16d22f86cfd9cb722aa7c2b46dc40d822d9a
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# Authenticators Actions
|
2
|
+
|
3
|
+
Details on the various actions that can be performed on the Authenticators resource, including the expected parameters and the potential responses.
|
4
|
+
|
5
|
+
##### Contents
|
6
|
+
|
7
|
+
* [InstantTOTP2FACode](#instanttotp2facode)
|
8
|
+
* [GetAuthenticators](#getauthenticators)
|
9
|
+
* [GetAuthenticatorsById](#getauthenticatorsbyid)
|
10
|
+
* [GetAuthenticator](#getauthenticator)
|
11
|
+
* [GetAuthenticatorById](#getauthenticatorbyid)
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
## InstantTOTP2FACode
|
16
|
+
|
17
|
+
Instant TOTP 2FA code
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
result = client.authenticators.instant_totp_2fa_code()
|
21
|
+
|
22
|
+
puts result
|
23
|
+
```
|
24
|
+
|
25
|
+
<br/>
|
26
|
+
|
27
|
+
## GetAuthenticators
|
28
|
+
|
29
|
+
Fetch Authenticators
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
result = client.authenticators.get_authenticators()
|
33
|
+
|
34
|
+
puts result
|
35
|
+
```
|
36
|
+
|
37
|
+
<br/>
|
38
|
+
|
39
|
+
## GetAuthenticatorsById
|
40
|
+
|
41
|
+
Fetch the TOTP 2FA code from one of your saved Keys
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
result = client.authenticators.get_authenticators_by_id()
|
45
|
+
|
46
|
+
puts result
|
47
|
+
```
|
48
|
+
|
49
|
+
<br/>
|
50
|
+
|
51
|
+
## GetAuthenticator
|
52
|
+
|
53
|
+
Fetch Authenticator
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
result = client.authenticators.get_authenticator()
|
57
|
+
|
58
|
+
puts result
|
59
|
+
```
|
60
|
+
|
61
|
+
<br/>
|
62
|
+
|
63
|
+
## GetAuthenticatorById
|
64
|
+
|
65
|
+
Fetch Authenticator By Id
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
result = client.authenticators.get_authenticator_by_id()
|
69
|
+
|
70
|
+
puts result
|
71
|
+
```
|
data/docs/messages.md
CHANGED
@@ -12,6 +12,7 @@ Details on the various actions that can be performed on the Messages resource, i
|
|
12
12
|
* [FetchMessageAttachments](#fetchmessageattachments)
|
13
13
|
* [FetchInboxMessageAttachment](#fetchinboxmessageattachment)
|
14
14
|
* [FetchMessageAttachment](#fetchmessageattachment)
|
15
|
+
* [FetchMessageLinksFull](#fetchmessagelinksfull)
|
15
16
|
* [FetchMessageLinks](#fetchmessagelinks)
|
16
17
|
* [FetchInboxMessageLinks](#fetchinboxmessagelinks)
|
17
18
|
* [DeleteAllDomainMessages](#deletealldomainmessages)
|
@@ -38,7 +39,11 @@ result = client.messages.fetch_inbox(
|
|
38
39
|
skip: my_skip
|
39
40
|
limit: my_limit
|
40
41
|
sort: my_sort
|
41
|
-
decodeSubject: my_decode_subject
|
42
|
+
decodeSubject: my_decode_subject,
|
43
|
+
cursor: my_cursor,
|
44
|
+
full: my_full,
|
45
|
+
delete: my_delete,
|
46
|
+
wait: my_wait)
|
42
47
|
|
43
48
|
puts result
|
44
49
|
```
|
@@ -67,7 +72,8 @@ Retrieves a specific message by id
|
|
67
72
|
```ruby
|
68
73
|
result = client.messages.fetch_message(
|
69
74
|
domainId: my_domain_id
|
70
|
-
messageId: my_message_id
|
75
|
+
messageId: my_message_id,
|
76
|
+
delete: my_delete)
|
71
77
|
|
72
78
|
puts result
|
73
79
|
```
|
@@ -151,6 +157,19 @@ puts result
|
|
151
157
|
|
152
158
|
<br/>
|
153
159
|
|
160
|
+
## FetchMessageLinksFull
|
161
|
+
|
162
|
+
Retrieves all links full found within a given email
|
163
|
+
|
164
|
+
```ruby
|
165
|
+
result = client.messages.fetch_message_links_full(
|
166
|
+
domainId: my_domain_id
|
167
|
+
messageId: my_message_id)
|
168
|
+
|
169
|
+
puts result
|
170
|
+
```
|
171
|
+
|
172
|
+
<br/>
|
154
173
|
|
155
174
|
## FetchMessageLinks
|
156
175
|
|
data/docs/stats.md
CHANGED
@@ -4,11 +4,24 @@ Details on the various actions that can be performed on the Stats resource, incl
|
|
4
4
|
|
5
5
|
##### Contents
|
6
6
|
|
7
|
+
* [GetTeamInfo](#getteaminfo)
|
7
8
|
* [GetTeamStats](#getteamstats)
|
8
9
|
* [GetTeam](#getteam)
|
9
10
|
|
10
11
|
<br/>
|
11
12
|
|
13
|
+
## GetTeamInfo
|
14
|
+
|
15
|
+
Retrieves info of team
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
result = client.stats.get_team_info()
|
19
|
+
|
20
|
+
puts result
|
21
|
+
```
|
22
|
+
|
23
|
+
<br/>
|
24
|
+
|
12
25
|
## GetTeamStats
|
13
26
|
|
14
27
|
Retrieves stats of team
|
data/docs/webhooks.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Webhooks Actions
|
2
|
+
|
3
|
+
Details on the various actions that can be performed on the Webhooks resource, including the expected parameters and the potential responses.
|
4
|
+
|
5
|
+
##### Contents
|
6
|
+
|
7
|
+
* [PrivateWebhook](#privatewebhook)
|
8
|
+
* [PrivateInboxWebhook](#privateinboxwebhook)
|
9
|
+
* [PrivateCustomServiceWebhook](#privatecustomservicewebhook)
|
10
|
+
* [PrivateCustomServiceInboxWebhook](#privatecustomserviceinboxwebhook)
|
11
|
+
|
12
|
+
<br/>
|
13
|
+
|
14
|
+
## PrivateWebhook
|
15
|
+
|
16
|
+
This command will Webhook messages into your Private Domain
|
17
|
+
The incoming Webhook will arrive in the inbox designated by the "to" field in the incoming request payload.
|
18
|
+
Webhooks into your Private System do NOT use your regular API Token.
|
19
|
+
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.
|
20
|
+
Check your Team Settings where you can create "Webhook Tokens" designed for this purpose.
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
result = client.webhooks.private_webhook()
|
24
|
+
|
25
|
+
puts result
|
26
|
+
```
|
27
|
+
|
28
|
+
<br/>
|
29
|
+
|
30
|
+
## PrivatePublicInboxWebhook
|
31
|
+
|
32
|
+
This command will deliver the message to the :inbox inbox
|
33
|
+
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).
|
34
|
+
As normal, Mailinator will list all messages in the Inbox page and via the Inbox API calls.
|
35
|
+
If the incoming JSON payload does not contain a "from" or "subject", then dummy values will be inserted in these fields.
|
36
|
+
You may retrieve such messages via the Web Interface, the API, or the Rule System
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
result = client.webhooks.private_inbox_webhook()
|
40
|
+
|
41
|
+
puts result
|
42
|
+
```
|
43
|
+
|
44
|
+
<br/>
|
45
|
+
|
46
|
+
## PrivateCustomServiceWebhook
|
47
|
+
|
48
|
+
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.
|
49
|
+
Mailinator intends to apply specific mappings for certain services that commonly publish webhooks.
|
50
|
+
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.
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
result = client.webhooks.private_custom_service_webhook()
|
54
|
+
|
55
|
+
puts result
|
56
|
+
```
|
57
|
+
|
58
|
+
<br/>
|
59
|
+
|
60
|
+
## PrivateCustomServiceInboxWebhook
|
61
|
+
|
62
|
+
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)
|
63
|
+
If you wish the message to arrive in a different inbox, you may append the destination inbox to the URL.
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
result = client.webhooks.private_custom_service_inbox_webhook()
|
67
|
+
|
68
|
+
puts result
|
69
|
+
```
|
@@ -0,0 +1,165 @@
|
|
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 Authenticators Resource
|
28
|
+
class Authenticators
|
29
|
+
|
30
|
+
def initialize(client)
|
31
|
+
@client = client
|
32
|
+
end
|
33
|
+
|
34
|
+
# Instant TOTP 2FA code
|
35
|
+
#
|
36
|
+
# Authentication:
|
37
|
+
# The client must be configured with a valid api
|
38
|
+
# access token to call this action.
|
39
|
+
#
|
40
|
+
# Parameters:
|
41
|
+
# * {string} totpSecretKey - totp secret key
|
42
|
+
#
|
43
|
+
# Responses:
|
44
|
+
# * Instant TOTP 2FA Code info (https://manybrain.github.io/m8rdocs/#instant-totp-2fa-code)
|
45
|
+
def instant_totp_2fa_code(params = {})
|
46
|
+
query_params = {}
|
47
|
+
headers = {}
|
48
|
+
body = nil
|
49
|
+
|
50
|
+
raise ArgumentError.new("totpSecretKey is required") unless params.has_key?(:totpSecretKey)
|
51
|
+
|
52
|
+
path = "/totp/#{params[:totpSecretKey]}"
|
53
|
+
|
54
|
+
response = @client.request(
|
55
|
+
method: :get,
|
56
|
+
path: path,
|
57
|
+
query: query_params,
|
58
|
+
headers: headers,
|
59
|
+
body: body)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Fetch Authenticators
|
63
|
+
#
|
64
|
+
# Authentication:
|
65
|
+
# The client must be configured with a valid api
|
66
|
+
# access token to call this action.
|
67
|
+
#
|
68
|
+
# Responses:
|
69
|
+
# * Collection of passcodes (https://manybrain.github.io/m8rdocs/#fetch-authenticators)
|
70
|
+
def get_authenticators()
|
71
|
+
query_params = {}
|
72
|
+
headers = {}
|
73
|
+
body = nil
|
74
|
+
|
75
|
+
path = "/authenticators"
|
76
|
+
|
77
|
+
response = @client.request(
|
78
|
+
method: :get,
|
79
|
+
path: path,
|
80
|
+
query: query_params,
|
81
|
+
headers: headers,
|
82
|
+
body: body)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Fetch the TOTP 2FA code from one of your saved Keys
|
86
|
+
#
|
87
|
+
# Authentication:
|
88
|
+
# The client must be configured with a valid api
|
89
|
+
# access token to call this action.
|
90
|
+
#
|
91
|
+
# Parameters:
|
92
|
+
# * {string} id - authenticator id
|
93
|
+
#
|
94
|
+
# Responses:
|
95
|
+
# * Authenticator (https://manybrain.github.io/m8rdocs/#fetch-authenticators-by-id)
|
96
|
+
def get_authenticators_by_id(params = {})
|
97
|
+
query_params = {}
|
98
|
+
headers = {}
|
99
|
+
body = nil
|
100
|
+
|
101
|
+
raise ArgumentError.new("id is required") unless params.has_key?(:id)
|
102
|
+
|
103
|
+
path = "/authenticators/#{params[:id]}"
|
104
|
+
|
105
|
+
response = @client.request(
|
106
|
+
method: :get,
|
107
|
+
path: path,
|
108
|
+
query: query_params,
|
109
|
+
headers: headers,
|
110
|
+
body: body)
|
111
|
+
end
|
112
|
+
|
113
|
+
# Fetch Authenticator
|
114
|
+
#
|
115
|
+
# Authentication:
|
116
|
+
# The client must be configured with a valid api
|
117
|
+
# access token to call this action.
|
118
|
+
#
|
119
|
+
# Responses:
|
120
|
+
# * Collection of passcodes (https://manybrain.github.io/m8rdocs/#fetch-authenticator)
|
121
|
+
def get_authenticator()
|
122
|
+
query_params = {}
|
123
|
+
headers = {}
|
124
|
+
body = nil
|
125
|
+
|
126
|
+
path = "/authenticator"
|
127
|
+
|
128
|
+
response = @client.request(
|
129
|
+
method: :get,
|
130
|
+
path: path,
|
131
|
+
query: query_params,
|
132
|
+
headers: headers,
|
133
|
+
body: body)
|
134
|
+
end
|
135
|
+
|
136
|
+
# Fetch Authenticator By Id
|
137
|
+
#
|
138
|
+
# Authentication:
|
139
|
+
# The client must be configured with a valid api
|
140
|
+
# access token to call this action.
|
141
|
+
#
|
142
|
+
# Parameters:
|
143
|
+
# * {string} id - authenticator id
|
144
|
+
#
|
145
|
+
# Responses:
|
146
|
+
# * Authenticator (https://manybrain.github.io/m8rdocs/#fetch-authenticator-by-id)
|
147
|
+
def get_authenticator_by_id(params = {})
|
148
|
+
query_params = {}
|
149
|
+
headers = {}
|
150
|
+
body = nil
|
151
|
+
|
152
|
+
raise ArgumentError.new("id is required") unless params.has_key?(:id)
|
153
|
+
|
154
|
+
path = "/authenticator/#{params[:id]}"
|
155
|
+
|
156
|
+
response = @client.request(
|
157
|
+
method: :get,
|
158
|
+
path: path,
|
159
|
+
query: query_params,
|
160
|
+
headers: headers,
|
161
|
+
body: body)
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
end
|
@@ -72,7 +72,9 @@ module MailinatorClient
|
|
72
72
|
response = HTTParty.send(method, path,
|
73
73
|
query: Utils.fix_query_arrays(options[:query]),
|
74
74
|
body: options[:body] && options[:body].to_json(),
|
75
|
-
headers: headers
|
75
|
+
headers: headers,
|
76
|
+
timeout: 125
|
77
|
+
)
|
76
78
|
|
77
79
|
result = response.parsed_response
|
78
80
|
if response.code >= 400
|
@@ -40,10 +40,14 @@ module MailinatorClient
|
|
40
40
|
# Parameters:
|
41
41
|
# * {string} domainId - The Domain name or the Domain id
|
42
42
|
# * {string} inbox - The Inbox name
|
43
|
-
# * {number} skip - Skip this many emails in your Private Domain
|
44
|
-
# * {number} limit - Number of emails to fetch from your Private Domain
|
45
|
-
# * {string} sort - Sort results by ascending or descending
|
46
|
-
# * {boolean} decodeSubject - true: decode encoded subjects
|
43
|
+
# * {number} skip - [Optional] Skip this many emails in your Private Domain
|
44
|
+
# * {number} limit - [Optional] Number of emails to fetch from your Private Domain
|
45
|
+
# * {string} sort - [Optional] Sort results by ascending or descending
|
46
|
+
# * {boolean} decodeSubject - [Optional] true: decode encoded subjects
|
47
|
+
# * {string} cursor - [Optional] Pagination cursor for large result sets (obtained from previous response)
|
48
|
+
# * {boolean} full - [Optional] Return full email content with body/attachments (true) or just metadata (false). Default: false
|
49
|
+
# * {string} delete - [Optional] Auto-delete message after retrieval (e.g., "10s" = 10 seconds, "5m" = 5 minutes)
|
50
|
+
# * {string} wait - [Optional] Maximum time to wait for new messages (e.g., "30s" = 30 seconds)
|
47
51
|
#
|
48
52
|
# Responses:
|
49
53
|
# * Collection of messages (https://manybrain.github.io/m8rdocs/#fetch-inbox-aka-fetch-message-summaries)
|
@@ -60,6 +64,10 @@ module MailinatorClient
|
|
60
64
|
query_params[:limit] = params[:limit] if params.has_key?(:limit)
|
61
65
|
query_params[:sort] = params[:sort] if params.has_key?(:sort)
|
62
66
|
query_params[:decodeSubject] = params[:decodeSubject] if params.has_key?(:decodeSubject)
|
67
|
+
query_params[:cursor] = params[:cursor] if params.has_key?(:cursor)
|
68
|
+
query_params[:full] = params[:full] if params.has_key?(:full)
|
69
|
+
query_params[:delete] = params[:delete] if params.has_key?(:delete)
|
70
|
+
query_params[:wait] = params[:wait] if params.has_key?(:wait)
|
63
71
|
|
64
72
|
path = "/domains/#{params[:domain]}/inboxes/#{params[:inbox]}"
|
65
73
|
|
@@ -113,6 +121,7 @@ module MailinatorClient
|
|
113
121
|
# Parameters:
|
114
122
|
# * {string} domainId - The Domain name or the Domain id
|
115
123
|
# * {string} messageId - The Message id
|
124
|
+
# * {string} delete - [Optional] Auto-delete message after retrieval (e.g., "10s" = 10 seconds, "5m" = 5 minutes)
|
116
125
|
#
|
117
126
|
# Responses:
|
118
127
|
# * Message (https://manybrain.github.io/m8rdocs/#fetch-message)
|
@@ -125,6 +134,8 @@ module MailinatorClient
|
|
125
134
|
raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
|
126
135
|
raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)
|
127
136
|
|
137
|
+
query_params[:delete] = params[:delete] if params.has_key?(:delete)
|
138
|
+
|
128
139
|
path = "/domains/#{params[:domain]}/messages/#{params[:messageId]}"
|
129
140
|
|
130
141
|
@client.request(
|
@@ -298,6 +309,37 @@ module MailinatorClient
|
|
298
309
|
body: body)
|
299
310
|
end
|
300
311
|
|
312
|
+
# Retrieves all links full info found within a given email.
|
313
|
+
#
|
314
|
+
# Authentication:
|
315
|
+
# The client must be configured with a valid api
|
316
|
+
# access token to call this action.
|
317
|
+
#
|
318
|
+
# Parameters:
|
319
|
+
# * {string} domainId - The Domain name or the Domain id
|
320
|
+
# * {string} messageId - The Message id
|
321
|
+
#
|
322
|
+
# Responses:
|
323
|
+
# * Collection of links full (https://manybrain.github.io/m8rdocs/#fetch-links-full)
|
324
|
+
def fetch_message_links_full(params = {})
|
325
|
+
params = Utils.symbolize_hash_keys(params)
|
326
|
+
query_params = { }
|
327
|
+
headers = {}
|
328
|
+
body = nil
|
329
|
+
|
330
|
+
raise ArgumentError.new("domain is required") unless params.has_key?(:domain)
|
331
|
+
raise ArgumentError.new("message id is required") unless params.has_key?(:messageId)
|
332
|
+
|
333
|
+
path = "/domains/#{params[:domain]}/messages/#{params[:messageId]}/linksfull"
|
334
|
+
|
335
|
+
@client.request(
|
336
|
+
method: :get,
|
337
|
+
path: path,
|
338
|
+
query: query_params,
|
339
|
+
headers: headers,
|
340
|
+
body: body)
|
341
|
+
end
|
342
|
+
|
301
343
|
# Retrieves all links found within a given email.
|
302
344
|
#
|
303
345
|
# Authentication:
|
@@ -31,6 +31,29 @@ module MailinatorClient
|
|
31
31
|
@client = client
|
32
32
|
end
|
33
33
|
|
34
|
+
# Retrieves info of team
|
35
|
+
#
|
36
|
+
# Authentication:
|
37
|
+
# The client must be configured with a valid api
|
38
|
+
# access token to call this action.
|
39
|
+
#
|
40
|
+
# Responses:
|
41
|
+
# * Collection of team info (https://manybrain.github.io/m8rdocs/#stats-api)
|
42
|
+
def get_team_info()
|
43
|
+
query_params = { }
|
44
|
+
headers = {}
|
45
|
+
body = nil
|
46
|
+
|
47
|
+
path = "/teaminfo"
|
48
|
+
|
49
|
+
@client.request(
|
50
|
+
method: :get,
|
51
|
+
path: path,
|
52
|
+
query: query_params,
|
53
|
+
headers: headers,
|
54
|
+
body: body)
|
55
|
+
end
|
56
|
+
|
34
57
|
# Retrieves stats of team
|
35
58
|
#
|
36
59
|
# Authentication:
|
@@ -38,7 +61,7 @@ module MailinatorClient
|
|
38
61
|
# access token to call this action.
|
39
62
|
#
|
40
63
|
# Responses:
|
41
|
-
# * Collection of team stats (https://manybrain.github.io/m8rdocs/#
|
64
|
+
# * Collection of team stats (https://manybrain.github.io/m8rdocs/#stats-api)
|
42
65
|
def get_team_stats()
|
43
66
|
query_params = { }
|
44
67
|
headers = {}
|
@@ -54,14 +77,14 @@ module MailinatorClient
|
|
54
77
|
body: body)
|
55
78
|
end
|
56
79
|
|
57
|
-
# Retrieves team
|
80
|
+
# Retrieves team stats
|
58
81
|
#
|
59
82
|
# Authentication:
|
60
83
|
# The client must be configured with a valid api
|
61
84
|
# access token to call this action.
|
62
85
|
#
|
63
86
|
# Responses:
|
64
|
-
# * Team
|
87
|
+
# * Team stats (https://manybrain.github.io/m8rdocs/#stats-api)
|
65
88
|
def get_team(params = {})
|
66
89
|
params = Utils.symbolize_hash_keys(params)
|
67
90
|
query_params = { }
|
@@ -0,0 +1,172 @@
|
|
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 Webhook messages into your Private Domain
|
35
|
+
# The incoming Webhook will arrive in the inbox designated by the "to" field in the incoming request payload.
|
36
|
+
# Webhooks into your Private System do NOT use your regular API Token.
|
37
|
+
# 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.
|
38
|
+
# Check your Team Settings where you can create "Webhook Tokens" designed for this purpose.
|
39
|
+
#
|
40
|
+
# Parameters:
|
41
|
+
# * {string} whToken - webhook token
|
42
|
+
# * {string} webhook - The Webhook object
|
43
|
+
#
|
44
|
+
# Responses:
|
45
|
+
# * PrivateWebhookResponse (https://manybrain.github.io/m8rdocs/#private-webhook)
|
46
|
+
def private_webhook(params = {})
|
47
|
+
query_params = { whtoken: "" }
|
48
|
+
headers = {}
|
49
|
+
body = nil
|
50
|
+
|
51
|
+
raise ArgumentError.new("whToken is required") unless params.has_key?(:whToken)
|
52
|
+
raise ArgumentError.new("webhook is required") unless params.has_key?(:webhook)
|
53
|
+
|
54
|
+
query_params[:whtoken] = params[:whToken] if params.has_key?(:whToken)
|
55
|
+
|
56
|
+
path = "/domains/private/webhook"
|
57
|
+
|
58
|
+
response = @client.request(
|
59
|
+
method: :post,
|
60
|
+
path: path,
|
61
|
+
query: query_params,
|
62
|
+
headers: headers,
|
63
|
+
body: body)
|
64
|
+
end
|
65
|
+
|
66
|
+
# This command will deliver the message to the :inbox inbox
|
67
|
+
# 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).
|
68
|
+
# As normal, Mailinator will list all messages in the Inbox page and via the Inbox API calls.
|
69
|
+
# If the incoming JSON payload does not contain a "from" or "subject", then dummy values will be inserted in these fields.
|
70
|
+
# You may retrieve such messages via the Web Interface, the API, or the Rule System
|
71
|
+
#
|
72
|
+
# Parameters:
|
73
|
+
# * {string} whToken - webhook token
|
74
|
+
# * {string} inbox - inbox
|
75
|
+
# * {string} webhook - The Webhook object
|
76
|
+
#
|
77
|
+
# Responses:
|
78
|
+
# * PrivateWebhookResponse (https://manybrain.github.io/m8rdocs/#private-inbox-webhook)
|
79
|
+
def private_inbox_webhook(params = {})
|
80
|
+
query_params = { whtoken: "" }
|
81
|
+
headers = {}
|
82
|
+
body = nil
|
83
|
+
|
84
|
+
raise ArgumentError.new("whToken is required") unless params.has_key?(:whToken)
|
85
|
+
raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
|
86
|
+
raise ArgumentError.new("webhook is required") unless params.has_key?(:webhook)
|
87
|
+
|
88
|
+
body = params[:webhook] if params.has_key?(:webhook)
|
89
|
+
|
90
|
+
query_params[:whtoken] = params[:whToken] if params.has_key?(:whToken)
|
91
|
+
|
92
|
+
path = "/domains/private/webhook/#{params[:inbox]}"
|
93
|
+
|
94
|
+
response = @client.request(
|
95
|
+
method: :post,
|
96
|
+
path: path,
|
97
|
+
query: query_params,
|
98
|
+
headers: headers,
|
99
|
+
body: body)
|
100
|
+
end
|
101
|
+
|
102
|
+
# 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.
|
103
|
+
# Mailinator intends to apply specific mappings for certain services that commonly publish webhooks.
|
104
|
+
# 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.
|
105
|
+
#
|
106
|
+
# Parameters:
|
107
|
+
# * {string} whToken - webhook token
|
108
|
+
# * {string} customService - custom service name
|
109
|
+
# * {string} webhook - The Webhook object
|
110
|
+
#
|
111
|
+
# Responses:
|
112
|
+
# * PrivateWebhookResponse (https://manybrain.github.io/m8rdocs/#private-custom-service-webhook)
|
113
|
+
def private_custom_service_webhook(params = {})
|
114
|
+
query_params = { whtoken: "" }
|
115
|
+
headers = {}
|
116
|
+
body = nil
|
117
|
+
|
118
|
+
raise ArgumentError.new("whToken is required") unless params.has_key?(:whToken)
|
119
|
+
raise ArgumentError.new("customService is required") unless params.has_key?(:customService)
|
120
|
+
raise ArgumentError.new("webhook is required") unless params.has_key?(:webhook)
|
121
|
+
|
122
|
+
body = params[:webhook] if params.has_key?(:webhook)
|
123
|
+
|
124
|
+
query_params[:whtoken] = params[:whToken] if params.has_key?(:whToken)
|
125
|
+
|
126
|
+
path = "/domains/private/#{params[:customService]}"
|
127
|
+
|
128
|
+
response = @client.request(
|
129
|
+
method: :post,
|
130
|
+
path: path,
|
131
|
+
query: query_params,
|
132
|
+
headers: headers,
|
133
|
+
body: body)
|
134
|
+
end
|
135
|
+
|
136
|
+
# 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)
|
137
|
+
# If you wish the message to arrive in a different inbox, you may append the destination inbox to the URL.
|
138
|
+
#
|
139
|
+
# Parameters:
|
140
|
+
# * {string} whToken - webhook token
|
141
|
+
# * {string} inbox - inbox
|
142
|
+
# * {string} customService - custom service name
|
143
|
+
# * {string} webhook - The Webhook object
|
144
|
+
#
|
145
|
+
# Responses:
|
146
|
+
# * PrivateWebhookResponse (https://manybrain.github.io/m8rdocs/#private-custom-service-inbox-webhook)
|
147
|
+
def private_custom_service_inbox_webhook(params = {})
|
148
|
+
query_params = { whtoken: "" }
|
149
|
+
headers = {}
|
150
|
+
body = nil
|
151
|
+
|
152
|
+
raise ArgumentError.new("whToken is required") unless params.has_key?(:whToken)
|
153
|
+
raise ArgumentError.new("customService is required") unless params.has_key?(:customService)
|
154
|
+
raise ArgumentError.new("inbox is required") unless params.has_key?(:inbox)
|
155
|
+
raise ArgumentError.new("webhook is required") unless params.has_key?(:webhook)
|
156
|
+
|
157
|
+
body = params[:webhook] if params.has_key?(:webhook)
|
158
|
+
|
159
|
+
query_params[:whtoken] = params[:whToken] if params.has_key?(:whToken)
|
160
|
+
|
161
|
+
path = "/domains/private/#{params[:customService]}/#{params[:inbox]}"
|
162
|
+
|
163
|
+
response = @client.request(
|
164
|
+
method: :post,
|
165
|
+
path: path,
|
166
|
+
query: query_params,
|
167
|
+
headers: headers,
|
168
|
+
body: body)
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
end
|
@@ -119,17 +119,36 @@ class MailinatorClientApiTest < MiniTest::Test
|
|
119
119
|
assert response != nil, "Expected post message response to not be nil"
|
120
120
|
assert response["status"] == "ok", "Expected post message response to be ok"
|
121
121
|
|
122
|
-
response = client.messages.fetch_inbox(domain:@domainName, inbox: @inboxAll, skip: 0, limit:
|
122
|
+
response = client.messages.fetch_inbox(domain:@domainName, inbox: @inboxAll, skip: 0, limit: 1, sort: "ascending", decodeSubject: false)
|
123
123
|
assert response != nil, "Expected fetch inbox response to not be nil"
|
124
124
|
assert response["msgs"] != nil, "Expected response fetch inbox messages to not be nil"
|
125
125
|
@message = response["msgs"][0]
|
126
126
|
@messageId = @message["id"]
|
127
127
|
|
128
|
+
response = client.messages.fetch_inbox(domain:@domainName, inbox: @inboxAll, limit: 1, cursor: response["cursor"])
|
129
|
+
assert response != nil, "Expected fetch inbox response to not be nil"
|
130
|
+
assert response["msgs"] != nil, "Expected response fetch inbox messages to not be nil"
|
131
|
+
|
132
|
+
response = client.messages.fetch_inbox(domain:@domainName, inbox: @inboxAll, limit: 1, full: true)
|
133
|
+
assert response != nil, "Expected fetch inbox response to not be nil"
|
134
|
+
assert response["msgs"] != nil, "Expected response fetch inbox messages to not be nil"
|
135
|
+
|
136
|
+
response = client.messages.fetch_inbox(domain:@domainName, inbox: @inboxAll, limit: 1, delete: "1m")
|
137
|
+
assert response != nil, "Expected fetch inbox response to not be nil"
|
138
|
+
assert response["msgs"] != nil, "Expected response fetch inbox messages to not be nil"
|
139
|
+
|
140
|
+
response = client.messages.fetch_inbox(domain:@domainName, inbox: @inboxAll, limit: 1, wait: "1m")
|
141
|
+
assert response != nil, "Expected fetch inbox response to not be nil"
|
142
|
+
assert response["msgs"] != nil, "Expected response fetch inbox messages to not be nil"
|
143
|
+
|
128
144
|
response = client.messages.fetch_inbox_message(domain:@domainName, inbox: @inboxAll, messageId: @messageId)
|
129
145
|
assert response != nil, "Expected fetch inbox message response to not be nil"
|
130
146
|
|
131
147
|
response = client.messages.fetch_message(domain:@domainName, messageId: @messageId)
|
132
148
|
assert response != nil, "Expected fetch message response to not be nil"
|
149
|
+
|
150
|
+
response = client.messages.fetch_message(domain:@domainName, messageId: @messageId, delete: "10s")
|
151
|
+
assert response != nil, "Expected fetch message response to not be nil"
|
133
152
|
|
134
153
|
response = client.messages.fetch_sms_message(domain:@domainName, teamSmsNumber: @teamSMSNumber)
|
135
154
|
assert response != nil, "Expected fetch sms message response to not be nil"
|
@@ -146,6 +165,10 @@ class MailinatorClientApiTest < MiniTest::Test
|
|
146
165
|
response = client.messages.fetch_message_attachment(domain:@domainName, messageId: @messageIdWithAttachment, attachmentId: @attachmentId)
|
147
166
|
assert response != nil, "Expected fetch message attachment response to not be nil"
|
148
167
|
|
168
|
+
response = client.messages.fetch_message_links_full(domain:@domainName, messageId: @messageId)
|
169
|
+
assert response != nil, "Expected fetch message links full response to not be nil"
|
170
|
+
assert response["links"] != nil, "Expected fetch message links links full response to not be nil"
|
171
|
+
|
149
172
|
response = client.messages.fetch_message_links(domain:@domainName, messageId: @messageId)
|
150
173
|
assert response != nil, "Expected fetch message links response to not be nil"
|
151
174
|
assert response["links"] != nil, "Expected fetch message links links response to not be nil"
|
@@ -184,6 +207,10 @@ class MailinatorClientApiTest < MiniTest::Test
|
|
184
207
|
assert response != nil, "Expected delete all domain messages response to not be nil"
|
185
208
|
assert response["status"] == "ok", "Expected delete all domain messages response to be ok"
|
186
209
|
|
210
|
+
response = client.stats.get_team_info
|
211
|
+
assert response != nil, "Expected response to not be nil"
|
212
|
+
assert response != nil, "Expected response team info to not be nil"
|
213
|
+
|
187
214
|
response = client.stats.get_team_stats
|
188
215
|
assert response != nil, "Expected response to not be nil"
|
189
216
|
assert response["stats"] != nil, "Expected response stats to not be nil"
|
@@ -199,19 +226,6 @@ class MailinatorClientApiTest < MiniTest::Test
|
|
199
226
|
}
|
200
227
|
|
201
228
|
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
229
|
|
216
230
|
response = clientWithoutAuthToken.webhooks.private_webhook(whToken: @webhookTokenPrivateDomain, webhook:webhook)
|
217
231
|
assert response != nil, "Expected private webhook status response to not be nil"
|
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.6
|
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-03-05 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
|