mailosaur 8.1.0 → 8.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +68 -34
- data/lib/Mailosaur/analysis.rb +10 -11
- data/lib/Mailosaur/devices.rb +18 -17
- data/lib/Mailosaur/files.rb +15 -17
- data/lib/Mailosaur/messages.rb +72 -76
- data/lib/Mailosaur/models/message.rb +1 -1
- data/lib/Mailosaur/models/server.rb +4 -4
- data/lib/Mailosaur/models/server_create_options.rb +1 -1
- data/lib/Mailosaur/models/server_list_result.rb +3 -3
- data/lib/Mailosaur/previews.rb +5 -4
- data/lib/Mailosaur/servers.rb +34 -32
- data/lib/Mailosaur/usage.rb +10 -7
- data/lib/Mailosaur/version.rb +1 -1
- data/lib/mailosaur.rb +21 -9
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 073b2f6c745fe6ad8d815c0039bfcc8a39547a805c6615a00b037ca1ec415760
|
|
4
|
+
data.tar.gz: e6427526ae18e2bb269ec25a37149e4f74c2b1ef36d4b71dc13f6b1e70f98bc4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 886ccbcd88720e84729cbad7259d4a71436610710e7123ca1f5b4993852a8721ce4ba6a7d55849cbeb8d058f8e5098e3c610b97d08651b6c8791d847e6f6fbd1
|
|
7
|
+
data.tar.gz: d24a3505d18503da0a53790e0237c93e74a744657db5aeba4ae47e7936b61fadf6aa4771ff67bc0c355762f83f425fc4bd08ca09f2fcbb6a1eceb7af236dbe24
|
data/README.md
CHANGED
|
@@ -10,21 +10,32 @@ Mailosaur lets you automate email and SMS tests as part of software development
|
|
|
10
10
|
|
|
11
11
|
This guide provides several key sections:
|
|
12
12
|
|
|
13
|
+
- [Mailosaur - Ruby library · ](#mailosaur---ruby-library--)
|
|
13
14
|
- [Get Started](#get-started)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
- [Installation](#installation)
|
|
16
|
+
- [Set your API key](#set-your-api-key)
|
|
17
|
+
- [Create your code](#create-your-code)
|
|
18
|
+
- [API Reference](#api-reference)
|
|
18
19
|
- [Creating an account](#creating-an-account)
|
|
19
20
|
- [Test email addresses with Mailosaur](#test-email-addresses-with-mailosaur)
|
|
20
21
|
- [Find an email](#find-an-email)
|
|
22
|
+
- [What is this code doing?](#what-is-this-code-doing)
|
|
23
|
+
- [My email wasn't found](#my-email-wasnt-found)
|
|
21
24
|
- [Find an SMS message](#find-an-sms-message)
|
|
22
25
|
- [Testing plain text content](#testing-plain-text-content)
|
|
26
|
+
- [Extracting verification codes from plain text](#extracting-verification-codes-from-plain-text)
|
|
23
27
|
- [Testing HTML content](#testing-html-content)
|
|
28
|
+
- [Working with HTML using Nokogiri](#working-with-html-using-nokogiri)
|
|
24
29
|
- [Working with hyperlinks](#working-with-hyperlinks)
|
|
30
|
+
- [Links in plain text (including SMS messages)](#links-in-plain-text-including-sms-messages)
|
|
25
31
|
- [Working with attachments](#working-with-attachments)
|
|
32
|
+
- [Writing an attachment to disk](#writing-an-attachment-to-disk)
|
|
26
33
|
- [Working with images and web beacons](#working-with-images-and-web-beacons)
|
|
34
|
+
- [Remotely-hosted images](#remotely-hosted-images)
|
|
35
|
+
- [Triggering web beacons](#triggering-web-beacons)
|
|
27
36
|
- [Spam checking](#spam-checking)
|
|
37
|
+
- [Development](#development)
|
|
38
|
+
- [Contacting us](#contacting-us)
|
|
28
39
|
|
|
29
40
|
You can find the full [Mailosaur documentation](https://mailosaur.com/docs/) on the website.
|
|
30
41
|
|
|
@@ -32,7 +43,7 @@ If you get stuck, just contact us at support@mailosaur.com.
|
|
|
32
43
|
|
|
33
44
|
### Installation
|
|
34
45
|
|
|
35
|
-
```
|
|
46
|
+
```sh
|
|
36
47
|
gem install mailosaur
|
|
37
48
|
```
|
|
38
49
|
|
|
@@ -46,11 +57,11 @@ export MAILOSAUR_API_KEY='your-api-key-here'
|
|
|
46
57
|
|
|
47
58
|
### Create your code
|
|
48
59
|
|
|
49
|
-
|
|
60
|
+
Now import the library and create a client:
|
|
50
61
|
|
|
51
62
|
```ruby
|
|
52
63
|
require 'mailosaur'
|
|
53
|
-
mailosaur = Mailosaur::MailosaurClient.new
|
|
64
|
+
mailosaur = Mailosaur::MailosaurClient.new
|
|
54
65
|
```
|
|
55
66
|
|
|
56
67
|
### API Reference
|
|
@@ -58,17 +69,17 @@ mailosaur = Mailosaur::MailosaurClient.new()
|
|
|
58
69
|
This library is powered by the Mailosaur [email & SMS testing API](https://mailosaur.com/docs/api/). You can easily check out the API itself by looking at our [API reference documentation](https://mailosaur.com/docs/api/) or via our Postman or Insomnia collections:
|
|
59
70
|
|
|
60
71
|
[](https://app.getpostman.com/run-collection/6961255-6cc72dff-f576-451a-9023-b82dec84f95d?action=collection%2Ffork&collection-url=entityId%3D6961255-6cc72dff-f576-451a-9023-b82dec84f95d%26entityType%3Dcollection%26workspaceId%3D386a4af1-4293-4197-8f40-0eb49f831325)
|
|
61
|
-
[](https://insomnia.rest/run/?label=Mailosaur&uri=https%3A%2F%2Fmailosaur.com%2Finsomnia.json)
|
|
62
73
|
|
|
63
74
|
## Creating an account
|
|
64
75
|
|
|
65
76
|
Create a [free trial account](https://mailosaur.com/app/signup) for Mailosaur via the website.
|
|
66
77
|
|
|
67
|
-
|
|
78
|
+
To start testing you'll need three things:
|
|
68
79
|
|
|
69
|
-
- **
|
|
70
|
-
- **
|
|
71
|
-
- **
|
|
80
|
+
- **API key** - [manage API keys within the Mailosaur Dashboard](https://mailosaur.com/app/keys). You can scope a key to a single inbox (server) — recommended — or create an account-level key. [Learn more about API keys](https://mailosaur.com/docs/managing-your-account/api-keys/).
|
|
81
|
+
- **Inbox (server) domain** - open [your inbox](https://mailosaur.com/app/servers/default) (server) within the Mailosaur Dashboard to see its domain name (e.g. `abc123.mailosaur.net`). You'll need this to send email to the inbox (server).
|
|
82
|
+
- **Inbox (server) ID** - the first part of the inbox (server) domain. For `abc123.mailosaur.net` the ID is `abc123`. You need this whenever you interact with the inbox (server) via the API.
|
|
72
83
|
|
|
73
84
|
## Test email addresses with Mailosaur
|
|
74
85
|
|
|
@@ -76,13 +87,13 @@ Mailosaur gives you an **unlimited number of test email addresses** - with no se
|
|
|
76
87
|
|
|
77
88
|
Here's how it works:
|
|
78
89
|
|
|
79
|
-
* When you create an account, you are given
|
|
80
|
-
* Every server has its own
|
|
90
|
+
* When you create an account, you are given an inbox (server).
|
|
91
|
+
* Every inbox (server) has its own domain name (e.g. `abc123.mailosaur.net`)
|
|
81
92
|
* Any email address that ends with `@{YOUR_SERVER_DOMAIN}` will work with Mailosaur without any special setup. For example:
|
|
82
93
|
* `build-423@abc123.mailosaur.net`
|
|
83
94
|
* `john.smith@abc123.mailosaur.net`
|
|
84
95
|
* `rAnDoM63423@abc123.mailosaur.net`
|
|
85
|
-
* You can create more servers when you need them. Each one will have its own domain name.
|
|
96
|
+
* You can create more inboxes (servers) when you need them. Each one will have its own domain name.
|
|
86
97
|
|
|
87
98
|
***Can't use test email addresses?** You can also [use SMTP to test email](https://mailosaur.com/docs/email-testing/sending-to-mailosaur/#sending-via-smtp). By connecting your product or website to Mailosaur via SMTP, Mailosaur will catch all email your application sends, regardless of the email address.*
|
|
88
99
|
|
|
@@ -93,13 +104,12 @@ In automated tests you will want to wait for a new email to arrive. This library
|
|
|
93
104
|
```ruby
|
|
94
105
|
require 'mailosaur'
|
|
95
106
|
|
|
96
|
-
mailosaur = Mailosaur::MailosaurClient.new
|
|
107
|
+
mailosaur = Mailosaur::MailosaurClient.new
|
|
97
108
|
|
|
98
|
-
# See https://mailosaur.com/app/project/api
|
|
99
109
|
server_id = "abc123"
|
|
100
110
|
server_domain = "abc123.mailosaur.net"
|
|
101
111
|
|
|
102
|
-
criteria = Mailosaur::Models::SearchCriteria.new
|
|
112
|
+
criteria = Mailosaur::Models::SearchCriteria.new
|
|
103
113
|
criteria.sent_to = "anything@" + server_domain
|
|
104
114
|
|
|
105
115
|
email = mailosaur.messages.get(server_id, criteria)
|
|
@@ -109,10 +119,27 @@ puts(email.subject) # "Hello world!"
|
|
|
109
119
|
|
|
110
120
|
### What is this code doing?
|
|
111
121
|
|
|
112
|
-
1. Sets up an instance of `MailosaurClient
|
|
113
|
-
2. Waits for an email to arrive at the server with ID `abc123`.
|
|
122
|
+
1. Sets up an instance of `MailosaurClient`, reading the API key from the `MAILOSAUR_API_KEY` environment variable.
|
|
123
|
+
2. Waits for an email to arrive at the inbox (server) with ID `abc123`.
|
|
114
124
|
3. Outputs the subject line of the email.
|
|
115
125
|
|
|
126
|
+
### My email wasn't found
|
|
127
|
+
|
|
128
|
+
First, check that the email you sent is visible in the [Mailosaur Dashboard](https://mailosaur.com/app/project/messages).
|
|
129
|
+
|
|
130
|
+
If it is, the likely reason is that by default, `messages.get` only searches emails received by Mailosaur in the last 1 hour. You can override this behavior (see the `received_after` argument below), however we only recommend doing this during setup, as your tests will generally run faster with the default settings:
|
|
131
|
+
|
|
132
|
+
```ruby
|
|
133
|
+
require 'date'
|
|
134
|
+
|
|
135
|
+
email = mailosaur.messages.get(
|
|
136
|
+
server_id,
|
|
137
|
+
criteria,
|
|
138
|
+
# Override received_after to search all messages since Jan 1st
|
|
139
|
+
received_after: DateTime.new(2021, 1, 1)
|
|
140
|
+
)
|
|
141
|
+
```
|
|
142
|
+
|
|
116
143
|
## Find an SMS message
|
|
117
144
|
|
|
118
145
|
**Important:** Trial accounts do not automatically have SMS access. Please contact our support team to enable a trial of SMS functionality.
|
|
@@ -122,11 +149,12 @@ If your account has [SMS testing](https://mailosaur.com/sms-testing/) enabled, y
|
|
|
122
149
|
```ruby
|
|
123
150
|
require 'mailosaur'
|
|
124
151
|
|
|
125
|
-
mailosaur = Mailosaur::MailosaurClient.new
|
|
152
|
+
mailosaur = Mailosaur::MailosaurClient.new
|
|
126
153
|
|
|
127
154
|
server_id = "abc123"
|
|
155
|
+
server_domain = "abc123.mailosaur.net"
|
|
128
156
|
|
|
129
|
-
criteria = Mailosaur::Models::SearchCriteria.new
|
|
157
|
+
criteria = Mailosaur::Models::SearchCriteria.new
|
|
130
158
|
criteria.sent_to = "4471235554444"
|
|
131
159
|
|
|
132
160
|
sms = mailosaur.messages.get(server_id, criteria)
|
|
@@ -148,18 +176,15 @@ end
|
|
|
148
176
|
|
|
149
177
|
### Extracting verification codes from plain text
|
|
150
178
|
|
|
151
|
-
You may have an email or SMS message that contains an account verification code, or some other one-time passcode.
|
|
152
|
-
|
|
153
|
-
Here is how to extract a 6-digit numeric code:
|
|
179
|
+
You may have an email or SMS message that contains an account verification code, or some other one-time passcode. Mailosaur automatically extracts these for you and makes them available via the `codes` array on the message content:
|
|
154
180
|
|
|
155
181
|
```ruby
|
|
156
182
|
puts(message.text.body) # "Your access code is 243546."
|
|
157
183
|
|
|
158
|
-
|
|
159
|
-
puts(match[0]) # "243546"
|
|
184
|
+
puts(message.text.codes[0].value) # "243546"
|
|
160
185
|
```
|
|
161
186
|
|
|
162
|
-
[Read more](https://mailosaur.com/docs/
|
|
187
|
+
[Read more](https://mailosaur.com/docs/automation/codes)
|
|
163
188
|
|
|
164
189
|
## Testing HTML content
|
|
165
190
|
|
|
@@ -169,9 +194,9 @@ Most emails also have an HTML body, as well as the plain text content. You can a
|
|
|
169
194
|
puts(message.html.body) # "<html><head ..."
|
|
170
195
|
```
|
|
171
196
|
|
|
172
|
-
### Working with HTML using
|
|
197
|
+
### Working with HTML using Nokogiri
|
|
173
198
|
|
|
174
|
-
If you need to traverse the HTML content of an email
|
|
199
|
+
If you need to traverse the HTML content of an email — for example, finding an element via a CSS selector — you can use the [Nokogiri](https://rubygems.org/gems/nokogiri) library.
|
|
175
200
|
|
|
176
201
|
```sh
|
|
177
202
|
gem install nokogiri
|
|
@@ -182,12 +207,12 @@ require 'nokogiri'
|
|
|
182
207
|
|
|
183
208
|
# ...
|
|
184
209
|
|
|
185
|
-
|
|
186
|
-
el =
|
|
210
|
+
doc = Nokogiri::HTML(message.html.body)
|
|
211
|
+
el = doc.at_css(".verification-code")
|
|
187
212
|
|
|
188
213
|
verification_code = el.text
|
|
189
214
|
|
|
190
|
-
puts
|
|
215
|
+
puts(verification_code) # "542163"
|
|
191
216
|
```
|
|
192
217
|
|
|
193
218
|
[Read more](https://mailosaur.com/docs/test-cases/html-content/)
|
|
@@ -207,7 +232,7 @@ puts(first_link.text) # "Google Search"
|
|
|
207
232
|
puts(first_link.href) # "https://www.google.com/"
|
|
208
233
|
```
|
|
209
234
|
|
|
210
|
-
**Important:** To ensure you always have valid emails
|
|
235
|
+
**Important:** To ensure you always have valid emails, Mailosaur only extracts links that have been correctly marked up with `<a>` or `<area>` tags.
|
|
211
236
|
|
|
212
237
|
### Links in plain text (including SMS messages)
|
|
213
238
|
|
|
@@ -245,6 +270,15 @@ first_attachment = message.attachments[0]
|
|
|
245
270
|
puts(first_attachment.length) # 4028
|
|
246
271
|
```
|
|
247
272
|
|
|
273
|
+
### Writing an attachment to disk
|
|
274
|
+
|
|
275
|
+
```ruby
|
|
276
|
+
first_attachment = message.attachments[1]
|
|
277
|
+
|
|
278
|
+
file_bytes = mailosaur.files.get_attachment(first_attachment.id)
|
|
279
|
+
File.binwrite(first_attachment.file_name, file_bytes)
|
|
280
|
+
```
|
|
281
|
+
|
|
248
282
|
## Working with images and web beacons
|
|
249
283
|
|
|
250
284
|
The `html.images` property of a message contains an array of images found within the HTML content of an email. The length of this array corresponds to the number of images found within an email:
|
data/lib/Mailosaur/analysis.rb
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
module Mailosaur
|
|
2
|
+
# Operations for analyzing the content and deliverability of an email, including SpamAssassin
|
|
3
|
+
# scoring and per-provider deliverability reports. Accessed via +client.analysis+.
|
|
2
4
|
class Analysis
|
|
3
5
|
#
|
|
4
6
|
# Creates and initializes a new instance of the Analysis class.
|
|
5
|
-
# @param conn client connection.
|
|
7
|
+
# @param conn [Faraday::Connection] The client connection.
|
|
8
|
+
# @param handle_http_error [Method] Callback used to convert HTTP error responses into errors.
|
|
6
9
|
#
|
|
7
10
|
def initialize(conn, handle_http_error)
|
|
8
11
|
@conn = conn
|
|
@@ -13,13 +16,11 @@ module Mailosaur
|
|
|
13
16
|
attr_reader :conn
|
|
14
17
|
|
|
15
18
|
#
|
|
16
|
-
# Perform a spam
|
|
19
|
+
# Perform a spam analysis of an email.
|
|
17
20
|
#
|
|
18
|
-
#
|
|
21
|
+
# @param email [String] The identifier of the message to be analyzed.
|
|
19
22
|
#
|
|
20
|
-
# @
|
|
21
|
-
#
|
|
22
|
-
# @return [SpamAnalysisResult] operation results.
|
|
23
|
+
# @return [Mailosaur::Models::SpamAnalysisResult] The spam score and filter results.
|
|
23
24
|
#
|
|
24
25
|
def spam(email)
|
|
25
26
|
response = conn.get "api/analysis/spam/#{email}"
|
|
@@ -29,13 +30,11 @@ module Mailosaur
|
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
#
|
|
32
|
-
# Perform a deliverability report
|
|
33
|
-
#
|
|
34
|
-
# Perform deliverability test on the specified email
|
|
33
|
+
# Perform a deliverability report of an email.
|
|
35
34
|
#
|
|
36
|
-
# @param email The identifier of the
|
|
35
|
+
# @param email [String] The identifier of the message to be analyzed.
|
|
37
36
|
#
|
|
38
|
-
# @return [DeliverabilityReport]
|
|
37
|
+
# @return [Mailosaur::Models::DeliverabilityReport] The deliverability report for the email.
|
|
39
38
|
#
|
|
40
39
|
def deliverability(email)
|
|
41
40
|
response = conn.get "api/analysis/deliverability/#{email}"
|
data/lib/Mailosaur/devices.rb
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
module Mailosaur
|
|
2
|
+
# Operations for managing virtual security devices and retrieving their current one-time
|
|
3
|
+
# passwords (OTPs), used to automate testing of app-based multi-factor authentication.
|
|
4
|
+
# Accessed via +client.devices+.
|
|
2
5
|
class Devices
|
|
3
6
|
#
|
|
4
7
|
# Creates and initializes a new instance of the Devices class.
|
|
5
|
-
# @param client connection.
|
|
8
|
+
# @param conn [Faraday::Connection] The client connection.
|
|
9
|
+
# @param handle_http_error [Method] Callback used to convert HTTP error responses into errors.
|
|
6
10
|
#
|
|
7
11
|
def initialize(conn, handle_http_error)
|
|
8
12
|
@conn = conn
|
|
@@ -12,12 +16,10 @@ module Mailosaur
|
|
|
12
16
|
# @return [Connection] the client connection.
|
|
13
17
|
attr_reader :conn
|
|
14
18
|
|
|
15
|
-
#
|
|
16
|
-
# List all devices
|
|
17
19
|
#
|
|
18
20
|
# Returns a list of your virtual security devices.
|
|
19
21
|
#
|
|
20
|
-
# @return [DeviceListResult]
|
|
22
|
+
# @return [Mailosaur::Models::DeviceListResult] Your devices.
|
|
21
23
|
#
|
|
22
24
|
def list
|
|
23
25
|
response = conn.get 'api/devices'
|
|
@@ -27,13 +29,12 @@ module Mailosaur
|
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
# Creates a new virtual security device and returns it.
|
|
32
|
+
# Creates a new virtual security device.
|
|
33
33
|
#
|
|
34
|
-
# @param device_create_options [DeviceCreateOptions]
|
|
34
|
+
# @param device_create_options [Mailosaur::Models::DeviceCreateOptions] Options used to
|
|
35
|
+
# create a new Mailosaur virtual security device.
|
|
35
36
|
#
|
|
36
|
-
# @return [Device]
|
|
37
|
+
# @return [Mailosaur::Models::Device] The newly-created device.
|
|
37
38
|
#
|
|
38
39
|
def create(device_create_options)
|
|
39
40
|
response = conn.post 'api/devices', device_create_options.to_json
|
|
@@ -43,13 +44,13 @@ module Mailosaur
|
|
|
43
44
|
end
|
|
44
45
|
|
|
45
46
|
#
|
|
46
|
-
#
|
|
47
|
-
#
|
|
48
|
-
# Retrieves the current one-time password for a saved device, or given base32-encoded shared secret.
|
|
47
|
+
# Retrieves the current one-time password for a saved device, or given base32-encoded
|
|
48
|
+
# shared secret.
|
|
49
49
|
#
|
|
50
|
-
# @param query [String] Either the unique identifier of the device, or a base32-encoded
|
|
50
|
+
# @param query [String] Either the unique identifier of the device, or a base32-encoded
|
|
51
|
+
# shared secret.
|
|
51
52
|
#
|
|
52
|
-
# @return [OtpResult]
|
|
53
|
+
# @return [Mailosaur::Models::OtpResult] The current one-time password.
|
|
53
54
|
#
|
|
54
55
|
def otp(query)
|
|
55
56
|
if query.include? '-'
|
|
@@ -68,11 +69,11 @@ module Mailosaur
|
|
|
68
69
|
end
|
|
69
70
|
|
|
70
71
|
#
|
|
71
|
-
#
|
|
72
|
+
# Permanently delete a virtual security device. This operation cannot be undone.
|
|
72
73
|
#
|
|
73
|
-
#
|
|
74
|
+
# @param id [String] The unique identifier of the device.
|
|
74
75
|
#
|
|
75
|
-
# @
|
|
76
|
+
# @return [nil] Once the device has been deleted.
|
|
76
77
|
#
|
|
77
78
|
def delete(id)
|
|
78
79
|
response = conn.delete "api/devices/#{id}"
|
data/lib/Mailosaur/files.rb
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
module Mailosaur
|
|
2
|
+
# Operations for downloading the raw content associated with a message — file attachments,
|
|
3
|
+
# the full EML source of an email, and rendered email previews. Accessed via +client.files+.
|
|
2
4
|
class Files
|
|
3
5
|
#
|
|
4
6
|
# Creates and initializes a new instance of the Files class.
|
|
5
|
-
# @param client connection.
|
|
7
|
+
# @param conn [Faraday::Connection] The client connection.
|
|
8
|
+
# @param handle_http_error [Method] Callback used to convert HTTP error responses into errors.
|
|
6
9
|
#
|
|
7
10
|
def initialize(conn, handle_http_error)
|
|
8
11
|
@conn = conn
|
|
@@ -13,14 +16,11 @@ module Mailosaur
|
|
|
13
16
|
attr_reader :conn
|
|
14
17
|
|
|
15
18
|
#
|
|
16
|
-
#
|
|
19
|
+
# Downloads a single attachment.
|
|
17
20
|
#
|
|
18
|
-
#
|
|
19
|
-
# required attachment.
|
|
21
|
+
# @param id [String] The identifier for the required attachment.
|
|
20
22
|
#
|
|
21
|
-
# @
|
|
22
|
-
#
|
|
23
|
-
# @return [NOT_IMPLEMENTED] operation results.
|
|
23
|
+
# @return [String] The attachment's binary content.
|
|
24
24
|
#
|
|
25
25
|
def get_attachment(id)
|
|
26
26
|
response = conn.get "api/files/attachments/#{id}"
|
|
@@ -29,14 +29,11 @@ module Mailosaur
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
# Downloads an EML file representing the specified email. Simply supply the
|
|
35
|
-
# unique identifier for the required email.
|
|
32
|
+
# Downloads an EML file representing the specified email.
|
|
36
33
|
#
|
|
37
|
-
# @param id The identifier
|
|
34
|
+
# @param id [String] The identifier for the required message.
|
|
38
35
|
#
|
|
39
|
-
# @return [
|
|
36
|
+
# @return [String] The raw EML content of the email.
|
|
40
37
|
#
|
|
41
38
|
def get_email(id)
|
|
42
39
|
response = conn.get "api/files/email/#{id}"
|
|
@@ -44,15 +41,16 @@ module Mailosaur
|
|
|
44
41
|
response.body
|
|
45
42
|
end
|
|
46
43
|
|
|
47
|
-
#
|
|
48
|
-
# Download an email preview
|
|
49
44
|
#
|
|
50
45
|
# Downloads a screenshot of your email rendered in a real email client. Simply supply
|
|
51
46
|
# the unique identifier for the required preview.
|
|
52
47
|
#
|
|
53
|
-
# @param id The identifier of the email preview to be downloaded.
|
|
48
|
+
# @param id [String] The identifier of the email preview to be downloaded.
|
|
49
|
+
#
|
|
50
|
+
# @return [String] The preview screenshot image content.
|
|
54
51
|
#
|
|
55
|
-
# @
|
|
52
|
+
# @raise [Mailosaur::MailosaurError] With error code +preview_timeout+ if the preview is
|
|
53
|
+
# not generated within the time limit.
|
|
56
54
|
#
|
|
57
55
|
def get_preview(id)
|
|
58
56
|
timeout = 120_000
|
data/lib/Mailosaur/messages.rb
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
require 'uri'
|
|
2
2
|
|
|
3
3
|
module Mailosaur
|
|
4
|
+
# Operations for finding, retrieving, creating, forwarding, replying to, and deleting the
|
|
5
|
+
# email and SMS messages received by your Mailosaur inboxes (servers). Accessed via +client.messages+.
|
|
4
6
|
class Messages
|
|
5
7
|
#
|
|
6
8
|
# Creates and initializes a new instance of the Messages class.
|
|
7
|
-
# @param client connection.
|
|
9
|
+
# @param conn [Faraday::Connection] The client connection.
|
|
10
|
+
# @param handle_http_error [Method] Callback used to convert HTTP error responses into errors.
|
|
8
11
|
#
|
|
9
12
|
def initialize(conn, handle_http_error)
|
|
10
13
|
@conn = conn
|
|
@@ -15,22 +18,24 @@ module Mailosaur
|
|
|
15
18
|
attr_reader :conn
|
|
16
19
|
|
|
17
20
|
#
|
|
18
|
-
#
|
|
21
|
+
# Waits for a message to be found. Returns as soon as a message matching the specified
|
|
22
|
+
# search criteria is found. This is the most efficient method of looking up a message,
|
|
23
|
+
# therefore we recommend using it wherever possible.
|
|
19
24
|
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
# @param server [String] The identifier of the server hosting the message.
|
|
24
|
-
# @param criteria [SearchCriteria] The search criteria to use in order to find
|
|
25
|
-
# a match.
|
|
25
|
+
# @param server [String] The unique identifier of the containing inbox (server).
|
|
26
|
+
# @param criteria [Mailosaur::Models::SearchCriteria] The criteria with which to find
|
|
27
|
+
# messages during a search.
|
|
26
28
|
# @param timeout [Integer] Specify how long to wait for a matching result
|
|
27
|
-
#
|
|
29
|
+
# (in milliseconds).
|
|
28
30
|
# @param received_after [DateTime] Limits results to only messages received
|
|
29
|
-
#
|
|
30
|
-
# @param dir [String] Optionally limits results based on the direction (
|
|
31
|
-
#
|
|
31
|
+
# after this date/time.
|
|
32
|
+
# @param dir [String] Optionally limits results based on the direction (+Sent+
|
|
33
|
+
# or +Received+), with the default being +Received+.
|
|
34
|
+
#
|
|
35
|
+
# @return [Mailosaur::Models::Message] The first message matching the criteria.
|
|
32
36
|
#
|
|
33
|
-
# @
|
|
37
|
+
# @raise [Mailosaur::MailosaurError] With error code +no_messages_found+ if no matching
|
|
38
|
+
# message exists, or +search_timeout+ if no matching message arrives before the timeout elapses.
|
|
34
39
|
#
|
|
35
40
|
def get(server, criteria, timeout: 10_000, received_after: DateTime.now - (1.0 / 24), dir: nil)
|
|
36
41
|
# Defaults timeout to 10s, receivedAfter to 1h
|
|
@@ -41,14 +46,12 @@ module Mailosaur
|
|
|
41
46
|
end
|
|
42
47
|
|
|
43
48
|
#
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
|
-
# Retrieves the detail for a single email message. Simply supply the unique
|
|
47
|
-
# identifier for the required message.
|
|
49
|
+
# Retrieves the detail for a single message. Must be used in conjunction with either
|
|
50
|
+
# {#list} or {#search} in order to get the unique identifier for the required message.
|
|
48
51
|
#
|
|
49
|
-
# @param id The identifier of the
|
|
52
|
+
# @param id [String] The unique identifier of the message to be retrieved.
|
|
50
53
|
#
|
|
51
|
-
# @return [Message]
|
|
54
|
+
# @return [Mailosaur::Models::Message] The full message.
|
|
52
55
|
#
|
|
53
56
|
def get_by_id(id)
|
|
54
57
|
response = conn.get "api/messages/#{id}"
|
|
@@ -58,12 +61,12 @@ module Mailosaur
|
|
|
58
61
|
end
|
|
59
62
|
|
|
60
63
|
#
|
|
61
|
-
#
|
|
64
|
+
# Permanently deletes a message. Also deletes any attachments related to the message.
|
|
65
|
+
# This operation cannot be undone.
|
|
62
66
|
#
|
|
63
|
-
#
|
|
64
|
-
# any attachments related to the message.
|
|
67
|
+
# @param id [String] The identifier for the message.
|
|
65
68
|
#
|
|
66
|
-
# @
|
|
69
|
+
# @return [nil] Once the message has been deleted.
|
|
67
70
|
#
|
|
68
71
|
def delete(id)
|
|
69
72
|
response = conn.delete "api/messages/#{id}"
|
|
@@ -71,24 +74,22 @@ module Mailosaur
|
|
|
71
74
|
nil
|
|
72
75
|
end
|
|
73
76
|
|
|
74
|
-
#
|
|
75
|
-
# List all messages
|
|
76
77
|
#
|
|
77
78
|
# Returns a list of your messages in summary form. The summaries are returned
|
|
78
79
|
# sorted by received date, with the most recently-received messages appearing
|
|
79
80
|
# first.
|
|
80
81
|
#
|
|
81
|
-
# @param server [String] The identifier of the
|
|
82
|
-
# @param page [Integer] Used in conjunction with
|
|
83
|
-
#
|
|
82
|
+
# @param server [String] The unique identifier of the required inbox (server).
|
|
83
|
+
# @param page [Integer] Used in conjunction with +items_per_page+ to support
|
|
84
|
+
# pagination.
|
|
84
85
|
# @param items_per_page [Integer] A limit on the number of results to be
|
|
85
|
-
#
|
|
86
|
+
# returned per page. Can be set between 1 and 1000 items, the default is 50.
|
|
86
87
|
# @param received_after [DateTime] Limits results to only messages received
|
|
87
|
-
#
|
|
88
|
-
# @param dir [String] Optionally limits results based on the direction (
|
|
89
|
-
#
|
|
88
|
+
# after this date/time.
|
|
89
|
+
# @param dir [String] Optionally limits results based on the direction (+Sent+
|
|
90
|
+
# or +Received+), with the default being +Received+.
|
|
90
91
|
#
|
|
91
|
-
# @return [MessageListResult]
|
|
92
|
+
# @return [Mailosaur::Models::MessageListResult] The message summaries.
|
|
92
93
|
#
|
|
93
94
|
def list(server, page: nil, items_per_page: nil, received_after: nil, dir: nil)
|
|
94
95
|
url = "api/messages?server=#{server}"
|
|
@@ -106,12 +107,11 @@ module Mailosaur
|
|
|
106
107
|
end
|
|
107
108
|
|
|
108
109
|
#
|
|
109
|
-
#
|
|
110
|
+
# Permanently delete all messages within an inbox (server). This operation cannot be undone.
|
|
110
111
|
#
|
|
111
|
-
#
|
|
112
|
-
# cannot be undone. Also deletes any attachments related to each message.
|
|
112
|
+
# @param server [String] The unique identifier of the inbox (server).
|
|
113
113
|
#
|
|
114
|
-
# @
|
|
114
|
+
# @return [nil] Once all messages within the inbox (server) have been deleted.
|
|
115
115
|
#
|
|
116
116
|
def delete_all(server)
|
|
117
117
|
response = conn.delete "api/messages?server=#{server}"
|
|
@@ -119,30 +119,31 @@ module Mailosaur
|
|
|
119
119
|
nil
|
|
120
120
|
end
|
|
121
121
|
|
|
122
|
-
#
|
|
123
|
-
# Search for messages
|
|
124
122
|
#
|
|
125
123
|
# Returns a list of messages matching the specified search criteria, in summary
|
|
126
124
|
# form. The messages are returned sorted by received date, with the most
|
|
127
125
|
# recently-received messages appearing first.
|
|
128
126
|
#
|
|
129
|
-
# @param server [String] The identifier of the server
|
|
130
|
-
# @param criteria [SearchCriteria] The
|
|
131
|
-
#
|
|
132
|
-
# @param page [Integer] Used in conjunction with
|
|
133
|
-
#
|
|
127
|
+
# @param server [String] The unique identifier of the inbox (server) to search.
|
|
128
|
+
# @param criteria [Mailosaur::Models::SearchCriteria] The criteria with which to find
|
|
129
|
+
# messages during a search.
|
|
130
|
+
# @param page [Integer] Used in conjunction with +items_per_page+ to support
|
|
131
|
+
# pagination.
|
|
134
132
|
# @param items_per_page [Integer] A limit on the number of results to be
|
|
135
|
-
#
|
|
133
|
+
# returned per page. Can be set between 1 and 1000 items, the default is 50.
|
|
136
134
|
# @param timeout [Integer] Specify how long to wait for a matching result
|
|
137
|
-
#
|
|
135
|
+
# (in milliseconds).
|
|
138
136
|
# @param received_after [DateTime] Limits results to only messages received
|
|
139
|
-
#
|
|
137
|
+
# after this date/time.
|
|
140
138
|
# @param error_on_timeout [Boolean] When set to false, an error will not be
|
|
141
|
-
#
|
|
142
|
-
# @param dir [String] Optionally limits results based on the direction (
|
|
143
|
-
#
|
|
139
|
+
# raised if the timeout is reached (default: true).
|
|
140
|
+
# @param dir [String] Optionally limits results based on the direction (+Sent+
|
|
141
|
+
# or +Received+), with the default being +Received+.
|
|
144
142
|
#
|
|
145
|
-
# @return [MessageListResult]
|
|
143
|
+
# @return [Mailosaur::Models::MessageListResult] The matching message summaries.
|
|
144
|
+
#
|
|
145
|
+
# @raise [Mailosaur::MailosaurError] With error code +search_timeout+ if no matching message
|
|
146
|
+
# is found before the timeout elapses, unless +error_on_timeout+ is set to false.
|
|
146
147
|
#
|
|
147
148
|
def search(server, criteria, page: nil, items_per_page: nil, timeout: nil, received_after: nil, error_on_timeout: true, dir: nil)
|
|
148
149
|
url = "api/messages/search?server=#{server}"
|
|
@@ -181,17 +182,16 @@ module Mailosaur
|
|
|
181
182
|
end
|
|
182
183
|
end
|
|
183
184
|
|
|
184
|
-
#
|
|
185
|
-
# Create a message.
|
|
186
185
|
#
|
|
187
186
|
# Creates a new message that can be sent to a verified email address. This is
|
|
188
187
|
# useful in scenarios where you want an email to trigger a workflow in your
|
|
189
|
-
# product
|
|
188
|
+
# product.
|
|
190
189
|
#
|
|
191
|
-
# @param server [String] The identifier of the
|
|
192
|
-
# @param
|
|
190
|
+
# @param server [String] The unique identifier of the required inbox (server).
|
|
191
|
+
# @param message_create_options [Mailosaur::Models::MessageCreateOptions] Options to use
|
|
192
|
+
# when creating a new message.
|
|
193
193
|
#
|
|
194
|
-
# @return [Message]
|
|
194
|
+
# @return [Mailosaur::Models::Message] The newly-created message.
|
|
195
195
|
#
|
|
196
196
|
def create(server, message_create_options)
|
|
197
197
|
response = conn.post "api/messages?server=#{server}", message_create_options.to_json
|
|
@@ -201,15 +201,14 @@ module Mailosaur
|
|
|
201
201
|
end
|
|
202
202
|
|
|
203
203
|
#
|
|
204
|
-
#
|
|
205
|
-
#
|
|
206
|
-
# Forwards the specified email to a verified email address.
|
|
204
|
+
# Forwards the specified message to a verified email address. This is useful for
|
|
205
|
+
# simulating a user forwarding one of your email messages.
|
|
207
206
|
#
|
|
208
|
-
# @param id [String] The identifier of the
|
|
209
|
-
# @param
|
|
210
|
-
#
|
|
207
|
+
# @param id [String] The unique identifier of the message to be forwarded.
|
|
208
|
+
# @param message_forward_options [Mailosaur::Models::MessageForwardOptions] Options to use
|
|
209
|
+
# when forwarding a message.
|
|
211
210
|
#
|
|
212
|
-
# @return [Message]
|
|
211
|
+
# @return [Mailosaur::Models::Message] The forwarded message.
|
|
213
212
|
#
|
|
214
213
|
def forward(id, message_forward_options)
|
|
215
214
|
response = conn.post "api/messages/#{id}/forward", message_forward_options.to_json
|
|
@@ -219,16 +218,14 @@ module Mailosaur
|
|
|
219
218
|
end
|
|
220
219
|
|
|
221
220
|
#
|
|
222
|
-
#
|
|
221
|
+
# Sends a reply to the specified message. This is useful for when simulating a user
|
|
222
|
+
# replying to one of your email or SMS messages.
|
|
223
223
|
#
|
|
224
|
-
#
|
|
225
|
-
#
|
|
224
|
+
# @param id [String] The unique identifier of the message to be replied to.
|
|
225
|
+
# @param message_reply_options [Mailosaur::Models::MessageReplyOptions] Options to use
|
|
226
|
+
# when replying to a message.
|
|
226
227
|
#
|
|
227
|
-
# @
|
|
228
|
-
# @param options [MessageReplyOptions] The options with which to reply to the email.
|
|
229
|
-
# against.
|
|
230
|
-
#
|
|
231
|
-
# @return [Message] operation result.
|
|
228
|
+
# @return [Mailosaur::Models::Message] The reply message.
|
|
232
229
|
#
|
|
233
230
|
def reply(id, message_reply_options)
|
|
234
231
|
response = conn.post "api/messages/#{id}/reply", message_reply_options.to_json
|
|
@@ -237,15 +234,14 @@ module Mailosaur
|
|
|
237
234
|
Mailosaur::Models::Message.new(model)
|
|
238
235
|
end
|
|
239
236
|
|
|
240
|
-
#
|
|
241
|
-
# Generate email previews.
|
|
242
237
|
#
|
|
243
238
|
# Generates screenshots of an email rendered in the specified email clients.
|
|
244
239
|
#
|
|
245
240
|
# @param id [String] The identifier of the email to preview.
|
|
246
|
-
# @param options [PreviewRequestOptions] The options with which to
|
|
241
|
+
# @param options [Mailosaur::Models::PreviewRequestOptions] The options with which to
|
|
242
|
+
# generate previews.
|
|
247
243
|
#
|
|
248
|
-
# @return [PreviewListResult]
|
|
244
|
+
# @return [Mailosaur::Models::PreviewListResult] The generated previews.
|
|
249
245
|
#
|
|
250
246
|
def generate_previews(id, options)
|
|
251
247
|
response = conn.post "api/messages/#{id}/screenshots", options.to_json
|
|
@@ -63,7 +63,7 @@ module Mailosaur
|
|
|
63
63
|
# @return [Metadata]
|
|
64
64
|
attr_accessor :metadata
|
|
65
65
|
|
|
66
|
-
# @return [String] Identifier for the server in which the message is
|
|
66
|
+
# @return [String] Identifier for the inbox (server) in which the message is
|
|
67
67
|
# located.
|
|
68
68
|
attr_accessor :server
|
|
69
69
|
end
|
|
@@ -8,17 +8,17 @@ module Mailosaur
|
|
|
8
8
|
@messages = data['messages']
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
# @return [String] Unique identifier for the server. Used as username for
|
|
11
|
+
# @return [String] Unique identifier for the inbox (server). Used as username for
|
|
12
12
|
# SMTP/POP3 authentication.
|
|
13
13
|
attr_accessor :id
|
|
14
14
|
|
|
15
|
-
# @return [String] A name used to identify the server.
|
|
15
|
+
# @return [String] A name used to identify the inbox (server).
|
|
16
16
|
attr_accessor :name
|
|
17
17
|
|
|
18
|
-
# @return Users (excluding administrators) who have access to the server.
|
|
18
|
+
# @return Users (excluding administrators) who have access to the inbox (server) when access is restricted.
|
|
19
19
|
attr_accessor :users
|
|
20
20
|
|
|
21
|
-
# @return [Integer] The number of messages currently in the server.
|
|
21
|
+
# @return [Integer] The number of messages currently in the inbox (server).
|
|
22
22
|
attr_accessor :messages
|
|
23
23
|
end
|
|
24
24
|
end
|
|
@@ -6,9 +6,9 @@ module Mailosaur
|
|
|
6
6
|
(data['items'] || []).each do |i| @items << Mailosaur::Models::Server.new(i) end
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
# @return [Array<Server>] The individual servers forming the result.
|
|
10
|
-
#
|
|
11
|
-
# recently-created server appearing first.
|
|
9
|
+
# @return [Array<Server>] The individual inboxes (servers) forming the result.
|
|
10
|
+
# Inboxes (servers) are returned sorted by creation date, with the most
|
|
11
|
+
# recently-created inbox (server) appearing first.
|
|
12
12
|
attr_accessor :items
|
|
13
13
|
end
|
|
14
14
|
end
|
data/lib/Mailosaur/previews.rb
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
module Mailosaur
|
|
2
|
+
# Operations for discovering the email clients available for generating email previews
|
|
3
|
+
# (screenshots of an email rendered in real clients). Accessed via +client.previews+.
|
|
2
4
|
class Previews
|
|
3
5
|
#
|
|
4
6
|
# Creates and initializes a new instance of the Previews class.
|
|
5
|
-
# @param client connection.
|
|
7
|
+
# @param conn [Faraday::Connection] The client connection.
|
|
8
|
+
# @param handle_http_error [Method] Callback used to convert HTTP error responses into errors.
|
|
6
9
|
#
|
|
7
10
|
def initialize(conn, handle_http_error)
|
|
8
11
|
@conn = conn
|
|
@@ -15,9 +18,7 @@ module Mailosaur
|
|
|
15
18
|
#
|
|
16
19
|
# List all email clients that can be used to generate email previews.
|
|
17
20
|
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
# @return [EmailClientListResult] operation results.
|
|
21
|
+
# @return [Mailosaur::Models::EmailClientListResult] The available email clients.
|
|
21
22
|
#
|
|
22
23
|
def list_email_clients
|
|
23
24
|
response = conn.get 'api/screenshots/clients'
|
data/lib/Mailosaur/servers.rb
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
module Mailosaur
|
|
2
|
+
# Operations for creating and managing your Mailosaur inboxes (servers) — they
|
|
3
|
+
# group your tests together, each with its own domain and SMTP/POP3/IMAP credentials.
|
|
4
|
+
# Accessed via +client.servers+.
|
|
2
5
|
class Servers
|
|
3
6
|
#
|
|
4
7
|
# Creates and initializes a new instance of the Servers class.
|
|
5
|
-
# @param client connection.
|
|
8
|
+
# @param conn [Faraday::Connection] The client connection.
|
|
9
|
+
# @param handle_http_error [Method] Callback used to convert HTTP error responses into errors.
|
|
6
10
|
#
|
|
7
11
|
def initialize(conn, handle_http_error)
|
|
8
12
|
@conn = conn
|
|
@@ -13,12 +17,10 @@ module Mailosaur
|
|
|
13
17
|
attr_reader :conn
|
|
14
18
|
|
|
15
19
|
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
# Returns a list of your virtual SMTP servers. Servers are returned sorted in
|
|
20
|
+
# Returns a list of your inboxes (servers). Inboxes (servers) are returned sorted in
|
|
19
21
|
# alphabetical order.
|
|
20
22
|
#
|
|
21
|
-
# @return [ServerListResult]
|
|
23
|
+
# @return [Mailosaur::Models::ServerListResult] Your inboxes (servers).
|
|
22
24
|
#
|
|
23
25
|
def list
|
|
24
26
|
response = conn.get 'api/servers'
|
|
@@ -28,13 +30,12 @@ module Mailosaur
|
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
# Creates a new virtual SMTP server and returns it.
|
|
33
|
+
# Creates a new inbox (server).
|
|
34
34
|
#
|
|
35
|
-
# @param server_create_options [ServerCreateOptions]
|
|
35
|
+
# @param server_create_options [Mailosaur::Models::ServerCreateOptions] Options used to
|
|
36
|
+
# create a new Mailosaur inbox (server).
|
|
36
37
|
#
|
|
37
|
-
# @return [Server]
|
|
38
|
+
# @return [Mailosaur::Models::Server] The newly-created inbox (server).
|
|
38
39
|
#
|
|
39
40
|
def create(server_create_options)
|
|
40
41
|
response = conn.post 'api/servers', server_create_options.to_json
|
|
@@ -44,14 +45,11 @@ module Mailosaur
|
|
|
44
45
|
end
|
|
45
46
|
|
|
46
47
|
#
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
# Retrieves the detail for a single server. Simply supply the unique identifier
|
|
50
|
-
# for the required server.
|
|
48
|
+
# Retrieves the detail for a single inbox (server).
|
|
51
49
|
#
|
|
52
|
-
# @param id [String] The identifier of the server
|
|
50
|
+
# @param id [String] The unique identifier of the inbox (server).
|
|
53
51
|
#
|
|
54
|
-
# @return [Server]
|
|
52
|
+
# @return [Mailosaur::Models::Server] The inbox (server).
|
|
55
53
|
#
|
|
56
54
|
def get(id)
|
|
57
55
|
response = conn.get "api/servers/#{id}"
|
|
@@ -61,14 +59,12 @@ module Mailosaur
|
|
|
61
59
|
end
|
|
62
60
|
|
|
63
61
|
#
|
|
64
|
-
#
|
|
62
|
+
# Retrieves the password for an inbox (server). This password can be used for SMTP, POP3, and
|
|
63
|
+
# IMAP connectivity.
|
|
65
64
|
#
|
|
66
|
-
#
|
|
67
|
-
# Simply supply the unique identifier for the required server.
|
|
65
|
+
# @param id [String] The unique identifier of the inbox (server).
|
|
68
66
|
#
|
|
69
|
-
# @
|
|
70
|
-
#
|
|
71
|
-
# @return [String] Server password.
|
|
67
|
+
# @return [String] The password for the inbox (server).
|
|
72
68
|
#
|
|
73
69
|
def get_password(id)
|
|
74
70
|
response = conn.get "api/servers/#{id}/password"
|
|
@@ -78,14 +74,12 @@ module Mailosaur
|
|
|
78
74
|
end
|
|
79
75
|
|
|
80
76
|
#
|
|
81
|
-
#
|
|
82
|
-
#
|
|
83
|
-
# Updats a single server and returns it.
|
|
77
|
+
# Updates the attributes of an inbox (server).
|
|
84
78
|
#
|
|
85
|
-
# @param id [String] The identifier of the server
|
|
86
|
-
# @param server [Server]
|
|
79
|
+
# @param id [String] The unique identifier of the inbox (server).
|
|
80
|
+
# @param server [Mailosaur::Models::Server] The updated inbox (server).
|
|
87
81
|
#
|
|
88
|
-
# @return [Server]
|
|
82
|
+
# @return [Mailosaur::Models::Server] The updated inbox (server).
|
|
89
83
|
#
|
|
90
84
|
def update(id, server)
|
|
91
85
|
response = conn.put "api/servers/#{id}", server.to_json
|
|
@@ -95,12 +89,12 @@ module Mailosaur
|
|
|
95
89
|
end
|
|
96
90
|
|
|
97
91
|
#
|
|
98
|
-
#
|
|
92
|
+
# Permanently delete an inbox (server). This will also delete all messages, associated attachments,
|
|
93
|
+
# etc. within the inbox (server). This operation cannot be undone.
|
|
99
94
|
#
|
|
100
|
-
#
|
|
101
|
-
# all messages and associated attachments within the server.
|
|
95
|
+
# @param id [String] The unique identifier of the inbox (server).
|
|
102
96
|
#
|
|
103
|
-
# @
|
|
97
|
+
# @return [nil] Once the inbox (server) has been deleted.
|
|
104
98
|
#
|
|
105
99
|
def delete(id)
|
|
106
100
|
response = conn.delete "api/servers/#{id}"
|
|
@@ -108,6 +102,14 @@ module Mailosaur
|
|
|
108
102
|
nil
|
|
109
103
|
end
|
|
110
104
|
|
|
105
|
+
#
|
|
106
|
+
# Generates a random email address by appending a random string in front of the
|
|
107
|
+
# domain name of the inbox (server).
|
|
108
|
+
#
|
|
109
|
+
# @param server [String] The identifier of the inbox (server).
|
|
110
|
+
#
|
|
111
|
+
# @return [String] A random email address ending in the domain of the inbox (server).
|
|
112
|
+
#
|
|
111
113
|
def generate_email_address(server)
|
|
112
114
|
host = ENV['MAILOSAUR_SMTP_HOST'] || 'mailosaur.net'
|
|
113
115
|
format('%s@%s.%s', SecureRandom.hex(3), server, host)
|
data/lib/Mailosaur/usage.rb
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
module Mailosaur
|
|
2
|
+
# Operations for inspecting your account's usage limits and recent transactional usage.
|
|
3
|
+
# These endpoints require authentication with an account-level API key. Accessed via +client.usage+.
|
|
2
4
|
class Usage
|
|
3
5
|
#
|
|
4
6
|
# Creates and initializes a new instance of the Usage class.
|
|
5
|
-
# @param client connection.
|
|
7
|
+
# @param conn [Faraday::Connection] The client connection.
|
|
8
|
+
# @param handle_http_error [Method] Callback used to convert HTTP error responses into errors.
|
|
6
9
|
#
|
|
7
10
|
def initialize(conn, handle_http_error)
|
|
8
11
|
@conn = conn
|
|
@@ -13,11 +16,10 @@ module Mailosaur
|
|
|
13
16
|
attr_reader :conn
|
|
14
17
|
|
|
15
18
|
#
|
|
16
|
-
# Retrieve account usage limits.
|
|
19
|
+
# Retrieve account usage limits. Details the current limits and usage for your account.
|
|
20
|
+
# This endpoint requires authentication with an account-level API key.
|
|
17
21
|
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
# @return [UsageAccountLimits] operation results.
|
|
22
|
+
# @return [Mailosaur::Models::UsageAccountLimits] The usage limits for your account.
|
|
21
23
|
#
|
|
22
24
|
def limits
|
|
23
25
|
response = conn.get 'api/usage/limits'
|
|
@@ -27,9 +29,10 @@ module Mailosaur
|
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
#
|
|
30
|
-
#
|
|
32
|
+
# Retrieves the last 31 days of transactional usage.
|
|
33
|
+
# This endpoint requires authentication with an account-level API key.
|
|
31
34
|
#
|
|
32
|
-
# @return [UsageTransactionListResult]
|
|
35
|
+
# @return [Mailosaur::Models::UsageTransactionListResult] The transactional usage for the last 31 days.
|
|
33
36
|
#
|
|
34
37
|
def transactions
|
|
35
38
|
response = conn.get 'api/usage/transactions'
|
data/lib/Mailosaur/version.rb
CHANGED
data/lib/mailosaur.rb
CHANGED
|
@@ -62,11 +62,16 @@ module Mailosaur
|
|
|
62
62
|
autoload :BaseModel, 'Mailosaur/models/base_model.rb'
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
+
# The Mailosaur client — the main entry point to the Mailosaur API. Construct an instance with
|
|
66
|
+
# your API key (or set the +MAILOSAUR_API_KEY+ environment variable), then use the operations
|
|
67
|
+
# namespaces (+messages+, +servers+, +files+, +devices+, +analysis+, +previews+, +usage+) to
|
|
68
|
+
# automate email and SMS testing.
|
|
65
69
|
class MailosaurClient
|
|
66
70
|
#
|
|
67
|
-
#
|
|
71
|
+
# Returns an instance of the Mailosaur client.
|
|
68
72
|
# @param api_key [String] Optional API key. Overrides the MAILOSAUR_API_KEY environment variable if set.
|
|
69
|
-
# @param base_url [String] the base
|
|
73
|
+
# @param base_url [String] Optionally overrides the base URL of the Mailosaur service.
|
|
74
|
+
# @raise [ArgumentError] If no API key is provided and the MAILOSAUR_API_KEY environment variable is not set.
|
|
70
75
|
#
|
|
71
76
|
def initialize(api_key = nil, base_url: 'https://mailosaur.com/')
|
|
72
77
|
resolved_api_key = api_key || ENV['MAILOSAUR_API_KEY']
|
|
@@ -77,37 +82,44 @@ module Mailosaur
|
|
|
77
82
|
@base_url = base_url
|
|
78
83
|
end
|
|
79
84
|
|
|
80
|
-
#
|
|
85
|
+
# Operations for analyzing email content and deliverability, including spam scoring.
|
|
86
|
+
# @return [Analysis] the analysis operations namespace.
|
|
81
87
|
def analysis
|
|
82
88
|
@analysis ||= Analysis.new(connection, method(:handle_http_error))
|
|
83
89
|
end
|
|
84
90
|
|
|
85
|
-
#
|
|
91
|
+
# Operations for downloading attachments, EML source, and email preview screenshots.
|
|
92
|
+
# @return [Files] the files operations namespace.
|
|
86
93
|
def files
|
|
87
94
|
@files ||= Files.new(connection, method(:handle_http_error))
|
|
88
95
|
end
|
|
89
96
|
|
|
90
|
-
#
|
|
97
|
+
# Operations for finding, retrieving, creating, and managing email and SMS messages.
|
|
98
|
+
# @return [Messages] the messages operations namespace.
|
|
91
99
|
def messages
|
|
92
100
|
@messages ||= Messages.new(connection, method(:handle_http_error))
|
|
93
101
|
end
|
|
94
102
|
|
|
95
|
-
#
|
|
103
|
+
# Operations for creating and managing your Mailosaur inboxes (servers).
|
|
104
|
+
# @return [Servers] the servers operations namespace.
|
|
96
105
|
def servers
|
|
97
106
|
@servers ||= Servers.new(connection, method(:handle_http_error))
|
|
98
107
|
end
|
|
99
108
|
|
|
100
|
-
#
|
|
109
|
+
# Operations for inspecting account usage limits and recent transactional usage.
|
|
110
|
+
# @return [Usage] the usage operations namespace.
|
|
101
111
|
def usage
|
|
102
112
|
@usage ||= Usage.new(connection, method(:handle_http_error))
|
|
103
113
|
end
|
|
104
114
|
|
|
105
|
-
#
|
|
115
|
+
# Operations for managing virtual security devices and retrieving their one-time passwords.
|
|
116
|
+
# @return [Devices] the devices operations namespace.
|
|
106
117
|
def devices
|
|
107
118
|
@devices ||= Devices.new(connection, method(:handle_http_error))
|
|
108
119
|
end
|
|
109
120
|
|
|
110
|
-
#
|
|
121
|
+
# Operations for discovering the email clients available for generating email previews.
|
|
122
|
+
# @return [Previews] the previews operations namespace.
|
|
111
123
|
def previews
|
|
112
124
|
@previews ||= Previews.new(connection, method(:handle_http_error))
|
|
113
125
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mailosaur
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 8.1.
|
|
4
|
+
version: 8.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mailosaur
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-05-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|