ruby-miradore 4.3.1 → 4.4.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: e723736ca0d695530b9e1542255704218bc0393916fb2fb43594f2207da3fb79
4
- data.tar.gz: b358ae47df701554c332186f0c9b089e0110368710cd9e41387918610ed6ea17
3
+ metadata.gz: 6970f265b7922dee506ea4625614c650157fa9c1205d3e411e5e70811a0f626a
4
+ data.tar.gz: 31aaa50424e7d70b8e3c58349bb3a9e0954ad27441a6f7cf2f8381f851e23d3a
5
5
  SHA512:
6
- metadata.gz: dc59038d193e6ad6392a327ddbf342907f05e4b805914c27c72bf71c41ac6175608cba59dcb20da2df3d1e69e8d1191af269e9f4cc3c08edb942483795616c1b
7
- data.tar.gz: 4cb5771a916087dbbb2b924890f98117e13ad0222a890e0d225f38caa9cd23190216b90d424646c5f2d6840b16fded3bfe65e81529b250fd670d85d8e8e763a8
6
+ metadata.gz: 20d16bf2aa88223b73c7964d6419407b505b7d39a1af4eca02670b06a0a893768ade53003e151453a4b1a05feaae16dbc3e9078957efeedc9dfc6d98fe215493
7
+ data.tar.gz: 60d40d8faedfb94a2c8121edd0b2ec86865e17467e66736007a16e9ecaa08345d45f867aff2968e91cd3bd9509c7cf72147e219576ff21d77337e29e194eaf34
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.0"
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,15 @@ 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'
18
- }
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
+
21
+ # Setup data from initializer
22
+ def self.setup
23
+ yield(self)
19
24
  end
20
25
 
21
26
  class Request
@@ -25,11 +30,11 @@ module Ruby
25
30
 
26
31
  attr_writer :subdomain, :auth, :json
27
32
 
28
- def initialize(json = {})
29
- super json
30
- @subdomain ||= json[:subdomain]
31
- @auth ||= json[:auth]
32
- @json ||= json.to_json
33
+ def initialize(args = {})
34
+ super args
35
+ @subdomain ||= args[:subdomain]
36
+ @auth ||= args[:auth]
37
+ @json ||= args.to_json
33
38
  remove_instance_variable(:@subdomain) if @subdomain.nil?
34
39
  remove_instance_variable(:@auth) if @auth.nil?
35
40
  end
@@ -40,18 +45,18 @@ module Ruby
40
45
  # If the superclass is Request the GET will call simple_v1 which will require the item which is class name.
41
46
  # otherwise will call to retrieve devices based on filters.
42
47
  #
43
- def all(**args)
48
+ def all(args = {})
44
49
  transform(
45
50
  Crack::XML.parse(
46
- http_method_v1(**args).body
51
+ http_method_v1(args).body
47
52
  ).dig('Content', 'Items'), args
48
53
  )
49
54
  end
50
55
 
51
- def call(**args)
56
+ def call(args = {})
52
57
  transform(
53
58
  Crack::XML.parse(
54
- http_method_v1(**args.merge(attribute: 'ID')).body
59
+ http_method_v1(args.merge(attribute: 'ID')).body
55
60
  )['Content'], args
56
61
  )
57
62
  end
@@ -60,8 +65,7 @@ module Ruby
60
65
  @json
61
66
  end
62
67
 
63
-
64
- def http_method_v1(**args)
68
+ def http_method_v1(args)
65
69
  url = Miradore.url[:v1] % args.merge(
66
70
  subdomain: @subdomain || args[:subdomain],
67
71
  auth: args.fetch(:auth, @auth),
@@ -96,48 +100,48 @@ module Ruby
96
100
  headers "Content-Type": 'application/json'
97
101
  headers "Accept": 'application/json'
98
102
 
99
- def initialize(json = {})
100
- super json
103
+ def initialize(args = {})
104
+ super args
101
105
  end
102
106
 
103
- def lock(**args)
104
- http_method(**args.merge(method: :post, id: id, action: __method__))
107
+ def lock(args = {})
108
+ http_method(args.merge(method: :post, id: id, action: __method__))
105
109
  end
106
110
 
107
- def lostmode(**args)
111
+ def lostmode(args = {})
108
112
  if args[0]
109
- http_method(**args.merge(method: :post, id: id, action: __method__))
113
+ http_method(args.merge(method: :post, id: id, action: __method__))
110
114
  else
111
- http_method(**args.merge(method: :delete, id: id, action: __method__))
115
+ http_method(args.merge(method: :delete, id: id, action: __method__))
112
116
  end
113
117
  end
114
118
 
115
- def reboot(**args)
116
- http_method(**args.merge(method: :post, id: id, action: __method__))
119
+ def reboot(args = {})
120
+ http_method(args.merge(method: :post, id: id, action: __method__))
117
121
  end
118
122
 
119
- def wipe(**args)
120
- http_method(**args.merge(method: :post, id: id, action: __method__))
123
+ def wipe(args = {})
124
+ http_method(args.merge(method: :post, id: id, action: __method__))
121
125
  end
122
126
 
123
- def location(**args)
124
- http_method(**args.merge(method: :get, action: __method__))
127
+ def location(args = {})
128
+ http_method(args.merge(method: :get, action: __method__))
125
129
  end
126
130
 
127
- def family(**args)
128
- http_method(**args.merge(method: :put, action: :category))
131
+ def family(args = {})
132
+ http_method(args.merge(method: :put, action: :category))
129
133
  end
130
134
 
131
- def model(**args)
132
- http_method(**args.merge(method: :put, action: __method__))
135
+ def model(args = {})
136
+ http_method(args.merge(method: :put, action: __method__))
133
137
  end
134
138
 
135
- def activate(**args)
136
- http_method(**args.merge(method: :post, action: __method__))
139
+ def activate(args = {})
140
+ http_method(args.merge(method: :post, action: __method__))
137
141
  end
138
142
 
139
- def retire(**args)
140
- http_method(**args.merge(method: :delete, id: id, action: nil))
143
+ def retire(args = {})
144
+ http_method(args.merge(method: :delete, id: id, action: nil))
141
145
  end
142
146
 
143
147
  def device_serial_number
@@ -153,16 +157,16 @@ module Ruby
153
157
  end
154
158
 
155
159
  def phone?
156
- %w[Android iOS WindowsPhone].include?(platform)
160
+ Miradore.phone_types.include?(platform)
157
161
  end
158
162
 
159
- def call(**args)
160
- http_method(**args)
163
+ def call(args = {})
164
+ http_method(args)
161
165
  end
162
166
 
163
167
  private
164
168
 
165
- def http_method(**args)
169
+ def http_method(args)
166
170
  self.class.headers 'X-API-Key' => @auth || args[:auth]
167
171
  url = Miradore.url[:v2] % {
168
172
  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.0
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-21 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