ruby-miradore 0.1.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d552be133b6f62fa669eeccc9869cc8ded81917d263b8acc726bc282839d229
4
- data.tar.gz: 86ada8f519beb1f459c310fabee0056ea61c0a24ff6d71fa07b0a7115fa17f5f
3
+ metadata.gz: 0a0d9f16881d0084b790f716f147d30a6c83ccd5e61c41aac6c3f4de3d5b9011
4
+ data.tar.gz: c1df3a2b189804ce4786bde6d7642560b84c337fa363a8de619815f4b8eb2deb
5
5
  SHA512:
6
- metadata.gz: 45ec251fef7fa5771b1f6233311d12d462565e8adcb12931d4185f99e478d77f3303dc6866fba65331aeeb9ff14b4552ac9c61e04c0b6d11bfedf5d60dd0fff8
7
- data.tar.gz: '06696846ee4387670af1dcc4c64e9a3a77f3cc57388b5d667c45ab36a4be225c035ed597287d0634ee1e2f7c19e09eb9ccf1d5530669d352a6222ea74e610eb1'
6
+ metadata.gz: ea9c4d455b6f4c17a5bc5c8145814e0d56b44353df5e74a2bef1179491c48dad7772b61ecac59af134b528b530493c86279ea1078ce3681e5af909cb583b4ffc
7
+ data.tar.gz: 23f81ab6559b89e6728ff29b228fd514a489a843819dc1482d8f9f67eacccb3e6c83c5f3b81296d9079bf77a5b99db84c1d951b565bd97978a428e4922dcb9f7
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
@@ -5,9 +5,7 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in ruby-miradore.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
9
- gem "rspec", "~> 3.0"
10
- gem "rubocop", "~> 1.7"
11
- gem "httparty", "~> 0.18.1"
12
- gem "finest-builder", "~> 0.0.4"
13
- gem "crack", "~> 0.4.5"
8
+ group :test do
9
+ gem "vcr"
10
+ gem "webmock"
11
+ end
data/Gemfile.lock CHANGED
@@ -1,16 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-miradore (0.1.1)
4
+ ruby-miradore (1.1.0)
5
+ crack (~> 0.4.5)
6
+ finest-builder (~> 0.0.4)
7
+ httparty (~> 0.18.1)
8
+ rake (~> 13.0)
9
+ rspec (~> 3.0)
10
+ rubocop (~> 1.7)
5
11
 
6
12
  GEM
7
13
  remote: https://rubygems.org/
8
14
  specs:
15
+ addressable (2.7.0)
16
+ public_suffix (>= 2.0.2, < 5.0)
9
17
  ast (2.4.2)
10
18
  crack (0.4.5)
11
19
  rexml
20
+ debase (2.3.2)
21
+ debase-ruby_core_source (~> 0.10.11)
22
+ debase-ruby_core_source (0.10.11)
12
23
  diff-lcs (1.4.4)
13
24
  finest-builder (0.0.5)
25
+ hashdiff (1.0.1)
14
26
  httparty (0.18.1)
15
27
  mime-types (~> 3.0)
16
28
  multi_xml (>= 0.5.2)
@@ -19,8 +31,9 @@ GEM
19
31
  mime-types-data (3.2021.0225)
20
32
  multi_xml (0.6.0)
21
33
  parallel (1.20.1)
22
- parser (3.0.1.0)
34
+ parser (3.0.1.1)
23
35
  ast (~> 2.4.1)
36
+ public_suffix (4.0.6)
24
37
  rainbow (3.0.0)
25
38
  rake (13.0.3)
26
39
  regexp_parser (2.1.1)
@@ -38,31 +51,35 @@ GEM
38
51
  diff-lcs (>= 1.2.0, < 2.0)
39
52
  rspec-support (~> 3.10.0)
40
53
  rspec-support (3.10.2)
41
- rubocop (1.13.0)
54
+ rubocop (1.14.0)
42
55
  parallel (~> 1.10)
