@vendit-dev/thirdparty-adapters 0.2.3 → 0.2.6

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
- constructor({ authenticator, redis }: {
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;
@@ -177,7 +177,6 @@ var SmartAccessAdapter = /** @class */ (function () {
177
177
  case 0: return [4 /*yield*/, this.getAccommodationAuthInfo({ accommodationId: accommodationId })];
178
178
  case 1:
179
179
  authInfo = _a.sent();
180
- console.log(authInfo);
181
180
  return [2 /*return*/, authInfo.accessToken];
182
181
  }
183
182
  });
@@ -204,11 +203,9 @@ var SmartAccessAdapter = /** @class */ (function () {
204
203
  _j.label = 2;
205
204
  case 2:
206
205
  requestArgs = __assign.apply(void 0, _c.concat([(_d.headers = __assign.apply(void 0, [__assign.apply(void 0, _e.concat([(_f)])), headers]), _d)]));
207
- console.log(requestArgs);
208
- return [4 /*yield*/, node_fetch_1.default("https://oauth-iot-stg.samsung-ihp.com/sa/oauth/" + route, requestArgs)];
206
+ return [4 /*yield*/, node_fetch_1.default(this.API_HOST + "/sa/oauth/" + route, requestArgs)];
209
207
  case 3:
210
208
  response = _j.sent();
211
- console.log(response);
212
209
  return [4 /*yield*/, response.json()];
213
210
  case 4:
214
211
  jsonResponse = _j.sent();
@@ -217,6 +214,24 @@ var SmartAccessAdapter = /** @class */ (function () {
217
214
  });
218
215
  });
219
216
  };
217
+ this.getRoomInfo = function (_a) {
218
+ var accommodationId = _a.accommodationId, roomId = _a.roomId;
219
+ return __awaiter(_this, void 0, void 0, function () {
220
+ var roomResponse;
221
+ return __generator(this, function (_b) {
222
+ switch (_b.label) {
223
+ case 0: return [4 /*yield*/, this.callSmartAccessApi({
224
+ accommodationId: accommodationId,
225
+ method: 'get',
226
+ route: "v1/room/" + roomId + "/roominfo",
227
+ })];
228
+ case 1:
229
+ roomResponse = _b.sent();
230
+ return [2 /*return*/, roomResponse];
231
+ }
232
+ });
233
+ });
234
+ };
220
235
  this.getRooms = function (accommodationId) { return __awaiter(_this, void 0, void 0, function () {
221
236
  var roomResponse;
222
237
  return __generator(this, function (_a) {
@@ -396,7 +411,6 @@ var SmartAccessAdapter = /** @class */ (function () {
396
411
  })];
397
412
  case 3:
398
413
  res = _b.sent();
399
- console.log(res);
400
414
  return [2 /*return*/, true];
401
415
  case 4: return [2 /*return*/];
402
416
  }
@@ -416,7 +430,6 @@ var SmartAccessAdapter = /** @class */ (function () {
416
430
  })];
417
431
  case 1:
418
432
  response = _b.sent();
419
- console.log(response);
420
433
  return [2 /*return*/, true];
421
434
  }
422
435
  });
@@ -444,6 +457,7 @@ var SmartAccessAdapter = /** @class */ (function () {
444
457
  });
445
458
  };
446
459
  this.authenticator = authenticator;
460
+ this.API_HOST = apiHost;
447
461
  this.redis = redis;
448
462
  this.mutexLock = new MutexLock({ hashPrefix: 'RES_SMARTACCESS_MUTEX_', mutexLockInterval: 50, redis: redis });
449
463
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendit-dev/thirdparty-adapters",
3
- "version": "0.2.3",
3
+ "version": "0.2.6",
4
4
  "description": "Third party adapters between v-cloud and other PMS/CMS providers.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {