ruby-miradore 4.3.1 → 4.4.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: e723736ca0d695530b9e1542255704218bc0393916fb2fb43594f2207da3fb79
4
- data.tar.gz: b358ae47df701554c332186f0c9b089e0110368710cd9e41387918610ed6ea17
3
+ metadata.gz: c854cbb5ab9cac28c6e4fb8c1d913f96531c54eaf0463a5c931d48020c045b40
4
+ data.tar.gz: 16db5100e8b11468ff2da6edeb797a135a30638882b97cefb33ca18adc815c1f
5
5
  SHA512:
6
- metadata.gz: dc59038d193e6ad6392a327ddbf342907f05e4b805914c27c72bf71c41ac6175608cba59dcb20da2df3d1e69e8d1191af269e9f4cc3c08edb942483795616c1b
7
- data.tar.gz: 4cb5771a916087dbbb2b924890f98117e13ad0222a890e0d225f38caa9cd23190216b90d424646c5f2d6840b16fded3bfe65e81529b250fd670d85d8e8e763a8
6
+ metadata.gz: 0b2e17d1750e09479355f82b4f14ced4c4273d712c6459449b71be3ec6d21482305748f75b6f3000e892cec72ac461e87145e8bf042e09bb36c798caa023d125
7
+ data.tar.gz: 944315dd81361acb3b6b283434b053a29b45499c3e947e04de03c5ae588c1a8819a6695eb75f1d72396bb11ff339f2d009ad585dbb1c2b8d92b5a69abfa28ec3
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.2
1
+ 3.2.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-miradore (4.3.1)
4
+ ruby-miradore (4.4.1)
5
5
  activesupport (~> 7.0)
6
6
  builder (~> 3.1)
7
7
  crack (~> 0.4)
@@ -14,7 +14,7 @@ PATH
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- activesupport (7.0.4)
17
+ activesupport (7.0.4.2)
18
18
  concurrent-ruby (~> 1.0, >= 1.0.2)
19
19
  i18n (>= 1.6, < 2)
20
20
  minitest (>= 5.1)
@@ -23,60 +23,58 @@ GEM
23
23
  public_suffix (>= 2.0.2, < 6.0)
24
24
  ast (2.4.2)
25
25
  builder (3.2.4)
26
- concurrent-ruby (1.1.10)
26
+ concurrent-ruby (1.2.0)
27
27
  crack (0.4.5)
28
28
  rexml
29
29
  diff-lcs (1.5.0)
30
30
  finest-builder (2.0.0)
31
31
  hashdiff (1.0.1)
32
- httparty (0.20.0)
33
- mime-types (~> 3.0)
32
+ httparty (0.21.0)
33
+ mini_mime (>= 1.0.0)
34
34
  multi_xml (>= 0.5.2)
35
35
  i18n (1.12.0)
36
36
  concurrent-ruby (~> 1.0)
37
- json (2.6.2)
38
- mime-types (3.4.1)
39
- mime-types-data (~> 3.2015)
40
- mime-types-data (3.2022.0105)
41
- minitest (5.16.3)
37
+ json (2.6.3)
38
+ mini_mime (1.1.2)
39
+ minitest (5.17.0)
42
40
  multi_xml (0.6.0)
43
41
  parallel (1.22.1)
44
- parser (3.1.2.1)
42
+ parser (3.2.1.0)
45
43
  ast (~> 2.4.1)
46
- public_suffix (5.0.0)
44
+ public_suffix (5.0.1)
47
45
  rainbow (3.1.1)
48
46
  rake (13.0.6)
49
- regexp_parser (2.6.0)
47
+ regexp_parser (2.7.0)
50
48
  rexml (3.2.5)
51
49
  rspec (3.12.0)
52
50
  rspec-core (~> 3.12.0)
53
51
  rspec-expectations (~> 3.12.0)
54
52
  rspec-mocks (~> 3.12.0)
55
- rspec-core (3.12.0)
53
+ rspec-core (3.12.1)
56
54
  rspec-support (~> 3.12.0)
57
- rspec-expectations (3.12.0)
55
+ rspec-expectations (3.12.2)
58
56
  diff-lcs (>= 1.2.0, < 2.0)
59
57
  rspec-support (~> 3.12.0)
60
- rspec-mocks (3.12.0)
58
+ rspec-mocks (3.12.3)
61
59
  diff-lcs (>= 1.2.0, < 2.0)
62
60
  rspec-support (~> 3.12.0)
63
61
  rspec-support (3.12.0)
64
- rubocop (1.39.0)
62
+ rubocop (1.45.1)
65
63
  json (~> 2.3)
66
64
  parallel (~> 1.10)
67
- parser (>= 3.1.2.1)
65
+ parser (>= 3.2.0.0)
68
66
  rainbow (>= 2.2.2, < 4.0)
69
67
  regexp_parser (>= 1.8, < 3.0)
70
68
  rexml (>= 3.2.5, < 4.0)
71
- rubocop-ast (>= 1.23.0, < 2.0)
69
+ rubocop-ast (>= 1.24.1, < 2.0)
72
70
  ruby-progressbar (~> 1.7)
73
- unicode-display_width (>= 1.4.0, < 3.0)
74
- rubocop-ast (1.23.0)
75
- parser (>= 3.1.1.0)
71
+ unicode-display_width (>= 2.4.0, < 3.0)
72
+ rubocop-ast (1.26.0)
73
+ parser (>= 3.2.1.0)
76
74
  ruby-progressbar (1.11.0)
77
- tzinfo (2.0.5)
75
+ tzinfo (2.0.6)
78
76
  concurrent-ruby (~> 1.0)
79
- unicode-display_width (2.3.0)
77
+ unicode-display_width (2.4.2)
80
78
  vcr (6.1.0)
81
79
  webmock (3.18.1)
82
80
  addressable (>= 2.8.0)
@@ -93,4 +91,4 @@ DEPENDENCIES
93
91
  webmock
94
92
 
95
93
  BUNDLED WITH
96
- 2.3.25
94
+ 2.4.5
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: patch
5
+ uri: https://test634.online.miradore.com/API/v2/Device/13/
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"userEmailAddress":"eduard@rzilient.club"}'
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: 401
23
+ message: Unauthorized
24
+ headers:
25
+ Content-Type:
26
+ - text/plain
27
+ Server:
28
+ - Microsoft-IIS/10.0
29
+ X-Content-Type-Options:
30
+ - nosniff
31
+ X-Frame-Options:
32
+ - SAMEORIGIN
33
+ Referrer-Policy:
34
+ - same-origin
35
+ Strict-Transport-Security:
36
+ - max-age=31536000; includeSubDomains
37
+ Date:
38
+ - Tue, 25 Oct 2022 10:51:38 GMT
39
+ Content-Length:
40
+ - '530'
41
+ body:
42
+ encoding: UTF-8
43
+ string: 'Status Code: 401; Unauthorized '
44
+ recorded_at: Tue, 25 Oct 2022 10:51:39 GMT
45
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: patch
5
+ uri: https://rzilient.online.miradore.com/API/v2/Device//
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"userEmailAddress":"eduard@rzilient.club"}'
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: 404
23
+ message: Not Found
24
+ headers:
25
+ Content-Type:
26
+ - text/plain
27
+ Server:
28
+ - Microsoft-IIS/10.0
29
+ X-Content-Type-Options:
30
+ - nosniff
31
+ X-Frame-Options:
32
+ - SAMEORIGIN
33
+ Referrer-Policy:
34
+ - same-origin
35
+ Strict-Transport-Security:
36
+ - max-age=31536000; includeSubDomains
37
+ Date:
38
+ - Tue, 25 Oct 2022 10:50:52 GMT
39
+ Content-Length:
40
+ - '527'
41
+ body:
42
+ encoding: UTF-8
43
+ string: 'Status Code: 404; Not Found '
44
+ recorded_at: Tue, 25 Oct 2022 10:50:52 GMT
45
+ recorded_with: VCR 6.0.0
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ruby
4
4
  module Miradore
5
- VERSION = "4.3.1"
5
+ VERSION = '4.4.1'
6
6
  end
7
7
  end
data/lib/ruby/miradore.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require_relative 'miradore/version'
4
4
  require 'active_support/isolated_execution_state'
5
5
  require 'active_support/core_ext/hash/conversions'
6
+ require 'active_support/core_ext/module/attribute_accessors'
6
7
  require 'httparty'
7
8
  require 'json'
8
9
  require 'crack/xml'
@@ -11,11 +12,25 @@ require 'finest/builder'
11
12
  module Ruby
12
13
  module Miradore
13
14
 
