ruby-miradore 2.0.3 → 2.2.4
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 +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -1
- data/Gemfile.lock +9 -9
- data/fixtures/vcr_cassettes/Change_User_Email_Address.yml +2 -2
- data/fixtures/vcr_cassettes/Change_User_Email_Address_Error.yml +2 -2
- data/fixtures/vcr_cassettes/Change_User_Email_Address_Without_v1.yml +2 -2
- data/fixtures/vcr_cassettes/Get_Device_Location.yml +5 -5
- data/fixtures/vcr_cassettes/Get__Mobile_Device.yml +6 -6
- data/fixtures/vcr_cassettes/InvDevice.yml +4 -4
- data/fixtures/vcr_cassettes/LockDevice_all.yml +2 -2
- data/fixtures/vcr_cassettes/add_new_other_device.yml +41 -0
- data/fixtures/vcr_cassettes/all_criteria.yml +56 -24
- data/fixtures/vcr_cassettes/auth_not_found.yml +2 -2
- data/fixtures/vcr_cassettes/error_by_serial_number.yml +2 -2
- data/fixtures/vcr_cassettes/full_list_and_details.yml +5 -5
- data/fixtures/vcr_cassettes/get_computer_device_to_update.yml +64 -0
- data/fixtures/vcr_cassettes/get_computer_device_to_update_2.yml +62 -0
- data/fixtures/vcr_cassettes/get_location.yml +2 -2
- data/fixtures/vcr_cassettes/get_user_from_miradore.yml +2 -2
- data/fixtures/vcr_cassettes/search_by_serial_number.yml +7 -7
- data/fixtures/vcr_cassettes/update_model_of_a_computer_device.yml +39 -0
- data/fixtures/vcr_cassettes/update_model_of_a_computer_device_v2.yml +40 -0
- data/fixtures/vcr_cassettes/update_model_of_a_computer_device_v2_2.yml +40 -0
- data/fixtures/vcr_cassettes/user_alredy_exist_in_miradore.yml +159 -0
- data/lib/ruby/miradore/version.rb +1 -1
- data/lib/ruby/miradore.rb +66 -35
- data/ruby-miradore-2.0.1.gem +0 -0
- data/ruby-miradore-2.0.2.gem +0 -0
- data/ruby-miradore-2.1.2.gem +0 -0
- data/ruby-miradore.gemspec +3 -1
- metadata +13 -8
- data/ruby-miradore-0.1.2.gem +0 -0
- data/ruby-miradore-0.1.3.gem +0 -0
- data/ruby-miradore-1.1.0.gem +0 -0
- data/ruby-miradore-1.1.1.gem +0 -0
- data/ruby-miradore-1.2.2.gem +0 -0
|
@@ -35,7 +35,7 @@ http_interactions:
|
|
|
35
35
|
X-Frame-Options:
|
|
36
36
|
- SAMEORIGIN
|
|
37
37
|
Date:
|
|
38
|
-
-
|
|
38
|
+
- Fri, 29 Oct 2021 13:37:45 GMT
|
|
39
39
|
Content-Length:
|
|
40
40
|
- '282'
|
|
41
41
|
body:
|
|
@@ -43,5 +43,5 @@ http_interactions:
|
|
|
43
43
|
string: <?xml version="1.0" encoding="utf-8"?><Content><Items count="1"><Organization><ID>1</ID><Name>PUR
|
|
44
44
|
Projet</Name><FullName>PUR Projet</FullName><Created>17.05.2021 09:02:43</Created><Modified>17.05.2021
|
|
45
45
|
09:02:43</Modified></Organization></Items></Content>
|
|
46
|
-
recorded_at:
|
|
46
|
+
recorded_at: Fri, 29 Oct 2021 13:37:43 GMT
|
|
47
47
|
recorded_with: VCR 6.0.0
|
|
@@ -35,12 +35,12 @@ http_interactions:
|
|
|
35
35
|
X-Frame-Options:
|
|
36
36
|
- SAMEORIGIN
|
|
37
37
|
Date:
|
|
38
|
-
-
|
|
38
|
+
- Fri, 29 Oct 2021 13:37:44 GMT
|
|
39
39
|
Content-Length:
|
|
40
40
|
- '301'
|
|
41
41
|
body:
|
|
42
42
|
encoding: ASCII-8BIT
|
|
43
43
|
string: <?xml version="1.0" encoding="utf-8"?><Content><Items count="1"><User><ID>2</ID><Email>edugarcas@gmail.com</Email><Source>GUI</Source><Status>Active</Status><Created>22.04.2021
|
|
44
44
|
06:32:00</Created><Modified>22.04.2021 06:32:00</Modified></User></Items></Content>
|
|
45
|
-
recorded_at:
|
|
45
|
+
recorded_at: Fri, 29 Oct 2021 13:37:43 GMT
|
|
46
46
|
recorded_with: VCR 6.0.0
|
|
@@ -39,15 +39,15 @@ http_interactions:
|
|
|
39
39
|
X-Frame-Options:
|
|
40
40
|
- SAMEORIGIN
|
|
41
41
|
Date:
|
|
42
|
-
-
|
|
42
|
+
- Fri, 29 Oct 2021 13:37:43 GMT
|
|
43
43
|
Content-Length:
|
|
44
|
-
- '
|
|
44
|
+
- '566'
|
|
45
45
|
body:
|
|
46
46
|
encoding: ASCII-8BIT
|
|
47
|
-
string: <?xml version="1.0" encoding="utf-8"?><Content><Items count="1"><Device><ID>2</ID><User><ID>
|
|
48
|
-
|
|
47
|
+
string: <?xml version="1.0" encoding="utf-8"?><Content><Items count="1"><Device><ID>2</ID><User><ID>3</ID></User><Enrollment><ID>9</ID><User><ID>3</ID></User></Enrollment><OnlineStatus>Active</OnlineStatus><LastReported>29.10.2021
|
|
48
|
+
07:55:57</LastReported><LastReportedDays>0</LastReportedDays><LastReportedHours>6</LastReportedHours><LastReportedMinutes>342</LastReportedMinutes><IPAddress>149.62.159.244</IPAddress><MACAddress>DC:71:96:FB:8A:56</MACAddress><Platform>WindowsDesktop</Platform><OSVersionName>Windows
|
|
49
49
|
10 Home (20H2)</OSVersionName><Client><ID>2</ID></Client><ConfigProfileDeployments
|
|
50
|
-
/><Status>AutoGenerated</Status><Created>29.04.2021 13:01:04</Created><Modified>
|
|
51
|
-
|
|
52
|
-
recorded_at:
|
|
50
|
+
/><Status>AutoGenerated</Status><Created>29.04.2021 13:01:04</Created><Modified>28.09.2021
|
|
51
|
+
15:32:10</Modified><Source>MiradoreOnline</Source></Device></Items></Content>
|
|
52
|
+
recorded_at: Fri, 29 Oct 2021 13:37:41 GMT
|
|
53
53
|
recorded_with: VCR 6.0.0
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: patch
|
|
5
|
+
uri: https://test634.online.miradore.com/API/v2/Device/9/
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: '{"category":"Laptops","friendlyname":"Eduard personal","userEmailAddress":"eduard@rzilient.club","location":["Barcelona"],"tags":["Personal"],"ownershipStartDate":"2021-11-03
|
|
9
|
+
10:25:18 +0100"}'
|
|
10
|
+
headers:
|
|
11
|
+
Content-Type:
|
|
12
|
+
- application/json
|
|
13
|
+
Accept:
|
|
14
|
+
- application/json
|
|
15
|
+
X-Api-Key:
|
|
16
|
+
-
|
|
17
|
+
Accept-Encoding:
|
|
18
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
19
|
+
User-Agent:
|
|
20
|
+
- Ruby
|
|
21
|
+
response:
|
|
22
|
+
status:
|
|
23
|
+
code: 200
|
|
24
|
+
message: OK
|
|
25
|
+
headers:
|
|
26
|
+
Server:
|
|
27
|
+
- Microsoft-IIS/10.0
|
|
28
|
+
X-Frame-Options:
|
|
29
|
+
- SAMEORIGIN
|
|
30
|
+
- SAMEORIGIN
|
|
31
|
+
Date:
|
|
32
|
+
- Wed, 03 Nov 2021 09:25:18 GMT
|
|
33
|
+
Content-Length:
|
|
34
|
+
- '0'
|
|
35
|
+
body:
|
|
36
|
+
encoding: UTF-8
|
|
37
|
+
string: ''
|
|
38
|
+
recorded_at: Wed, 03 Nov 2021 09:25:19 GMT
|
|
39
|
+
recorded_with: VCR 6.0.0
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: put
|
|
5
|
+
uri: https://test634.online.miradore.com/API/v2/Device/9/category
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: '"Laptops"'
|
|
9
|
+
headers:
|
|
10
|
+
Content-Type:
|
|
11
|
+
- application/json
|
|
12
|
+
Accept:
|
|
13
|
+
- application/json
|
|
14
|
+
X-Api-Key:
|
|
15
|
+
-
|
|
16
|
+
Accept-Encoding:
|
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
18
|
+
User-Agent:
|
|
19
|
+
- Ruby
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 200
|
|
23
|
+
message: OK
|
|
24
|
+
headers:
|
|
25
|
+
Content-Type:
|
|
26
|
+
- application/json; charset=utf-8
|
|
27
|
+
Server:
|
|
28
|
+
- Microsoft-IIS/10.0
|
|
29
|
+
X-Frame-Options:
|
|
30
|
+
- SAMEORIGIN
|
|
31
|
+
- SAMEORIGIN
|
|
32
|
+
Date:
|
|
33
|
+
- Wed, 03 Nov 2021 10:48:33 GMT
|
|
34
|
+
Content-Length:
|
|
35
|
+
- '81'
|
|
36
|
+
body:
|
|
37
|
+
encoding: UTF-8
|
|
38
|
+
string: '{"categoryID":3,"name":"Laptops","description":null,"deviceCount":2,"image":null}'
|
|
39
|
+
recorded_at: Wed, 03 Nov 2021 10:48:34 GMT
|
|
40
|
+
recorded_with: VCR 6.0.0
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: put
|
|
5
|
+
uri: https://test634.online.miradore.com/API/v2/Device/9/model
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: '{"model":"test"}'
|
|
9
|
+
headers:
|
|
10
|
+
Content-Type:
|
|
11
|
+
- application/json
|
|
12
|
+
Accept:
|
|
13
|
+
- application/json
|
|
14
|
+
X-Api-Key:
|
|
15
|
+
- 1_8,Yo-TV8QyCiBUF
|
|
16
|
+
Accept-Encoding:
|
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
18
|
+
User-Agent:
|
|
19
|
+
- Ruby
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 400
|
|
23
|
+
message: Bad Request
|
|
24
|
+
headers:
|
|
25
|
+
Content-Type:
|
|
26
|
+
- application/json; charset=utf-8
|
|
27
|
+
Server:
|
|
28
|
+
- Microsoft-IIS/10.0
|
|
29
|
+
X-Frame-Options:
|
|
30
|
+
- SAMEORIGIN
|
|
31
|
+
- SAMEORIGIN
|
|
32
|
+
Date:
|
|
33
|
+
- Wed, 03 Nov 2021 13:30:26 GMT
|
|
34
|
+
Content-Length:
|
|
35
|
+
- '2'
|
|
36
|
+
body:
|
|
37
|
+
encoding: UTF-8
|
|
38
|
+
string: "{}"
|
|
39
|
+
recorded_at: Wed, 03 Nov 2021 13:30:27 GMT
|
|
40
|
+
recorded_with: VCR 6.0.0
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: post
|
|
5
|
+
uri: https://rzilient.online.miradore.com/API/User?auth=&filters=&select=*,ID
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: |
|
|
9
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
10
|
+
<Content>
|
|
11
|
+
<Items>
|
|
12
|
+
<User>
|
|
13
|
+
<Email>jim.straw@trestacom.com</Email>
|
|
14
|
+
<Firstname>Jim</Firstname>
|
|
15
|
+
<Lastname>Straw</Lastname>
|
|
16
|
+
<PhoneNumber>123456789</PhoneNumber>
|
|
17
|
+
</User>
|
|
18
|
+
</Items>
|
|
19
|
+
</Content>
|
|
20
|
+
headers:
|
|
21
|
+
Accept-Encoding:
|
|
22
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
23
|
+
Accept:
|
|
24
|
+
- "*/*"
|
|
25
|
+
User-Agent:
|
|
26
|
+
- Ruby
|
|
27
|
+
response:
|
|
28
|
+
status:
|
|
29
|
+
code: 400
|
|
30
|
+
message: Bad Request
|
|
31
|
+
headers:
|
|
32
|
+
Cache-Control:
|
|
33
|
+
- no-cache
|
|
34
|
+
Pragma:
|
|
35
|
+
- no-cache
|
|
36
|
+
Content-Length:
|
|
37
|
+
- '179'
|
|
38
|
+
Content-Type:
|
|
39
|
+
- text/xml; charset=utf-8
|
|
40
|
+
Expires:
|
|
41
|
+
- "-1"
|
|
42
|
+
Server:
|
|
43
|
+
- Microsoft-IIS/10.0
|
|
44
|
+
X-Aspnet-Version:
|
|
45
|
+
- 4.0.30319
|
|
46
|
+
X-Frame-Options:
|
|
47
|
+
- SAMEORIGIN
|
|
48
|
+
Date:
|
|
49
|
+
- Tue, 02 Nov 2021 11:37:07 GMT
|
|
50
|
+
body:
|
|
51
|
+
encoding: UTF-8
|
|
52
|
+
string: "<Content><Error><Description>Failed to validate imported 'User':
|
|
53
|
+
Email 'jim.straw@trestacom.com' is already in use.</Description><Code>400</Code></Error></Content>"
|
|
54
|
+
recorded_at: Tue, 02 Nov 2021 11:37:08 GMT
|
|
55
|
+
- request:
|
|
56
|
+
method: post
|
|
57
|
+
uri: https://rzilient.online.miradore.com/API/User?auth=&filters=&select=*,ID
|
|
58
|
+
body:
|
|
59
|
+
encoding: UTF-8
|
|
60
|
+
string: |
|
|
61
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
62
|
+
<Content>
|
|
63
|
+
<Items>
|
|
64
|
+
<User>
|
|
65
|
+
<Email>jim.straw@trestacom.com</Email>
|
|
66
|
+
<Firstname>Jim</Firstname>
|
|
67
|
+
<Lastname>Straw</Lastname>
|
|
68
|
+
<PhoneNumber>123456789</PhoneNumber>
|
|
69
|
+
</User>
|
|
70
|
+
</Items>
|
|
71
|
+
</Content>
|
|
72
|
+
headers:
|
|
73
|
+
Accept-Encoding:
|
|
74
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
75
|
+
Accept:
|
|
76
|
+
- "*/*"
|
|
77
|
+
User-Agent:
|
|
78
|
+
- Ruby
|
|
79
|
+
response:
|
|
80
|
+
status:
|
|
81
|
+
code: 400
|
|
82
|
+
message: Bad Request
|
|
83
|
+
headers:
|
|
84
|
+
Cache-Control:
|
|
85
|
+
- no-cache
|
|
86
|
+
Pragma:
|
|
87
|
+
- no-cache
|
|
88
|
+
Content-Length:
|
|
89
|
+
- '179'
|
|
90
|
+
Content-Type:
|
|
91
|
+
- text/xml; charset=utf-8
|
|
92
|
+
Expires:
|
|
93
|
+
- "-1"
|
|
94
|
+
Server:
|
|
95
|
+
- Microsoft-IIS/10.0
|
|
96
|
+
X-Aspnet-Version:
|
|
97
|
+
- 4.0.30319
|
|
98
|
+
X-Frame-Options:
|
|
99
|
+
- SAMEORIGIN
|
|
100
|
+
Date:
|
|
101
|
+
- Tue, 02 Nov 2021 11:37:12 GMT
|
|
102
|
+
body:
|
|
103
|
+
encoding: UTF-8
|
|
104
|
+
string: "<Content><Error><Description>Failed to validate imported 'User':
|
|
105
|
+
Email 'jim.straw@trestacom.com' is already in use.</Description><Code>400</Code></Error></Content>"
|
|
106
|
+
recorded_at: Tue, 02 Nov 2021 11:37:12 GMT
|
|
107
|
+
- request:
|
|
108
|
+
method: post
|
|
109
|
+
uri: https://rzilient.online.miradore.com/API/User?auth=&filters=&select=*,ID
|
|
110
|
+
body:
|
|
111
|
+
encoding: UTF-8
|
|
112
|
+
string: |
|
|
113
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
114
|
+
<Content>
|
|
115
|
+
<Items>
|
|
116
|
+
<User>
|
|
117
|
+
<Email>jim.straw@trestacom.com</Email>
|
|
118
|
+
<Firstname>Jim</Firstname>
|
|
119
|
+
<Lastname>Straw</Lastname>
|
|
120
|
+
<PhoneNumber>123456789</PhoneNumber>
|
|
121
|
+
</User>
|
|
122
|
+
</Items>
|
|
123
|
+
</Content>
|
|
124
|
+
headers:
|
|
125
|
+
Accept-Encoding:
|
|
126
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
127
|
+
Accept:
|
|
128
|
+
- "*/*"
|
|
129
|
+
User-Agent:
|
|
130
|
+
- Ruby
|
|
131
|
+
response:
|
|
132
|
+
status:
|
|
133
|
+
code: 400
|
|
134
|
+
message: Bad Request
|
|
135
|
+
headers:
|
|
136
|
+
Cache-Control:
|
|
137
|
+
- no-cache
|
|
138
|
+
Pragma:
|
|
139
|
+
- no-cache
|
|
140
|
+
Content-Length:
|
|
141
|
+
- '179'
|
|
142
|
+
Content-Type:
|
|
143
|
+
- text/xml; charset=utf-8
|
|
144
|
+
Expires:
|
|
145
|
+
- "-1"
|
|
146
|
+
Server:
|
|
147
|
+
- Microsoft-IIS/10.0
|
|
148
|
+
X-Aspnet-Version:
|
|
149
|
+
- 4.0.30319
|
|
150
|
+
X-Frame-Options:
|
|
151
|
+
- SAMEORIGIN
|
|
152
|
+
Date:
|
|
153
|
+
- Tue, 02 Nov 2021 11:37:54 GMT
|
|
154
|
+
body:
|
|
155
|
+
encoding: UTF-8
|
|
156
|
+
string: "<Content><Error><Description>Failed to validate imported 'User':
|
|
157
|
+
Email 'jim.straw@trestacom.com' is already in use.</Description><Code>400</Code></Error></Content>"
|
|
158
|
+
recorded_at: Tue, 02 Nov 2021 11:37:54 GMT
|
|
159
|
+
recorded_with: VCR 6.0.0
|
data/lib/ruby/miradore.rb
CHANGED
|
@@ -32,54 +32,58 @@ module Ruby
|
|
|
32
32
|
remove_instance_variable(:@auth) if @auth.nil?
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
#
|
|
36
|
-
# This call will perform all GET calls regardless the API version that it's calling.
|
|
37
|
-
# The version would be determined based on the superclass name.
|
|
38
|
-
# If the superclass is Request the GET will call simple_v1 which will require the item which is class name.
|
|
39
|
-
# otherwise will call to retrieve devices based on filters.
|
|
40
|
-
#
|
|
41
|
-
def self.all(**args)
|
|
42
|
-
response = JSON.parse(
|
|
43
|
-
Crack::XML.parse(
|
|
44
|
-
get(
|
|
45
|
-
Miradore.url[version] % args.merge(
|
|
46
|
-
item: object_name,
|
|
47
|
-
attribute: args.fetch(:attribute, "*"),
|
|
48
|
-
auth: args.fetch(:auth, nil),
|
|
49
|
-
filter: args.fetch(:filter, nil)
|
|
50
|
-
)
|
|
51
|
-
).body
|
|
52
|
-
).to_json,
|
|
53
|
-
quirks_mode: true
|
|
54
|
-
).dig("Content", "Items")
|
|
55
|
-
transform(response, args)
|
|
56
|
-
rescue StandardError => e
|
|
57
|
-
MiradoreError.new({ error: e&.message || "Error connecting to manager service provider", status: :not_found })
|
|
58
|
-
end
|
|
59
|
-
|
|
60
35
|
class << self
|
|
36
|
+
#
|
|
37
|
+
# This call will perform all GET calls regardless the API version that it's calling.
|
|
38
|
+
# The version would be determined based on the superclass name.
|
|
39
|
+
# If the superclass is Request the GET will call simple_v1 which will require the item which is class name.
|
|
40
|
+
# otherwise will call to retrieve devices based on filters.
|
|
41
|
+
#
|
|
42
|
+
def all(**args)
|
|
43
|
+
transform(
|
|
44
|
+
Crack::XML.parse(
|
|
45
|
+
http_method(args).body
|
|
46
|
+
).dig("Content", "Items"), args
|
|
47
|
+
)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def add(**args)
|
|
51
|
+
transform(
|
|
52
|
+
Crack::XML.parse(
|
|
53
|
+
http_method(args.merge(method: :post, attribute: "ID")).body
|
|
54
|
+
)["Content"]
|
|
55
|
+
)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
protected
|
|
59
|
+
|
|
60
|
+
def http_method(**args)
|
|
61
|
+
url = Miradore.url[version] % args.merge(
|
|
62
|
+
item: to_s.split("::").last,
|
|
63
|
+
attribute: args.fetch(:attribute, "*"),
|
|
64
|
+
auth: args.fetch(:auth, nil),
|
|
65
|
+
filter: args.fetch(:filter, nil)
|
|
66
|
+
)
|
|
67
|
+
method(args.fetch(:method, :get)).call(url, body: args.fetch(:body, nil))
|
|
68
|
+
end
|
|
69
|
+
|
|
61
70
|
private
|
|
62
71
|
|
|
63
72
|
def transform(res, args = {})
|
|
64
|
-
instance_name = "Ruby::Miradore::#{res.keys.first.capitalize}"
|
|
65
73
|
if res.values.first.is_a?(Array)
|
|
66
74
|
return res.values.first.map! do |e|
|
|
67
|
-
|
|
75
|
+
const_get(to_s).new(args.merge(e.transform_keys(&:downcase)))
|
|
68
76
|
end
|
|
69
77
|
end
|
|
70
|
-
|
|
71
|
-
Object.const_get(instance_name).new(args.merge(res.values.first&.transform_keys(&:downcase)))
|
|
78
|
+
const_get(to_s).new(args.merge(res.values.first&.transform_keys(&:downcase)))
|
|
72
79
|
rescue StandardError
|
|
73
|
-
|
|
80
|
+
{ error: "#{to_s.split("::").last}(s) not found", status: :not_found }
|
|
74
81
|
end
|
|
75
82
|
|
|
76
83
|
def version
|
|
77
84
|
superclass == Object ? :request_v1 : :item_v1
|
|
78
85
|
end
|
|
79
86
|
|
|
80
|
-
def object_name
|
|
81
|
-
to_s.split("::").last
|
|
82
|
-
end
|
|
83
87
|
end
|
|
84
88
|
|
|
85
89
|
end
|
|
@@ -114,8 +118,36 @@ module Ruby
|
|
|
114
118
|
http_method(args.merge(method: :get, action: __method__))
|
|
115
119
|
end
|
|
116
120
|
|
|
121
|
+
def family(**args)
|
|
122
|
+
http_method(args.merge(method: :put, action: :category))
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def model(**args)
|
|
126
|
+
http_method(args.merge(method: :put, action: __method__))
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def device_serial_number
|
|
130
|
+
invdevice.serial_number || invdevice.hardware_serial_number
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def device_model
|
|
134
|
+
invdevice.marketing_name || invdevice.product_name
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def online?
|
|
138
|
+
onlinestatus.downcase.to_sym == :active
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def phone?
|
|
142
|
+
!!invdevice&.imei
|
|
143
|
+
end
|
|
144
|
+
|
|
117
145
|
def patch(**args)
|
|
118
|
-
http_method(args.merge(method:
|
|
146
|
+
http_method(args.merge(method: __method__))
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def post(**args)
|
|
150
|
+
http_method(args.merge(method: __method__))
|
|
119
151
|
end
|
|
120
152
|
|
|
121
153
|
private
|
|
@@ -138,6 +170,5 @@ module Ruby
|
|
|
138
170
|
|
|
139
171
|
class Organization < Request; end
|
|
140
172
|
|
|
141
|
-
class MiradoreError < Request; end
|
|
142
173
|
end
|
|
143
174
|
end
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/ruby-miradore.gemspec
CHANGED
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
|
12
12
|
spec.description = "Miradore MSP Ruby Gem"
|
|
13
13
|
spec.homepage = "https://github.com/eddygarcas/ruby-miradore"
|
|
14
14
|
spec.license = "MIT"
|
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.
|
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.4")
|
|
16
16
|
|
|
17
17
|
spec.metadata["allowed_push_host"] = "https://rubygems.org/"
|
|
18
18
|
|
|
@@ -31,6 +31,8 @@ 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 "activesupport", "~> 6.1"
|
|
35
|
+
#spec.add_dependency 'builder', '~> 3.1'
|
|
34
36
|
spec.add_dependency "crack", "~> 0.4"
|
|
35
37
|
spec.add_dependency "finest-builder", "~> 1.0"
|
|
36
38
|
spec.add_dependency "httparty", "~> 0.18"
|
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: 2.
|
|
4
|
+
version: 2.2.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eduard Garcia Castelló
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-11-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: crack
|
|
@@ -122,20 +122,25 @@ files:
|
|
|
122
122
|
- fixtures/vcr_cassettes/Get__Mobile_Device.yml
|
|
123
123
|
- fixtures/vcr_cassettes/InvDevice.yml
|
|
124
124
|
- fixtures/vcr_cassettes/LockDevice_all.yml
|
|
125
|
+
- fixtures/vcr_cassettes/add_new_other_device.yml
|
|
125
126
|
- fixtures/vcr_cassettes/all_criteria.yml
|
|
126
127
|
- fixtures/vcr_cassettes/auth_not_found.yml
|
|
127
128
|
- fixtures/vcr_cassettes/error_by_serial_number.yml
|
|
128
129
|
- fixtures/vcr_cassettes/full_list_and_details.yml
|
|
130
|
+
- fixtures/vcr_cassettes/get_computer_device_to_update.yml
|
|
131
|
+
- fixtures/vcr_cassettes/get_computer_device_to_update_2.yml
|
|
129
132
|
- fixtures/vcr_cassettes/get_location.yml
|
|
130
133
|
- fixtures/vcr_cassettes/get_user_from_miradore.yml
|
|
131
134
|
- fixtures/vcr_cassettes/search_by_serial_number.yml
|
|
135
|
+
- fixtures/vcr_cassettes/update_model_of_a_computer_device.yml
|
|
136
|
+
- fixtures/vcr_cassettes/update_model_of_a_computer_device_v2.yml
|
|
137
|
+
- fixtures/vcr_cassettes/update_model_of_a_computer_device_v2_2.yml
|
|
138
|
+
- fixtures/vcr_cassettes/user_alredy_exist_in_miradore.yml
|
|
132
139
|
- lib/ruby/miradore.rb
|
|
133
140
|
- lib/ruby/miradore/version.rb
|
|
134
|
-
- ruby-miradore-0.1.
|
|
135
|
-
- ruby-miradore-0.
|
|
136
|
-
- ruby-miradore-
|
|
137
|
-
- ruby-miradore-1.1.1.gem
|
|
138
|
-
- ruby-miradore-1.2.2.gem
|
|
141
|
+
- ruby-miradore-2.0.1.gem
|
|
142
|
+
- ruby-miradore-2.0.2.gem
|
|
143
|
+
- ruby-miradore-2.1.2.gem
|
|
139
144
|
- ruby-miradore.gemspec
|
|
140
145
|
homepage: https://github.com/eddygarcas/ruby-miradore
|
|
141
146
|
licenses:
|
|
@@ -153,7 +158,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
153
158
|
requirements:
|
|
154
159
|
- - ">="
|
|
155
160
|
- !ruby/object:Gem::Version
|
|
156
|
-
version: 2.7.
|
|
161
|
+
version: 2.7.4
|
|
157
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
163
|
requirements:
|
|
159
164
|
- - ">="
|
data/ruby-miradore-0.1.2.gem
DELETED
|
Binary file
|
data/ruby-miradore-0.1.3.gem
DELETED
|
Binary file
|
data/ruby-miradore-1.1.0.gem
DELETED
|
Binary file
|
data/ruby-miradore-1.1.1.gem
DELETED
|
Binary file
|
data/ruby-miradore-1.2.2.gem
DELETED
|
Binary file
|