ruby-miradore 0.1.3 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +18 -7
- data/fixtures/vcr_cassettes/InvDevice.yml +52 -0
- data/fixtures/vcr_cassettes/LockDevice.yml +42 -0
- data/fixtures/vcr_cassettes/all_criteria.yml +70 -0
- data/fixtures/vcr_cassettes/search_by_serial_number.yml +59 -0
- data/lib/ruby/miradore.rb +66 -29
- data/lib/ruby/miradore/version.rb +1 -1
- data/ruby-miradore.gemspec +1 -1
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6979f506ee2d6cb79c84d293e6b23d3f070fd2b6dce994ccca8e56200370aa36
|
4
|
+
data.tar.gz: 9c4140d50011ac5e14068b2904b0ee83d728e498fc28e14616ee0de12ac3b1f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81714a69059bdbee40054b73ec081ba1f9dbfb0fbe4827e604ebc604ba8f82372062578099b39e7054d9f78a1bf2a0494e8f398f7a0f8d63b41afc163ee2f393
|
7
|
+
data.tar.gz: c5d74b1042dc1d941dfe0a1d58d852879c0c0771025370637996029d9457f56b22640b48556043b5acbc9a0867e09c816e548cb87d7259498b6e92291d984cde
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ruby-miradore (
|
4
|
+
ruby-miradore (1.1.1)
|
5
5
|
crack (~> 0.4.5)
|
6
|
-
finest-builder (~> 0.0.
|
6
|
+
finest-builder (~> 0.0.5)
|
7
7
|
httparty (~> 0.18.1)
|
8
8
|
rake (~> 13.0)
|
9
9
|
rspec (~> 3.0)
|
@@ -12,11 +12,14 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
+
addressable (2.7.0)
|
16
|
+
public_suffix (>= 2.0.2, < 5.0)
|
15
17
|
ast (2.4.2)
|
16
18
|
crack (0.4.5)
|
17
19
|
rexml
|
18
20
|
diff-lcs (1.4.4)
|
19
21
|
finest-builder (0.0.5)
|
22
|
+
hashdiff (1.0.1)
|
20
23
|
httparty (0.18.1)
|
21
24
|
mime-types (~> 3.0)
|
22
25
|
multi_xml (>= 0.5.2)
|
@@ -25,8 +28,9 @@ GEM
|
|
25
28
|
mime-types-data (3.2021.0225)
|
26
29
|
multi_xml (0.6.0)
|
27
30
|
parallel (1.20.1)
|
28
|
-
parser (3.0.1.
|
31
|
+
parser (3.0.1.1)
|
29
32
|
ast (~> 2.4.1)
|
33
|
+
public_suffix (4.0.6)
|
30
34
|
rainbow (3.0.0)
|
31
35
|
rake (13.0.3)
|
32
36
|
regexp_parser (2.1.1)
|
@@ -44,19 +48,24 @@ GEM
|
|
44
48
|
diff-lcs (>= 1.2.0, < 2.0)
|
45
49
|
rspec-support (~> 3.10.0)
|
46
50
|
rspec-support (3.10.2)
|
47
|
-
rubocop (1.
|
51
|
+
rubocop (1.14.0)
|
48
52
|
parallel (~> 1.10)
|
49
53
|
parser (>= 3.0.0.0)
|
50
54
|
rainbow (>= 2.2.2, < 4.0)
|
51
55
|
regexp_parser (>= 1.8, < 3.0)
|
52
56
|
rexml
|
53
|
-
rubocop-ast (>= 1.
|
57
|
+
rubocop-ast (>= 1.5.0, < 2.0)
|
54
58
|
ruby-progressbar (~> 1.7)
|
55
59
|
unicode-display_width (>= 1.4.0, < 3.0)
|
56
|
-
rubocop-ast (1.
|
57
|
-
parser (>=
|
60
|
+
rubocop-ast (1.5.0)
|
61
|
+
parser (>= 3.0.1.1)
|
58
62
|
ruby-progressbar (1.11.0)
|
59
63
|
unicode-display_width (2.0.0)
|
64
|
+
vcr (6.0.0)
|
65
|
+
webmock (3.12.2)
|
66
|
+
addressable (>= 2.3.6)
|
67
|
+
crack (>= 0.3.2)
|
68
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
60
69
|
|
61
70
|
PLATFORMS
|
62
71
|
x86_64-darwin-20
|
@@ -64,6 +73,8 @@ PLATFORMS
|
|
64
73
|
|
65
74
|
DEPENDENCIES
|
66
75
|
ruby-miradore!
|
76
|
+
vcr
|
77
|
+
webmock
|
67
78
|
|
68
79
|
BUNDLED WITH
|
69
80
|
2.2.15
|
@@ -0,0 +1,52 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://rzilient.online.miradore.com/API/Device?auth=&filters=&select=ID,InvDevice.*
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Cache-Control:
|
22
|
+
- no-cache
|
23
|
+
Pragma:
|
24
|
+
- no-cache
|
25
|
+
Content-Type:
|
26
|
+
- text/xml
|
27
|
+
Expires:
|
28
|
+
- "-1"
|
29
|
+
Server:
|
30
|
+
- Microsoft-IIS/10.0
|
31
|
+
X-Aspnet-Version:
|
32
|
+
- 4.0.30319
|
33
|
+
X-Powered-By:
|
34
|
+
- ASP.NET
|
35
|
+
X-Frame-Options:
|
36
|
+
- SAMEORIGIN
|
37
|
+
Date:
|
38
|
+
- Thu, 13 May 2021 15:14:47 GMT
|
39
|
+
Content-Length:
|
40
|
+
- '1166'
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: '<?xml version="1.0" encoding="utf-8"?><Content><Items count="2"><Device><ID>1</ID><InvDevice><Model>Apple
|
44
|
+
iPhone9,3</Model><Manufacturer>Apple</Manufacturer><ProductName>iPhone9,3</ProductName><SoftwareVersion>iOS
|
45
|
+
14.4.2</SoftwareVersion><SerialNumber>C76TLUEMHG7F</SerialNumber><IMEI>355332088433360</IMEI><WiFiMAC>d4:dc:cd:d6:09:be</WiFiMAC><BluetoothMAC>d4:dc:cd:d6:09:e1</BluetoothMAC><UDID>84c87a9edf0c577227b96dcbe7bf45713c358ede</UDID><StoreAccountActive>True</StoreAccountActive><DoNotDisturbActive>False</DoNotDisturbActive><DeviceType>MN8X2QL</DeviceType><EASIdentifier>LU1R1J5V0H73JCTEJ2A732LI8G</EASIdentifier><DeviceName>iPhone
|
46
|
+
de: Eduard</DeviceName><InventoryTime>13.05.2021 14:18:41</InventoryTime></InvDevice></Device><Device><ID>2</ID><InvDevice><Model>ASUSTeK
|
47
|
+
COMPUTER INC. VivoBook_ASUSLaptop X712FA_X712FA</Model><Manufacturer>ASUSTeK
|
48
|
+
COMPUTER INC.</Manufacturer><ProductName>VivoBook_ASUSLaptop X712FA_X712FA</ProductName><SoftwareVersion>Windows
|
49
|
+
10 Home (20H2)</SoftwareVersion><SerialNumber>K8N0CV07315233B</SerialNumber><DeviceName>QUENTIN</DeviceName><InventoryTime>12.05.2021
|
50
|
+
12:30:16</InventoryTime></InvDevice></Device></Items></Content>'
|
51
|
+
recorded_at: Thu, 13 May 2021 15:14:48 GMT
|
52
|
+
recorded_with: VCR 6.0.0
|
@@ -0,0 +1,42 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://rzilient.online.miradore.com/API/v2/Device/1/lock
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
X-Api-Key:
|
11
|
+
- 3_IHBPttQ.ub[OG27
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
Accept:
|
15
|
+
- "*/*"
|
16
|
+
User-Agent:
|
17
|
+
- Ruby
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Content-Type:
|
24
|
+
- application/json; charset=utf-8
|
25
|
+
Server:
|
26
|
+
- Microsoft-IIS/10.0
|
27
|
+
X-Powered-By:
|
28
|
+
- ARR/3.0
|
29
|
+
- ASP.NET
|
30
|
+
- ASP.NET
|
31
|
+
X-Frame-Options:
|
32
|
+
- SAMEORIGIN
|
33
|
+
- SAMEORIGIN
|
34
|
+
Date:
|
35
|
+
- Thu, 13 May 2021 15:14:48 GMT
|
36
|
+
Content-Length:
|
37
|
+
- '2'
|
38
|
+
body:
|
39
|
+
encoding: UTF-8
|
40
|
+
string: '""'
|
41
|
+
recorded_at: Thu, 13 May 2021 15:14:48 GMT
|
42
|
+
recorded_with: VCR 6.0.0
|
@@ -0,0 +1,70 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://rzilient.online.miradore.com/API/Device?auth=&filters=&select=*,Category.*,InvDevice.*,InvStorage.*,InvOS.*,Enrollment.*,Client.*,User.*,Location.*,Security.*,ReportedLocation.*
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Cache-Control:
|
22
|
+
- no-cache
|
23
|
+
Pragma:
|
24
|
+
- no-cache
|
25
|
+
Content-Type:
|
26
|
+
- text/xml
|
27
|
+
Expires:
|
28
|
+
- "-1"
|
29
|
+
Server:
|
30
|
+
- Microsoft-IIS/10.0
|
31
|
+
X-Aspnet-Version:
|
32
|
+
- 4.0.30319
|
33
|
+
X-Powered-By:
|
34
|
+
- ASP.NET
|
35
|
+
X-Frame-Options:
|
36
|
+
- SAMEORIGIN
|
37
|
+
Date:
|
38
|
+
- Thu, 13 May 2021 15:14:48 GMT
|
39
|
+
Content-Length:
|
40
|
+
- '4613'
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: '<?xml version="1.0" encoding="utf-8"?><Content><Items count="2"><Device><ID>1</ID><User><ID>2</ID><Email>edugarcas@gmail.com</Email><Source>GUI</Source><Status>Active</Status><Created>22.04.2021
|
44
|
+
06:32:00</Created><Modified>22.04.2021 06:32:00</Modified></User><Category><ID>1</ID><Name>Smartphone</Name></Category><Enrollment><ID>5</ID><User><ID>2</ID></User><Created>22.04.2021
|
45
|
+
06:32:00</Created><Completed>22.04.2021 06:33:20</Completed><Type>Email</Type><Sender>eduard@rzilient.club</Sender></Enrollment><OnlineStatus>Active</OnlineStatus><LastReported>13.05.2021
|
46
|
+
15:14:15</LastReported><LastReportedDays>0</LastReportedDays><LastReportedHours>0</LastReportedHours><LastReportedMinutes>0</LastReportedMinutes><IPAddress>46.25.48.185</IPAddress><MACAddress>d4:dc:cd:d6:09:be</MACAddress><Platform>iOS</Platform><Client><ID>1</ID><ManagementType>iOSUnsupervised</ManagementType></Client><ConfigProfileDeployments><ConfigProfileDeployment><ID>1</ID><ConfigProfile><ID>5</ID></ConfigProfile></ConfigProfileDeployment><ConfigProfileDeployment><ID>2</ID><ConfigProfile><ID>6</ID></ConfigProfile></ConfigProfileDeployment></ConfigProfileDeployments><OSVersionName>iOS
|
47
|
+
14.4.2</OSVersionName><Status>AutoGenerated</Status><Created>22.04.2021 06:33:20</Created><Modified>27.04.2021
|
48
|
+
09:20:21</Modified><Source>MiradoreOnline</Source><InvDevice><Model>Apple
|
49
|
+
iPhone9,3</Model><Manufacturer>Apple</Manufacturer><ProductName>iPhone9,3</ProductName><SoftwareVersion>iOS
|
50
|
+
14.4.2</SoftwareVersion><SerialNumber>C76TLUEMHG7F</SerialNumber><IMEI>355332088433360</IMEI><WiFiMAC>d4:dc:cd:d6:09:be</WiFiMAC><BluetoothMAC>d4:dc:cd:d6:09:e1</BluetoothMAC><UDID>84c87a9edf0c577227b96dcbe7bf45713c358ede</UDID><StoreAccountActive>True</StoreAccountActive><DoNotDisturbActive>False</DoNotDisturbActive><DeviceType>MN8X2QL</DeviceType><EASIdentifier>LU1R1J5V0H73JCTEJ2A732LI8G</EASIdentifier><DeviceName>iPhone
|
51
|
+
de: Eduard</DeviceName><InventoryTime>13.05.2021 14:18:41</InventoryTime></InvDevice><InvStorages><InvStorage><Type>Internal</Type><FreeSpace>16310157685</FreeSpace><TotalSpace>34359738368</TotalSpace><InventoryTime>13.05.2021
|
52
|
+
14:18:41</InventoryTime></InvStorage></InvStorages><InvOS><Platform>iOS</Platform><Version>14.4.2</Version><Build>18D70</Build><InventoryTime>13.05.2021
|
53
|
+
14:18:41</InventoryTime></InvOS><Security><PasscodeSet>Yes</PasscodeSet><EncryptionStatus>Enabled</EncryptionStatus></Security><ReportedLocation><Latitude>41.39850887104272</Latitude><Longitude>2.163043615588689</Longitude><Provider>Unknown</Provider><FixTime>29.04.2021
|
54
|
+
13:55:02</FixTime><InventoryTime>29.04.2021 13:55:20</InventoryTime></ReportedLocation></Device><Device><ID>2</ID><User><ID>3</ID><Name>de
|
55
|
+
Lambert Quentin</Name><Email>quentin@rzilient.club</Email><Firstname>Quentin</Firstname><Lastname>de
|
56
|
+
Lambert</Lastname><Source>GUI</Source><Status>Active</Status><Created>22.04.2021
|
57
|
+
06:51:53</Created><Modified>22.04.2021 06:51:53</Modified></User><Enrollment><ID>9</ID><User><ID>3</ID></User><Created>29.04.2021
|
58
|
+
12:22:31</Created><Completed>29.04.2021 13:01:04</Completed><Type>Email</Type><Sender>eduard@rzilient.club</Sender></Enrollment><OnlineStatus>Active</OnlineStatus><LastReported>13.05.2021
|
59
|
+
12:30:02</LastReported><LastReportedDays>0</LastReportedDays><LastReportedHours>3</LastReportedHours><LastReportedMinutes>164</LastReportedMinutes><IPAddress>46.27.180.174</IPAddress><MACAddress>DC:71:96:FB:8A:56</MACAddress><Platform>WindowsDesktop</Platform><Client><ID>2</ID><ManagementType>BuiltInMDM</ManagementType></Client><ConfigProfileDeployments
|
60
|
+
/><OSVersionName>Windows 10 Home (20H2)</OSVersionName><Status>AutoGenerated</Status><Created>29.04.2021
|
61
|
+
13:01:04</Created><Modified>29.04.2021 13:01:04</Modified><Source>MiradoreOnline</Source><InvDevice><Model>ASUSTeK
|
62
|
+
COMPUTER INC. VivoBook_ASUSLaptop X712FA_X712FA</Model><Manufacturer>ASUSTeK
|
63
|
+
COMPUTER INC.</Manufacturer><ProductName>VivoBook_ASUSLaptop X712FA_X712FA</ProductName><SoftwareVersion>Windows
|
64
|
+
10 Home (20H2)</SoftwareVersion><SerialNumber>K8N0CV07315233B</SerialNumber><DeviceName>QUENTIN</DeviceName><InventoryTime>12.05.2021
|
65
|
+
12:30:16</InventoryTime></InvDevice><InvStorages><InvStorage><Type>Internal</Type><Volume>C:
|
66
|
+
OS</Volume><FreeSpace>382347399168</FreeSpace><TotalSpace>511137091584</TotalSpace><InventoryTime>12.05.2021
|
67
|
+
12:30:16</InventoryTime></InvStorage></InvStorages><InvOS><Platform>WindowsDesktop</Platform><Version>10.0.19042.928</Version><Language>fr-FR</Language><InventoryTime>12.05.2021
|
68
|
+
12:30:16</InventoryTime></InvOS><Security><PasscodeSet>Unknown</PasscodeSet><EncryptionStatus>Disabled</EncryptionStatus></Security></Device></Items></Content>'
|
69
|
+
recorded_at: Thu, 13 May 2021 15:14:48 GMT
|
70
|
+
recorded_with: VCR 6.0.0
|
@@ -0,0 +1,59 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://rzilient.online.miradore.com/API/Device?auth=&filters=(InvDevice.SerialNumber%20eq%20K8N0CV07315233B)&select=*,Category.*,InvDevice.*,InvStorage.*,InvOS.*,Enrollment.*,Client.*,User.*,Location.*,Security.*,ReportedLocation.*
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Cache-Control:
|
22
|
+
- no-cache
|
23
|
+
Pragma:
|
24
|
+
- no-cache
|
25
|
+
Content-Type:
|
26
|
+
- text/xml
|
27
|
+
Expires:
|
28
|
+
- "-1"
|
29
|
+
Server:
|
30
|
+
- Microsoft-IIS/10.0
|
31
|
+
X-Aspnet-Version:
|
32
|
+
- 4.0.30319
|
33
|
+
X-Powered-By:
|
34
|
+
- ASP.NET
|
35
|
+
X-Frame-Options:
|
36
|
+
- SAMEORIGIN
|
37
|
+
Date:
|
38
|
+
- Thu, 13 May 2021 15:14:48 GMT
|
39
|
+
Content-Length:
|
40
|
+
- '2046'
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: '<?xml version="1.0" encoding="utf-8"?><Content><Items count="1"><Device><ID>2</ID><User><ID>3</ID><Name>de
|
44
|
+
Lambert Quentin</Name><Email>quentin@rzilient.club</Email><Firstname>Quentin</Firstname><Lastname>de
|
45
|
+
Lambert</Lastname><Source>GUI</Source><Status>Active</Status><Created>22.04.2021
|
46
|
+
06:51:53</Created><Modified>22.04.2021 06:51:53</Modified></User><Enrollment><ID>9</ID><User><ID>3</ID></User><Created>29.04.2021
|
47
|
+
12:22:31</Created><Completed>29.04.2021 13:01:04</Completed><Type>Email</Type><Sender>eduard@rzilient.club</Sender></Enrollment><OnlineStatus>Active</OnlineStatus><LastReported>13.05.2021
|
48
|
+
12:30:02</LastReported><LastReportedDays>0</LastReportedDays><LastReportedHours>3</LastReportedHours><LastReportedMinutes>164</LastReportedMinutes><IPAddress>46.27.180.174</IPAddress><MACAddress>DC:71:96:FB:8A:56</MACAddress><Platform>WindowsDesktop</Platform><Client><ID>2</ID><ManagementType>BuiltInMDM</ManagementType></Client><ConfigProfileDeployments
|
49
|
+
/><OSVersionName>Windows 10 Home (20H2)</OSVersionName><Status>AutoGenerated</Status><Created>29.04.2021
|
50
|
+
13:01:04</Created><Modified>29.04.2021 13:01:04</Modified><Source>MiradoreOnline</Source><InvDevice><Model>ASUSTeK
|
51
|
+
COMPUTER INC. VivoBook_ASUSLaptop X712FA_X712FA</Model><Manufacturer>ASUSTeK
|
52
|
+
COMPUTER INC.</Manufacturer><ProductName>VivoBook_ASUSLaptop X712FA_X712FA</ProductName><SoftwareVersion>Windows
|
53
|
+
10 Home (20H2)</SoftwareVersion><SerialNumber>K8N0CV07315233B</SerialNumber><DeviceName>QUENTIN</DeviceName><InventoryTime>12.05.2021
|
54
|
+
12:30:16</InventoryTime></InvDevice><InvStorages><InvStorage><Type>Internal</Type><Volume>C:
|
55
|
+
OS</Volume><FreeSpace>382347399168</FreeSpace><TotalSpace>511137091584</TotalSpace><InventoryTime>12.05.2021
|
56
|
+
12:30:16</InventoryTime></InvStorage></InvStorages><InvOS><Platform>WindowsDesktop</Platform><Version>10.0.19042.928</Version><Language>fr-FR</Language><InventoryTime>12.05.2021
|
57
|
+
12:30:16</InventoryTime></InvOS><Security><PasscodeSet>Unknown</PasscodeSet><EncryptionStatus>Disabled</EncryptionStatus></Security></Device></Items></Content>'
|
58
|
+
recorded_at: Thu, 13 May 2021 15:14:48 GMT
|
59
|
+
recorded_with: VCR 6.0.0
|
data/lib/ruby/miradore.rb
CHANGED
@@ -1,47 +1,60 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "miradore/version"
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
4
|
+
require "httparty"
|
5
|
+
require "json"
|
6
|
+
require "crack/xml"
|
7
|
+
require "finest/builder"
|
8
8
|
|
9
9
|
module Ruby
|
10
10
|
module Miradore
|
11
|
-
class
|
12
|
-
|
13
|
-
@@msp_api_key = ENV['MSP_API_KEY']
|
11
|
+
class MspConnectionError < StandardError; end
|
14
12
|
|
15
13
|
def self.api_key
|
16
|
-
|
14
|
+
ENV["MSP_API_KEY"]
|
17
15
|
end
|
18
16
|
|
19
|
-
def self.
|
17
|
+
def self.url
|
20
18
|
{
|
21
|
-
|
22
|
-
|
19
|
+
simple_v1: "https://%<subdomain>s.online.miradore.com/API/Device?auth=%<auth>s&select=ID,%<item>s.*&filters=%<filter>s",
|
20
|
+
v1: "https://%<subdomain>s.online.miradore.com/API/Device?auth=%<auth>s&select=*,Category.*,InvDevice.*,InvStorage.*,InvOS.*,Enrollment.*,Client.*,User.*,Location.*,Security.*,ReportedLocation.*&filters=%<filter>s",
|
21
|
+
v2: "https://%<subdomain>s.online.miradore.com/API/v2/Device/%<id>s/%<method>s"
|
23
22
|
}
|
24
23
|
end
|
25
24
|
|
26
|
-
def self.url(version = :v1, *args)
|
27
|
-
Miradore::api_urls[version] % { subdomain: args[0], id: args[1], method: args[2], auth: Miradore::api_key }
|
28
|
-
end
|
29
|
-
|
30
25
|
class Request
|
31
26
|
include HTTParty
|
32
27
|
format :json
|
33
28
|
|
34
29
|
attr_reader :subdomain
|
35
30
|
|
36
|
-
def self.all(
|
37
|
-
response = JSON.parse(
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
31
|
+
def self.all(**args)
|
32
|
+
response = JSON.parse(
|
33
|
+
Crack::XML.parse(
|
34
|
+
get(
|
35
|
+
Miradore.url[version] % args.merge(item: class_name, auth: args.fetch(:auth, Miradore.api_key), filter: args.fetch(:filter, nil))
|
36
|
+
).body
|
37
|
+
).to_json,
|
38
|
+
quirks_mode: true
|
39
|
+
).dig("Content", "Items", "Device")
|
40
|
+
transform(response, args)
|
41
|
+
rescue StandardError
|
42
|
+
raise MspConnectionError, "Error connecting Manager Service Provider"
|
43
43
|
end
|
44
44
|
|
45
|
+
def self.transform(response, args = {})
|
46
|
+
return response.map! { |e| Device.new(e.transform_keys(&:downcase), args) } if response.is_a?(Array)
|
47
|
+
|
48
|
+
Device.new(response.transform_keys(&:downcase), args)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.version
|
52
|
+
superclass == Request ? :simple_v1 : :v1
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.class_name
|
56
|
+
to_s.split("::").last
|
57
|
+
end
|
45
58
|
end
|
46
59
|
|
47
60
|
class Device
|
@@ -49,12 +62,13 @@ module Ruby
|
|
49
62
|
include HTTParty
|
50
63
|
format :json
|
51
64
|
|
52
|
-
|
65
|
+
attr_writer :subdomain, :auth
|
53
66
|
|
54
|
-
def initialize(json = nil,
|
67
|
+
def initialize(json = nil, args = {})
|
55
68
|
super json
|
56
|
-
@subdomain = subdomain
|
57
|
-
|
69
|
+
@subdomain = args[:subdomain]
|
70
|
+
@auth = args[:auth]
|
71
|
+
remove_instance_variable(:@subdomain) if @subdomain.nil?
|
58
72
|
end
|
59
73
|
|
60
74
|
def lock(*args)
|
@@ -62,7 +76,7 @@ module Ruby
|
|
62
76
|
end
|
63
77
|
|
64
78
|
def lostmode(*args)
|
65
|
-
if
|
79
|
+
if args[0]
|
66
80
|
http_method(:post, id, __method__)
|
67
81
|
else
|
68
82
|
http_method(:delete, id, __method__)
|
@@ -80,11 +94,34 @@ module Ruby
|
|
80
94
|
private
|
81
95
|
|
82
96
|
def http_method(*args)
|
83
|
-
self.class.headers
|
84
|
-
|
97
|
+
self.class.headers "X-API-Key" => @auth || Miradore.api_key
|
98
|
+
url = Miradore.url[:v2] % { subdomain: @subdomain, id: args[1], method: args[2] }
|
99
|
+
self.class.method(args[0]).call(url)
|
100
|
+
rescue StandardError
|
101
|
+
raise MspConnectionError, "Error connecting to manager service provider"
|
85
102
|
end
|
86
103
|
|
87
104
|
end
|
88
105
|
|
106
|
+
class Category < Request; end
|
107
|
+
|
108
|
+
class InvDevice < Request; end
|
109
|
+
|
110
|
+
class InvStorage < Request; end
|
111
|
+
|
112
|
+
class InvOS < Request; end
|
113
|
+
|
114
|
+
class Enrollment < Request; end
|
115
|
+
|
116
|
+
class Client < Request; end
|
117
|
+
|
118
|
+
class User < Request; end
|
119
|
+
|
120
|
+
class Location < Request; end
|
121
|
+
|
122
|
+
class Security < Request; end
|
123
|
+
|
124
|
+
class ReportedLocation < Request; end
|
125
|
+
|
89
126
|
end
|
90
127
|
end
|
data/ruby-miradore.gemspec
CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_dependency "rspec", "~> 3.0"
|
36
36
|
spec.add_dependency "rubocop", "~> 1.7"
|
37
37
|
spec.add_dependency "httparty", "~> 0.18.1"
|
38
|
-
spec.add_dependency "finest-builder", "~> 0.0.
|
38
|
+
spec.add_dependency "finest-builder", "~> 0.0.5"
|
39
39
|
spec.add_dependency "crack", "~> 0.4.5"
|
40
40
|
|
41
41
|
# For more information and examples about making a new gem, checkout our
|
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
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.0.
|
75
|
+
version: 0.0.5
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.0.
|
82
|
+
version: 0.0.5
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: crack
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,6 +114,10 @@ files:
|
|
114
114
|
- Rakefile
|
115
115
|
- bin/console
|
116
116
|
- bin/setup
|
117
|
+
- fixtures/vcr_cassettes/InvDevice.yml
|
118
|
+
- fixtures/vcr_cassettes/LockDevice.yml
|
119
|
+
- fixtures/vcr_cassettes/all_criteria.yml
|
120
|
+
- fixtures/vcr_cassettes/search_by_serial_number.yml
|
117
121
|
- lib/ruby/miradore.rb
|
118
122
|
- lib/ruby/miradore/version.rb
|
119
123
|
- ruby-miradore-0.1.0.gem
|