alula-ruby 1.10.5 → 2.0.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: 59c0a310113d936038d7403de4c1dfa5d90bf8fbb960e17c1ef66761bf8aad43
4
- data.tar.gz: 597408051879859c200fc483c88982dd7b1cff056d731f5e0e0e6eadb646146b
3
+ metadata.gz: 7aea00c9f68b3480d7f0f8cd06e749844deaa4463b3d58a1de2d4313d4b8c30d
4
+ data.tar.gz: 02fff4cc28c21d167ab150878ac237f7817fe7a9c263e74fdf5870689c960563
5
5
  SHA512:
6
- metadata.gz: 97db75fe5030f83ca1929c37cfb135bd5be82bd156495593f18c06517cd4094bea53c332f30fa9172a282e91c35036490a4c09894bae81563989e60f9af4b4e9
7
- data.tar.gz: 0e764d69e7fdf2018a3b074dc3cca6bffc58663a385415eaa1e3b7499c6c40981f8ecb61060383daa8101da738a6da8b443091dc172425ef861efb3d2e28e39e
6
+ metadata.gz: 347e820ffc7916c366756d7bb1702f59b3c55bc01d39cfc5e0fc8a70d7ecae45bd7d75fe9a5f06cc565ecb239c214ced9e53c0f9919731370e3c0c9f287e8010
7
+ data.tar.gz: 0e2c99e918c0a4d4efd52b3068725edc355fdac293acf83d9dc707f76ce97792e720ad399f36930c14f14188663b9312ac55a8e360a32417fe8234fc74ac1f79
data/README.md CHANGED
@@ -440,6 +440,11 @@ Note: You do need to be authorized against our private ECR registry. This is man
440
440
 
441
441
  Occasionally under heavy use the dockerized API may lose or drop its databases, resulting in the test suite erroring completly and very quickly. To fix this simply restart the API with `docker-compose -f alula-docker-compose.yml down && docker-compose -f alula-docker-compose.yml up -d`
442
442
 
443
+ ### Adding a new device
444
+
445
+ Optional: When a new device is added, methods for it can be exposed inside lib/alula/helpers/device_helpers/program_id_helper.rb. The device ID can be added to existing consts or new methods can be
446
+ created for the specific device.
447
+
443
448
  ## Importing GEM in AC Docker
444
449
 
445
450
  Most of the times, the work we do in alula ruby includes just updating the model/procedures and push the changes, without having to worry about the configuration mentioned above. When we make changes to alula ruby locally we need to test if the gem file works.
data/VERSION.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  | Version | Date | Description |
4
4
  | ------- | ------------| --------------------------------------------------------------------------- |
5
+ | v2.0.0 | 2024-10-17 | Add device helpers, breaking change - removed `is_` from methods returning a boolean |
5
6
  | v1.10.5 | 2024-10-11 | Adding chime_info proc |
6
7
  | v1.10.4 | 2024-10-07 | Adding sd_card_status to camera record, restructured sd status proc accessors |
