@vendit-dev/thirdparty-adapters 0.7.5 → 0.7.6-beta.1

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.
@@ -73,21 +73,26 @@ export default class SmartAccessAdapter {
73
73
  lockList: SmartAccessRoomKey[];
74
74
  }>;
75
75
  getRoomsWithDevices: (accommodationId: string) => Promise<SmartAccessRoom[]>;
76
- createPinCodeForRoom: ({ roomId, accommodationId, userType, keyType, startDate, endDate, }: {
76
+ createPinCodeForRoom: ({ roomId, accommodationId, userType, keyType, startDate, endDate, pinCode, }: {
77
77
  roomId: string;
78
78
  accommodationId: string;
79
79
  userType: 'GUEST' | 'EMPLOYEE';
80
80
  keyType: 'SCHEDULE' | 'ONETIME';
81
81
  startDate: Date;
82
82
  endDate: Date;
83
+ /**
84
+ * @description 4~12자리 출입 비밀번호, 미입력 시 시스템에서 6자리 랜덤 키 발급(권장)
85
+ */
86
+ pinCode?: string | null | undefined;
83
87
  }) => Promise<any>;
84
- modifyPinCodeByKeyId: ({ keyId, accommodationId, userType, keyType, startDate, endDate, }: {
88
+ modifyPinCodeByKeyId: ({ keyId, accommodationId, userType, keyType, startDate, endDate, pinCode, }: {
85
89
  keyId: string;
86
90
  accommodationId: string;
87
91
  userType: 'GUEST' | 'EMPLOYEE';
88
92
  keyType: 'SCHEDULE' | 'ONETIME';
89
93
  startDate: Date;
90
94
  endDate: Date;
95
+ pinCode?: string | undefined;
91
96
  }) => Promise<any>;
92
97
  deletePinCodeByKeyId: ({ keyId, accommodationId, }: {
93
98
  keyId: string;
@@ -293,12 +293,12 @@ var SmartAccessAdapter = /** @class */ (function () {
293
293
  });
294
294
  }); };
295
295
  this.createPinCodeForRoom = function (_a) {
296
- var roomId = _a.roomId, accommodationId = _a.accommodationId, userType = _a.userType, keyType = _a.keyType, startDate = _a.startDate, endDate = _a.endDate;
296
+ var roomId = _a.roomId, accommodationId = _a.accommodationId, userType = _a.userType, keyType = _a.keyType, startDate = _a.startDate, endDate = _a.endDate, _b = _a.pinCode, pinCode = _b === void 0 ? null : _b;
297
297
  return __awaiter(_this, void 0, void 0, function () {
298
298
  var foundProperty, data, parsedProperty, parsedData, pinCodeResult, keyId, pinCodeQuery, lockInfo;
299
- var _b;
300
- return __generator(this, function (_c) {
301
- switch (_c.label) {
299
+ var _c;
300
+ return __generator(this, function (_d) {
301
+ switch (_d.label) {
302
302
  case 0: return [4 /*yield*/, this.authenticator.getThirdPartyPropertyByRelatedId({
303
303
  accommodationId: accommodationId,
304
304
  provider: this.PROVIDER_KEY,
@@ -306,7 +306,7 @@ var SmartAccessAdapter = /** @class */ (function () {
306
306
  type: 'room',
307
307
  })];
308
308
  case 1:
309
- foundProperty = _c.sent();
309
+ foundProperty = _d.sent();
310
310
  if (!(foundProperty === null || foundProperty === void 0 ? void 0 : foundProperty.result)) return [3 /*break*/, 4];
311
311
  data = foundProperty.data;
312
312
  parsedProperty = JSON.parse(data);
@@ -317,7 +317,7 @@ var SmartAccessAdapter = /** @class */ (function () {
317
317
  params: {
318
318
  userType: userType,
319
319
  keyType: keyType,
320
- pinCode: null,
320
+ pinCode: pinCode,
321
321
  roomId: parsedProperty.thirdPartyId,
322
322
  accessStartDate: (0, moment_1.default)(startDate)
323
323
  .add(9, 'hours')
@@ -326,7 +326,7 @@ var SmartAccessAdapter = /** @class */ (function () {
326
326
  },
327
327
  })];
328
328
  case 2:
329
- pinCodeResult = _c.sent();
329
+ pinCodeResult = _d.sent();
330
330
  keyId = pinCodeResult.keyId;
331
331
  return [4 /*yield*/, this.callSmartAccessApi({
332
332
  accommodationId: accommodationId,
@@ -334,35 +334,35 @@ var SmartAccessAdapter = /** @class */ (function () {
334
334
  route: "v1/key/".concat(keyId, "/pincode"),
335
335
  })];
336
336
  case 3:
337
- pinCodeQuery = _c.sent();
338
- lockInfo = ((_b = pinCodeQuery === null || pinCodeQuery === void 0 ? void 0 : pinCodeQuery.lockList) === null || _b === void 0 ? void 0 : _b[0]) || {};
337
+ pinCodeQuery = _d.sent();
338
+ lockInfo = ((_c = pinCodeQuery === null || pinCodeQuery === void 0 ? void 0 : pinCodeQuery.lockList) === null || _c === void 0 ? void 0 : _c[0]) || {};
339
339
  return [2 /*return*/, __assign(__assign({}, lockInfo), { pinCode: (lockInfo === null || lockInfo === void 0 ? void 0 : lockInfo.pinCode) || (parsedData === null || parsedData === void 0 ? void 0 : parsedData.masterPinCode), keyId: keyId, pinCodeResult: pinCodeResult })];
340
- case 4: return [2 /*return*/];
340
+ case 4: return [2 /*return*/, {
341
+ error: 'THIRDPARTY_PROPERTY_NOT_FOUND',
342
+ }];
341
343
  }
342
344
  });
343
345
  });
344
346
  };
345
347
  this.modifyPinCodeByKeyId = function (_a) {
346
- var keyId = _a.keyId, accommodationId = _a.accommodationId, userType = _a.userType, keyType = _a.keyType, startDate = _a.startDate, endDate = _a.endDate;
348
+ var keyId = _a.keyId, accommodationId = _a.accommodationId, userType = _a.userType, keyType = _a.keyType, startDate = _a.startDate, endDate = _a.endDate, pinCode = _a.pinCode;
347
349
  return __awaiter(_this, void 0, void 0, function () {
348
- var pinCodeResult, pinCodeQuery;
350
+ var pinCodeResult, newKeyId, pinCodeQuery;
349
351
  return __generator(this, function (_b) {
350
352
  switch (_b.label) {
351
353
  case 0: return [4 /*yield*/, this.callSmartAccessApi({
352
354
  accommodationId: accommodationId,
353
355
  method: 'put',
354
356
  route: "v1/key/".concat(keyId, "/pincode"),
355
- params: {
356
- userType: userType,
357
- keyType: keyType,
358
- accessStartDate: (0, moment_1.default)(startDate)
357
+ params: __assign({ userType: userType, keyType: keyType, accessStartDate: (0, moment_1.default)(startDate)
359
358
  .add(9, 'hours')
360
- .format('YYYYMMDDHHmm'),
361
- accessEndDate: (0, moment_1.default)(endDate).add(9, 'hours').format('YYYYMMDDHHmm'),
362
- },
359
+ .format('YYYYMMDDHHmm'), accessEndDate: (0, moment_1.default)(endDate).add(9, 'hours').format('YYYYMMDDHHmm') }, (pinCode && {
360
+ pinCode: pinCode,
361
+ })),
363
362
  })];
364
363
  case 1:
365
364
  pinCodeResult = _b.sent();
365
+ newKeyId = pinCodeResult.keyId;
366
366
  return [4 /*yield*/, this.callSmartAccessApi({
367
367
  accommodationId: accommodationId,
368
368
  method: 'get',
@@ -370,7 +370,7 @@ var SmartAccessAdapter = /** @class */ (function () {
370
370
  })];
371
371
  case 2:
372
372
  pinCodeQuery = _b.sent();
373
- return [2 /*return*/, __assign(__assign({}, pinCodeQuery.lockList[0]), { keyId: keyId })];
373
+ return [2 /*return*/, __assign(__assign({}, pinCodeQuery.lockList[0]), { keyId: newKeyId })];
374
374
  }
375
375
  });
376
376
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendit-dev/thirdparty-adapters",
3
- "version": "0.7.5",
3
+ "version": "0.7.6-beta.1",
4
4
  "description": "Third party adapters between v-cloud and other PMS/CMS providers.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -1 +0,0 @@
1
- export declare function findMinimumNumbersForSum(target: number, numbers: number[]): number[];
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findMinimumNumbersForSum = void 0;
4
- function findMinimumNumbersForSum(target, numbers) {
5
- // Sort the numbers array in descending order.
6
- numbers.sort(function (a, b) { return b - a; });
7
- var sum = 0;
8
- var result = [];
9
- for (var _i = 0, numbers_1 = numbers; _i < numbers_1.length; _i++) {
10
- var number = numbers_1[_i];
11
- while (sum + number <= target) {
12
- sum += number;
13
- result.push(number);
14
- }
15
- // Early exit if the target is reached or exceeded.
16
- if (sum >= target) {
17
- break;
18
- }
19
- }
20
- // If the sum is not reached, no solution exists with the given numbers.
21
- if (sum < target) {
22
- return [];
23
- }
24
- return result;
25
- }
26
- exports.findMinimumNumbersForSum = findMinimumNumbersForSum;