ruby-miradore 0.2.1 → 1.2.1

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: ae4429c886f0c83f4f8e45ed0e5ca2c8a33b3c3b170e60c0061180a476ed5edf
4
- data.tar.gz: f8ee91a7f7893fbc7a1b43976a5673ee0d8aed2e5cf40097862a182b5127e453
3
+ metadata.gz: e0bd96940a4c4d640f0096d5a49e8adbee0df4e7992cd265ce230533ae94df59
4
+ data.tar.gz: 645bb0e57c7c7b34ffed49641da01f9ca06a93ec061cc19b8e9e050c7039f3b1
5
5
  SHA512:
6
- metadata.gz: 29c3cba4f3ec8e0708a737c9217de99caed9880bc3b24e56b220c5cac27f148e3acba2fb53a2715340a2ee379fa67ea5c12b4cfb66297a7477b515fc95e79520
7
- data.tar.gz: 199c7dddd4b12a9c79ee411a9bdca3ac314afa12db5c9c7d5a0a63fc29151352fbf2834f51eba0a96cdb688ec2e7280aa4a036824ef7fd13f773c76e79ecbce2
6
+ metadata.gz: 46aea179dfa2b8297345caf2e07c863d1d7b1851af7bac1e4349d1b5b7654c8a7883cccd9a1ca4dd009c0cc9402793b1f3340a445af8e5eb9af75e96268b1b58
7
+ data.tar.gz: bc4f5528e43eb569243e52502232c84073370b3d642ca95ac776a1578f2518b37bc6d736ee03334a4ab01e37e44fe0bdba1920566123690fa296e14453611fa6
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.1)
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,48 +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
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")
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 || "Error connecting to manager service provider", status: :not_found }, args)
43
+ end
36
44
 
37
- if response.is_a?(Array)
38
- response.map! { |e| Device.new(e.transform_keys(&:downcase), subdomain) }
39
- else
40
- Device.new(response.transform_keys(&:downcase), subdomain)
41
- end
42
- rescue StandardError
43
- raise MspConnectionError.new("Error connecting to manager service provider")
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
44
53
  end
45
54
 
55
+ def self.class_name
56
+ to_s.split("::").last
57
+ end
46
58
  end
47
59
 
48
60
  class Device
@@ -50,12 +62,13 @@ module Ruby
50
62
  include HTTParty
51
63
  format :json
52
64
 
53
- attr_reader :subdomain
65
+ attr_writer :subdomain, :auth
54
66
 
55
- def initialize(json = nil, subdomain = nil)
67
+ def initialize(json = nil, args = {})
56
68
  super json
57
- @subdomain = subdomain
58
- remove_instance_variable(:@subdomain) if subdomain.nil?
69
+ @subdomain = args[:subdomain]
70
+ @auth = args[:auth]
71
+ remove_instance_variable(:@subdomain) if @subdomain.nil?
59
72
  end
60
73
 
61
74
  def lock(*args)
@@ -63,7 +76,7 @@ module Ruby
63
76
  end
64
77
 
65
78
  def lostmode(*args)
66
- if (args[0])
79
+ if args[0]
67
80
  http_method(:post, id, __method__)
68
81
  else
69
82
  http_method(:delete, id, __method__)
@@ -81,13 +94,34 @@ module Ruby
81
94
  private
82
95
 
83
96
  def http_method(*args)
84
- self.class.headers 'X-API-Key' => Miradore::api_key
85
- self.class.method(args[0]).call(Miradore::url(:v2, subdomain, args[1], args[2]))
86
- rescue StandardError
87
- raise MspConnectionError.new("Error connecting to manager service provider")
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 => err
101
+ { error: err&.message || "Error connecting to manager service provider", status: :not_found }
88
102
  end
89
103
 
90
104
  end
91
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
+
92
126
  end
93
127
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ruby
4
4
  module Miradore
5
- VERSION = "0.2.1"
5
+ VERSION = "1.2.1"
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.1
4
+ version: 1.2.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-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