7
8
  | v1.10.3 | 2024-10-07 | Updating get_sd_status_proc to match video API's update |
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Alula
4
+ module DeviceHelpers
5
+ #
6
+ # Relies on the implementing class having reader properties of `auto_cfg`.
7
+ # Translates it into a usable string
8
+ module AttributeTranslationsHelper
9
+ PANEL_NAME_MAP = {
10
+ 0 => 'Honeywell/Vista',
11
+ 1 => 'Honeywell/Vista+Passive',
12
+ 2 => 'Honeywell/Lynx',
13
+ 3 => 'Honeywell/Lynx+Passive',
14
+ 4 => 'DSC/Depricated',
15
+ 5 => 'GE-Interlogix/Caddx',
16
+ 6 => 'DSC/Alexor',
17
+ 7 => 'DSC/PowerSeries',
18
+ 8 => 'Dialer Capture or Keyswitch',
19
+ 9 => 'GE-Interlogix/Concord',
20
+ 10 => '',
21
+ 11 => 'Gateway',
22
+ 12 => 'GE Simon XT/XTi',
23
+ 13 => 'Cinch',
24
+ 14 => 'Helix',
25
+ 15 => 'Clare D3',
26
+ 19 => 'No Panel'
27
+ }.freeze
28
+
29
+ #
30
+ # autoCfg contains multiple pieces of information depending on how you examine it.
31
+ # Doing a bitwise operation with 0xff takes the last 8 bits,
32
+ # which is the connected panel ID.
33
+ # https://ipdatatel.atlassian.net/wiki/spaces/SYS/pages/16482314/auto+cfg
34
+ def panel_name
35
+ panel_id = auto_cfg.to_i & 0xff
36
+ self.class::PANEL_NAME_MAP[panel_id] || "Unknown (#{panel_id})"
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Alula
4
+ module DeviceHelpers
5
+ # Helper methods for determining the device type based on the program ID
6
+ module ProgramIdHelper
7
+ CONNECT_PROGRAM_IDS = [
8
+ 211, # D3
9
+ 4096, # Camera
10
+ 35, # BAT-FIRE
11
+ 34, # BAT-CONNECT
12
+ 33, # CONNECT-XT
13
+ 32, # CONNECT+
14
+ 36, # CONNECT-XiP
15
+ 38, # WTP-01 (is ALDER-WTP)
16
+ 39, # BAT-Mini
17
+ 40, # CONNECT-FLX
18
+ 41, # CONNECT+PRO
19
+ 42, # CONNECT+PRO-SC
20
+ 43, # BAT-Mini AV
21
+ 44, # WTP-02 (is ALDER-WTP_WIFI)
22
+ 45, # Connect-FLX-Z
23
+ 46, # Connect-FLX-DUAL
24
+ 47 # Connect-FLX-DUAL-Z
25
+ ].freeze
26
+
27
+ GSM_PROGRAM_IDS = [
28
+ 15, 271, # IPD-BAT-CDMA
29
+ 16, 272, # IPD-BAT-CDMA-WIFI
30
+ 17, # IPD-BAT-CDMA-L
31
+ 783, # BAT-LTE
32
+ 788 # BAT-LTE-WIFI
33
+ ].freeze
34
+
35
+ KAMI_CAMERA_PROGRAM_IDS = [
36
+ 3072,
37
+ 3073,
38
+ 3074,
39
+ 3075,
40
+ 3076,
41
+ 3090
42
+ ].freeze
43
+
44
+ EUFY_CAMERA_PROGRAM_IDS = [
45
+ 3086,
46
+ 3087,
47
+ 3088,
48
+ 3089,
49
+ 3091
50
+ ].freeze
51
+
52
+ XIP_FAMILY_PROGRAM_IDS = [
53
+ 36, # CONNECT-XiP
54
+ 40, # C+Flex
55
+ 41, # C+Pro
56
+ 42, # C+Pro-SC
57
+ 45, # C+Flex-Z
58
+ 46, # C+Flex-Dual
59
+ 47 # C+Flex-Dual-Z
60
+ ].freeze
61
+
62
+ def connect_device?
63
+ self.class::CONNECT_PROGRAM_IDS.include?(program_id)
64
+ end
65
+
66
+ def legacy_device?
67
+ !connect_device?
68
+ end
69
+
70
+ def gsm_device?
71
+ self.class::GSM_PROGRAM_IDS.include?(program_id)
72
+ end
73
+
74
+ def connect_xt?
75
+ program_id == 33
76
+ end
77
+
78
+ def alder_wtp?
79
+ program_id == 38
80
+ end
81
+
82
+ def kami_camera?
83
+ self.class::KAMI_CAMERA_PROGRAM_IDS.include?(program_id)
84
+ end
85
+
86
+ def eufy_camera?
87
+ self.class::EUFY_CAMERA_PROGRAM_IDS.include?(program_id)
88
+ end
89
+
90
+ def connect_xip?
91
+ program_id == 36
92
+ end
93
+
94
+ def bat_mini?
95
+ [39, 43].include?(program_id)
96
+ end
97
+
98
+ def xip_family?
99
+ self.class::XIP_FAMILY_PROGRAM_IDS.include?(program_id)
100
+ end
101
+ end
102
+ end
103
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alula
2
4
  class Device < Alula::RestResource