14
- def self.url
15
- {
16
- v1: 'https://%<subdomain>s.online.miradore.com/API/%<item>s/%<id>s?auth=%<auth>s&select=*,%<attribute>s&filters=%<filter>s&options=%<options>s',
17
- v2: 'https://%<subdomain>s.online.miradore.com/API/v2/Device/%<id>s/%<method>s'
15
+ mattr_accessor :url, default: {
16
+ v1: 'https://%<subdomain>s.online.miradore.com/API/%<item>s/%<id>s?auth=%<auth>s&select=*,%<attribute>s&filters=%<filter>s&options=%<options>s',
17
+ v2: 'https://%<subdomain>s.online.miradore.com/API/v2/Device/%<id>s/%<method>s'
18
+ }
19
+ mattr_accessor :phone_types, default: %w[Android iOS WindowsPhone]
20
+ mattr_accessor :commands, default: {
21
+ mobile: {
22
+ lostmode: {
23
+ message: 'This device has been reported as lost and its location has been identified, please return before authorities arrive.',
24
+ phoneNumber: '',
25
+ footnote: 'Contact Support team to unlock.',
26
+ enableLocationTracking: true
27
+ }
18
28
  }
29
+ }
30
+
31
+ # Setup data from initializer
32
+ def self.setup
33
+ yield(self)
19
34
  end
20
35
 
21
36
  class Request
@@ -25,11 +40,11 @@ module Ruby
25
40
 
26
41
  attr_writer :subdomain, :auth, :json
27
42
 
28
- def initialize(json = {})
29
- super json
30
- @subdomain ||= json[:subdomain]
31
- @auth ||= json[:auth]
32
- @json ||= json.to_json
43
+ def initialize(args = {})
44
+ super args
45
+ @subdomain ||= args[:subdomain]
46
+ @auth ||= args[:auth]
47
+ @json ||= args.to_json
33
48
  remove_instance_variable(:@subdomain) if @subdomain.nil?
34
49
  remove_instance_variable(:@auth) if @auth.nil?
35
50
  end
@@ -40,18 +55,18 @@ module Ruby
40
55
  # If the superclass is Request the GET will call simple_v1 which will require the item which is class name.
41
56
  # otherwise will call to retrieve devices based on filters.
42
57
  #
43
- def all(**args)
58
+ def all(args = {})
44
59
  transform(
45
60
  Crack::XML.parse(
46
- http_method_v1(**args).body
61
+ http_method_v1(args).body
47
62
  ).dig('Content', 'Items'), args
48
63
  )
49
64
  end
50
65
 
51
- def call(**args)
66
+ def call(args = {})
52
67
  transform(
53
68
  Crack::XML.parse(
54
- http_method_v1(**args.merge(attribute: 'ID')).body
69
+ http_method_v1(args.merge(attribute: 'ID')).body
55
70
  )['Content'], args
56
71
  )
57
72
  end
@@ -60,8 +75,7 @@ module Ruby
60
75
  @json
61
76
  end
62
77
 
63
-
64
- def http_method_v1(**args)
78
+ def http_method_v1(args)
65
79
  url = Miradore.url[:v1] % args.merge(
66
80
  subdomain: @subdomain || args[:subdomain],
67
81
  auth: args.fetch(:auth, @auth),
@@ -85,7 +99,7 @@ module Ruby
85
99
  end
86
100
  self.class.new(args.merge(res.values.first&.transform_keys(&:downcase)))
87
101
  rescue StandardError
88
- { error: "#{self.class.to_s.split("::").last}(s) not found", status: :not_found }
102
+ { error: "#{self.class.to_s.split('::').last}(s) not found", status: :not_found }
89
103
  end
90
104
 
91
105
  end
@@ -96,48 +110,48 @@ module Ruby
96
110
  headers "Content-Type": 'application/json'
97
111
  headers "Accept": 'application/json'
98
112
 
99
- def initialize(json = {})
100
- super json
113
+ def initialize(args = {})
114
+ super args
101
115
  end
102
116
 
103
- def lock(**args)
104
- http_method(**args.merge(method: :post, id: id, action: __method__))
117
+ def lock(args = {})
118
+ http_method(args.merge(method: :post, id: id, action: __method__))
105
119
  end
106
120
 
107
- def lostmode(**args)
108
- if args[0]
109
- http_method(**args.merge(method: :post, id: id, action: __method__))
121
+ def lostmode(args = {})
122
+ if args.fetch(:enable, false)
123
+ http_method(args.merge(method: :post, id: id, action: __method__, body: Miradore.commands[:mobile][:lostmode]))
110
124
  else
111
- http_method(**args.merge(method: :delete, id: id, action: __method__))
125
+ http_method(args.merge(method: :delete, id: id, action: __method__))
112
126
  end
113
127
  end
114
128
 
115
- def reboot(**args)
116
- http_method(**args.merge(method: :post, id: id, action: __method__))
129
+ def reboot(args = {})
130
+ http_method(args.merge(method: :post, id: id, action: __method__))
117
131
  end
118
132
 
119
- def wipe(**args)
120
- http_method(**args.merge(method: :post, id: id, action: __method__))
133
+ def wipe(args = {})
134
+ http_method(args.merge(method: :post, id: id, action: __method__))
121
135
  end
122
136
 
123
- def location(**args)
124
- http_method(**args.merge(method: :get, action: __method__))
137
+ def location(args = {})
138
+ http_method(args.merge(method: :get, action: __method__))
125
139
  end
126
140
 
127
- def family(**args)
128
- http_method(**args.merge(method: :put, action: :category))
141
+ def family(args = {})
142
+ http_method(args.merge(method: :put, action: :category))
129
143
  end
130
144
 
131
- def model(**args)
132
- http_method(**args.merge(method: :put, action: __method__))
145
+ def model(args = {})
146
+ http_method(args.merge(method: :put, action: __method__))
133
147
  end
134
148
 
135
- def activate(**args)
136
- http_method(**args.merge(method: :post, action: __method__))
149
+ def activate(args = {})
150
+ http_method(args.merge(method: :post, action: __method__))
137
151
  end
138
152
 
139
- def retire(**args)
140
- http_method(**args.merge(method: :delete, id: id, action: nil))
153
+ def retire(args = {})
154
+ http_method(args.merge(method: :delete, id: id, action: nil))
141
155
  end
142
156
 
143
157
  def device_serial_number
@@ -153,16 +167,16 @@ module Ruby
153
167
  end
154
168
 
155
169
  def phone?
156
- %w[Android iOS WindowsPhone].include?(platform)
170
+ Miradore.phone_types.include?(platform)
157
171
  end
158
172
 
159
- def call(**args)
160
- http_method(**args)
173
+ def call(args = {})
174
+ http_method(args)
161
175
  end
162
176
 
163
177
  private
164
178
 
165
- def http_method(**args)
179
+ def http_method(args)
166
180
  self.class.headers 'X-API-Key' => @auth || args[:auth]
167
181
  url = Miradore.url[:v2] % {
168
182
  subdomain: @subdomain || args[:subdomain],
@@ -3,16 +3,16 @@
3
3
  require_relative "lib/ruby/miradore/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "ruby-miradore"
7
- spec.version = Ruby::Miradore::VERSION
8
- spec.authors = ["Eduard Garcia Castelló"]
9
- spec.email = %w[edugarcas@gmail.com eduard@rzilient.club]
6
+ spec.name = "ruby-miradore"
7
+ spec.version = Ruby::Miradore::VERSION
8
+ spec.authors = ["Eduard Garcia Castelló"]
9
+ spec.email = %w[edugarcas@gmail.com eduard@rzilient.club]
10
10
 
11
- spec.summary = "Miradore is a MSP providing an API to get devices information as well s perform some security actions."
12
- spec.description = "Miradore MSP Ruby Gem"
13
- spec.homepage = "https://github.com/eddygarcas/ruby-miradore"
14
- spec.license = "MIT"
15
- spec.required_ruby_version = Gem::Requirement.new(">= 3.1.2")
11
+ spec.summary = "Miradore is a MSP providing an API to get devices information as well s perform some security actions."
12
+ spec.description = "Miradore MSP Ruby Gem"
13
+ spec.homepage = "https://github.com/eddygarcas/ruby-miradore"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.2.0")
16
16
 
17
17
  spec.metadata["allowed_push_host"] = "https://rubygems.org/"
18
18
 
@@ -25,8 +25,8 @@ Gem::Specification.new do |spec|
25
25
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
26
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
27
27
  end
28
- spec.bindir = "exe"
29
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ["lib"]
31
31
 
32
32
  # Uncomment to register a new dependency of your gem
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-miradore
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.1
4
+ version: 4.4.1
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: 2022-11-14 00:00:00.000000000 Z
11
+ date: 2023-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -143,6 +143,8 @@ files:
143
143
  - Rakefile
144
144
  - bin/console
145
145
  - bin/setup
146
+ - fixtures/vcr_cassettes/Change_User_Email_Address.yml
147
+ - fixtures/vcr_cassettes/Change_User_Email_Address_Error.yml
146
148
  - fixtures/vcr_cassettes/Change_User_Email_Address_Without_v1.yml
147
149
  - fixtures/vcr_cassettes/Get_Device_Location.yml
148
150
  - fixtures/vcr_cassettes/Get__Mobile_Device.yml
@@ -186,14 +188,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
186
188
  requirements:
187
189
  - - ">="
188
190
  - !ruby/object:Gem::Version
189
- version: 3.1.2
191
+ version: 3.2.0
190
192
  required_rubygems_version: !ruby/object:Gem::Requirement
191
193
  requirements:
192
194
  - - ">="
193
195
  - !ruby/object:Gem::Version
194
196
  version: '0'
195
197
  requirements: []
196
- rubygems_version: 3.3.7
198
+ rubygems_version: 3.4.1
197
199
  signing_key:
198
200
  specification_version: 4
199
201
  summary: Miradore is a MSP providing an API to get devices information as well s perform