43
56
  parser (>= 3.0.0.0)
44
57
  rainbow (>= 2.2.2, < 4.0)
45
58
  regexp_parser (>= 1.8, < 3.0)
46
59
  rexml
47
- rubocop-ast (>= 1.2.0, < 2.0)
60
+ rubocop-ast (>= 1.5.0, < 2.0)
48
61
  ruby-progressbar (~> 1.7)
49
62
  unicode-display_width (>= 1.4.0, < 3.0)
50
- rubocop-ast (1.4.1)
51
- parser (>= 2.7.1.5)
63
+ rubocop-ast (1.5.0)
64
+ parser (>= 3.0.1.1)
52
65
  ruby-progressbar (1.11.0)
53
66
  unicode-display_width (2.0.0)
67
+ vcr (6.0.0)
68
+ webmock (3.12.2)
69
+ addressable (>= 2.3.6)
70
+ crack (>= 0.3.2)
71
+ hashdiff (>= 0.4.0, < 2.0.0)
54
72
 
55
73
  PLATFORMS
56
74
  x86_64-darwin-20
75
+ x86_64-linux
57
76
 
58
77
  DEPENDENCIES
59
- crack
60
- finest-builder (~> 0.0.4)
61
- httparty
62
- rake (~> 13.0)
63
- rspec (~> 3.0)
64
- rubocop (~> 1.7)
78
+ debase
79
+ debase-ruby_core_source
65
80
  ruby-miradore!
81
+ vcr
82
+ webmock
66
83
 
67
84
  BUNDLED WITH
68
85
  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
+ - Wed, 12 May 2021 14:31:33 GMT
39
+ Content-Length:
40
+ - '1165'
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>True</DoNotDisturbActive><DeviceType>MN8X2QL</DeviceType><EASIdentifier>LU1R1J5V0H73JCTEJ2A732LI8G</EASIdentifier><DeviceName>iPhone
46
+ de: Eduard</DeviceName><InventoryTime>11.05.2021 22:04:19</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: Wed, 12 May 2021 14:31:34 GMT
52
+ 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
+ - Wed, 12 May 2021 14:00:01 GMT
39
+ Content-Length:
40
+ - '4612'
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>12.05.2021
46
+ 12:25:30</LastReported><LastReportedDays>0</LastReportedDays><LastReportedHours>2</LastReportedHours><LastReportedMinutes>95</LastReportedMinutes><IPAddress>31.4.148.80</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>True</DoNotDisturbActive><DeviceType>MN8X2QL</DeviceType><EASIdentifier>LU1R1J5V0H73JCTEJ2A732LI8G</EASIdentifier><DeviceName>iPhone
51
+ de: Eduard</DeviceName><InventoryTime>11.05.2021 22:04:19</InventoryTime></InvDevice><InvStorages><InvStorage><Type>Internal</Type><FreeSpace>16347488304</FreeSpace><TotalSpace>34359738368</TotalSpace><InventoryTime>11.05.2021
52
+ 22:04:19</InventoryTime></InvStorage></InvStorages><InvOS><Platform>iOS</Platform><Version>14.4.2</Version><Build>18D70</Build><InventoryTime>11.05.2021
53
+ 22:04:19</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>12.05.2021
59
+ 12:30:15</LastReported><LastReportedDays>0</LastReportedDays><LastReportedHours>2</LastReportedHours><LastReportedMinutes>90</LastReportedMinutes><IPAddress>37.223.114.163</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: Wed, 12 May 2021 14:00:02 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
+ - Wed, 12 May 2021 14:31:33 GMT
39
+ Content-Length:
40
+ - '2047'
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>12.05.2021
48
+ 12:30:15</LastReported><LastReportedDays>0</LastReportedDays><LastReportedHours>2</LastReportedHours><LastReportedMinutes>121</LastReportedMinutes><IPAddress>37.223.114.163</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: Wed, 12 May 2021 14:31:34 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 '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
12
-
13
- @@msp_api_key = ENV['MSP_API_KEY']
11
+ class MspConnectionError < StandardError; end
14
12
 
15
13
  def self.api_key
16
- @@msp_api_key
14
+ ENV["MSP_API_KEY"]
17
15
  end
18
16
 
19
- def self.api_urls
17
+ def self.url
20
18
  {
21
- v1: 'https://%{subdomain}.online.miradore.com/API/Device?auth=%{auth}&select=*,Category.*,InvDevice.*,InvStorage.*,InvOS.*,Enrollment.*,Client.*,User.*,Location.*,Security.*,ReportedLocation.*',
22
- 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"
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(subdomain, *args)
37
- response = JSON.parse(Crack::XML.parse(get(Miradore::url(:v1, subdomain)).body).to_json, :quirks_mode => true).dig("Content", "Items", "Device")
38
- if response.is_a?(Array)
39
- response.map! { |e| Device.new(e.transform_keys(&:downcase), subdomain) }
40
- else
41
- Device.new(response.transform_keys(&:downcase), subdomain)
42
- 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, 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,11 +62,12 @@ module Ruby
49
62
  include HTTParty
50
63
  format :json
51
64
 
52
- attr_reader :subdomain
65
+ attr_reader :subdomain, :auth
53
66
 
54
- def initialize(json = nil, subdomain = nil)
67
+ def initialize(json = nil, args = {})
55
68
  super json
56
- @subdomain = subdomain
69
+ @subdomain = args[:subdomain]
70
+ @auth = args[:auth]
57
71
  remove_instance_variable(:@subdomain) if subdomain.nil?
58
72
  end
59
73
 
@@ -62,7 +76,7 @@ module Ruby
62
76
  end
63
77
 
64
78
  def lostmode(*args)
65
- if (args[0])
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 'X-API-Key' => Miradore::api_key
84
- 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"
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ruby
4
4
  module Miradore
5
- VERSION = "0.1.2"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
@@ -31,6 +31,12 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  # Uncomment to register a new dependency of your gem
33
33
  # spec.add_dependency "example-gem", "~> 1.0"
34
+ spec.add_dependency "rake", "~> 13.0"
35
+ spec.add_dependency "rspec", "~> 3.0"
36
+ spec.add_dependency "rubocop", "~> 1.7"
37
+ spec.add_dependency "httparty", "~> 0.18.1"
38
+ spec.add_dependency "finest-builder", "~> 0.0.4"
39
+ spec.add_dependency "crack", "~> 0.4.5"
34
40
 
35
41
  # For more information and examples about making a new gem, checkout our
36
42
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,15 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-miradore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 1.1.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-04-30 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2021-05-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '13.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '13.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: httparty
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.18.1
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.18.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: finest-builder
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.0.4
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.0.4
83
+ - !ruby/object:Gem::Dependency
84
+ name: crack
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.4.5
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.4.5
13
97
  description: Miradore MSP Ruby Gem
14
98
  email:
15
99
  - eduard@rzilient.club
@@ -30,6 +114,9 @@ files:
30
114
  - Rakefile
31
115
  - bin/console
32
116
  - bin/setup
117
+ - fixtures/vcr_cassettes/InvDevice.yml
118
+ - fixtures/vcr_cassettes/all_criteria.yml
119
+ - fixtures/vcr_cassettes/search_by_serial_number.yml
33
120
  - lib/ruby/miradore.rb
34
121
  - lib/ruby/miradore/version.rb
35
122
  - ruby-miradore-0.1.0.gem
@@ -58,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
145
  - !ruby/object:Gem::Version
59
146
  version: '0'
60
147
  requirements: []
61
- rubygems_version: 3.1.4
148
+ rubygems_version: 3.1.6
62
149
  signing_key:
63
150
  specification_version: 4
64
151
  summary: Miradore is a MSP providing an API to get devices information as well s perform