3
5
  extend Alula::ResourceAttributes
@@ -6,8 +8,10 @@ module Alula
6
8
  extend Alula::ApiOperations::List
7
9
  extend Alula::ApiOperations::Save
8
10
 
9
- include Alula::DeviceAttributeTranslations
11
+ include Alula::DeviceHelpers::AttributeTranslationsHelper
12
+ include Alula::DeviceHelpers::ProgramIdHelper
10
13
 
14
+ # Nested class for features_selected field
11
15
  class FeaturesSelected < Alula::ObjectField
12
16
  field :alarm_transmission, type: :boolean
13
17
  field :alarm_notifications, type: :boolean
@@ -89,35 +93,35 @@ module Alula
89
93
  sortable: false,
90
94
  filterable: false,
91
95
  creatable_by: [],
92
- patchable_by: [:system, :station, :dealer, :technician]
96
+ patchable_by: %i[system station dealer technician]
93
97
 
94
98
  field :interactive_enabled,
95
99
  type: :boolean,
96
100
  sortable: false,
97
101
  filterable: false,
98
102
  creatable_by: [],
99
- patchable_by: [:system, :station, :dealer, :technician]
103
+ patchable_by: %i[system station dealer technician]
100
104
 
101
105
  field :remote_user_logging_feature_enabled,
102
106
  type: :boolean,
103
107
  sortable: false,
104
108
  filterable: false,
105
109
  creatable_by: [],
106
- patchable_by: [:system, :station, :dealer, :technician]
110
+ patchable_by: %i[system station dealer technician]
107
111
 
108
112
  field :push_notification_enabled,
109
113
  type: :boolean,
110
114
  sortable: false,
111
115
  filterable: false,
112
116
  creatable_by: [],
113
- patchable_by: [:system, :station, :dealer, :technician]
117
+ patchable_by: %i[system station dealer technician]
114
118
 
115
119
  field :user_sync_disabled,
116
120
  type: :boolean,
117
121
  sortable: false,
118
122
  filterable: false,
119
123
  creatable_by: [],
120
- patchable_by: [:system, :station, :dealer, :technician]
124
+ patchable_by: %i[system station dealer technician]
121
125
 
122
126
  field :auto_cfg,
123
127
  type: :string,
@@ -180,7 +184,7 @@ module Alula
180
184
  sortable: false,
181
185
  filterable: false,
182
186
  creatable_by: [],
183
- patchable_by: [:system, :station, :dealer, :technician, :user]
187
+ patchable_by: %i[system station dealer technician user]
184
188
 
185
189
  field :online_status,
186
190
  type: :string,
@@ -229,63 +233,63 @@ module Alula
229
233
  sortable: true,
230
234
  filterable: true,
231
235
  creatable_by: [],
232
- patchable_by: [:system, :station, :dealer, :technician, :user]
236
+ patchable_by: %i[system station dealer technician user]
233
237
 
234
238
  field :station_phone_number,
235
239
  type: :string,
236
240
  sortable: false,
237
241
  filterable: false,
238
242
  creatable_by: [],
239
- patchable_by: [:system, :station, :dealer, :technician]
243
+ patchable_by: %i[system station dealer technician]
240
244
 
241
245
  field :station_account_number,
242
246
  type: :string,
243
247
  sortable: false,
244
248
  filterable: true,
245
249
  creatable_by: [],
246
- patchable_by: [:system, :station, :dealer, :technician]
250
+ patchable_by: %i[system station dealer technician]
247
251
 
248
252
  field :station_aux_number,
249
253
  type: :string,
250
254
  sortable: false,
251
255
  filterable: false,
252
256
  creatable_by: [],
253
- patchable_by: [:system, :station, :dealer, :technician]
257
+ patchable_by: %i[system station dealer technician]
254
258
 
