ruby-miradore 4.3.1 → 4.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile.lock +23 -25
- data/fixtures/vcr_cassettes/Change_User_Email_Address.yml +45 -0
- data/fixtures/vcr_cassettes/Change_User_Email_Address_Error.yml +45 -0
- data/lib/ruby/miradore/version.rb +1 -1
- data/lib/ruby/miradore.rb +56 -42
- data/ruby-miradore.gemspec +11 -11
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c854cbb5ab9cac28c6e4fb8c1d913f96531c54eaf0463a5c931d48020c045b40
|
4
|
+
data.tar.gz: 16db5100e8b11468ff2da6edeb797a135a30638882b97cefb33ca18adc815c1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b2e17d1750e09479355f82b4f14ced4c4273d712c6459449b71be3ec6d21482305748f75b6f3000e892cec72ac461e87145e8bf042e09bb36c798caa023d125
|
7
|
+
data.tar.gz: 944315dd81361acb3b6b283434b053a29b45499c3e947e04de03c5ae588c1a8819a6695eb75f1d72396bb11ff339f2d009ad585dbb1c2b8d92b5a69abfa28ec3
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.2.0
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ruby-miradore (4.
|
4
|
+
ruby-miradore (4.4.1)
|
5
5
|
activesupport (~> 7.0)
|
6
6
|
builder (~> 3.1)
|
7
7
|
crack (~> 0.4)
|
@@ -14,7 +14,7 @@ PATH
|
|
14
14
|
GEM
|
15
15
|
remote: https://rubygems.org/
|
16
16
|
specs:
|
17
|
-
activesupport (7.0.4)
|
17
|
+
activesupport (7.0.4.2)
|
18
18
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
19
|
i18n (>= 1.6, < 2)
|
20
20
|
minitest (>= 5.1)
|
@@ -23,60 +23,58 @@ GEM
|
|
23
23
|
public_suffix (>= 2.0.2, < 6.0)
|
24
24
|
ast (2.4.2)
|
25
25
|
builder (3.2.4)
|
26
|
-
concurrent-ruby (1.
|
26
|
+
concurrent-ruby (1.2.0)
|
27
27
|
crack (0.4.5)
|
28
28
|
rexml
|
29
29
|
diff-lcs (1.5.0)
|
30
30
|
finest-builder (2.0.0)
|
31
31
|
hashdiff (1.0.1)
|
32
|
-
httparty (0.
|
33
|
-
|
32
|
+
httparty (0.21.0)
|
33
|
+
mini_mime (>= 1.0.0)
|
34
34
|
multi_xml (>= 0.5.2)
|
35
35
|
i18n (1.12.0)
|
36
36
|
concurrent-ruby (~> 1.0)
|
37
|
-
json (2.6.
|
38
|
-
|
39
|
-
|
40
|
-
mime-types-data (3.2022.0105)
|
41
|
-
minitest (5.16.3)
|
37
|
+
json (2.6.3)
|
38
|
+
mini_mime (1.1.2)
|
39
|
+
minitest (5.17.0)
|
42
40
|
multi_xml (0.6.0)
|
43
41
|
parallel (1.22.1)
|
44
|
-
parser (3.
|
42
|
+
parser (3.2.1.0)
|
45
43
|
ast (~> 2.4.1)
|
46
|
-
public_suffix (5.0.
|
44
|
+
public_suffix (5.0.1)
|
47
45
|
rainbow (3.1.1)
|
48
46
|
rake (13.0.6)
|
49
|
-
regexp_parser (2.
|
47
|
+
regexp_parser (2.7.0)
|
50
48
|
rexml (3.2.5)
|
51
49
|
rspec (3.12.0)
|
52
50
|
rspec-core (~> 3.12.0)
|
53
51
|
rspec-expectations (~> 3.12.0)
|
54
52
|
rspec-mocks (~> 3.12.0)
|
55
|
-
rspec-core (3.12.
|
53
|
+
rspec-core (3.12.1)
|
56
54
|
rspec-support (~> 3.12.0)
|
57
|
-
rspec-expectations (3.12.
|
55
|
+
rspec-expectations (3.12.2)
|
58
56
|
diff-lcs (>= 1.2.0, < 2.0)
|
59
57
|
rspec-support (~> 3.12.0)
|
60
|
-
rspec-mocks (3.12.
|
58
|
+
rspec-mocks (3.12.3)
|
61
59
|
diff-lcs (>= 1.2.0, < 2.0)
|
62
60
|
rspec-support (~> 3.12.0)
|
63
61
|
rspec-support (3.12.0)
|
64
|
-
rubocop (1.
|
62
|
+
rubocop (1.45.1)
|
65
63
|
json (~> 2.3)
|
66
64
|
parallel (~> 1.10)
|
67
|
-
parser (>= 3.
|
65
|
+
parser (>= 3.2.0.0)
|
68
66
|
rainbow (>= 2.2.2, < 4.0)
|
69
67
|
regexp_parser (>= 1.8, < 3.0)
|
70
68
|
rexml (>= 3.2.5, < 4.0)
|
71
|
-
rubocop-ast (>= 1.
|
69
|
+
rubocop-ast (>= 1.24.1, < 2.0)
|
72
70
|
ruby-progressbar (~> 1.7)
|
73
|
-
unicode-display_width (>=
|
74
|
-
rubocop-ast (1.
|
75
|
-
parser (>= 3.
|
71
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
72
|
+
rubocop-ast (1.26.0)
|
73
|
+
parser (>= 3.2.1.0)
|
76
74
|
ruby-progressbar (1.11.0)
|
77
|
-
tzinfo (2.0.
|
75
|
+
tzinfo (2.0.6)
|
78
76
|
concurrent-ruby (~> 1.0)
|
79
|
-
unicode-display_width (2.
|
77
|
+
unicode-display_width (2.4.2)
|
80
78
|
vcr (6.1.0)
|
81
79
|
webmock (3.18.1)
|
82
80
|
addressable (>= 2.8.0)
|
@@ -93,4 +91,4 @@ DEPENDENCIES
|
|
93
91
|
webmock
|
94
92
|
|
95
93
|
BUNDLED WITH
|
96
|
-
2.
|
94
|
+
2.4.5
|
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: patch
|
5
|
+
uri: https://test634.online.miradore.com/API/v2/Device/13/
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"userEmailAddress":"eduard@rzilient.club"}'
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
X-Api-Key:
|
15
|
+
- 1_8,Yo-TV8QyCiBUF
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
User-Agent:
|
19
|
+
- Ruby
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 401
|
23
|
+
message: Unauthorized
|
24
|
+
headers:
|
25
|
+
Content-Type:
|
26
|
+
- text/plain
|
27
|
+
Server:
|
28
|
+
- Microsoft-IIS/10.0
|
29
|
+
X-Content-Type-Options:
|
30
|
+
- nosniff
|
31
|
+
X-Frame-Options:
|
32
|
+
- SAMEORIGIN
|
33
|
+
Referrer-Policy:
|
34
|
+
- same-origin
|
35
|
+
Strict-Transport-Security:
|
36
|
+
- max-age=31536000; includeSubDomains
|
37
|
+
Date:
|
38
|
+
- Tue, 25 Oct 2022 10:51:38 GMT
|
39
|
+
Content-Length:
|
40
|
+
- '530'
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: 'Status Code: 401; Unauthorized '
|
44
|
+
recorded_at: Tue, 25 Oct 2022 10:51:39 GMT
|
45
|
+
recorded_with: VCR 6.0.0
|
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: patch
|
5
|
+
uri: https://rzilient.online.miradore.com/API/v2/Device//
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"userEmailAddress":"eduard@rzilient.club"}'
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
X-Api-Key:
|
15
|
+
- ''
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
User-Agent:
|
19
|
+
- Ruby
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 404
|
23
|
+
message: Not Found
|
24
|
+
headers:
|
25
|
+
Content-Type:
|
26
|
+
- text/plain
|
27
|
+
Server:
|
28
|
+
- Microsoft-IIS/10.0
|
29
|
+
X-Content-Type-Options:
|
30
|
+
- nosniff
|
31
|
+
X-Frame-Options:
|
32
|
+
- SAMEORIGIN
|
33
|
+
Referrer-Policy:
|
34
|
+
- same-origin
|
35
|
+
Strict-Transport-Security:
|
36
|
+
- max-age=31536000; includeSubDomains
|
37
|
+
Date:
|
38
|
+
- Tue, 25 Oct 2022 10:50:52 GMT
|
39
|
+
Content-Length:
|
40
|
+
- '527'
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: 'Status Code: 404; Not Found '
|
44
|
+
recorded_at: Tue, 25 Oct 2022 10:50:52 GMT
|
45
|
+
recorded_with: VCR 6.0.0
|
data/lib/ruby/miradore.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require_relative 'miradore/version'
|
4
4
|
require 'active_support/isolated_execution_state'
|
5
5
|
require 'active_support/core_ext/hash/conversions'
|
6
|
+
require 'active_support/core_ext/module/attribute_accessors'
|
6
7
|
require 'httparty'
|
7
8
|
require 'json'
|
8
9
|
require 'crack/xml'
|
@@ -11,11 +12,25 @@ require 'finest/builder'
|
|
11
12
|
module Ruby
|
12
13
|
module Miradore
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
mattr_accessor :url, default: {
|
16
|
+
v1: 'https://%<subdomain>s.online.miradore.com/API/%<item>s/%<id>s?auth=%<auth>s&select=*,%<attribute>s&filters=%<filter>s&options=%<options>s',
|
17
|
+
v2: 'https://%<subdomain>s.online.miradore.com/API/v2/Device/%<id>s/%<method>s'
|
18
|
+
}
|
19
|
+
mattr_accessor :phone_types, default: %w[Android iOS WindowsPhone]
|
20
|
+
mattr_accessor :commands, default: {
|
21
|
+
mobile: {
|
22
|
+
lostmode: {
|
23
|
+
message: 'This device has been reported as lost and its location has been identified, please return before authorities arrive.',
|
24
|
+
phoneNumber: '',
|
25
|
+
footnote: 'Contact Support team to unlock.',
|
26
|
+
enableLocationTracking: true
|
27
|
+
}
|
18
28
|
}
|
29
|
+
}
|
30
|
+
|
31
|
+
# Setup data from initializer
|
32
|
+
def self.setup
|
33
|
+
yield(self)
|
19
34
|
end
|
20
35
|
|
21
36
|
class Request
|
@@ -25,11 +40,11 @@ module Ruby
|
|
25
40
|
|
26
41
|
attr_writer :subdomain, :auth, :json
|
27
42
|
|
28
|
-
def initialize(
|
29
|
-
super
|
30
|
-
@subdomain ||=
|
31
|
-
@auth ||=
|
32
|
-
@json ||=
|
43
|
+
def initialize(args = {})
|
44
|
+
super args
|
45
|
+
@subdomain ||= args[:subdomain]
|
46
|
+
@auth ||= args[:auth]
|
47
|
+
@json ||= args.to_json
|
33
48
|
remove_instance_variable(:@subdomain) if @subdomain.nil?
|
34
49
|
remove_instance_variable(:@auth) if @auth.nil?
|
35
50
|
end
|
@@ -40,18 +55,18 @@ module Ruby
|
|
40
55
|
# If the superclass is Request the GET will call simple_v1 which will require the item which is class name.
|
41
56
|
# otherwise will call to retrieve devices based on filters.
|
42
57
|
#
|
43
|
-
def all(
|
58
|
+
def all(args = {})
|
44
59
|
transform(
|
45
60
|
Crack::XML.parse(
|
46
|
-
http_method_v1(
|
61
|
+
http_method_v1(args).body
|
47
62
|
).dig('Content', 'Items'), args
|
48
63
|
)
|
49
64
|
end
|
50
65
|
|
51
|
-
def call(
|
66
|
+
def call(args = {})
|
52
67
|
transform(
|
53
68
|
Crack::XML.parse(
|
54
|
-
http_method_v1(
|
69
|
+
http_method_v1(args.merge(attribute: 'ID')).body
|
55
70
|
)['Content'], args
|
56
71
|
)
|
57
72
|
end
|
@@ -60,8 +75,7 @@ module Ruby
|
|
60
75
|
@json
|
61
76
|
end
|
62
77
|
|
63
|
-
|
64
|
-
def http_method_v1(**args)
|
78
|
+
def http_method_v1(args)
|
65
79
|
url = Miradore.url[:v1] % args.merge(
|
66
80
|
subdomain: @subdomain || args[:subdomain],
|
67
81
|
auth: args.fetch(:auth, @auth),
|
@@ -85,7 +99,7 @@ module Ruby
|
|
85
99
|
end
|
86
100
|
self.class.new(args.merge(res.values.first&.transform_keys(&:downcase)))
|
87
101
|
rescue StandardError
|
88
|
-
{ error: "#{self.class.to_s.split(
|
102
|
+
{ error: "#{self.class.to_s.split('::').last}(s) not found", status: :not_found }
|
89
103
|
end
|
90
104
|
|
91
105
|
end
|
@@ -96,48 +110,48 @@ module Ruby
|
|
96
110
|
headers "Content-Type": 'application/json'
|
97
111
|
headers "Accept": 'application/json'
|
98
112
|
|
99
|
-
def initialize(
|
100
|
-
super
|
113
|
+
def initialize(args = {})
|
114
|
+
super args
|
101
115
|
end
|
102
116
|
|
103
|
-
def lock(
|
104
|
-
http_method(
|
117
|
+
def lock(args = {})
|
118
|
+
http_method(args.merge(method: :post, id: id, action: __method__))
|
105
119
|
end
|
106
120
|
|
107
|
-
def lostmode(
|
108
|
-
if args
|
109
|
-
http_method(
|
121
|
+
def lostmode(args = {})
|
122
|
+
if args.fetch(:enable, false)
|
123
|
+
http_method(args.merge(method: :post, id: id, action: __method__, body: Miradore.commands[:mobile][:lostmode]))
|
110
124
|
else
|
111
|
-
http_method(
|
125
|
+
http_method(args.merge(method: :delete, id: id, action: __method__))
|
112
126
|
end
|
113
127
|
end
|
114
128
|
|
115
|
-
def reboot(
|
116
|
-
http_method(
|
129
|
+
def reboot(args = {})
|
130
|
+
http_method(args.merge(method: :post, id: id, action: __method__))
|
117
131
|
end
|
118
132
|
|
119
|
-
def wipe(
|
120
|
-
http_method(
|
133
|
+
def wipe(args = {})
|
134
|
+
http_method(args.merge(method: :post, id: id, action: __method__))
|
121
135
|
end
|
122
136
|
|
123
|
-
def location(
|
124
|
-
http_method(
|
137
|
+
def location(args = {})
|
138
|
+
http_method(args.merge(method: :get, action: __method__))
|
125
139
|
end
|
126
140
|
|
127
|
-
def family(
|
128
|
-
http_method(
|
141
|
+
def family(args = {})
|
142
|
+
http_method(args.merge(method: :put, action: :category))
|
129
143
|
end
|
130
144
|
|
131
|
-
def model(
|
132
|
-
http_method(
|
145
|
+
def model(args = {})
|
146
|
+
http_method(args.merge(method: :put, action: __method__))
|
133
147
|
end
|
134
148
|
|
135
|
-
def activate(
|
136
|
-
http_method(
|
149
|
+
def activate(args = {})
|
150
|
+
http_method(args.merge(method: :post, action: __method__))
|
137
151
|
end
|
138
152
|
|
139
|
-
def retire(
|
140
|
-
http_method(
|
153
|
+
def retire(args = {})
|
154
|
+
http_method(args.merge(method: :delete, id: id, action: nil))
|
141
155
|
end
|
142
156
|
|
143
157
|
def device_serial_number
|
@@ -153,16 +167,16 @@ module Ruby
|
|
153
167
|
end
|
154
168
|
|
155
169
|
def phone?
|
156
|
-
|
170
|
+
Miradore.phone_types.include?(platform)
|
157
171
|
end
|
158
172
|
|
159
|
-
def call(
|
160
|
-
http_method(
|
173
|
+
def call(args = {})
|
174
|
+
http_method(args)
|
161
175
|
end
|
162
176
|
|
163
177
|
private
|
164
178
|
|
165
|
-
def http_method(
|
179
|
+
def http_method(args)
|
166
180
|
self.class.headers 'X-API-Key' => @auth || args[:auth]
|
167
181
|
url = Miradore.url[:v2] % {
|
168
182
|
subdomain: @subdomain || args[:subdomain],
|
data/ruby-miradore.gemspec
CHANGED
@@ -3,16 +3,16 @@
|
|
3
3
|
require_relative "lib/ruby/miradore/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name
|
7
|
-
spec.version
|
8
|
-
spec.authors
|
9
|
-
spec.email
|
6
|
+
spec.name = "ruby-miradore"
|
7
|
+
spec.version = Ruby::Miradore::VERSION
|
8
|
+
spec.authors = ["Eduard Garcia Castelló"]
|
9
|
+
spec.email = %w[edugarcas@gmail.com eduard@rzilient.club]
|
10
10
|
|
11
|
-
spec.summary
|
12
|
-
spec.description
|
13
|
-
spec.homepage
|
14
|
-
spec.license
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 3.
|
11
|
+
spec.summary = "Miradore is a MSP providing an API to get devices information as well s perform some security actions."
|
12
|
+
spec.description = "Miradore MSP Ruby Gem"
|
13
|
+
spec.homepage = "https://github.com/eddygarcas/ruby-miradore"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.2.0")
|
16
16
|
|
17
17
|
spec.metadata["allowed_push_host"] = "https://rubygems.org/"
|
18
18
|
|
@@ -25,8 +25,8 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
26
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
27
27
|
end
|
28
|
-
spec.bindir
|
29
|
-
spec.executables
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
30
|
spec.require_paths = ["lib"]
|
31
31
|
|
32
32
|
# Uncomment to register a new dependency of your gem
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-miradore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduard Garcia Castelló
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -143,6 +143,8 @@ files:
|
|
143
143
|
- Rakefile
|
144
144
|
- bin/console
|
145
145
|
- bin/setup
|
146
|
+
- fixtures/vcr_cassettes/Change_User_Email_Address.yml
|
147
|
+
- fixtures/vcr_cassettes/Change_User_Email_Address_Error.yml
|
146
148
|
- fixtures/vcr_cassettes/Change_User_Email_Address_Without_v1.yml
|
147
149
|
- fixtures/vcr_cassettes/Get_Device_Location.yml
|
148
150
|
- fixtures/vcr_cassettes/Get__Mobile_Device.yml
|
@@ -186,14 +188,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
186
188
|
requirements:
|
187
189
|
- - ">="
|
188
190
|
- !ruby/object:Gem::Version
|
189
|
-
version: 3.
|
191
|
+
version: 3.2.0
|
190
192
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
193
|
requirements:
|
192
194
|
- - ">="
|
193
195
|
- !ruby/object:Gem::Version
|
194
196
|
version: '0'
|
195
197
|
requirements: []
|
196
|
-
rubygems_version: 3.
|
198
|
+
rubygems_version: 3.4.1
|
197
199
|
signing_key:
|
198
200
|
specification_version: 4
|
199
201
|
summary: Miradore is a MSP providing an API to get devices information as well s perform
|