ring-client-api 11.7.3 → 11.7.4

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.
@@ -14,6 +14,7 @@ export declare function getBatteryLevel(data: Pick<CameraData, 'battery_life' |
14
14
  export declare function getSearchQueryString(options: CameraEventOptions | (HistoryOptions & {
15
15
  accountId: string;
16
16
  })): string;
17
+ export declare function cleanSnapshotUuid(uuid?: string | null): string | null | undefined;
17
18
  export declare class RingCamera extends Subscribed {
18
19
  private initialData;
19
20
  isDoorbot: boolean;
@@ -40,6 +41,7 @@ export declare class RingCamera extends Subscribed {
40
41
  get name(): string;
41
42
  get activeNotifications(): PushNotificationDing[];
42
43
  get latestNotification(): PushNotificationDing | undefined;
44
+ get latestNotificationSnapshotUuid(): string | undefined;
43
45
  get batteryLevel(): number | null;
44
46
  get hasBattery(): boolean;
45
47
  get hasLowBattery(): boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RingCamera = exports.getSearchQueryString = exports.getBatteryLevel = void 0;
3
+ exports.RingCamera = exports.cleanSnapshotUuid = exports.getSearchQueryString = exports.getBatteryLevel = void 0;
4
4
  const ring_types_1 = require("./ring-types");
5
5
  const rest_client_1 = require("./rest-client");
6
6
  const rxjs_1 = require("rxjs");
@@ -58,6 +58,13 @@ function getSearchQueryString(options) {
58
58
  return queryString.length ? `?${queryString}` : '';
59
59
  }
60
60
  exports.getSearchQueryString = getSearchQueryString;
61
+ function cleanSnapshotUuid(uuid) {
62
+ if (!uuid) {
63
+ return uuid;
64
+ }
65
+ return uuid.replace(/:.*$/, '');
66
+ }
67
+ exports.cleanSnapshotUuid = cleanSnapshotUuid;
61
68
  class RingCamera extends subscribed_1.Subscribed {
62
69
  constructor(initialData, isDoorbot, restClient, avoidSnapshotBatteryDrain) {
63
70
  super();
@@ -124,6 +131,10 @@ class RingCamera extends subscribed_1.Subscribed {
124
131
  const notifications = this.activeNotifications;
125
132
  return notifications[notifications.length - 1];
126
133
  }
134
+ get latestNotificationSnapshotUuid() {
135
+ const notification = this.latestNotification;
136
+ return notification?.ding.image_uuid;
137
+ }
127
138
  get batteryLevel() {
128
139
  if (!('battery_life' in this.data)) {
129
140
  return null;
@@ -368,7 +379,7 @@ class RingCamera extends subscribed_1.Subscribed {
368
379
  'after-ms': afterMs,
369
380
  'max-wait-ms': maxWaitMs,
370
381
  extras: force ? 'force' : undefined,
371
- uuid,
382
+ uuid: cleanSnapshotUuid(uuid),
372
383
  },
373
384
  headers: {
374
385
  accept: 'image/jpeg',
@@ -381,7 +392,7 @@ class RingCamera extends subscribed_1.Subscribed {
381
392
  }
382
393
  getSnapshotByUuid(uuid) {
383
394
  return this.restClient.request({
384
- url: (0, rest_client_1.clientApi)('snapshots/uuid?uuid=' + uuid),
395
+ url: (0, rest_client_1.clientApi)('snapshots/uuid?uuid=' + cleanSnapshotUuid(uuid)),
385
396
  responseType: 'buffer',
386
397
  headers: {
387
398
  accept: 'image/jpeg',
@@ -22,4 +22,16 @@ describe('Ring Camera', () => {
22
22
  expect((0, index_1.getBatteryLevel)({ battery_life: '92', battery_life_2: 100 })).toEqual(92);
23
23
  });
24
24
  });
25
+ describe('cleanSnapshotUuid', () => {
26
+ it('should return the original uuid if it is already clean', () => {
27
+ expect((0, index_1.cleanSnapshotUuid)('c2a0a397-3538-422d-bb4e-51837a56b870')).toBe('c2a0a397-3538-422d-bb4e-51837a56b870');
28
+ });
29
+ it('should return remove anything after :', () => {
30
+ expect((0, index_1.cleanSnapshotUuid)('c2a0a397-3538-422d-bb4e-51837a56b870:122429140')).toBe('c2a0a397-3538-422d-bb4e-51837a56b870');
31
+ });
32
+ it('should handle falsy values', () => {
33
+ expect((0, index_1.cleanSnapshotUuid)(undefined)).toBe(undefined);
34
+ expect((0, index_1.cleanSnapshotUuid)(null)).toBe(null);
35
+ });
36
+ });
25
37
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ring-client-api",
3
- "version": "11.7.3",
3
+ "version": "11.7.4",
4
4
  "description": "Unofficial API for Ring doorbells, cameras, security alarm system and smart lighting",
5
5
  "main": "lib/index.js",
6
6
  "exports": {