ruby-miradore 0.2.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 405212ead3dfabe0b3840b4cc3c878740242ad0cec68b41eebc8b67d56a29b65
4
- data.tar.gz: e61eedd27ba72ee50ef45a1ee006f75e57f02da04ac977e6c177932e51900e0b
3
+ metadata.gz: 338792104a27889aad298d2b97f3f79100e774b8eb7161d96d7de1a09ebe578b
4
+ data.tar.gz: c6e05d216ddb750e749b61dbb4487aba8b5c5ce0457ee5bfa3889d850a571b50
5
5
  SHA512:
6
- metadata.gz: 6c74e7a276050c13e76a4e1dd6f93b6628b17c6484245e6b248410876d5916cc023cb2a4088f963ab04a9167a1499bf64a9a1afb837f5542f2a80eae16bc6059
7
- data.tar.gz: d8b7e2b15f757775020f8d524c532e32a73035173347f5ea8f8e7d578518f49a1912616d0db18369d619a98f5e1b1dc94a67496e859e45c41adff40aa91c6a4e
6
+ metadata.gz: d9e91118e6397499f9db195c832dc601d5b50b430f29707e9fa16d39945452a55e0d64873000b1760fb2f00b0c9f1e8d703a00725e6e9eaf01276a457bb0f51e
7
+ data.tar.gz: 7d4002a412b10a034b95ec0635c555543dc6ff6cbab6cdcbd3ec850323c1893ca921d28e998a8e136e316d30ea8ac19a3e5efea16ef3ac690d7e0c0edf72e014
data/.rubocop.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 2.7.3
3
+ NewCops: disable
3
4
 
4
5
  Style/StringLiterals:
5
6
  Enabled: true
data/Gemfile CHANGED
@@ -4,3 +4,8 @@ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in ruby-miradore.gemspec
6
6
  gemspec
7
+
8
+ group :test do
9
+ gem "vcr"
10
+ gem "webmock"
11
+ end
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-miradore (0.2.0)
4
+ ruby-miradore (1.2.0)
5
5
  crack (~> 0.4.5)
6
- finest-builder (~> 0.0.4)
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)
@@ -27,6 +30,7 @@ GEM
27
30
  parallel (1.20.1)
28
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.13.0)
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.2.0, < 2.0)
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
60
  rubocop-ast (1.5.0)
57
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,45 @@
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: 401
19
+ message: Unauthorized
20
+ headers:
21
+ Cache-Control:
22
+ - no-cache
23
+ Pragma:
24
+ - no-cache
25
+ Content-Length:
26
+ - '98'
27
+ Content-Type:
28
+ - text/xml; charset=utf-8
29
+ Expires:
30
+ - "-1"
31
+ Server:
32
+ - Microsoft-IIS/10.0
33
+ X-Aspnet-Version:
34
+ - 4.0.30319
35
+ X-Powered-By:
36
+ - ASP.NET
37
+ X-Frame-Options:
38
+ - SAMEORIGIN
39
+ Date:
40
+ - Tue, 18 May 2021 10:29:27 GMT
41
+ body:
42
+ encoding: UTF-8
43
+ string: "<Content><Error><Description>Authentication failed</Description><Code>401</Code></Error></Content>"
44
+ recorded_at: Tue, 18 May 2021 10:29:24 GMT
45
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://rzilient.online.miradore.com/API/Device?auth=&filters=(InvDevice.SerialNumber%20eq%20SRE)&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
+ - Tue, 18 May 2021 10:05:37 GMT
39
+ Content-Length:
40
+ - '76'
41
+ body:
42
+ encoding: UTF-8
43
+ string: <?xml version="1.0" encoding="utf-8"?><Content><Items count="0" /></Content>
44
+ recorded_at: Tue, 18 May 2021 10:05:34 GMT
45
+ 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,45 +1,60 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "miradore/version"
4
- require 'httparty'
5
- require 'json'
6
- require 'crack/xml'
7
- require 'finest/builder'
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 Error < StandardError; end
11
+ class MspConnectionError < StandardError; end
12
12
 