255
259
  field :override_account_number,
256
260
  type: :boolean,
257
261
  sortable: false,
258
262
  filterable: false,
259
263
  creatable_by: [],
260
- patchable_by: [:system, :station, :dealer, :technician]
264
+ patchable_by: %i[system station dealer technician]
261
265
 
262
266
  field :signal_suppress_open_close,
263
267
  type: :boolean,
264
268
  sortable: false,
265
269
  filterable: false,
266
270
  creatable_by: [],
267
- patchable_by: [:system, :station, :dealer, :technician]
271
+ patchable_by: %i[system station dealer technician]
268
272
 
269
273
  field :signal_suppress_bypass,
270
274
  type: :boolean,
271
275
  sortable: false,
272
276
  filterable: false,
273
277
  creatable_by: [],
274
- patchable_by: [:system, :station, :dealer, :technician]
278
+ patchable_by: %i[system station dealer technician]
275
279
 
276
280
  field :open_close_suppression,
277
281
  type: :boolean,
278
282
  sortable: false,
279
283
  filterable: false,
280
284
  creatable_by: [],
281
- patchable_by: [:system, :station, :dealer, :technician]
285
+ patchable_by: %i[system station dealer technician]
282
286
 
283
287
  field :convert_sia_to_contact_id,
284
288
  type: :boolean,
285
289
  sortable: false,
286
290
  filterable: false,
287
291
  creatable_by: [],
288
- patchable_by: [:system, :station, :dealer, :technician]
292
+ patchable_by: %i[system station dealer technician]
289
293
 
290
294
  field :downloader_phone_number,
291
295
  type: :string,
@@ -299,112 +303,112 @@ module Alula
299
303
  sortable: false,
300
304
  filterable: true,
301
305
  creatable_by: [],
302
- patchable_by: [:system, :station, :dealer, :technician]
306
+ patchable_by: %i[system station dealer technician]
303
307
 
304
308
  field :network_trouble_timeout,
305
309
  type: :string,
306
310
  sortable: false,
307
311
  filterable: false,
308
312
  creatable_by: [],
309
- patchable_by: [:system, :station, :dealer, :technician]
313
+ patchable_by: %i[system station dealer technician]
310
314
 
311
315
  field :physical_address1,
312
316
  type: :string,
313
317
  sortable: false,
314
318
  filterable: true,
315
319
  creatable_by: [],
316
- patchable_by: [:system, :station, :dealer, :technician, :user]
320
+ patchable_by: %i[system station dealer technician user]
317
321
 
318
322
  field :physical_address2,
319
323
  type: :string,
320
324
  sortable: false,
321
325
  filterable: true,
322
326
  creatable_by: [],
323
- patchable_by: [:system, :station, :dealer, :technician, :user]
327
+ patchable_by: %i[system station dealer technician user]
324
328
 
325
329
  field :physical_street_number,
326
330
  type: :string,
327
331
  sortable: false,
328
332
  filterable: true,
329
333
  creatable_by: [],
330
- patchable_by: [:system, :station, :dealer, :technician, :user]
334
+ patchable_by: %i[system station dealer technician user]
331
335
 
332
336
  field :physical_street_name,
333
337
  type: :string,
334
338
  sortable: false,
335
339
  filterable: true,
336
340
  creatable_by: [],
337
- patchable_by: [:system, :station, :dealer, :technician, :user]
341
+ patchable_by: %i[system station dealer technician user]
338
342
 
339
343
  field :physical_street_direction,
340
344
  type: :string,
341
345
  sortable: false,
342
346
  filterable: true,
343
347
  creatable_by: [],
344
- patchable_by: [:system, :station, :dealer, :technician, :user]
348
+ patchable_by: %i[system station dealer technician user]
345
349
 
346
350
  field :physical_city,
347
351
  type: :string,
348
352
  sortable: false,
349
353
  filterable: true,
350
354
  creatable_by: [],
