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 +4 -4
- data/.rspec +0 -2
- data/README.md +11 -9
- data/VERSION.md +3 -0
- data/lib/alula/api_operations/save.rb +5 -1
- data/lib/alula/client.rb +1 -1
- data/lib/alula/client_configuration.rb +2 -1
- data/lib/alula/errors.rb +8 -0
- data/lib/alula/resources/device.rb +7 -0
- data/lib/alula/resources/video/base_resource.rb +15 -0
- data/lib/alula/resources/video/device.rb +8 -0
- data/lib/alula/version.rb +1 -1
- data/lib/alula.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74c4d19ef1d5c29584d0cc44323a1fbf63fe80d5ab6eacfc09c78f1316511caf
|
4
|
+
data.tar.gz: ba207cd8c9f29e07a564c561da49e36650d98ff19ee043bbcfbe4e468b181481
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a702cb33c8448b1be68e4b5046fb7b54f878b8d1b23bb77db03953e3a785d43bfc054f10895c6a63bb2c45aa02a5bbd1b24ba90a625a4cf7510417ffb3e39f1b
|
7
|
+
data.tar.gz: d1095d24d4c0cf1de9297ea32c796b1edc6f9df0bd1165cae6a4bc890f06ebb3e08a560a75292b28613d385990d1bcf409f438593dff1aafce132acec3ac3c26
|
data/.rspec
CHANGED
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.
|
46
|
-
|
47
|
-
|
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
|
-
|
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.
|
54
|
-
c.
|
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
@@ -1,6 +1,7 @@
|
|
1
1
|
module Alula
|
2
2
|
class ClientConfiguration
|
3
|
-
|
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
@@ -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
data/lib/alula.rb
CHANGED
@@ -130,10 +130,10 @@ module Alula
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def self.logger
|
133
|
-
|
133
|
+
@@logger ||= defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
134
134
|
end
|
135
135
|
|
136
136
|
def self.logger=(logger)
|
137
|
-
|
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.
|
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-
|
11
|
+
date: 2022-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|