alula-ruby 0.54.0 → 0.57.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: 5fe8c069cbf129ad7f52be697c4159cad1e78ef655316eae5ee26de2e184a8df
4
- data.tar.gz: cdcda384977cae4869f73892f8a0f309f2965be5b180b56500f0453dc1da27df
3
+ metadata.gz: 74c4d19ef1d5c29584d0cc44323a1fbf63fe80d5ab6eacfc09c78f1316511caf
4
+ data.tar.gz: ba207cd8c9f29e07a564c561da49e36650d98ff19ee043bbcfbe4e468b181481
5
5
  SHA512:
6
- metadata.gz: 7ff734d5a1ab9e49a77262d7f7b8aa05676bb526e123351f89dc4e6984f1b842fbb6b69502e8d54ddf0fb384d722d0fd23d02d0c1d052ccbc0a79bd16fd6feaf
7
- data.tar.gz: b7cdcdeb6fd33066c52b8cd1f6a4ba274bfa4c793f14cc6165b547da5e32110d112135156c370d8aaf3a782e25f7c9406904697b4847730fd6c1387e99fea6c4
6
+ metadata.gz: a702cb33c8448b1be68e4b5046fb7b54f878b8d1b23bb77db03953e3a785d43bfc054f10895c6a63bb2c45aa02a5bbd1b24ba90a625a4cf7510417ffb3e39f1b
7
+ data.tar.gz: d1095d24d4c0cf1de9297ea32c796b1edc6f9df0bd1165cae6a4bc890f06ebb3e08a560a75292b28613d385990d1bcf409f438593dff1aafce132acec3ac3c26
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,6 @@
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 |
90
+ | v0.56.0 | 2022-07-08 | Add save! that raises an exception |
91
+ | v0.57.0 | 2022-07-19 | Add Alula Messenger to device object |
@@ -24,6 +24,10 @@ module Alula
24
24
  handle_errors(response)
25
25
  end
26
26
 
27
+ def save!
28
+ save || raise(ValidationError.new(self.errors))
29
+ end
30
+
27
31
  def create
28
32
  data = {
29
33
  attributes: as_patchable_json
@@ -78,4 +82,4 @@ module Alula
78
82
  end
79
83
  end
80
84
  end
81
- end
85
+ end
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|
data/lib/alula/errors.rb CHANGED
@@ -166,4 +166,12 @@ module Alula
166
166
  false
167
167
  end
168
168
  end
169
+
170
+ class ValidationError < AlulaError
171
+ attr_reader :errors
172
+
173
+ def initialize(errors)
174
+ @errors = errors
175
+ end
176
+ end
169
177
  end
@@ -712,5 +712,12 @@ module Alula
712
712
  filterable: true,
713
713
  creatable_by: [],
714
714
  patchable_by: []
715
+
716
+ field 'features_selected.alula_messenger'.to_sym,
717
+ type: :boolean,
718
+ sortable: false,
719
+ filterable: true,
720
+ creatable_by: [],
721
+ patchable_by: []
715
722
  end
716
723
  end
@@ -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.57.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.57.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-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty