mailosaur 6.0.2 → 6.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/Mailosaur/analysis.rb +1 -1
- data/lib/Mailosaur/files.rb +2 -2
- data/lib/Mailosaur/mailosaur_error.rb +4 -4
- data/lib/Mailosaur/messages.rb +10 -10
- data/lib/Mailosaur/models/base_model.rb +1 -2
- data/lib/Mailosaur/models/image.rb +1 -1
- data/lib/Mailosaur/models/message.rb +5 -5
- data/lib/Mailosaur/models/message_content.rb +2 -2
- data/lib/Mailosaur/models/message_list_result.rb +2 -2
- data/lib/Mailosaur/models/message_summary.rb +6 -6
- data/lib/Mailosaur/models/metadata.rb +1 -1
- data/lib/Mailosaur/models/server.rb +1 -1
- data/lib/Mailosaur/models/server_list_result.rb +1 -1
- data/lib/Mailosaur/models/spam_filter_results.rb +1 -1
- data/lib/Mailosaur/servers.rb +4 -4
- data/lib/Mailosaur/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 527f1eadb528e82ab2e1a56047b7494e1fcaf43d7d12c57c33511df5274c35f1
|
4
|
+
data.tar.gz: 8216fc4682a238eeb6f29a6f0b71426b6c684c5973d50c364be0019566403599
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0da89f9b5d8c3b176e1188904a054e241b379269e20151157f0d3a4dc8080a7bc6a9f14387314b4adc2f7e794b82662444e3bc13bff0971ae8de1f11b033c928
|
7
|
+
data.tar.gz: f4d7c3e0c3a10ab0f6c33ec8d0d15f24354aef15b297395afbaa010d443d2f7484d90ec4ae01760e02d444306dcb57baf74e5139aa281b589474c803bf9f6e7c
|
data/lib/Mailosaur/analysis.rb
CHANGED
@@ -22,7 +22,7 @@ module Mailosaur
|
|
22
22
|
#
|
23
23
|
def spam(email)
|
24
24
|
response = conn.get 'api/analysis/spam/' + email
|
25
|
-
|
25
|
+
|
26
26
|
unless response.status == 200
|
27
27
|
error_model = JSON.load(response.body)
|
28
28
|
mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + response.status.to_s + '\'', error_model)
|
data/lib/Mailosaur/files.rb
CHANGED
@@ -23,7 +23,7 @@ module Mailosaur
|
|
23
23
|
#
|
24
24
|
def get_attachment(id)
|
25
25
|
response = conn.get 'api/files/attachments/' + id
|
26
|
-
|
26
|
+
|
27
27
|
unless response.status == 200
|
28
28
|
error_model = JSON.load(response.body)
|
29
29
|
mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + response.status.to_s + '\'', error_model)
|
@@ -45,7 +45,7 @@ module Mailosaur
|
|
45
45
|
#
|
46
46
|
def get_email(id)
|
47
47
|
response = conn.get 'api/files/email/' + id
|
48
|
-
|
48
|
+
|
49
49
|
unless response.status == 200
|
50
50
|
error_model = JSON.load(response.body)
|
51
51
|
mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + response.status.to_s + '\'', error_model)
|
@@ -14,10 +14,10 @@ module Mailosaur
|
|
14
14
|
@model = nil
|
15
15
|
|
16
16
|
unless error_model.nil?
|
17
|
-
@type = error_model[
|
18
|
-
@messages = error_model[
|
19
|
-
@model = error_model[
|
20
|
-
end
|
17
|
+
@type = error_model['type']
|
18
|
+
@messages = error_model['messages']
|
19
|
+
@model = error_model['model']
|
20
|
+
end
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
data/lib/Mailosaur/messages.rb
CHANGED
@@ -20,9 +20,9 @@ module Mailosaur
|
|
20
20
|
# @param server [String] The identifier of the server hosting the message.
|
21
21
|
# @param criteria [SearchCriteria] The search criteria to use in order to find
|
22
22
|
# a match.
|
23
|
-
# @param timeout [Integer] Specify how long to wait for a matching result
|
23
|
+
# @param timeout [Integer] Specify how long to wait for a matching result
|
24
24
|
# (in milliseconds).
|
25
|
-
# @param received_after [DateTime] Limits results to only messages received
|
25
|
+
# @param received_after [DateTime] Limits results to only messages received
|
26
26
|
# after this date/time.
|
27
27
|
#
|
28
28
|
# @return [Message] operation results.
|
@@ -47,7 +47,7 @@ module Mailosaur
|
|
47
47
|
#
|
48
48
|
def get_by_id(id)
|
49
49
|
response = conn.get 'api/messages/' + id
|
50
|
-
|
50
|
+
|
51
51
|
unless response.status == 200
|
52
52
|
error_model = JSON.load(response.body)
|
53
53
|
mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + response.status.to_s + '\'', error_model)
|
@@ -99,7 +99,7 @@ module Mailosaur
|
|
99
99
|
url += items_per_page ? '&itemsPerPage=' + items_per_page : ''
|
100
100
|
|
101
101
|
response = conn.get url
|
102
|
-
|
102
|
+
|
103
103
|
unless response.status == 200
|
104
104
|
error_model = JSON.load(response.body)
|
105
105
|
mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + response.status.to_s + '\'', error_model)
|
@@ -144,9 +144,9 @@ module Mailosaur
|
|
144
144
|
# pagination.
|
145
145
|
# @param items_per_page [Integer] A limit on the number of results to be
|
146
146
|
# returned per page. Can be set between 1 and 1000 items, the default is 50.
|
147
|
-
# @param timeout [Integer] Specify how long to wait for a matching result
|
147
|
+
# @param timeout [Integer] Specify how long to wait for a matching result
|
148
148
|
# (in milliseconds).
|
149
|
-
# @param received_after [DateTime] Limits results to only messages received
|
149
|
+
# @param received_after [DateTime] Limits results to only messages received
|
150
150
|
# after this date/time.
|
151
151
|
#
|
152
152
|
# @return [MessageListResult] operation results.
|
@@ -160,9 +160,9 @@ module Mailosaur
|
|
160
160
|
poll_count = 0
|
161
161
|
start_time = Time.now.to_f
|
162
162
|
|
163
|
-
loop do
|
163
|
+
loop do
|
164
164
|
response = conn.post url, criteria.to_json
|
165
|
-
|
165
|
+
|
166
166
|
unless response.status == 200
|
167
167
|
error_model = JSON.load(response.body)
|
168
168
|
mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + response.status.to_s + '\'', error_model) # rubocop:disable Metrics/LineLength
|
@@ -173,9 +173,9 @@ module Mailosaur
|
|
173
173
|
return Mailosaur::Models::MessageListResult.new(model) if timeout.to_i.zero? || !model['items'].empty?
|
174
174
|
|
175
175
|
delay_pattern = (response.headers['x-ms-delay'] || '1000').split(',').map(&:to_i)
|
176
|
-
|
176
|
+
|
177
177
|
delay = poll_count >= delay_pattern.length ? delay_pattern[delay_pattern.length - 1] : delay_pattern[poll_count]
|
178
|
-
|
178
|
+
|
179
179
|
poll_count += 1
|
180
180
|
|
181
181
|
## Stop if timeout will be exceeded
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Mailosaur
|
2
2
|
module Models
|
3
3
|
class BaseModel
|
4
|
-
def to_json
|
4
|
+
def to_json(*_args)
|
5
5
|
hash = {}
|
6
6
|
instance_variables.each do |var|
|
7
7
|
key = var.to_s.delete('@').split('_').collect(&:capitalize).join
|
@@ -13,4 +13,3 @@ module Mailosaur
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
16
|
-
|
@@ -4,19 +4,19 @@ module Mailosaur
|
|
4
4
|
def initialize(data = {})
|
5
5
|
@id = data['id']
|
6
6
|
@from = []
|
7
|
-
(data['from'] || []).each do |
|
7
|
+
(data['from'] || []).each do |i| @from << Mailosaur::Models::MessageAddress.new(i) end
|
8
8
|
@to = []
|
9
|
-
(data['to'] || []).each do |
|
9
|
+
(data['to'] || []).each do |i| @to << Mailosaur::Models::MessageAddress.new(i) end
|
10
10
|
@cc = []
|
11
|
-
(data['cc'] || []).each do |
|
11
|
+
(data['cc'] || []).each do |i| @cc << Mailosaur::Models::MessageAddress.new(i) end
|
12
12
|
@bcc = []
|
13
|
-
(data['bcc'] || []).each do |
|
13
|
+
(data['bcc'] || []).each do |i| @bcc << Mailosaur::Models::MessageAddress.new(i) end
|
14
14
|
@received = DateTime.parse(data['received'])
|
15
15
|
@subject = data['subject']
|
16
16
|
@html = Mailosaur::Models::MessageContent.new(data['html'])
|
17
17
|
@text = Mailosaur::Models::MessageContent.new(data['text'])
|
18
18
|
@attachments = []
|
19
|
-
(data['attachments'] || []).each do |
|
19
|
+
(data['attachments'] || []).each do |i| @attachments << Mailosaur::Models::Attachment.new(i) end
|
20
20
|
@metadata = Mailosaur::Models::Metadata.new(data['metadata'])
|
21
21
|
@server = data['server']
|
22
22
|
end
|
@@ -3,9 +3,9 @@ module Mailosaur
|
|
3
3
|
class MessageContent < BaseModel
|
4
4
|
def initialize(data = {})
|
5
5
|
@links = []
|
6
|
-
(data['links'] || []).each do |
|
6
|
+
(data['links'] || []).each do |i| @links << Mailosaur::Models::Link.new(i) end
|
7
7
|
@images = []
|
8
|
-
(data['images'] || []).each do |
|
8
|
+
(data['images'] || []).each do |i| @images << Mailosaur::Models::Image.new(i) end
|
9
9
|
@body = data['body']
|
10
10
|
end
|
11
11
|
|
@@ -3,9 +3,9 @@ module Mailosaur
|
|
3
3
|
class MessageListResult < BaseModel
|
4
4
|
def initialize(data = {})
|
5
5
|
@items = []
|
6
|
-
(data['items'] || []).each do |
|
6
|
+
(data['items'] || []).each do |i| @items << Mailosaur::Models::MessageSummary.new(i) end
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
# @return [Array<MessageSummary>] The individual summaries of each
|
10
10
|
# message forming the result. Summaries are returned sorted by received
|
11
11
|
# date, with the most recently-received messages appearing first.
|
@@ -5,19 +5,19 @@ module Mailosaur
|
|
5
5
|
@id = data['id']
|
6
6
|
@server = data['server']
|
7
7
|
@rcpt = []
|
8
|
-
(data['rcpt'] || []).each do |
|
8
|
+
(data['rcpt'] || []).each do |i| @rcpt << Mailosaur::Models::MessageAddress.new(i) end
|
9
9
|
@from = []
|
10
|
-
(data['from'] || []).each do |
|
10
|
+
(data['from'] || []).each do |i| @from << Mailosaur::Models::MessageAddress.new(i) end
|
11
11
|
@to = []
|
12
|
-
(data['to'] || []).each do |
|
12
|
+
(data['to'] || []).each do |i| @to << Mailosaur::Models::MessageAddress.new(i) end
|
13
13
|
@cc = []
|
14
|
-
(data['cc'] || []).each do |
|
14
|
+
(data['cc'] || []).each do |i| @cc << Mailosaur::Models::MessageAddress.new(i) end
|
15
15
|
@bcc = []
|
16
|
-
(data['bcc'] || []).each do |
|
16
|
+
(data['bcc'] || []).each do |i| @bcc << Mailosaur::Models::MessageAddress.new(i) end
|
17
17
|
@received = DateTime.parse(data['received'])
|
18
18
|
@subject = data['subject']
|
19
19
|
@summary = data['summary']
|
20
|
-
@attachments = data['attachments']
|
20
|
+
@attachments = data['attachments']
|
21
21
|
end
|
22
22
|
|
23
23
|
# @return
|
@@ -3,7 +3,7 @@ module Mailosaur
|
|
3
3
|
class Metadata < BaseModel
|
4
4
|
def initialize(data = {})
|
5
5
|
@headers = []
|
6
|
-
(data['headers'] || []).each do |
|
6
|
+
(data['headers'] || []).each do |i| @headers << Mailosaur::Models::MessageHeader.new(i) end
|
7
7
|
end
|
8
8
|
|
9
9
|
# @return [Array<MessageHeader>] Email headers.
|
@@ -8,7 +8,7 @@ module Mailosaur
|
|
8
8
|
@users = data['users']
|
9
9
|
@messages = data['messages']
|
10
10
|
@forwarding_rules = []
|
11
|
-
(data['forwardingRules'] || []).each do |
|
11
|
+
(data['forwardingRules'] || []).each do |i| @forwarding_rules << Mailosaur::Models::ForwardingRule.new(i) end
|
12
12
|
end
|
13
13
|
|
14
14
|
# @return [String] Unique identifier for the server. Used as username for
|
@@ -3,7 +3,7 @@ module Mailosaur
|
|
3
3
|
class ServerListResult < BaseModel
|
4
4
|
def initialize(data = {})
|
5
5
|
@items = []
|
6
|
-
(data['items'] || []).each do |
|
6
|
+
(data['items'] || []).each do |i| @items << Mailosaur::Models::Server.new(i) end
|
7
7
|
end
|
8
8
|
|
9
9
|
# @return [Array<Server>] The individual servers forming the result.
|
@@ -3,7 +3,7 @@ module Mailosaur
|
|
3
3
|
class SpamFilterResults < BaseModel
|
4
4
|
def initialize(data = {})
|
5
5
|
@spam_assassin = []
|
6
|
-
(data['spamAssassin'] || []).each do |
|
6
|
+
(data['spamAssassin'] || []).each do |i| @spam_assassin << Mailosaur::Models::SpamAssassinRule.new(i) end
|
7
7
|
end
|
8
8
|
|
9
9
|
# @return [Array<SpamAssassinRule>]
|
data/lib/Mailosaur/servers.rb
CHANGED
@@ -21,7 +21,7 @@ module Mailosaur
|
|
21
21
|
#
|
22
22
|
def list
|
23
23
|
response = conn.get 'api/servers'
|
24
|
-
|
24
|
+
|
25
25
|
unless response.status == 200
|
26
26
|
error_model = JSON.load(response.body)
|
27
27
|
mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + response.status.to_s + '\'', error_model)
|
@@ -43,7 +43,7 @@ module Mailosaur
|
|
43
43
|
#
|
44
44
|
def create(server_create_options)
|
45
45
|
response = conn.post 'api/servers', server_create_options.to_json
|
46
|
-
|
46
|
+
|
47
47
|
unless response.status == 200
|
48
48
|
error_model = JSON.load(response.body)
|
49
49
|
mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + response.status.to_s + '\'', error_model)
|
@@ -66,7 +66,7 @@ module Mailosaur
|
|
66
66
|
#
|
67
67
|
def get(id)
|
68
68
|
response = conn.get 'api/servers/' + id
|
69
|
-
|
69
|
+
|
70
70
|
unless response.status == 200
|
71
71
|
error_model = JSON.load(response.body)
|
72
72
|
mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + response.status.to_s + '\'', error_model)
|
@@ -89,7 +89,7 @@ module Mailosaur
|
|
89
89
|
#
|
90
90
|
def update(id, server)
|
91
91
|
response = conn.put 'api/servers/' + id, server.to_json
|
92
|
-
|
92
|
+
|
93
93
|
unless response.status == 200
|
94
94
|
error_model = JSON.load(response.body)
|
95
95
|
mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + response.status.to_s + '\'', error_model)
|
data/lib/Mailosaur/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailosaur
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.
|
4
|
+
version: 6.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mailosaur Ltd
|
@@ -96,14 +96,14 @@ dependencies:
|
|
96
96
|
requirements:
|
97
97
|
- - "~>"
|
98
98
|
- !ruby/object:Gem::Version
|
99
|
-
version: 0.
|
99
|
+
version: 0.68.0
|
100
100
|
type: :development
|
101
101
|
prerelease: false
|
102
102
|
version_requirements: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
104
|
- - "~>"
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version: 0.
|
106
|
+
version: 0.68.0
|
107
107
|
- !ruby/object:Gem::Dependency
|
108
108
|
name: shoulda-context
|
109
109
|
requirement: !ruby/object:Gem::Requirement
|