351
- patchable_by: [:system, :station, :dealer, :technician, :user]
355
+ patchable_by: %i[system station dealer technician user]
352
356
 
353
357
  field :physical_state,
354
358
  type: :string,
355
359
  sortable: false,
356
360
  filterable: true,
357
361
  creatable_by: [],
358
- patchable_by: [:system, :station, :dealer, :technician, :user]
362
+ patchable_by: %i[system station dealer technician user]
359
363
 
360
364
  field :physical_zip,
361
365
  type: :string,
362
366
  sortable: false,
363
367
  filterable: true,
364
368
  creatable_by: [],
365
- patchable_by: [:system, :station, :dealer, :technician, :user]
369
+ patchable_by: %i[system station dealer technician user]
366
370
 
367
371
  field :physical_site_number,
368
372
  type: :string,
369
373
  sortable: false,
370
374
  filterable: true,
371
375
  creatable_by: [],
372
- patchable_by: [:system, :station, :dealer, :technician, :user]
376
+ patchable_by: %i[system station dealer technician user]
373
377
 
374
378
  field :physical_suite,
375
379
  type: :string,
376
380
  sortable: false,
377
381
  filterable: true,
378
382
  creatable_by: [],
379
- patchable_by: [:system, :station, :dealer, :technician, :user]
383
+ patchable_by: %i[system station dealer technician user]
380
384
 
381
385
  field :physical_floor,
382
386
  type: :string,
383
387
  sortable: false,
384
388
  filterable: true,
385
389
  creatable_by: [],
386
- patchable_by: [:system, :station, :dealer, :technician, :user]
390
+ patchable_by: %i[system station dealer technician user]
387
391
 
388
392
  field :physical_description,
389
393
  type: :string,
390
394
  sortable: false,
391
395
  filterable: true,
392
396
  creatable_by: [],
393
- patchable_by: [:system, :station, :dealer, :technician, :user]
397
+ patchable_by: %i[system station dealer technician user]
394
398
 
395
399
  field :two_way_voice_enabled,
396
400
  type: :boolean,
397
401
  sortable: false,
398
402
  filterable: false,
399
403
  creatable_by: [],
400
- patchable_by: [:system, :station, :dealer, :technician]
404
+ patchable_by: %i[system station dealer technician]
401
405
 
402
406
  field :sia_two_way_voice_enabled,
403
407
  type: :boolean,
404
408
  sortable: false,
405
409
  filterable: false,
406
410
  creatable_by: [],
407
- patchable_by: [:system, :station, :dealer, :technician]
411
+ patchable_by: %i[system station dealer technician]
408
412
 
409
413
  field :date_deactivated,
410
414
  type: :date,
@@ -454,7 +458,7 @@ module Alula
454
458
  sortable: false,
455
459
  filterable: true,
456
460
  creatable_by: [],
457
- patchable_by: [:system, :station, :dealer, :technician],
461
+ patchable_by: %i[system station dealer technician],
458
462
  use: FeaturesSelected
459
463
 
460
464
  field :any_trouble,
@@ -90,11 +90,11 @@ module Alula
90
90
  patchable_by: %i[system station dealer user],
91
91
  creatable_by: %i[system station dealer user]
92
92
 
93
- def is_jsw?
93
+ def jsw?
94
94
  manufacturer == 'jsw'
95
95
  end
96
96
 
97
- def is_hik?
97
+ def hik?
98
98
  manufacturer == 'hikvision'
99
99
  end
100
100
  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 = '1.10.5'
4
+ VERSION = '2.0.0'
5
5
  end
data/lib/alula.rb CHANGED
@@ -24,7 +24,8 @@ require_relative 'alula/client_configuration'
24
24
  require_relative 'alula/errors'
25
25
  require_relative 'alula/list_object'
26
26
  require_relative 'alula/oauth'
27
- require_relative 'alula/helpers/device_attribute_translations'
27
+ require_relative 'alula/helpers/device_helpers/attribute_translations_helper'
28
+ require_relative 'alula/helpers/device_helpers/program_id_helper'
28
29
  require_relative 'alula/resources/billing_program'
