mailosaur 7.7.0 → 7.8.0
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/devices.rb +83 -0
- data/lib/Mailosaur/messages.rb +6 -6
- data/lib/Mailosaur/models/device.rb +16 -0
- data/lib/Mailosaur/models/device_create_options.rb +16 -0
- data/lib/Mailosaur/models/device_list_result.rb +13 -0
- data/lib/Mailosaur/models/otp_result.rb +16 -0
- data/lib/Mailosaur/servers.rb +6 -6
- data/lib/Mailosaur/usage.rb +2 -2
- data/lib/Mailosaur/version.rb +1 -1
- data/lib/mailosaur.rb +10 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eeaf9bb2c4d001d8f0ec173e4fb0fcbe02515cbb2ac1eae04c2f9961811dad2c
|
4
|
+
data.tar.gz: cdcf3c7bdd32cde468875fac15003169d65a4283b38de7c8970c1f3870a08d8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 534cdf190200dcf2b24ef400f598dec13de6466fa347d46c90a967e3c7c45c9ba1ed024da2fd67a9ce0afa3c41e886b6cffe2e3af8c711cb2fe8f2185805efab
|
7
|
+
data.tar.gz: 16ab4b387df53be279ad409e9d04d479c17db62f43db17b5ed60df256ee28c617b2fa6ed4d22e9df64b8a7b3f26e05e5b8ea02a7f1c97927d745932522296684
|
data/lib/Mailosaur/analysis.rb
CHANGED
@@ -24,7 +24,7 @@ module Mailosaur
|
|
24
24
|
def spam(email)
|
25
25
|
response = conn.get "api/analysis/spam/#{email}"
|
26
26
|
@handle_http_error.call(response) unless response.status == 200
|
27
|
-
model = JSON.
|
27
|
+
model = JSON.parse(response.body)
|
28
28
|
Mailosaur::Models::SpamAnalysisResult.new(model)
|
29
29
|
end
|
30
30
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Mailosaur
|
2
|
+
class Devices
|
3
|
+
#
|
4
|
+
# Creates and initializes a new instance of the Devices class.
|
5
|
+
# @param client connection.
|
6
|
+
#
|
7
|
+
def initialize(conn, handle_http_error)
|
8
|
+
@conn = conn
|
9
|
+
@handle_http_error = handle_http_error
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [Connection] the client connection.
|
13
|
+
attr_reader :conn
|
14
|
+
|
15
|
+
#
|
16
|
+
# List all devices
|
17
|
+
#
|
18
|
+
# Returns a list of your virtual security devices.
|
19
|
+
#
|
20
|
+
# @return [DeviceListResult] operation results.
|
21
|
+
#
|
22
|
+
def list
|
23
|
+
response = conn.get 'api/devices'
|
24
|
+
@handle_http_error.call(response) unless response.status == 200
|
25
|
+
model = JSON.parse(response.body)
|
26
|
+
Mailosaur::Models::DeviceListResult.new(model)
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Create a device
|
31
|
+
#
|
32
|
+
# Creates a new virtual security device and returns it.
|
33
|
+
#
|
34
|
+
# @param device_create_options [DeviceCreateOptions]
|
35
|
+
#
|
36
|
+
# @return [Device] operation results.
|
37
|
+
#
|
38
|
+
def create(device_create_options)
|
39
|
+
response = conn.post 'api/devices', device_create_options.to_json
|
40
|
+
@handle_http_error.call(response) unless response.status == 200
|
41
|
+
model = JSON.parse(response.body)
|
42
|
+
Mailosaur::Models::Device.new(model)
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# Retrieve OTP
|
47
|
+
#
|
48
|
+
# Retrieves the current one-time password for a saved device, or given base32-encoded shared secret.
|
49
|
+
#
|
50
|
+
# @param query [String] Either the unique identifier of the device, or a base32-encoded shared secret.
|
51
|
+
#
|
52
|
+
# @return [OtpResult] operation results.
|
53
|
+
#
|
54
|
+
def otp(query)
|
55
|
+
if query.include? '-'
|
56
|
+
response = conn.get "api/devices/#{query}/otp"
|
57
|
+
@handle_http_error.call(response) unless response.status == 200
|
58
|
+
model = JSON.parse(response.body)
|
59
|
+
return Mailosaur::Models::OtpResult.new(model)
|
60
|
+
end
|
61
|
+
|
62
|
+
options = Mailosaur::Models::DeviceCreateOptions.new
|
63
|
+
options.shared_secret = query
|
64
|
+
response = conn.post 'api/devices/otp', options.to_json
|
65
|
+
@handle_http_error.call(response) unless response.status == 200
|
66
|
+
model = JSON.parse(response.body)
|
67
|
+
Mailosaur::Models::OtpResult.new(model)
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
# Delete a device
|
72
|
+
#
|
73
|
+
# Permanently deletes a device. This operation cannot be undone.
|
74
|
+
#
|
75
|
+
# @param id [String] The identifier of the device to be deleted.
|
76
|
+
#
|
77
|
+
def delete(id)
|
78
|
+
response = conn.delete "api/devices/#{id}"
|
79
|
+
@handle_http_error.call(response) unless response.status == 204
|
80
|
+
nil
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/Mailosaur/messages.rb
CHANGED
@@ -51,7 +51,7 @@ module Mailosaur
|
|
51
51
|
def get_by_id(id)
|
52
52
|
response = conn.get "api/messages/#{id}"
|
53
53
|
@handle_http_error.call(response) unless response.status == 200
|
54
|
-
model = JSON.
|
54
|
+
model = JSON.parse(response.body)
|
55
55
|
Mailosaur::Models::Message.new(model)
|
56
56
|
end
|
57
57
|
|
@@ -96,7 +96,7 @@ module Mailosaur
|
|
96
96
|
|
97
97
|
@handle_http_error.call(response) unless response.status == 200
|
98
98
|
|
99
|
-
model = JSON.
|
99
|
+
model = JSON.parse(response.body)
|
100
100
|
Mailosaur::Models::MessageListResult.new(model)
|
101
101
|
end
|
102
102
|
|
@@ -151,7 +151,7 @@ module Mailosaur
|
|
151
151
|
|
152
152
|
@handle_http_error.call(response) unless response.status == 200
|
153
153
|
|
154
|
-
model = JSON.
|
154
|
+
model = JSON.parse(response.body)
|
155
155
|
return Mailosaur::Models::MessageListResult.new(model) if timeout.to_i.zero? || !model['items'].empty?
|
156
156
|
|
157
157
|
delay_pattern = (response.headers['x-ms-delay'] || '1000').split(',').map(&:to_i)
|
@@ -186,7 +186,7 @@ module Mailosaur
|
|
186
186
|
def create(server, message_create_options)
|
187
187
|
response = conn.post "api/messages?server=#{server}", message_create_options.to_json
|
188
188
|
@handle_http_error.call(response) unless response.status == 200
|
189
|
-
model = JSON.
|
189
|
+
model = JSON.parse(response.body)
|
190
190
|
Mailosaur::Models::Message.new(model)
|
191
191
|
end
|
192
192
|
|
@@ -204,7 +204,7 @@ module Mailosaur
|
|
204
204
|
def forward(id, message_forward_options)
|
205
205
|
response = conn.post "api/messages/#{id}/forward", message_forward_options.to_json
|
206
206
|
@handle_http_error.call(response) unless response.status == 200
|
207
|
-
model = JSON.
|
207
|
+
model = JSON.parse(response.body)
|
208
208
|
Mailosaur::Models::Message.new(model)
|
209
209
|
end
|
210
210
|
|
@@ -223,7 +223,7 @@ module Mailosaur
|
|
223
223
|
def reply(id, message_reply_options)
|
224
224
|
response = conn.post "api/messages/#{id}/reply", message_reply_options.to_json
|
225
225
|
@handle_http_error.call(response) unless response.status == 200
|
226
|
-
model = JSON.
|
226
|
+
model = JSON.parse(response.body)
|
227
227
|
Mailosaur::Models::Message.new(model)
|
228
228
|
end
|
229
229
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Mailosaur
|
2
|
+
module Models
|
3
|
+
class Device < BaseModel
|
4
|
+
def initialize(data = {})
|
5
|
+
@id = data['id']
|
6
|
+
@name = data['name']
|
7
|
+
end
|
8
|
+
|
9
|
+
# @return [String] Unique identifier for the device.
|
10
|
+
attr_accessor :id
|
11
|
+
|
12
|
+
# @return [String] The name of the device.
|
13
|
+
attr_accessor :name
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Mailosaur
|
2
|
+
module Models
|
3
|
+
class DeviceCreateOptions < BaseModel
|
4
|
+
def initialize(data = {})
|
5
|
+
@name = data['name']
|
6
|
+
@shared_secret = data['shared_secret']
|
7
|
+
end
|
8
|
+
|
9
|
+
# @return [String] A name used to identify the device.
|
10
|
+
attr_accessor :name
|
11
|
+
|
12
|
+
# @return [String] The base32-encoded shared secret for this device.
|
13
|
+
attr_accessor :shared_secret
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Mailosaur
|
2
|
+
module Models
|
3
|
+
class DeviceListResult < BaseModel
|
4
|
+
def initialize(data = {})
|
5
|
+
@items = []
|
6
|
+
(data['items'] || []).each { |i| @items << Mailosaur::Models::Device.new(i) }
|
7
|
+
end
|
8
|
+
|
9
|
+
# @return [Array<Device>] The individual devices forming the result.
|
10
|
+
attr_accessor :items
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Mailosaur
|
2
|
+
module Models
|
3
|
+
class OtpResult < BaseModel
|
4
|
+
def initialize(data = {})
|
5
|
+
@code = data['code']
|
6
|
+
@expires = data['expires']
|
7
|
+
end
|
8
|
+
|
9
|
+
# @return [String] The current one-time password.
|
10
|
+
attr_accessor :code
|
11
|
+
|
12
|
+
# @return [String] The expiry date/time of the current one-time password.
|
13
|
+
attr_accessor :expires
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/Mailosaur/servers.rb
CHANGED
@@ -23,7 +23,7 @@ module Mailosaur
|
|
23
23
|
def list
|
24
24
|
response = conn.get 'api/servers'
|
25
25
|
@handle_http_error.call(response) unless response.status == 200
|
26
|
-
model = JSON.
|
26
|
+
model = JSON.parse(response.body)
|
27
27
|
Mailosaur::Models::ServerListResult.new(model)
|
28
28
|
end
|
29
29
|
|
@@ -39,7 +39,7 @@ module Mailosaur
|
|
39
39
|
def create(server_create_options)
|
40
40
|
response = conn.post 'api/servers', server_create_options.to_json
|
41
41
|
@handle_http_error.call(response) unless response.status == 200
|
42
|
-
model = JSON.
|
42
|
+
model = JSON.parse(response.body)
|
43
43
|
Mailosaur::Models::Server.new(model)
|
44
44
|
end
|
45
45
|
|
@@ -56,7 +56,7 @@ module Mailosaur
|
|
56
56
|
def get(id)
|
57
57
|
response = conn.get "api/servers/#{id}"
|
58
58
|
@handle_http_error.call(response) unless response.status == 200
|
59
|
-
model = JSON.
|
59
|
+
model = JSON.parse(response.body)
|
60
60
|
Mailosaur::Models::Server.new(model)
|
61
61
|
end
|
62
62
|
|
@@ -73,7 +73,7 @@ module Mailosaur
|
|
73
73
|
def get_password(id)
|
74
74
|
response = conn.get "api/servers/#{id}/password"
|
75
75
|
@handle_http_error.call(response) unless response.status == 200
|
76
|
-
model = JSON.
|
76
|
+
model = JSON.parse(response.body)
|
77
77
|
model['value']
|
78
78
|
end
|
79
79
|
|
@@ -90,7 +90,7 @@ module Mailosaur
|
|
90
90
|
def update(id, server)
|
91
91
|
response = conn.put "api/servers/#{id}", server.to_json
|
92
92
|
@handle_http_error.call(response) unless response.status == 200
|
93
|
-
model = JSON.
|
93
|
+
model = JSON.parse(response.body)
|
94
94
|
Mailosaur::Models::Server.new(model)
|
95
95
|
end
|
96
96
|
|
@@ -110,7 +110,7 @@ module Mailosaur
|
|
110
110
|
|
111
111
|
def generate_email_address(server)
|
112
112
|
host = ENV['MAILOSAUR_SMTP_HOST'] || 'mailosaur.net'
|
113
|
-
'%s@%s.%s'
|
113
|
+
format('%s@%s.%s', SecureRandom.hex(3), server, host)
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
data/lib/Mailosaur/usage.rb
CHANGED
@@ -22,7 +22,7 @@ module Mailosaur
|
|
22
22
|
def limits
|
23
23
|
response = conn.get 'api/usage/limits'
|
24
24
|
@handle_http_error.call(response) unless response.status == 200
|
25
|
-
model = JSON.
|
25
|
+
model = JSON.parse(response.body)
|
26
26
|
Mailosaur::Models::UsageAccountLimits.new(model)
|
27
27
|
end
|
28
28
|
|
@@ -34,7 +34,7 @@ module Mailosaur
|
|
34
34
|
def transactions
|
35
35
|
response = conn.get 'api/usage/transactions'
|
36
36
|
@handle_http_error.call(response) unless response.status == 200
|
37
|
-
model = JSON.
|
37
|
+
model = JSON.parse(response.body)
|
38
38
|
Mailosaur::Models::UsageTransactionListResult.new(model)
|
39
39
|
end
|
40
40
|
end
|
data/lib/Mailosaur/version.rb
CHANGED
data/lib/mailosaur.rb
CHANGED
@@ -14,6 +14,7 @@ module Mailosaur
|
|
14
14
|
autoload :Messages, 'Mailosaur/messages.rb'
|
15
15
|
autoload :Servers, 'Mailosaur/servers.rb'
|
16
16
|
autoload :Usage, 'Mailosaur/usage.rb'
|
17
|
+
autoload :Devices, 'Mailosaur/devices.rb'
|
17
18
|
autoload :MailosaurError, 'Mailosaur/mailosaur_error.rb'
|
18
19
|
|
19
20
|
module Models
|
@@ -42,6 +43,10 @@ module Mailosaur
|
|
42
43
|
autoload :UsageAccountLimit, 'Mailosaur/models/usage_account_limit.rb'
|
43
44
|
autoload :UsageTransactionListResult, 'Mailosaur/models/usage_transaction_list_result.rb'
|
44
45
|
autoload :UsageTransaction, 'Mailosaur/models/usage_transaction.rb'
|
46
|
+
autoload :Device, 'Mailosaur/models/device.rb'
|
47
|
+
autoload :DeviceListResult, 'Mailosaur/models/device_list_result.rb'
|
48
|
+
autoload :DeviceCreateOptions, 'Mailosaur/models/device_create_options.rb'
|
49
|
+
autoload :OtpResult, 'Mailosaur/models/otp_result.rb'
|
45
50
|
autoload :BaseModel, 'Mailosaur/models/base_model.rb'
|
46
51
|
end
|
47
52
|
|
@@ -81,6 +86,11 @@ module Mailosaur
|
|
81
86
|
@usage ||= Usage.new(connection, method(:handle_http_error))
|
82
87
|
end
|
83
88
|
|
89
|
+
# @return [Devices] usage
|
90
|
+
def devices
|
91
|
+
@devices ||= Devices.new(connection, method(:handle_http_error))
|
92
|
+
end
|
93
|
+
|
84
94
|
private
|
85
95
|
|
86
96
|
def connection
|
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.
|
4
|
+
version: 7.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mailosaur
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -148,12 +148,16 @@ files:
|
|
148
148
|
- LICENSE
|
149
149
|
- README.md
|
150
150
|
- lib/Mailosaur/analysis.rb
|
151
|
+
- lib/Mailosaur/devices.rb
|
151
152
|
- lib/Mailosaur/files.rb
|
152
153
|
- lib/Mailosaur/mailosaur_error.rb
|
153
154
|
- lib/Mailosaur/messages.rb
|
154
155
|
- lib/Mailosaur/models/attachment.rb
|
155
156
|
- lib/Mailosaur/models/base_model.rb
|
156
157
|
- lib/Mailosaur/models/code.rb
|
158
|
+
- lib/Mailosaur/models/device.rb
|
159
|
+
- lib/Mailosaur/models/device_create_options.rb
|
160
|
+
- lib/Mailosaur/models/device_list_result.rb
|
157
161
|
- lib/Mailosaur/models/image.rb
|
158
162
|
- lib/Mailosaur/models/link.rb
|
159
163
|
- lib/Mailosaur/models/message.rb
|
@@ -166,6 +170,7 @@ files:
|
|
166
170
|
- lib/Mailosaur/models/message_reply_options.rb
|
167
171
|
- lib/Mailosaur/models/message_summary.rb
|
168
172
|
- lib/Mailosaur/models/metadata.rb
|
173
|
+
- lib/Mailosaur/models/otp_result.rb
|
169
174
|
- lib/Mailosaur/models/search_criteria.rb
|
170
175
|
- lib/Mailosaur/models/server.rb
|
171
176
|
- lib/Mailosaur/models/server_create_options.rb
|
@@ -206,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
211
|
- !ruby/object:Gem::Version
|
207
212
|
version: '0'
|
208
213
|
requirements: []
|
209
|
-
rubygems_version: 3.
|
214
|
+
rubygems_version: 3.3.7
|
210
215
|
signing_key:
|
211
216
|
specification_version: 4
|
212
217
|
summary: The Mailosaur Ruby library
|