mailosaur 7.0.0 → 7.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ded354d904892b5edb18803695bda97a368a55bcf8bee8f1b3f7cc3d54223a8
4
- data.tar.gz: 5e7e2e660129a7c4067d1ef74075f3f1be5e2ca8a78411199acb77b3c6b2352d
3
+ metadata.gz: 27d013e44169ed1c8b0881334b94ce03d76177c35b48202058683a271a7920a8
4
+ data.tar.gz: 3fd514240ac76ddfe02296e7a67b97f10b9d5fc711e1c7d321a1222cc1caef0a
5
5
  SHA512:
6
- metadata.gz: c2217d5763f88bc5c4d8a5f769ab327c0a31e1e781300a8cff5fb264297568c05e664c4d431359b49cc401e1756b9a52e070d71a87489822da0069aaf3bf8d9c
7
- data.tar.gz: a489db754706165b9c1a5637d73bd5fd5ab236c3fdfa81f6fe25e36d534b789425290e1c63d33107c0a79bc177e1eb20ee93101b3ab0dc8a18d7b99a6814b465
6
+ metadata.gz: 173665bfe6e3ac1b5eacc99f8e4e3b8bf6e7e9487e4852be057473468b56c00c9f53d38ac95218587fd07d86301efcf98b7ce04f234c93dff5df66aa6c8db402
7
+ data.tar.gz: 81b04fd97abcfaf0784973d7cf9e1b627d6f28664b1c38a43133f47a001f743a128102520d764d52fba0e7ca825625219b41121feb207b5f489eff569c1dac25
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Mailosaur Ruby Client Library
2
2
 
