@vendit-dev/thirdparty-adapters 0.2.2 → 0.2.5
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.
|
@@ -39,9 +39,11 @@ export default class SmartAccessAdapter {
|
|
|
39
39
|
authenticator: UserServiceGrpcCaller;
|
|
40
40
|
redis: any;
|
|
41
41
|
PROVIDER_KEY: string;
|
|
42
|
-
|
|
42
|
+
API_HOST: string;
|
|
43
|
+
constructor({ authenticator, redis, apiHost }: {
|
|
43
44
|
authenticator: UserServiceGrpcCaller;
|
|
44
45
|
redis: any;
|
|
46
|
+
apiHost: string;
|
|
45
47
|
});
|
|
46
48
|
checkSmartAccessIntegration: ({ accommodationId }: {
|
|
47
49
|
accommodationId: string;
|
|
@@ -57,6 +59,10 @@ export default class SmartAccessAdapter {
|
|
|
57
59
|
method?: string | undefined;
|
|
58
60
|
headers?: any;
|
|
59
61
|
}) => Promise<any>;
|
|
62
|
+
getRoomInfo: ({ accommodationId, roomId }: {
|
|
63
|
+
accommodationId: string;
|
|
64
|
+
roomId: string;
|
|
65
|
+
}) => Promise<SmartAccessRoom>;
|
|
60
66
|
getRooms: (accommodationId: string) => Promise<SmartAccessRoom[]>;
|
|
61
67
|
getDevices: (accommodationId: string) => Promise<any>;
|
|
62
68
|
getRoomsWithDevices: (accommodationId: string) => Promise<SmartAccessRoom[]>;
|
|
@@ -107,7 +107,7 @@ exports.MutexLock = MutexLock;
|
|
|
107
107
|
var SmartAccessAdapter = /** @class */ (function () {
|
|
108
108
|
function SmartAccessAdapter(_a) {
|
|
109
109
|
var _this = this;
|
|
110
|
-
var authenticator = _a.authenticator, redis = _a.redis;
|
|
110
|
+
var authenticator = _a.authenticator, redis = _a.redis, apiHost = _a.apiHost;
|
|
111
111
|
this.PROVIDER_KEY = 'SamsungSmartAccess';
|
|
112
112
|
this.checkSmartAccessIntegration = function (_a) {
|
|
113
113
|
var accommodationId = _a.accommodationId;
|
|
@@ -204,11 +204,9 @@ var SmartAccessAdapter = /** @class */ (function () {
|
|
|
204
204
|
_j.label = 2;
|
|
205
205
|
case 2:
|
|
206
206
|
requestArgs = __assign.apply(void 0, _c.concat([(_d.headers = __assign.apply(void 0, [__assign.apply(void 0, _e.concat([(_f)])), headers]), _d)]));
|
|
207
|
-
|
|
208
|
-
return [4 /*yield*/, node_fetch_1.default("https://oauth-iot-stg.samsung-ihp.com/sa/oauth/" + route, requestArgs)];
|
|
207
|
+
return [4 /*yield*/, node_fetch_1.default(this.API_HOST + "/sa/oauth/" + route, requestArgs)];
|
|
209
208
|
case 3:
|
|
210
209
|
response = _j.sent();
|
|
211
|
-
console.log(response);
|
|
212
210
|
return [4 /*yield*/, response.json()];
|
|
213
211
|
case 4:
|
|
214
212
|
jsonResponse = _j.sent();
|
|
@@ -217,6 +215,24 @@ var SmartAccessAdapter = /** @class */ (function () {
|
|
|
217
215
|
});
|
|
218
216
|
});
|
|
219
217
|
};
|
|
218
|
+
this.getRoomInfo = function (_a) {
|
|
219
|
+
var accommodationId = _a.accommodationId, roomId = _a.roomId;
|
|
220
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
221
|
+
var roomResponse;
|
|
222
|
+
return __generator(this, function (_b) {
|
|
223
|
+
switch (_b.label) {
|
|
224
|
+
case 0: return [4 /*yield*/, this.callSmartAccessApi({
|
|
225
|
+
accommodationId: accommodationId,
|
|
226
|
+
method: 'get',
|
|
227
|
+
route: "v1/room/" + roomId + "/roominfo",
|
|
228
|
+
})];
|
|
229
|
+
case 1:
|
|
230
|
+
roomResponse = _b.sent();
|
|
231
|
+
return [2 /*return*/, roomResponse];
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
};
|
|
220
236
|
this.getRooms = function (accommodationId) { return __awaiter(_this, void 0, void 0, function () {
|
|
221
237
|
var roomResponse;
|
|
222
238
|
return __generator(this, function (_a) {
|
|
@@ -396,7 +412,6 @@ var SmartAccessAdapter = /** @class */ (function () {
|
|
|
396
412
|
})];
|
|
397
413
|
case 3:
|
|
398
414
|
res = _b.sent();
|
|
399
|
-
console.log(res);
|
|
400
415
|
return [2 /*return*/, true];
|
|
401
416
|
case 4: return [2 /*return*/];
|
|
402
417
|
}
|
|
@@ -416,7 +431,6 @@ var SmartAccessAdapter = /** @class */ (function () {
|
|
|
416
431
|
})];
|
|
417
432
|
case 1:
|
|
418
433
|
response = _b.sent();
|
|
419
|
-
console.log(response);
|
|
420
434
|
return [2 /*return*/, true];
|
|
421
435
|
}
|
|
422
436
|
});
|
|
@@ -438,12 +452,13 @@ var SmartAccessAdapter = /** @class */ (function () {
|
|
|
438
452
|
foundRoomProperty = _b.sent();
|
|
439
453
|
if (!(foundRoomProperty === null || foundRoomProperty === void 0 ? void 0 : foundRoomProperty.result))
|
|
440
454
|
return [2 /*return*/, false];
|
|
441
|
-
return [2 /*return*/, foundRoomProperty.data];
|
|
455
|
+
return [2 /*return*/, JSON.parse(foundRoomProperty.data)];
|
|
442
456
|
}
|
|
443
457
|
});
|
|
444
458
|
});
|
|
445
459
|
};
|
|
446
460
|
this.authenticator = authenticator;
|
|
461
|
+
this.API_HOST = apiHost;
|
|
447
462
|
this.redis = redis;
|
|
448
463
|
this.mutexLock = new MutexLock({ hashPrefix: 'RES_SMARTACCESS_MUTEX_', mutexLockInterval: 50, redis: redis });
|
|
449
464
|
}
|