13
13
  def self.api_key
14
- @@msp_api_key = ENV['MSP_API_KEY']
14
+ ENV["MSP_API_KEY"]
15
15
  end
16
16
 
17
- def self.api_urls
17
+ def self.url
18
18
  {
19
- v1: 'https://%{subdomain}.online.miradore.com/API/Device?auth=%{auth}&select=*,Category.*,InvDevice.*,InvStorage.*,InvOS.*,Enrollment.*,Client.*,User.*,Location.*,Security.*,ReportedLocation.*',
20
- v2: 'https://%{subdomain}.online.miradore.com/API/v2/Device/%{id}/%{method}'
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"
21
22
  }
22
23
  end
23
24
 
24
- def self.url(version = :v1, *args)
25
- Miradore::api_urls[version] % { subdomain: args[0], id: args[1], method: args[2], auth: Miradore::api_key }
26
- end
27
-
28
- class Listing
25
+ class Request
29
26
  include HTTParty
30
27
  format :json
31
28
 
32
29
  attr_reader :subdomain
33
30
 
34
- def self.all(subdomain, *args)
35
- response = JSON.parse(Crack::XML.parse(get(Miradore::url(:v1, subdomain)).body).to_json, :quirks_mode => true).dig("Content", "Items", "Device")
36
- if response.is_a?(Array)
37
- response.map! { |e| Device.new(e.transform_keys(&:downcase), subdomain) }
38
- else
39
- Device.new(response.transform_keys(&:downcase), subdomain)
40
- end
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 || { error: "Device(s) not found", status: :not_found }, args)
41
+ rescue StandardError => err
42
+ transform(response || { error: err.message, status: :not_found }, args)
41
43
  end
42
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
43
58
  end
44
59
 
45
60
  class Device
@@ -47,12 +62,13 @@ module Ruby
47
62
  include HTTParty
48
63
  format :json
49
64
 
50
- attr_reader :subdomain
65
+ attr_writer :subdomain, :auth
51
66
 
52
- def initialize(json = nil, subdomain = nil)
67
+ def initialize(json = nil, args = {})
53
68
  super json
54
- @subdomain = subdomain
55
- remove_instance_variable(:@subdomain) if subdomain.nil?
69
+ @subdomain = args[:subdomain]
70
+ @auth = args[:auth]
71
+ remove_instance_variable(:@subdomain) if @subdomain.nil?
56
72
  end
57
73
 
58
74
  def lock(*args)
@@ -60,7 +76,7 @@ module Ruby
60
76
  end
61
77
 
62
78
  def lostmode(*args)
63
- if (args[0])
79
+ if args[0]
64
80
  http_method(:post, id, __method__)
65
81
  else
66
82
  http_method(:delete, id, __method__)
@@ -78,11 +94,34 @@ module Ruby
78
94
  private
79
95
 
80
96
  def http_method(*args)
81
- self.class.headers 'X-API-Key' => Miradore::api_key
82
- self.class.method(args[0]).call(Miradore::url(:v2, subdomain, args[1], args[2]))
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"
83
102
  end
84
103
 
85
104
  end
86
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
+
87
126
  end
88
127
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ruby
4
4
  module Miradore
5
- VERSION = "0.2.0"
5
+ VERSION = "1.2.0"
6
6
  end
7
7
  end
@@ -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.4"
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: 0.2.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduard
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-03 00:00:00.000000000 Z
11
+ date: 2021-05-18 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.4
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.4
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,12 @@ 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/auth_not_found.yml
121
+ - fixtures/vcr_cassettes/error_by_serial_number.yml
122
+ - fixtures/vcr_cassettes/search_by_serial_number.yml
117
123
  - lib/ruby/miradore.rb
118
124
  - lib/ruby/miradore/version.rb
119
125
  - ruby-miradore-0.1.0.gem