3
- [Mailosaur](https://mailosaur.com) allows you to automate tests involving email. Allowing you to perform end-to-end automated and functional email testing.
3
+ [Mailosaur](https://mailosaur.com) lets you automate email and SMS tests, like account verification and password resets, and integrate these into your CI/CD pipeline.
4
4
 
5
5
  [![](https://github.com/mailosaur/mailosaur-ruby/workflows/CI/badge.svg)](https://github.com/mailosaur/mailosaur-ruby/actions)
6
6
 
@@ -10,29 +10,52 @@
10
10
  gem install mailosaur
11
11
  ```
12
12
 
13
- ## Documentation and usage examples
13
+ ## Documentation
14
14
 
15
- [Mailosaur's documentation](https://mailosaur.com/docs) includes all the information and usage examples you'll need.
15
+ Please see the [Ruby client reference](https://mailosaur.com/docs/email-testing/ruby/client-reference/) for the most up-to-date documentation.
16
16
 
17
- ## Running tests
17
+ ## Usage
18
18
 
19
- Once you've cloned this repository locally, you can simply run:
19
+ example.rb
20
20
 
21
+ ```ruby
22
+ require "mailosaur"
23
+ mailosaur = Mailosaur::MailosaurClient.new("YOUR_API_KEY")
24
+
25
+ result = mailosaur.servers.list()
26
+
27
+ print("You have a server called: " + result.items[0].name)
21
28
  ```
29
+
30
+ ## Development
31
+
32
+ You must have the following prerequisites installed:
33
+
34
+ * [Bundler](https://bundler.io/)
35
+
36
+ Install all development dependencies:
37
+
38
+ ```sh
22
39
  bundle install
40
+ ```
41
+
42
+ The test suite requires the following environment variables to be set:
23
43
 
44
+ ```sh
45
+ export MAILOSAUR_BASE_URL=https://mailosaur.com/
24
46
  export MAILOSAUR_API_KEY=your_api_key
25
47
  export MAILOSAUR_SERVER=server_id
48
+ ```
49
+
50
+ Run all tests:
26
51
 
52
+ ```sh
27
53
  bundle exec rake test
28
54
  ```
29
55
 
30
- ## Linting code
56
+ Lint code (via Rubocop):
31
57
 
32
- Simply run Rubocop:
33
-
34
- ```
35
- bundle install
58
+ ```sh
36
59
  bundle exec rubocop
37
60
  ```
38
61
 
@@ -34,7 +34,7 @@ module Mailosaur
34
34
  # Defaults timeout to 10s, receivedAfter to 1h
35
35
  raise Mailosaur::MailosaurError.new('Must provide a valid Server ID.', 'invalid_request') if server.length != 8
36
36
 
37
- result = search(server, criteria, timeout: timeout, received_after: received_after)
37
+ result = search(server, criteria, page: 0, items_per_page: 1, timeout: timeout, received_after: received_after)
38
38
  get_by_id(result.items[0].id)
39
39
  end
40
40
 
@@ -132,10 +132,12 @@ module Mailosaur
132
132
  # (in milliseconds).
133
133
  # @param received_after [DateTime] Limits results to only messages received
134
134
  # after this date/time.
135
+ # @param error_on_timeout [Boolean] When set to false, an error will not be
136
+ # throw if timeout is reached (default: true).
135
137
  #
136
138
  # @return [MessageListResult] operation results.
137
139
  #
138
- def search(server, criteria, page: nil, items_per_page: nil, timeout: nil, received_after: nil) # rubocop:disable all
140
+ def search(server, criteria, page: nil, items_per_page: nil, timeout: nil, received_after: nil, error_on_timeout: true) # rubocop:disable all
139
141
  url = 'api/messages/search?server=' + server
140
142
  url += page ? '&page=' + page.to_s : ''
141
143
  url += items_per_page ? '&itemsPerPage=' + items_per_page.to_s : ''
@@ -160,6 +162,8 @@ module Mailosaur
160
162
 
161
163
  ## Stop if timeout will be exceeded
162
164
  if ((1000 * (Time.now.to_f - start_time).to_i) + delay) > timeout
165
+ return Mailosaur::Models::MessageListResult.new(model) unless error_on_timeout
166
+
163
167
  raise Mailosaur::MailosaurError.new('No matching messages found in time. By default, only messages received in the last hour are checked (use receivedAfter to override this).', 'search_timeout')
164
168
  end
165
169
 
@@ -2,11 +2,17 @@ module Mailosaur
2
2
  module Models
3
3
  class SearchCriteria < BaseModel
4
4
  def initialize(data = {})
5
+ @sent_from = data['sentFrom']
5
6
  @sent_to = data['sentTo']
6
7
  @subject = data['subject']
7
8
  @body = data['body']
9
+ @match = data['match'] || 'ALL'
8
10
  end
9
11
 
12
+ # @return [String] The full email address from which the target email was
13
+ # sent.
14
+ attr_accessor :sent_from
15
+
10
16
  # @return [String] The full email address to which the target email was
11
17
  # sent.
12
18
  attr_accessor :sent_to
@@ -18,6 +24,11 @@ module Mailosaur
18
24
  # @return [String] The value to seek within the target email's HTML or
19
25
  # text body.
20
26
  attr_accessor :body
27
+
28
+ # @return [String] If set to ALL (default), then only results that match all
29
+ # specified criteria will be returned. If set to ANY, results that match any of the
30
+ # specified criteria will be returned.
31
+ attr_accessor :match
21
32
  end
22
33
  end
23
34
  end
@@ -3,21 +3,15 @@ module Mailosaur
3
3
  class Server < BaseModel
4
4
  def initialize(data = {})
5
5
  @id = data['id']
6
- @password = data['password']
7
6
  @name = data['name']
8
7
  @users = data['users']
9
8
  @messages = data['messages']
10
- @forwarding_rules = []
11
- (data['forwardingRules'] || []).each do |i| @forwarding_rules << Mailosaur::Models::ForwardingRule.new(i) end
12
9
  end
13
10
 
14
11
  # @return [String] Unique identifier for the server. Used as username for
15
12
  # SMTP/POP3 authentication.
16
13
  attr_accessor :id
17
14
 
18
- # @return [String] SMTP/POP3 password.
19
- attr_accessor :password
20
-
21
15
  # @return [String] A name used to identify the server.
22
16
  attr_accessor :name
23
17
 
@@ -26,10 +20,6 @@ module Mailosaur
26
20
 
27
21
  # @return [Integer] The number of messages currently in the server.
28
22
  attr_accessor :messages
29
-
30
- # @return [Array<ForwardingRule>] The rules used to manage email
31
- # forwarding for this server.
32
- attr_accessor :forwarding_rules
33
23
  end
34
24
  end
35
25
  end
@@ -60,6 +60,23 @@ module Mailosaur
60
60
  Mailosaur::Models::Server.new(model)
61
61
  end
62
62
 
63
+ #
64
+ # Retrieve server password
65
+ #
66
+ # Retrieves the password for use with SMTP and POP3 for a single server.
67
+ # Simply supply the unique identifier for the required server.
68
+ #
69
+ # @param id [String] The identifier of the server.
70
+ #
71
+ # @return [String] Server password.
72
+ #
73
+ def get_password(id)
74
+ response = conn.get 'api/servers/' + id + '/password'
75
+ @handle_http_error.call(response) unless response.status == 200
76
+ model = JSON.load(response.body)
77
+ model['value']
78
+ end
79
+
63
80
  #
64
81
  # Update a server
65
82
  #
@@ -92,8 +109,8 @@ module Mailosaur
92
109
  end
93
110
 
94
111
  def generate_email_address(server)
95
- host = ENV['MAILOSAUR_SMTP_HOST'] || 'mailosaur.io'
96
- '%s.%s@%s' % [SecureRandom.hex(3), server, host]
112
+ host = ENV['MAILOSAUR_SMTP_HOST'] || 'mailosaur.net'
113
+ '%s@%s.%s' % [SecureRandom.hex(3), server, host]
97
114
  end
98
115
  end
99
116
  end
@@ -1,3 +1,3 @@
1
1
  module Mailosaur
2
- VERSION = '7.0.0'.freeze
2
+ VERSION = '7.2.1'.freeze
3
3
  end
data/lib/mailosaur.rb CHANGED
@@ -27,7 +27,6 @@ module Mailosaur
27
27
  autoload :MessageListResult, 'Mailosaur/models/message_list_result.rb'
28
28
  autoload :Attachment, 'Mailosaur/models/attachment.rb'
29
29
  autoload :SearchCriteria, 'Mailosaur/models/search_criteria.rb'
30
- autoload :ForwardingRule, 'Mailosaur/models/forwarding_rule.rb'
31
30
  autoload :MessageContent, 'Mailosaur/models/message_content.rb'
32
31
  autoload :Server, 'Mailosaur/models/server.rb'
33
32
  autoload :Link, 'Mailosaur/models/link.rb'
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: 7.0.0
4
+ version: 7.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mailosaur
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-15 00:00:00.000000000 Z
11
+ date: 2021-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -159,7 +159,6 @@ files:
159
159
  - lib/Mailosaur/messages.rb
160
160
  - lib/Mailosaur/models/attachment.rb
161
161
  - lib/Mailosaur/models/base_model.rb
162
- - lib/Mailosaur/models/forwarding_rule.rb
163
162
  - lib/Mailosaur/models/image.rb
164
163
  - lib/Mailosaur/models/link.rb
165
164
  - lib/Mailosaur/models/message.rb
@@ -204,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
203
  - !ruby/object:Gem::Version
205
204
  version: '0'
206
205
  requirements: []
207
- rubygems_version: 3.1.2
206
+ rubygems_version: 3.2.15
208
207
  signing_key:
209
208
  specification_version: 4
210
209
  summary: The Mailosaur Ruby library
@@ -1,25 +0,0 @@
1
- module Mailosaur
2
- module Models
3
- class ForwardingRule < BaseModel
4
- def initialize(data = {})
5
- @field = data['field']
6
- @operator = data['operator']
7
- @value = data['value']
8
- @forward_to = data['forwardTo']
9
- end
10
-
11
- # @return [Enum] Possible values include: 'from', 'to', 'subject'
12
- attr_accessor :field
13
-
14
- # @return [Enum] Possible values include: 'endsWith', 'startsWith',
15
- # 'contains'
16
- attr_accessor :operator
17
-
18
- # @return [String]
19
- attr_accessor :value
20
-
21
- # @return [String]
22
- attr_accessor :forward_to
23
- end
24
- end
25
- end