alula-ruby 0.54.0 → 0.55.0

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: 5fe8c069cbf129ad7f52be697c4159cad1e78ef655316eae5ee26de2e184a8df
4
- data.tar.gz: cdcda384977cae4869f73892f8a0f309f2965be5b180b56500f0453dc1da27df
3
+ metadata.gz: 7c65ba0c26beba1371c3637219cc8e0177f6b2f75d21d74a1f08173f7ddd9ae4
4
+ data.tar.gz: f53a3c944df2be8b2db9b6c13caddcf919706de53b38f3c18c7d5621bbb3b48e
5
5
  SHA512:
6
- metadata.gz: 7ff734d5a1ab9e49a77262d7f7b8aa05676bb526e123351f89dc4e6984f1b842fbb6b69502e8d54ddf0fb384d722d0fd23d02d0c1d052ccbc0a79bd16fd6feaf
7
- data.tar.gz: b7cdcdeb6fd33066c52b8cd1f6a4ba274bfa4c793f14cc6165b547da5e32110d112135156c370d8aaf3a782e25f7c9406904697b4847730fd6c1387e99fea6c4
6
+ metadata.gz: c63fd1baee26d1c821a2787fd7f2ab26ed76292e11c74b6148a1f567b1c25a282d28509d3cd3ed4e8be9b55b4f89dfd1e4374377588af2c59e87179975678387
7
+ data.tar.gz: 296cde15d36f05120a947fcaaedaf9f8dfe0f95d60bce233178ff84eca65f2c881ab301bf1830594166b8079e445bc3144afc5f2b5147091193014dbdaee397f
data/.rspec CHANGED
@@ -1,3 +1 @@
1
- --format documentation
2
- --color
3
1
  --require spec_helper
data/README.md CHANGED
@@ -40,21 +40,23 @@ creds = Alula::Oauth.authenticate(username: "a username", password: "a password"
40
40
  ```
41
41
 
42
42
  ## Configuring
43
-
43
+ There are two types of settings in the `Alula::Client` configuration:
44
+ The first one are the ones that will have a fixed value in the application lifecicle so its better to put them in an initializer.
44
45
  ```ruby
45
- Alula::Client.config.api_key = your API key
46
- Alula::Client.config.api_url = The environment URL you will be accessing
47
- Alula::Client.config.user_agent = A short name for your script/application
46
+ Alula::Client.configure do |c|
47
+ c.api_key = # your API key
48
+ c.debug = # if set to true will log requests to the API
49
+ c.user_agent = # A short name for your script/application
50
+ end
48
51
  ```
49
- -or-
52
+ The second one are the ones that are stored in the request Rack env, so those need to set on each request (to the application).
50
53
  ```ruby
51
54
  Alula::Client.configure do |d|
52
- c.api_key = your API key
53
- c.api_url = The environment URL you will be accessing
54
- c.user_agent = A short name for your script/application
55
+ c.api_key = # your API key
56
+ c.role = # User/Customer role
57
+ c.customer_id = # The user_id, optional, only for video API requests
55
58
  end
56
59
  ```
57
- **Note:** You will also need to add the configuration option `customer_id` to access resources of the video API.
58
60
 
59
61
  ## Usage
60
62
 
data/VERSION.md CHANGED
@@ -86,3 +86,4 @@
86
86
  | v0.52.0 | 2022-06-15 | Filter receiver connections based on station id |
87
87
  | v0.53.0 | 2022-06-15 | Filter feature plans on name |
88
88
  | v0.54.0 | 2022-06-21 | Add support for devices from the video API |
89
+ | v0.55.0 | 2022-06-25 | Add some devices helpers and improves specs |
data/lib/alula/client.rb CHANGED
@@ -14,7 +14,7 @@ module Alula
14
14
  end
15
15
 
16
16
  def configure
17
- yield config
17
+ yield config if block_given?
18
18
  end
19
19
 
20
20
  def request(http_method, resource_path, filters = {}, opts = {})
@@ -1,6 +1,7 @@
1
1
  module Alula
2
2
  class ClientConfiguration
3
- REQUEST_ATTRIBUTES = %i[api_key api_url debug customer_id user_agent]
3
+ attr_accessor :api_url, :debug, :user_agent
4
+ REQUEST_ATTRIBUTES = %i[api_key customer_id]
4
5
 
5
6
  # Using RequestStore so we're thread safe even with our non-thread-safe architecture :(
6
7
  REQUEST_ATTRIBUTES.each do |prop|
@@ -31,6 +31,21 @@ module Alula
31
31
  end
32
32
 
33
33
  api_name :video
34
+
35
+ def construct_from(json_object)
36
+ @raw_data = json_object.dup
37
+ @values = json_object
38
+
39
+ self.id = json_object['id'] unless [nil, ''].include?(json_object['id'])
40
+
41
+ @dirty_attributes = Set.new
42
+ @errors = ModelErrors.new(self.class)
43
+
44
+ @related_models = {}
45
+ cache_links(json_object['relationships'] || {})
46
+
47
+ self
48
+ end
34
49
  end
35
50
  end
36
51
  end
@@ -11,6 +11,14 @@ module Alula
11
11
  field :name, type: :string
12
12
  field :serial_number, type: :string
13
13
  field :verification_code, type: :string
14
+
15
+ def is_jsw?
16
+ manufacturer == 'jsw'
17
+ end
18
+
19
+ def is_hik?
20
+ manufacturer == 'hikvision'
21
+ end
14
22
  end
15
23
  end
16
24
  end
data/lib/alula/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alula
4
- VERSION = '0.54.0'
4
+ VERSION = '0.55.0'
5
5
  end
data/lib/alula.rb CHANGED
@@ -130,10 +130,10 @@ module Alula
130
130
  end
131
131
 
132
132
  def self.logger
133
- RequestStore.store['logger'] ||= defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
133
+ @@logger ||= defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
134
134
  end
135
135
 
136
136
  def self.logger=(logger)
137
- RequestStore.store['logger'] = logger
137
+ @@logger = logger
138
138
  end
139
139
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alula-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.54.0
4
+ version: 0.55.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Titus Johnson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-21 00:00:00.000000000 Z
11
+ date: 2022-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty