ruby-miradore 4.2.1 → 4.4.0
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/.travis.yml +1 -1
- data/Gemfile.lock +41 -41
- data/fixtures/vcr_cassettes/Change_User_Email_Address.yml +7 -7
- data/fixtures/vcr_cassettes/Change_User_Email_Address_Error.yml +9 -4
- data/lib/ruby/miradore/version.rb +1 -1
- data/lib/ruby/miradore.rb +45 -41
- data/ruby-miradore.gemspec +12 -12
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6970f265b7922dee506ea4625614c650157fa9c1205d3e411e5e70811a0f626a
|
4
|
+
data.tar.gz: 31aaa50424e7d70b8e3c58349bb3a9e0954ad27441a6f7cf2f8381f851e23d3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20d16bf2aa88223b73c7964d6419407b505b7d39a1af4eca02670b06a0a893768ade53003e151453a4b1a05feaae16dbc3e9078957efeedc9dfc6d98fe215493
|
7
|
+
data.tar.gz: 60d40d8faedfb94a2c8121edd0b2ec86865e17467e66736007a16e9ecaa08345d45f867aff2968e91cd3bd9509c7cf72147e219576ff21d77337e29e194eaf34
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.2.0
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
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)
|
8
|
-
finest-builder (~>
|
8
|
+
finest-builder (~> 2.0)
|
9
9
|
httparty (~> 0.20)
|
10
10
|
rake (~> 13.0)
|
11
11
|
rspec (~> 3.10)
|
@@ -14,69 +14,69 @@ PATH
|
|
14
14
|
GEM
|
15
15
|
remote: https://rubygems.org/
|
16
16
|
specs:
|
17
|
-
activesupport (7.0.2
|
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)
|
21
21
|
tzinfo (~> 2.0)
|
22
|
-
addressable (2.8.
|
23
|
-
public_suffix (>= 2.0.2, <
|
22
|
+
addressable (2.8.1)
|
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
|
-
finest-builder (
|
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
|
-
i18n (1.
|
35
|
+
i18n (1.12.0)
|
36
36
|
concurrent-ruby (~> 1.0)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
minitest (5.15.0)
|
37
|
+
json (2.6.3)
|
38
|
+
mini_mime (1.1.2)
|
39
|
+
minitest (5.17.0)
|
41
40
|
multi_xml (0.6.0)
|
42
|
-
parallel (1.
|
43
|
-
parser (3.
|
41
|
+
parallel (1.22.1)
|
42
|
+
parser (3.2.1.0)
|
44
43
|
ast (~> 2.4.1)
|
45
|
-
public_suffix (
|
44
|
+
public_suffix (5.0.1)
|
46
45
|
rainbow (3.1.1)
|
47
46
|
rake (13.0.6)
|
48
|
-
regexp_parser (2.
|
47
|
+
regexp_parser (2.7.0)
|
49
48
|
rexml (3.2.5)
|
50
|
-
rspec (3.
|
51
|
-
rspec-core (~> 3.
|
52
|
-
rspec-expectations (~> 3.
|
53
|
-
rspec-mocks (~> 3.
|
54
|
-
rspec-core (3.
|
55
|
-
rspec-support (~> 3.
|
56
|
-
rspec-expectations (3.
|
49
|
+
rspec (3.12.0)
|
50
|
+
rspec-core (~> 3.12.0)
|
51
|
+
rspec-expectations (~> 3.12.0)
|
52
|
+
rspec-mocks (~> 3.12.0)
|
53
|
+
rspec-core (3.12.1)
|
54
|
+
rspec-support (~> 3.12.0)
|
55
|
+
rspec-expectations (3.12.2)
|
57
56
|
diff-lcs (>= 1.2.0, < 2.0)
|
58
|
-
rspec-support (~> 3.
|
59
|
-
rspec-mocks (3.
|
57
|
+
rspec-support (~> 3.12.0)
|
58
|
+
rspec-mocks (3.12.3)
|
60
59
|
diff-lcs (>= 1.2.0, < 2.0)
|
61
|
-
rspec-support (~> 3.
|
62
|
-
rspec-support (3.
|
63
|
-
rubocop (1.
|
60
|
+
rspec-support (~> 3.12.0)
|
61
|
+
rspec-support (3.12.0)
|
62
|
+
rubocop (1.45.1)
|
63
|
+
json (~> 2.3)
|
64
64
|
parallel (~> 1.10)
|
65
|
-
parser (>= 3.
|
65
|
+
parser (>= 3.2.0.0)
|
66
66
|
rainbow (>= 2.2.2, < 4.0)
|
67
67
|
regexp_parser (>= 1.8, < 3.0)
|
68
|
-
rexml
|
69
|
-
rubocop-ast (>= 1.
|
68
|
+
rexml (>= 3.2.5, < 4.0)
|
69
|
+
rubocop-ast (>= 1.24.1, < 2.0)
|
70
70
|
ruby-progressbar (~> 1.7)
|
71
|
-
unicode-display_width (>=
|
72
|
-
rubocop-ast (1.
|
73
|
-
parser (>= 3.
|
71
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
72
|
+
rubocop-ast (1.26.0)
|
73
|
+
parser (>= 3.2.1.0)
|
74
74
|
ruby-progressbar (1.11.0)
|
75
|
-
tzinfo (2.0.
|
75
|
+
tzinfo (2.0.6)
|
76
76
|
concurrent-ruby (~> 1.0)
|
77
|
-
unicode-display_width (2.
|
78
|
-
vcr (6.
|
79
|
-
webmock (3.
|
77
|
+
unicode-display_width (2.4.2)
|
78
|
+
vcr (6.1.0)
|
79
|
+
webmock (3.18.1)
|
80
80
|
addressable (>= 2.8.0)
|
81
81
|
crack (>= 0.3.2)
|
82
82
|
hashdiff (>= 0.4.0, < 2.0.0)
|
@@ -91,4 +91,4 @@ DEPENDENCIES
|
|
91
91
|
webmock
|
92
92
|
|
93
93
|
BUNDLED WITH
|
94
|
-
2.
|
94
|
+
2.4.5
|
@@ -19,11 +19,11 @@ http_interactions:
|
|
19
19
|
- Ruby
|
20
20
|
response:
|
21
21
|
status:
|
22
|
-
code:
|
23
|
-
message:
|
22
|
+
code: 401
|
23
|
+
message: Unauthorized
|
24
24
|
headers:
|
25
25
|
Content-Type:
|
26
|
-
-
|
26
|
+
- text/plain
|
27
27
|
Server:
|
28
28
|
- Microsoft-IIS/10.0
|
29
29
|
X-Content-Type-Options:
|
@@ -35,11 +35,11 @@ http_interactions:
|
|
35
35
|
Strict-Transport-Security:
|
36
36
|
- max-age=31536000; includeSubDomains
|
37
37
|
Date:
|
38
|
-
-
|
38
|
+
- Tue, 25 Oct 2022 10:51:38 GMT
|
39
39
|
Content-Length:
|
40
|
-
- '
|
40
|
+
- '530'
|
41
41
|
body:
|
42
42
|
encoding: UTF-8
|
43
|
-
string:
|
44
|
-
recorded_at:
|
43
|
+
string: 'Status Code: 401; Unauthorized '
|
44
|
+
recorded_at: Tue, 25 Oct 2022 10:51:39 GMT
|
45
45
|
recorded_with: VCR 6.0.0
|
@@ -12,7 +12,7 @@ http_interactions:
|
|
12
12
|
Accept:
|
13
13
|
- application/json
|
14
14
|
X-Api-Key:
|
15
|
-
-
|
15
|
+
- ''
|
16
16
|
Accept-Encoding:
|
17
17
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
18
|
User-Agent:
|
@@ -26,15 +26,20 @@ http_interactions:
|
|
26
26
|
- text/plain
|
27
27
|
Server:
|
28
28
|
- Microsoft-IIS/10.0
|
29
|
+
X-Content-Type-Options:
|
30
|
+
- nosniff
|
29
31
|
X-Frame-Options:
|
30
32
|
- SAMEORIGIN
|
31
|
-
-
|
33
|
+
Referrer-Policy:
|
34
|
+
- same-origin
|
35
|
+
Strict-Transport-Security:
|
36
|
+
- max-age=31536000; includeSubDomains
|
32
37
|
Date:
|
33
|
-
-
|
38
|
+
- Tue, 25 Oct 2022 10:50:52 GMT
|
34
39
|
Content-Length:
|
35
40
|
- '527'
|
36
41
|
body:
|
37
42
|
encoding: UTF-8
|
38
43
|
string: 'Status Code: 404; Not Found '
|
39
|
-
recorded_at:
|
44
|
+
recorded_at: Tue, 25 Oct 2022 10:50:52 GMT
|
40
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,15 @@ require 'finest/builder'
|
|
11
12
|
module Ruby
|
12
13
|
module Miradore
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
+
|
21
|
+
# Setup data from initializer
|
22
|
+
def self.setup
|
23
|
+
yield(self)
|
19
24
|
end
|
20
25
|
|
21
26
|
class Request
|
@@ -25,11 +30,11 @@ module Ruby
|
|
25
30
|
|
26
31
|
attr_writer :subdomain, :auth, :json
|
27
32
|
|
28
|
-
def initialize(
|
29
|
-
super
|
30
|
-
@subdomain ||=
|
31
|
-
@auth ||=
|
32
|
-
@json ||=
|
33
|
+
def initialize(args = {})
|
34
|
+
super args
|
35
|
+
@subdomain ||= args[:subdomain]
|
36
|
+
@auth ||= args[:auth]
|
37
|
+
@json ||= args.to_json
|
33
38
|
remove_instance_variable(:@subdomain) if @subdomain.nil?
|
34
39
|
remove_instance_variable(:@auth) if @auth.nil?
|
35
40
|
end
|
@@ -40,18 +45,18 @@ module Ruby
|
|
40
45
|
# If the superclass is Request the GET will call simple_v1 which will require the item which is class name.
|
41
46
|
# otherwise will call to retrieve devices based on filters.
|
42
47
|
#
|
43
|
-
def all(
|
48
|
+
def all(args = {})
|
44
49
|
transform(
|
45
50
|
Crack::XML.parse(
|
46
|
-
http_method_v1(
|
51
|
+
http_method_v1(args).body
|
47
52
|
).dig('Content', 'Items'), args
|
48
53
|
)
|
49
54
|
end
|
50
55
|
|
51
|
-
def call(
|
56
|
+
def call(args = {})
|
52
57
|
transform(
|
53
58
|
Crack::XML.parse(
|
54
|
-
http_method_v1(
|
59
|
+
http_method_v1(args.merge(attribute: 'ID')).body
|
55
60
|
)['Content'], args
|
56
61
|
)
|
57
62
|
end
|
@@ -60,8 +65,7 @@ module Ruby
|
|
60
65
|
@json
|
61
66
|
end
|
62
67
|
|
63
|
-
|
64
|
-
def http_method_v1(**args)
|
68
|
+
def http_method_v1(args)
|
65
69
|
url = Miradore.url[:v1] % args.merge(
|
66
70
|
subdomain: @subdomain || args[:subdomain],
|
67
71
|
auth: args.fetch(:auth, @auth),
|
@@ -96,48 +100,48 @@ module Ruby
|
|
96
100
|
headers "Content-Type": 'application/json'
|
97
101
|
headers "Accept": 'application/json'
|
98
102
|
|
99
|
-
def initialize(
|
100
|
-
super
|
103
|
+
def initialize(args = {})
|
104
|
+
super args
|
101
105
|
end
|
102
106
|
|
103
|
-
def lock(
|
104
|
-
http_method(
|
107
|
+
def lock(args = {})
|
108
|
+
http_method(args.merge(method: :post, id: id, action: __method__))
|
105
109
|
end
|
106
110
|
|
107
|
-
def lostmode(
|
111
|
+
def lostmode(args = {})
|
108
112
|
if args[0]
|
109
|
-
http_method(
|
113
|
+
http_method(args.merge(method: :post, id: id, action: __method__))
|
110
114
|
else
|
111
|
-
http_method(
|
115
|
+
http_method(args.merge(method: :delete, id: id, action: __method__))
|
112
116
|
end
|
113
117
|
end
|
114
118
|
|
115
|
-
def reboot(
|
116
|
-
http_method(
|
119
|
+
def reboot(args = {})
|
120
|
+
http_method(args.merge(method: :post, id: id, action: __method__))
|
117
121
|
end
|
118
122
|
|
119
|
-
def wipe(
|
120
|
-
http_method(
|
123
|
+
def wipe(args = {})
|
124
|
+
http_method(args.merge(method: :post, id: id, action: __method__))
|
121
125
|
end
|
122
126
|
|
123
|
-
def location(
|
124
|
-
http_method(
|
127
|
+
def location(args = {})
|
128
|
+
http_method(args.merge(method: :get, action: __method__))
|
125
129
|
end
|
126
130
|
|
127
|
-
def family(
|
128
|
-
http_method(
|
131
|
+
def family(args = {})
|
132
|
+
http_method(args.merge(method: :put, action: :category))
|
129
133
|
end
|
130
134
|
|
131
|
-
def model(
|
132
|
-
http_method(
|
135
|
+
def model(args = {})
|
136
|
+
http_method(args.merge(method: :put, action: __method__))
|
133
137
|
end
|
134
138
|
|
135
|
-
def activate(
|
136
|
-
http_method(
|
139
|
+
def activate(args = {})
|
140
|
+
http_method(args.merge(method: :post, action: __method__))
|
137
141
|
end
|
138
142
|
|
139
|
-
def retire(
|
140
|
-
http_method(
|
143
|
+
def retire(args = {})
|
144
|
+
http_method(args.merge(method: :delete, id: id, action: nil))
|
141
145
|
end
|
142
146
|
|
143
147
|
def device_serial_number
|
@@ -153,16 +157,16 @@ module Ruby
|
|
153
157
|
end
|
154
158
|
|
155
159
|
def phone?
|
156
|
-
|
160
|
+
Miradore.phone_types.include?(platform)
|
157
161
|
end
|
158
162
|
|
159
|
-
def call(
|
160
|
-
http_method(
|
163
|
+
def call(args = {})
|
164
|
+
http_method(args)
|
161
165
|
end
|
162
166
|
|
163
167
|
private
|
164
168
|
|
165
|
-
def http_method(
|
169
|
+
def http_method(args)
|
166
170
|
self.class.headers 'X-API-Key' => @auth || args[:auth]
|
167
171
|
url = Miradore.url[:v2] % {
|
168
172
|
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
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_dependency "activesupport", "~> 7.0"
|
35
35
|
spec.add_dependency 'builder', '~> 3.1'
|
36
36
|
spec.add_dependency "crack", "~> 0.4"
|
37
|
-
spec.add_dependency "finest-builder", "~>
|
37
|
+
spec.add_dependency "finest-builder", "~> 2.0"
|
38
38
|
spec.add_dependency "httparty", "~> 0.20"
|
39
39
|
spec.add_dependency "rake", "~> 13.0"
|
40
40
|
spec.add_dependency "rspec", "~> 3.10"
|
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.0
|
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-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '2.0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '2.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: httparty
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -188,14 +188,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
188
188
|
requirements:
|
189
189
|
- - ">="
|
190
190
|
- !ruby/object:Gem::Version
|
191
|
-
version: 3.
|
191
|
+
version: 3.2.0
|
192
192
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
193
|
requirements:
|
194
194
|
- - ">="
|
195
195
|
- !ruby/object:Gem::Version
|
196
196
|
version: '0'
|
197
197
|
requirements: []
|
198
|
-
rubygems_version: 3.
|
198
|
+
rubygems_version: 3.4.1
|
199
199
|
signing_key:
|
200
200
|
specification_version: 4
|
201
201
|
summary: Miradore is a MSP providing an API to get devices information as well s perform
|