29
30
  require_relative 'alula/resources/device'
30
31
  require_relative 'alula/resources/device_charge'
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: 1.10.5
4
+ version: 2.0.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: 2024-10-11 00:00:00.000000000 Z
11
+ date: 2024-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -209,7 +209,8 @@ files:
209
209
  - lib/alula/client_configuration.rb
210
210
  - lib/alula/errors.rb
211
211
  - lib/alula/filter_builder.rb
212
- - lib/alula/helpers/device_attribute_translations.rb
212
+ - lib/alula/helpers/device_helpers/attribute_translations_helper.rb
213
+ - lib/alula/helpers/device_helpers/program_id_helper.rb
213
214
  - lib/alula/helpers/jwt_helper.rb
214
215
  - lib/alula/list_object.rb
215
216
  - lib/alula/meta.rb
@@ -1,68 +0,0 @@
1
- module Alula
2
-
3
- #
4
- # Relies on the implementing class having reader properties of `program_id`
5
- # and `auto_cfg`. Translates those values into usable strings
6
- module DeviceAttributeTranslations
7
- PROGRAM_ID_MAP = {
8
- 32 => 'CONNECT+',
9
- 35 => 'BAT-FIRE',
10
- 34 => 'BAT-CONNECT',
11
- 211 => 'CLARE-D3',
12
- 4096 => 'CAMERA',
13
- 783 => 'BAT-LTE',
14
- 0 => 'IPD-BAT',
15
- 1 => 'IPD-BAT',
16
- 2 => 'IPD-BAT',
17
- 3 => 'IPD-BAT-ZKI',
18
- 4 => 'IPD-BAT',
19
- 8 => 'IPD-BAT',
20
- 6 => 'IPD-ZGW',
21
- 9 => 'IPD-BAT-U',
22
- 11 => 'IPD-ZGW',
23
- 15 => 'IPD-BAT-CDMA',
24
- 16 => 'IPD-BAT-WIFI',
25
- 17 => 'IPD-BAT-CDMA-L',
26
- 18 => 'IPD-MPWC',
27
- 19 => 'IPD-CAT-CDMA',
28
- 20 => 'IPD-BAT-CDMA-WIFI',
29
- 22 => 'IPD-CAT-XT',
30
- 33 => 'IGM',
31
- 271 => 'IPD-BAT-CDMA1'
32
- }.freeze
33
-
34
- PANEL_NAME_MAP = {
35
- 0 => 'Honeywell/Vista',
36
- 1 => 'Honeywell/Vista+Passive',
37
- 2 => 'Honeywell/Lynx',
38
- 3 => 'Honeywell/Lynx+Passive',
39
- 4 => 'DSC/Depricated',
40
- 5 => 'GE-Interlogix/Caddx',
41
- 6 => 'DSC/Alexor',
42
- 7 => 'DSC/PowerSeries',
43
- 8 => 'Dialer Capture or Keyswitch',
44
- 9 => 'GE-Interlogix/Concord',
45
- 10 => '',
46
- 11 => 'Gateway',
47
- 12 => 'GE Simon XT/XTi',
48
- 13 => 'Cinch',
49
- 14 => 'Helix',
50
- 15 => 'Clare D3',
51
- 19 => 'No Panel',
52
- }.freeze
53
-
54
- def device_name
55
- self.class::PROGRAM_ID_MAP[self.program_id] || "Unknown (#{self.program_id})"
56
- end
57
-
58
- #
59
- # autoCfg contains multiple pieces of information depending on how you examine it.
60
- # Doing a bitwise operation with 0xff takes the last 8 bits,
61
- # which is the connected panel ID.
62
- # https://ipdatatel.atlassian.net/wiki/spaces/SYS/pages/16482314/auto+cfg
63
- def panel_name
64
- panel_id = auto_cfg.to_i & 0xff
65
- self.class::PANEL_NAME_MAP[panel_id] || "Unknown (#{panel_id})"
66
- end
67
- end
68
- end