mailosaur 7.3.0 → 7.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +273 -12
- data/lib/Mailosaur/analysis.rb +1 -1
- data/lib/Mailosaur/files.rb +2 -2
- data/lib/Mailosaur/mailosaur_error.rb +1 -3
- data/lib/Mailosaur/messages.rb +67 -11
- data/lib/Mailosaur/models/attachment.rb +4 -0
- data/lib/Mailosaur/models/message_create_options.rb +35 -0
- data/lib/Mailosaur/models/message_forward_options.rb +23 -0
- data/lib/Mailosaur/models/message_reply_options.rb +22 -0
- data/lib/Mailosaur/servers.rb +4 -4
- data/lib/Mailosaur/version.rb +1 -1
- data/lib/mailosaur.rb +5 -2
- metadata +25 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba11091df0403a909d8a57e7700554de73b60d7210c5ded9464bfb11275b9b21
|
4
|
+
data.tar.gz: 62145309ef9d9e55381e05ef7e26f0d8c5eee04120a798e46a505c9f8eb4a22f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6a98ecd886efcd9b6b682a01ab84fd4d9f85fdbcacdbd7f6ca80997a354e294418bda65ad4c20e0fb116c9bc77ae2c05a75ab5d56a82ec5f3b526caaf2c2ab8
|
7
|
+
data.tar.gz: 19438600dabe29a2e5557636068f83d688950e3e5e52ecef0aeeb9400e522f28b61f1bb5367951fe88e375192944be754362cf05b23e702938f8fd9132261b99
|
data/README.md
CHANGED
@@ -1,30 +1,291 @@
|
|
1
|
-
# Mailosaur Ruby
|
1
|
+
# [Mailosaur - Ruby library](https://mailosaur.com/) · [](https://github.com/mailosaur/mailosaur-ruby/actions)
|
2
2
|
|
3
|
-
|
3
|
+
Mailosaur lets you automate email and SMS tests as part of software development and QA.
|
4
4
|
|
5
|
-
|
5
|
+
- **Unlimited test email addresses for all** - every account gives users an unlimited number of test email addresses to test with.
|
6
|
+
- **End-to-end (e2e) email and SMS testing** Allowing you to set up end-to-end tests for password reset emails, account verification processes and MFA/one-time passcodes sent via text message.
|
7
|
+
- **Fake SMTP servers** Mailosaur also provides dummy SMTP servers to test with; allowing you to catch email in staging environments - preventing email being sent to customers by mistake.
|
6
8
|
|
7
|
-
##
|
9
|
+
## Get Started
|
10
|
+
|
11
|
+
This guide provides several key sections:
|
12
|
+
|
13
|
+
- [Get Started](#get-started)
|
14
|
+
- [Creating an account](#creating-an-account)
|
15
|
+
- [Test email addresses with Mailosaur](#test-email-addresses-with-mailosaur)
|
16
|
+
- [Find an email](#find-an-email)
|
17
|
+
- [Find an SMS message](#find-an-sms-message)
|
18
|
+
- [Testing plain text content](#testing-plain-text-content)
|
19
|
+
- [Testing HTML content](#testing-html-content)
|
20
|
+
- [Working with hyperlinks](#working-with-hyperlinks)
|
21
|
+
- [Working with attachments](#working-with-attachments)
|
22
|
+
- [Working with images and web beacons](#working-with-images-and-web-beacons)
|
23
|
+
- [Spam checking](#spam-checking)
|
24
|
+
|
25
|
+
You can find the full [Mailosaur documentation](https://mailosaur.com/docs/) on the website.
|
26
|
+
|
27
|
+
If you get stuck, just contact us at support@mailosaur.com.
|
28
|
+
|
29
|
+
### Installation
|
8
30
|
|
9
31
|
```
|
10
32
|
gem install mailosaur
|
11
33
|
```
|
12
34
|
|
13
|
-
|
35
|
+
Then import the library into your code. The value for `YOUR_API_KEY` is covered in the next step ([creating an account](#creating-an-account)):
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
require 'mailosaur'
|
39
|
+
mailosaur = Mailosaur::MailosaurClient.new("YOUR_API_KEY")
|
40
|
+
```
|
41
|
+
|
42
|
+
### API Reference
|
43
|
+
|
44
|
+
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:
|
45
|
+
|
46
|
+
[](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)
|
47
|
+
[](https://insomnia.rest/run/?label=Mailosaur&uri=https%3A%2F%2Fmailosaur.com%2Finsomnia.json)
|
48
|
+
|
49
|
+
## Creating an account
|
50
|
+
|
51
|
+
Create a [free trial account](https://mailosaur.com/app/signup) for Mailosaur via the website.
|
52
|
+
|
53
|
+
Once you have this, navigate to the [API tab](https://mailosaur.com/app/project/api) to find the following values:
|
54
|
+
|
55
|
+
- **Server ID** - Servers act like projects, which group your tests together. You need this ID whenever you interact with a server via the API.
|
56
|
+
- **Server Domain** - Every server has its own domain name. You'll need this to send email to your server.
|
57
|
+
- **API Key** - You can create an API key per server (recommended), or an account-level API key to use across your whole account. [Learn more about API keys](https://mailosaur.com/docs/managing-your-account/api-keys/).
|
14
58
|
|
15
|
-
|
59
|
+
## Test email addresses with Mailosaur
|
16
60
|
|
17
|
-
|
61
|
+
Mailosaur gives you an **unlimited number of test email addresses** - with no setup or coding required!
|
18
62
|
|
19
|
-
|
63
|
+
Here's how it works:
|
64
|
+
|
65
|
+
* When you create an account, you are given a server.
|
66
|
+
* Every server has its own **Server Domain** name (e.g. `abc123.mailosaur.net`)
|
67
|
+
* Any email address that ends with `@{YOUR_SERVER_DOMAIN}` will work with Mailosaur without any special setup. For example:
|
68
|
+
* `build-423@abc123.mailosaur.net`
|
69
|
+
* `john.smith@abc123.mailosaur.net`
|
70
|
+
* `rAnDoM63423@abc123.mailosaur.net`
|
71
|
+
* You can create more servers when you need them. Each one will have its own domain name.
|
72
|
+
|
73
|
+
***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.*
|
74
|
+
|
75
|
+
## Find an email
|
76
|
+
|
77
|
+
In automated tests you will want to wait for a new email to arrive. This library makes that easy with the `messages.get` method. Here's how you use it:
|
20
78
|
|
21
79
|
```ruby
|
22
|
-
require
|
23
|
-
|
80
|
+
require 'mailosaur'
|
81
|
+
|
82
|
+
mailosaur = Mailosaur::MailosaurClient.new("API_KEY")
|
83
|
+
|
84
|
+
# See https://mailosaur.com/app/project/api
|
85
|
+
server_id = "abc123"
|
86
|
+
server_domain = "abc123.mailosaur.net"
|
87
|
+
|
88
|
+
criteria = Mailosaur::Models::SearchCriteria.new()
|
89
|
+
criteria.sent_to = "anything@" + server_domain
|
90
|
+
|
91
|
+
email = mailosaur.messages.get(server_id, criteria)
|
92
|
+
|
93
|
+
puts(email.subject) # "Hello world!"
|
94
|
+
```
|
95
|
+
|
96
|
+
### What is this code doing?
|
97
|
+
|
98
|
+
1. Sets up an instance of `MailosaurClient` with your API key.
|
99
|
+
2. Waits for an email to arrive at the server with ID `abc123`.
|
100
|
+
3. Outputs the subject line of the email.
|
101
|
+
|
102
|
+
## Find an SMS message
|
103
|
+
|
104
|
+
**Important:** Trial accounts do not automatically have SMS access. Please contact our support team to enable a trial of SMS functionality.
|
105
|
+
|
106
|
+
If your account has [SMS testing](https://mailosaur.com/sms-testing/) enabled, you can reserve phone numbers to test with, then use the Mailosaur API in a very similar way to when testing email:
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
require 'mailosaur'
|
110
|
+
|
111
|
+
mailosaur = Mailosaur::MailosaurClient.new("API_KEY")
|
112
|
+
|
113
|
+
server_id = "abc123"
|
114
|
+
|
115
|
+
criteria = Mailosaur::Models::SearchCriteria.new()
|
116
|
+
criteria.sent_to = "4471235554444"
|
117
|
+
|
118
|
+
sms = mailosaur.messages.get(server_id, criteria)
|
119
|
+
|
120
|
+
puts(sms.text.body)
|
121
|
+
```
|
122
|
+
|
123
|
+
## Testing plain text content
|
124
|
+
|
125
|
+
Most emails, and all SMS messages, should have a plain text body. Mailosaur exposes this content via the `text.body` property on an email or SMS message:
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
puts(message.text.body) # "Hi Jason, ..."
|
129
|
+
|
130
|
+
if message.text.body.include? "Jason"
|
131
|
+
puts("Email contains 'Jason'")
|
132
|
+
end
|
133
|
+
```
|
134
|
+
|
135
|
+
### Extracting verification codes from plain text
|
136
|
+
|
137
|
+
You may have an email or SMS message that contains an account verification code, or some other one-time passcode. You can extract content like this using a simple regex.
|
138
|
+
|
139
|
+
Here is how to extract a 6-digit numeric code:
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
puts(message.text.body) # "Your access code is 243546."
|
143
|
+
|
144
|
+
match = message.text.body.match(/([0-9]{6})/)
|
145
|
+
puts(match[0]) # "243546"
|
146
|
+
```
|
147
|
+
|
148
|
+
[Read more](https://mailosaur.com/docs/test-cases/text-content/)
|
149
|
+
|
150
|
+
## Testing HTML content
|
151
|
+
|
152
|
+
Most emails also have an HTML body, as well as the plain text content. You can access HTML content in a very similar way to plain text:
|
153
|
+
|
154
|
+
```ruby
|
155
|
+
puts(message.html.body) # "<html><head ..."
|
156
|
+
```
|
157
|
+
|
158
|
+
### Working with HTML using nokogiri
|
159
|
+
|
160
|
+
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.
|
161
|
+
|
162
|
+
```sh
|
163
|
+
gem install nokogiri
|
164
|
+
```
|
165
|
+
|
166
|
+
```ruby
|
167
|
+
require 'nokogiri'
|
168
|
+
|
169
|
+
# ...
|
170
|
+
|
171
|
+
@doc = Nokogiri::HTML(message.html.body)
|
172
|
+
el = @doc.css(".verification-code")
|
173
|
+
|
174
|
+
verification_code = el.text
|
175
|
+
|
176
|
+
puts verification_code # "542163"
|
177
|
+
```
|
178
|
+
|
179
|
+
[Read more](https://mailosaur.com/docs/test-cases/html-content/)
|
180
|
+
|
181
|
+
## Working with hyperlinks
|
182
|
+
|
183
|
+
When an email is sent with an HTML body, Mailosaur automatically extracts any hyperlinks found within anchor (`<a>`) and area (`<area>`) elements and makes these viable via the `html.links` array.
|
184
|
+
|
185
|
+
Each link has a text property, representing the display text of the hyperlink within the body, and an href property containing the target URL:
|
186
|
+
|
187
|
+
```ruby
|
188
|
+
# How many links?
|
189
|
+
puts(message.html.links.length) # 2
|
190
|
+
|
191
|
+
first_link = message.html.links[0]
|
192
|
+
puts(first_link.text) # "Google Search"
|
193
|
+
puts(first_link.href) # "https://www.google.com/"
|
194
|
+
```
|
195
|
+
|
196
|
+
**Important:** To ensure you always have valid emails. Mailosaur only extracts links that have been correctly marked up with `<a>` or `<area>` tags.
|
197
|
+
|
198
|
+
### Links in plain text (including SMS messages)
|
199
|
+
|
200
|
+
Mailosaur auto-detects links in plain text content too, which is especially useful for SMS testing:
|
201
|
+
|
202
|
+
```ruby
|
203
|
+
# How many links?
|
204
|
+
puts(message.text.links.length) # 2
|
205
|
+
|
206
|
+
first_link = message.text.links[0]
|
207
|
+
puts(first_link.href) # "https://www.google.com/"
|
208
|
+
```
|
209
|
+
|
210
|
+
## Working with attachments
|
211
|
+
|
212
|
+
If your email includes attachments, you can access these via the `attachments` property:
|
213
|
+
|
214
|
+
```ruby
|
215
|
+
# How many attachments?
|
216
|
+
puts(message.attachments.length) # 2
|
217
|
+
```
|
218
|
+
|
219
|
+
Each attachment contains metadata on the file name and content type:
|
220
|
+
|
221
|
+
```ruby
|
222
|
+
first_attachment = message.attachments[0]
|
223
|
+
puts(first_attachment.file_name) # "contract.pdf"
|
224
|
+
puts(first_attachment.content_type) # "application/pdf"
|
225
|
+
```
|
226
|
+
|
227
|
+
The `length` property returns the size of the attached file (in bytes):
|
228
|
+
|
229
|
+
```ruby
|
230
|
+
first_attachment = message.attachments[0]
|
231
|
+
puts(first_attachment.length) # 4028
|
232
|
+
```
|
233
|
+
|
234
|
+
## Working with images and web beacons
|
235
|
+
|
236
|
+
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:
|
237
|
+
|
238
|
+
```ruby
|
239
|
+
# How many images in the email?
|
240
|
+
puts(message.html.images.length) # 1
|
241
|
+
```
|
242
|
+
|
243
|
+
### Remotely-hosted images
|
244
|
+
|
245
|
+
Emails will often contain many images that are hosted elsewhere, such as on your website or product. It is recommended to check that these images are accessible by your recipients.
|
246
|
+
|
247
|
+
All images should have an alternative text description, which can be checked using the `alt` attribute.
|
248
|
+
|
249
|
+
```ruby
|
250
|
+
image = message.html.images[0]
|
251
|
+
puts(image.alt) # "Hot air balloon"
|
252
|
+
```
|
253
|
+
|
254
|
+
### Triggering web beacons
|
255
|
+
|
256
|
+
A web beacon is a small image that can be used to track whether an email has been opened by a recipient.
|
257
|
+
|
258
|
+
Because a web beacon is simply another form of remotely-hosted image, you can use the `src` attribute to perform an HTTP request to that address:
|
259
|
+
|
260
|
+
```ruby
|
261
|
+
image = message.html.images[0]
|
262
|
+
puts(image.src) # "https://example.com/s.png?abc123"
|
263
|
+
|
264
|
+
# Make an HTTP call to trigger the web beacon
|
265
|
+
uri = URI(image.src)
|
266
|
+
Net::HTTP.start(uri.host, uri.port,
|
267
|
+
:use_ssl => uri.scheme == 'https') do |http|
|
268
|
+
request = Net::HTTP::Get.new uri
|
269
|
+
|
270
|
+
response = http.request request # Net::HTTPResponse object
|
271
|
+
puts(response.code) # 200
|
272
|
+
end
|
273
|
+
```
|
274
|
+
|
275
|
+
## Spam checking
|
276
|
+
|
277
|
+
You can perform a [SpamAssassin](https://spamassassin.apache.org/) check against an email. The structure returned matches the [spam test object](https://mailosaur.com/docs/api/#spam):
|
278
|
+
|
279
|
+
```ruby
|
280
|
+
result = mailosaur.analysis.spam(message.id)
|
24
281
|
|
25
|
-
result
|
282
|
+
puts(result.score) # 0.5
|
26
283
|
|
27
|
-
|
284
|
+
for r in result.spam_filter_results.spam_assassin do
|
285
|
+
puts(r.rule)
|
286
|
+
puts(r.description)
|
287
|
+
puts(r.score)
|
288
|
+
end
|
28
289
|
```
|
29
290
|
|
30
291
|
## Development
|
data/lib/Mailosaur/analysis.rb
CHANGED
@@ -22,7 +22,7 @@ module Mailosaur
|
|
22
22
|
# @return [SpamAnalysisResult] operation results.
|
23
23
|
#
|
24
24
|
def spam(email)
|
25
|
-
response = conn.get
|
25
|
+
response = conn.get "api/analysis/spam/#{email}"
|
26
26
|
@handle_http_error.call(response) unless response.status == 200
|
27
27
|
model = JSON.load(response.body)
|
28
28
|
Mailosaur::Models::SpamAnalysisResult.new(model)
|
data/lib/Mailosaur/files.rb
CHANGED
@@ -23,7 +23,7 @@ module Mailosaur
|
|
23
23
|
# @return [NOT_IMPLEMENTED] operation results.
|
24
24
|
#
|
25
25
|
def get_attachment(id)
|
26
|
-
response = conn.get
|
26
|
+
response = conn.get "api/files/attachments/#{id}"
|
27
27
|
@handle_http_error.call(response) unless response.status == 200
|
28
28
|
response.body
|
29
29
|
end
|
@@ -39,7 +39,7 @@ module Mailosaur
|
|
39
39
|
# @return [NOT_IMPLEMENTED] operation results.
|
40
40
|
#
|
41
41
|
def get_email(id)
|
42
|
-
response = conn.get
|
42
|
+
response = conn.get "api/files/email/#{id}"
|
43
43
|
@handle_http_error.call(response) unless response.status == 200
|
44
44
|
response.body
|
45
45
|
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module Mailosaur
|
2
2
|
class MailosaurError < StandardError
|
3
|
-
attr_reader :error_type
|
4
|
-
attr_reader :http_status_code
|
5
|
-
attr_reader :http_response_body
|
3
|
+
attr_reader :error_type, :http_status_code, :http_response_body
|
6
4
|
|
7
5
|
def initialize(message = '', error_type = '', http_status_code = nil, http_response_body = nil)
|
8
6
|
super(message)
|
data/lib/Mailosaur/messages.rb
CHANGED
@@ -49,7 +49,7 @@ module Mailosaur
|
|
49
49
|
# @return [Message] operation results.
|
50
50
|
#
|
51
51
|
def get_by_id(id)
|
52
|
-
response = conn.get
|
52
|
+
response = conn.get "api/messages/#{id}"
|
53
53
|
@handle_http_error.call(response) unless response.status == 200
|
54
54
|
model = JSON.load(response.body)
|
55
55
|
Mailosaur::Models::Message.new(model)
|
@@ -64,7 +64,7 @@ module Mailosaur
|
|
64
64
|
# @param id The identifier of the message to be deleted.
|
65
65
|
#
|
66
66
|
def delete(id)
|
67
|
-
response = conn.delete
|
67
|
+
response = conn.delete "api/messages/#{id}"
|
68
68
|
@handle_http_error.call(response) unless response.status == 204
|
69
69
|
nil
|
70
70
|
end
|
@@ -87,10 +87,10 @@ module Mailosaur
|
|
87
87
|
# @return [MessageListResult] operation results.
|
88
88
|
#
|
89
89
|
def list(server, page: nil, items_per_page: nil, received_after: nil)
|
90
|
-
url =
|
91
|
-
url += page ?
|
92
|
-
url += items_per_page ?
|
93
|
-
url += received_after ?
|
90
|
+
url = "api/messages?server=#{server}"
|
91
|
+
url += page ? "&page=#{page}" : ''
|
92
|
+
url += items_per_page ? "&itemsPerPage=#{items_per_page}" : ''
|
93
|
+
url += received_after ? "&receivedAfter=#{CGI.escape(received_after.iso8601)}" : ''
|
94
94
|
|
95
95
|
response = conn.get url
|
96
96
|
|
@@ -109,7 +109,7 @@ module Mailosaur
|
|
109
109
|
# @param server [String] The identifier of the server to be emptied.
|
110
110
|
#
|
111
111
|
def delete_all(server)
|
112
|
-
response = conn.delete
|
112
|
+
response = conn.delete "api/messages?server=#{server}"
|
113
113
|
@handle_http_error.call(response) unless response.status == 204
|
114
114
|
nil
|
115
115
|
end
|
@@ -138,10 +138,10 @@ module Mailosaur
|
|
138
138
|
# @return [MessageListResult] operation results.
|
139
139
|
#
|
140
140
|
def search(server, criteria, page: nil, items_per_page: nil, timeout: nil, received_after: nil, error_on_timeout: true) # rubocop:disable all
|
141
|
-
url =
|
142
|
-
url += page ?
|
143
|
-
url += items_per_page ?
|
144
|
-
url += received_after ?
|
141
|
+
url = "api/messages/search?server=#{server}"
|
142
|
+
url += page ? "&page=#{page}" : ''
|
143
|
+
url += items_per_page ? "&itemsPerPage=#{items_per_page}" : ''
|
144
|
+
url += received_after ? "&receivedAfter=#{CGI.escape(received_after.iso8601)}" : ''
|
145
145
|
|
146
146
|
poll_count = 0
|
147
147
|
start_time = Time.now.to_f
|
@@ -170,5 +170,61 @@ module Mailosaur
|
|
170
170
|
sleep(delay / 1000)
|
171
171
|
end
|
172
172
|
end
|
173
|
+
|
174
|
+
#
|
175
|
+
# Create a message.
|
176
|
+
#
|
177
|
+
# Creates a new message that can be sent to a verified email address. This is
|
178
|
+
# useful in scenarios where you want an email to trigger a workflow in your
|
179
|
+
# product
|
180
|
+
#
|
181
|
+
# @param server [String] The identifier of the server to create the message in.
|
182
|
+
# @param options [MessageCreateOptions] The options with which to create the message.
|
183
|
+
#
|
184
|
+
# @return [Message] operation result.
|
185
|
+
#
|
186
|
+
def create(server, message_create_options)
|
187
|
+
response = conn.post "api/messages?server=#{server}", message_create_options.to_json
|
188
|
+
@handle_http_error.call(response) unless response.status == 200
|
189
|
+
model = JSON.load(response.body)
|
190
|
+
Mailosaur::Models::Message.new(model)
|
191
|
+
end
|
192
|
+
|
193
|
+
#
|
194
|
+
# Forward an email.
|
195
|
+
#
|
196
|
+
# Forwards the specified email to a verified email address.
|
197
|
+
#
|
198
|
+
# @param id [String] The identifier of the email to forward.
|
199
|
+
# @param options [MessageForwardOptions] The options with which to forward the email.
|
200
|
+
# against.
|
201
|
+
#
|
202
|
+
# @return [Message] operation result.
|
203
|
+
#
|
204
|
+
def forward(id, message_forward_options)
|
205
|
+
response = conn.post "api/messages/#{id}/forward", message_forward_options.to_json
|
206
|
+
@handle_http_error.call(response) unless response.status == 200
|
207
|
+
model = JSON.load(response.body)
|
208
|
+
Mailosaur::Models::Message.new(model)
|
209
|
+
end
|
210
|
+
|
211
|
+
#
|
212
|
+
# Reply to an email.
|
213
|
+
#
|
214
|
+
# Sends a reply to the specified email. This is useful for when simulating a user
|
215
|
+
# replying to one of your emails.
|
216
|
+
#
|
217
|
+
# @param id [String] The identifier of the email to reply to.
|
218
|
+
# @param options [MessageReplyOptions] The options with which to reply to the email.
|
219
|
+
# against.
|
220
|
+
#
|
221
|
+
# @return [Message] operation result.
|
222
|
+
#
|
223
|
+
def reply(id, message_reply_options)
|
224
|
+
response = conn.post "api/messages/#{id}/reply", message_reply_options.to_json
|
225
|
+
@handle_http_error.call(response) unless response.status == 200
|
226
|
+
model = JSON.load(response.body)
|
227
|
+
Mailosaur::Models::Message.new(model)
|
228
|
+
end
|
173
229
|
end
|
174
230
|
end
|
@@ -5,6 +5,7 @@ module Mailosaur
|
|
5
5
|
@id = data['id']
|
6
6
|
@content_type = data['contentType']
|
7
7
|
@file_name = data['fileName']
|
8
|
+
@content = data['content']
|
8
9
|
@content_id = data['contentId']
|
9
10
|
@length = data['length']
|
10
11
|
@url = data['url']
|
@@ -19,6 +20,9 @@ module Mailosaur
|
|
19
20
|
# @return [String]
|
20
21
|
attr_accessor :file_name
|
21
22
|
|
23
|
+
# @return [String]
|
24
|
+
attr_accessor :content
|
25
|
+
|
22
26
|
# @return [String]
|
23
27
|
attr_accessor :content_id
|
24
28
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Mailosaur
|
2
|
+
module Models
|
3
|
+
class MessageCreateOptions < BaseModel
|
4
|
+
def initialize(data = {})
|
5
|
+
@to = data['to']
|
6
|
+
@send = data['send']
|
7
|
+
@subject = data['subject']
|
8
|
+
@text = data['text']
|
9
|
+
@html = data['html']
|
10
|
+
@attachments = data['attachments']
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [String] The email address to which the email will be sent.
|
14
|
+
# Must be a verified email address.
|
15
|
+
attr_accessor :to
|
16
|
+
|
17
|
+
# @return [Boolean] If true, email will be sent upon creation.
|
18
|
+
attr_accessor :send
|
19
|
+
|
20
|
+
# @return [String] The email subject line.
|
21
|
+
attr_accessor :subject
|
22
|
+
|
23
|
+
# @return [String] The plain text body of the email. Note that only
|
24
|
+
# text or html can be supplied, not both.
|
25
|
+
attr_accessor :text
|
26
|
+
|
27
|
+
# @return [String] The HTML body of the email. Note that only text
|
28
|
+
# or html can be supplied, not both.
|
29
|
+
attr_accessor :html
|
30
|
+
|
31
|
+
# @return [Array<Attachment>] Any message attachments.
|
32
|
+
attr_accessor :attachments
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Mailosaur
|
2
|
+
module Models
|
3
|
+
class MessageForwardOptions < BaseModel
|
4
|
+
def initialize(data = {})
|
5
|
+
@to = data['to']
|
6
|
+
@text = data['text']
|
7
|
+
@html = data['html']
|
8
|
+
end
|
9
|
+
|
10
|
+
# @return [String] The email address to which the email will be sent.
|
11
|
+
# Must be a verified email address.
|
12
|
+
attr_accessor :to
|
13
|
+
|
14
|
+
# @return [String] Any additional plain text content to forward the
|
15
|
+
# email with. Note that only text or html can be supplied, not both.
|
16
|
+
attr_accessor :text
|
17
|
+
|
18
|
+
# @return [String] Any additional HTML content to forward the email
|
19
|
+
# with. Note that only html or text can be supplied, not both.
|
20
|
+
attr_accessor :html
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Mailosaur
|
2
|
+
module Models
|
3
|
+
class MessageReplyOptions < BaseModel
|
4
|
+
def initialize(data = {})
|
5
|
+
@text = data['text']
|
6
|
+
@html = data['html']
|
7
|
+
@attachments = data['attachments']
|
8
|
+
end
|
9
|
+
|
10
|
+
# @return [String] Any additional plain text content to include in
|
11
|
+
# the reply. Note that only text or html can be supplied, not both.
|
12
|
+
attr_accessor :text
|
13
|
+
|
14
|
+
# @return [String] Any additional HTML content to include in the
|
15
|
+
# reply. Note that only html or text can be supplied, not both.
|
16
|
+
attr_accessor :html
|
17
|
+
|
18
|
+
# @return [Array<Attachment>] Any message attachments.
|
19
|
+
attr_accessor :attachments
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/Mailosaur/servers.rb
CHANGED
@@ -54,7 +54,7 @@ module Mailosaur
|
|
54
54
|
# @return [Server] operation results.
|
55
55
|
#
|
56
56
|
def get(id)
|
57
|
-
response = conn.get
|
57
|
+
response = conn.get "api/servers/#{id}"
|
58
58
|
@handle_http_error.call(response) unless response.status == 200
|
59
59
|
model = JSON.load(response.body)
|
60
60
|
Mailosaur::Models::Server.new(model)
|
@@ -71,7 +71,7 @@ module Mailosaur
|
|
71
71
|
# @return [String] Server password.
|
72
72
|
#
|
73
73
|
def get_password(id)
|
74
|
-
response = conn.get
|
74
|
+
response = conn.get "api/servers/#{id}/password"
|
75
75
|
@handle_http_error.call(response) unless response.status == 200
|
76
76
|
model = JSON.load(response.body)
|
77
77
|
model['value']
|
@@ -88,7 +88,7 @@ module Mailosaur
|
|
88
88
|
# @return [Server] operation results.
|
89
89
|
#
|
90
90
|
def update(id, server)
|
91
|
-
response = conn.put
|
91
|
+
response = conn.put "api/servers/#{id}", server.to_json
|
92
92
|
@handle_http_error.call(response) unless response.status == 200
|
93
93
|
model = JSON.load(response.body)
|
94
94
|
Mailosaur::Models::Server.new(model)
|
@@ -103,7 +103,7 @@ module Mailosaur
|
|
103
103
|
# @param id [String] The identifier of the server to be deleted.
|
104
104
|
#
|
105
105
|
def delete(id)
|
106
|
-
response = conn.delete
|
106
|
+
response = conn.delete "api/servers/#{id}"
|
107
107
|
@handle_http_error.call(response) unless response.status == 204
|
108
108
|
nil
|
109
109
|
end
|
data/lib/Mailosaur/version.rb
CHANGED
data/lib/mailosaur.rb
CHANGED
@@ -26,6 +26,9 @@ module Mailosaur
|
|
26
26
|
autoload :MessageSummary, 'Mailosaur/models/message_summary.rb'
|
27
27
|
autoload :Image, 'Mailosaur/models/image.rb'
|
28
28
|
autoload :MessageListResult, 'Mailosaur/models/message_list_result.rb'
|
29
|
+
autoload :MessageCreateOptions, 'Mailosaur/models/message_create_options.rb'
|
30
|
+
autoload :MessageForwardOptions, 'Mailosaur/models/message_forward_options.rb'
|
31
|
+
autoload :MessageReplyOptions, 'Mailosaur/models/message_reply_options.rb'
|
29
32
|
autoload :Attachment, 'Mailosaur/models/attachment.rb'
|
30
33
|
autoload :SearchCriteria, 'Mailosaur/models/search_criteria.rb'
|
31
34
|
autoload :MessageContent, 'Mailosaur/models/message_content.rb'
|
@@ -83,9 +86,9 @@ module Mailosaur
|
|
83
86
|
Faraday.new(@base_url, {
|
84
87
|
headers: {
|
85
88
|
content_type: 'application/json; charset=utf-8',
|
86
|
-
user_agent:
|
89
|
+
user_agent: "mailosaur-ruby/#{Mailosaur::VERSION}"
|
87
90
|
}
|
88
|
-
}).tap { |conn| conn.basic_auth
|
91
|
+
}).tap { |conn| conn.request(:basic_auth, @api_key, '') }
|
89
92
|
end
|
90
93
|
|
91
94
|
def handle_http_error(response)
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailosaur
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mailosaur
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "<="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.0'
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.9
|
19
|
+
version: '0.9'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - "<="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '1.0'
|
30
27
|
- - ">="
|
31
28
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.9
|
29
|
+
version: '0.9'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: json
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "<="
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '3.0'
|
40
37
|
- - ">="
|
41
38
|
- !ruby/object:Gem::Version
|
42
39
|
version: 1.7.5
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '4'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - "<="
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '3.0'
|
50
47
|
- - ">="
|
51
48
|
- !ruby/object:Gem::Version
|
52
49
|
version: 1.7.5
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '4'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: mail
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,34 +76,28 @@ dependencies:
|
|
76
76
|
requirements:
|
77
77
|
- - "~>"
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: '
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 12.3.0
|
79
|
+
version: '13.0'
|
83
80
|
type: :development
|
84
81
|
prerelease: false
|
85
82
|
version_requirements: !ruby/object:Gem::Requirement
|
86
83
|
requirements:
|
87
84
|
- - "~>"
|
88
85
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
90
|
-
- - ">="
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
version: 12.3.0
|
86
|
+
version: '13.0'
|
93
87
|
- !ruby/object:Gem::Dependency
|
94
88
|
name: rubocop
|
95
89
|
requirement: !ruby/object:Gem::Requirement
|
96
90
|
requirements:
|
97
91
|
- - "~>"
|
98
92
|
- !ruby/object:Gem::Version
|
99
|
-
version:
|
93
|
+
version: 1.19.0
|
100
94
|
type: :development
|
101
95
|
prerelease: false
|
102
96
|
version_requirements: !ruby/object:Gem::Requirement
|
103
97
|
requirements:
|
104
98
|
- - "~>"
|
105
99
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
100
|
+
version: 1.19.0
|
107
101
|
- !ruby/object:Gem::Dependency
|
108
102
|
name: shoulda-context
|
109
103
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,8 +158,11 @@ files:
|
|
164
158
|
- lib/Mailosaur/models/message.rb
|
165
159
|
- lib/Mailosaur/models/message_address.rb
|
166
160
|
- lib/Mailosaur/models/message_content.rb
|
161
|
+
- lib/Mailosaur/models/message_create_options.rb
|
162
|
+
- lib/Mailosaur/models/message_forward_options.rb
|
167
163
|
- lib/Mailosaur/models/message_header.rb
|
168
164
|
- lib/Mailosaur/models/message_list_result.rb
|
165
|
+
- lib/Mailosaur/models/message_reply_options.rb
|
169
166
|
- lib/Mailosaur/models/message_summary.rb
|
170
167
|
- lib/Mailosaur/models/metadata.rb
|
171
168
|
- lib/Mailosaur/models/search_criteria.rb
|
@@ -201,14 +198,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
201
198
|
requirements:
|
202
199
|
- - ">="
|
203
200
|
- !ruby/object:Gem::Version
|
204
|
-
version: '2.
|
201
|
+
version: '2.5'
|
205
202
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
203
|
requirements:
|
207
204
|
- - ">="
|
208
205
|
- !ruby/object:Gem::Version
|
209
206
|
version: '0'
|
210
207
|
requirements: []
|
211
|
-
rubygems_version: 3.2.
|
208
|
+
rubygems_version: 3.2.22
|
212
209
|
signing_key:
|
213
210
|
specification_version: 4
|
214
211
|
summary: The Mailosaur Ruby library
|