@vendit-dev/thirdparty-adapters 0.3.4 → 0.3.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.
- package/lib/adapters/sanhaWings.d.ts +16 -10
- package/lib/adapters/sanhaWings.js +83 -39
- package/lib/adapters/smartAccess.js +0 -2
- package/lib/adapters/themrIoT.d.ts +145 -0
- package/lib/adapters/themrIoT.js +285 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -1
- package/package.json +1 -1
|
@@ -35,7 +35,7 @@ export declare class WingsApiController {
|
|
|
35
35
|
constructor({ contextApi }: {
|
|
36
36
|
contextApi: string;
|
|
37
37
|
});
|
|
38
|
-
callWingsApi: ({ route, params, auth }: {
|
|
38
|
+
callWingsApi: ({ route, params, auth, }: {
|
|
39
39
|
route: string;
|
|
40
40
|
params?: any;
|
|
41
41
|
auth: {
|
|
@@ -45,7 +45,7 @@ export declare class WingsApiController {
|
|
|
45
45
|
}) => Promise<WingsApiCommonResponse>;
|
|
46
46
|
}
|
|
47
47
|
export default class WingsAdapter {
|
|
48
|
-
static indexAccommodation: ({ accommodationId }: {
|
|
48
|
+
static indexAccommodation: ({ accommodationId, }: {
|
|
49
49
|
accommodationId: string;
|
|
50
50
|
}) => string;
|
|
51
51
|
static authFromCredentials: ({ vendorId, companyId, apiKey, kioskIp, }: WingsCommonCredential) => {
|
|
@@ -62,17 +62,17 @@ export default class WingsAdapter {
|
|
|
62
62
|
authenticator: UserServiceGrpcCaller;
|
|
63
63
|
redis: any;
|
|
64
64
|
PROVIDER_KEY: string;
|
|
65
|
-
constructor({ authenticator, redis }: {
|
|
65
|
+
constructor({ authenticator, redis, }: {
|
|
66
66
|
authenticator: UserServiceGrpcCaller;
|
|
67
67
|
redis: any;
|
|
68
68
|
});
|
|
69
|
-
checkWingsIntegration: ({ accommodationId }: {
|
|
69
|
+
checkWingsIntegration: ({ accommodationId, }: {
|
|
70
70
|
accommodationId: string;
|
|
71
71
|
}) => Promise<boolean>;
|
|
72
|
-
getAccommodationAuthInfo: ({ accommodationId }: {
|
|
72
|
+
getAccommodationAuthInfo: ({ accommodationId, }: {
|
|
73
73
|
accommodationId: string;
|
|
74
74
|
}) => Promise<VenditWingsAuthInfo>;
|
|
75
|
-
getHotelInformation: ({ accommodationId }: {
|
|
75
|
+
getHotelInformation: ({ accommodationId, }: {
|
|
76
76
|
accommodationId: string;
|
|
77
77
|
}) => Promise<any>;
|
|
78
78
|
checkInReservation: ({ accommodationId, reservationNumber, sequenceNumber, startDate, endDate, carNumber, }: {
|
|
@@ -83,15 +83,20 @@ export default class WingsAdapter {
|
|
|
83
83
|
endDate: string;
|
|
84
84
|
carNumber: string;
|
|
85
85
|
}) => Promise<any>;
|
|
86
|
-
cancelCheckInReservation: ({ accommodationId, folioNumber }: {
|
|
86
|
+
cancelCheckInReservation: ({ accommodationId, folioNumber, }: {
|
|
87
87
|
accommodationId: string;
|
|
88
88
|
folioNumber: string;
|
|
89
89
|
}) => Promise<boolean>;
|
|
90
|
-
getReservationByNumber: ({ accommodationId, reservationNumber }: {
|
|
90
|
+
getReservationByNumber: ({ accommodationId, reservationNumber, }: {
|
|
91
91
|
accommodationId: string;
|
|
92
92
|
reservationNumber: string;
|
|
93
93
|
}) => Promise<any>;
|
|
94
|
-
|
|
94
|
+
updateReservation: ({ accommodationId, reservationNumber, mobileNumber, }: {
|
|
95
|
+
accommodationId: string;
|
|
96
|
+
reservationNumber: string;
|
|
97
|
+
mobileNumber: string;
|
|
98
|
+
}) => Promise<true | null>;
|
|
99
|
+
getPurchaseAmount: ({ accommodationId, folioNumber, }: {
|
|
95
100
|
accommodationId: string;
|
|
96
101
|
folioNumber: string;
|
|
97
102
|
}) => Promise<null | undefined>;
|
|
@@ -124,7 +129,7 @@ export default class WingsAdapter {
|
|
|
124
129
|
walkinInfo: any;
|
|
125
130
|
roomInfo: [unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown];
|
|
126
131
|
} | null>;
|
|
127
|
-
processWalkIn: ({ accommodationId, roomTypeCode, startDate, endDate, nights, salesDate, guestName, adultCount, childCount, dailyRoomFees, carNumber, }: {
|
|
132
|
+
processWalkIn: ({ accommodationId, roomTypeCode, startDate, endDate, nights, salesDate, guestName, adultCount, childCount, dailyRoomFees, carNumber, mobileNumber, }: {
|
|
128
133
|
accommodationId: string;
|
|
129
134
|
roomTypeCode: string;
|
|
130
135
|
startDate: string;
|
|
@@ -136,6 +141,7 @@ export default class WingsAdapter {
|
|
|
136
141
|
childCount: number;
|
|
137
142
|
dailyRoomFees: Array<string>;
|
|
138
143
|
carNumber: string;
|
|
144
|
+
mobileNumber: string;
|
|
139
145
|
}) => Promise<any>;
|
|
140
146
|
getCheckOutInfo: ({ accommodationId, folioNumber, roomKey, }: {
|
|
141
147
|
accommodationId: string;
|
|
@@ -142,7 +142,10 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
142
142
|
if (existingAuth) {
|
|
143
143
|
return [2 /*return*/, JSON.parse(existingAuth)];
|
|
144
144
|
}
|
|
145
|
-
return [4 /*yield*/, this.authenticator.getThirdPartyCredential({
|
|
145
|
+
return [4 /*yield*/, this.authenticator.getThirdPartyCredential({
|
|
146
|
+
accommodationId: accommodationId,
|
|
147
|
+
provider: this.PROVIDER_KEY,
|
|
148
|
+
})];
|
|
146
149
|
case 5:
|
|
147
150
|
newAuth = _b.sent();
|
|
148
151
|
if (!!newAuth) return [3 /*break*/, 7];
|
|
@@ -299,10 +302,45 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
299
302
|
});
|
|
300
303
|
});
|
|
301
304
|
};
|
|
305
|
+
this.updateReservation = function (_a) {
|
|
306
|
+
var accommodationId = _a.accommodationId, reservationNumber = _a.reservationNumber, mobileNumber = _a.mobileNumber;
|
|
307
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
308
|
+
var authInfo, response, err_5;
|
|
309
|
+
return __generator(this, function (_b) {
|
|
310
|
+
switch (_b.label) {
|
|
311
|
+
case 0: return [4 /*yield*/, this.getAccommodationAuthInfo({ accommodationId: accommodationId })];
|
|
312
|
+
case 1:
|
|
313
|
+
authInfo = _b.sent();
|
|
314
|
+
_b.label = 2;
|
|
315
|
+
case 2:
|
|
316
|
+
_b.trys.push([2, 4, , 5]);
|
|
317
|
+
return [4 /*yield*/, apiController.callWingsApi({
|
|
318
|
+
route: 'ki01/kioskUpdateRsvn',
|
|
319
|
+
auth: WingsAdapter.authFromCredentials(authInfo.credential),
|
|
320
|
+
params: {
|
|
321
|
+
RSVN_NO: reservationNumber,
|
|
322
|
+
MOBILE_NO: mobileNumber,
|
|
323
|
+
},
|
|
324
|
+
})];
|
|
325
|
+
case 3:
|
|
326
|
+
response = _b.sent();
|
|
327
|
+
if (!response) {
|
|
328
|
+
throw new Error('Data not updated');
|
|
329
|
+
}
|
|
330
|
+
return [2 /*return*/, true];
|
|
331
|
+
case 4:
|
|
332
|
+
err_5 = _b.sent();
|
|
333
|
+
console.log(err_5);
|
|
334
|
+
return [2 /*return*/, null];
|
|
335
|
+
case 5: return [2 /*return*/];
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
};
|
|
302
340
|
this.getPurchaseAmount = function (_a) {
|
|
303
341
|
var accommodationId = _a.accommodationId, folioNumber = _a.folioNumber;
|
|
304
342
|
return __awaiter(_this, void 0, void 0, function () {
|
|
305
|
-
var authInfo, response,
|
|
343
|
+
var authInfo, response, err_6;
|
|
306
344
|
return __generator(this, function (_b) {
|
|
307
345
|
switch (_b.label) {
|
|
308
346
|
case 0: return [4 /*yield*/, this.getAccommodationAuthInfo({ accommodationId: accommodationId })];
|
|
@@ -322,8 +360,8 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
322
360
|
response = _b.sent();
|
|
323
361
|
return [3 /*break*/, 5];
|
|
324
362
|
case 4:
|
|
325
|
-
|
|
326
|
-
console.log(
|
|
363
|
+
err_6 = _b.sent();
|
|
364
|
+
console.log(err_6);
|
|
327
365
|
return [2 /*return*/, null];
|
|
328
366
|
case 5: return [2 /*return*/];
|
|
329
367
|
}
|
|
@@ -333,7 +371,7 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
333
371
|
this.getWalkinInfo = function (_a) {
|
|
334
372
|
var accommodationId = _a.accommodationId, startDate = _a.startDate, endDate = _a.endDate, adultCount = _a.adultCount, childCount = _a.childCount, langType = _a.langType;
|
|
335
373
|
return __awaiter(_this, void 0, void 0, function () {
|
|
336
|
-
var authInfo, response, _b, walkinInfo, roomInfo,
|
|
374
|
+
var authInfo, response, _b, walkinInfo, roomInfo, err_7;
|
|
337
375
|
return __generator(this, function (_c) {
|
|
338
376
|
switch (_c.label) {
|
|
339
377
|
case 0: return [4 /*yield*/, this.getAccommodationAuthInfo({ accommodationId: accommodationId })];
|
|
@@ -361,8 +399,8 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
361
399
|
roomInfo: roomInfo,
|
|
362
400
|
}];
|
|
363
401
|
case 4:
|
|
364
|
-
|
|
365
|
-
console.log(
|
|
402
|
+
err_7 = _c.sent();
|
|
403
|
+
console.log(err_7);
|
|
366
404
|
return [2 /*return*/, null];
|
|
367
405
|
case 5: return [2 /*return*/];
|
|
368
406
|
}
|
|
@@ -372,7 +410,7 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
372
410
|
this.getWalkInRoomRate = function (_a) {
|
|
373
411
|
var accommodationId = _a.accommodationId, roomTypeCode = _a.roomTypeCode, startDate = _a.startDate, endDate = _a.endDate, salesDate = _a.salesDate;
|
|
374
412
|
return __awaiter(_this, void 0, void 0, function () {
|
|
375
|
-
var authInfo, response, resultData,
|
|
413
|
+
var authInfo, response, resultData, err_8;
|
|
376
414
|
return __generator(this, function (_b) {
|
|
377
415
|
switch (_b.label) {
|
|
378
416
|
case 0: return [4 /*yield*/, this.getAccommodationAuthInfo({ accommodationId: accommodationId })];
|
|
@@ -397,8 +435,8 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
397
435
|
resultData = response.resultData;
|
|
398
436
|
return [2 /*return*/, resultData];
|
|
399
437
|
case 4:
|
|
400
|
-
|
|
401
|
-
console.log(
|
|
438
|
+
err_8 = _b.sent();
|
|
439
|
+
console.log(err_8);
|
|
402
440
|
return [2 /*return*/, null];
|
|
403
441
|
case 5: return [2 /*return*/];
|
|
404
442
|
}
|
|
@@ -408,7 +446,7 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
408
446
|
this.queryWalkinRoomTypesWithPrices = function (_a) {
|
|
409
447
|
var accommodationId = _a.accommodationId, startDate = _a.startDate, endDate = _a.endDate, adultCount = _a.adultCount, childCount = _a.childCount, langType = _a.langType;
|
|
410
448
|
return __awaiter(_this, void 0, void 0, function () {
|
|
411
|
-
var authInfo, response, _b, walkinInfo, roomInfo, roomInfoWithPrices,
|
|
449
|
+
var authInfo, response, _b, walkinInfo, roomInfo, roomInfoWithPrices, err_9;
|
|
412
450
|
var _this = this;
|
|
413
451
|
return __generator(this, function (_c) {
|
|
414
452
|
switch (_c.label) {
|
|
@@ -465,8 +503,8 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
465
503
|
roomInfo: roomInfoWithPrices,
|
|
466
504
|
}];
|
|
467
505
|
case 5:
|
|
468
|
-
|
|
469
|
-
console.log(
|
|
506
|
+
err_9 = _c.sent();
|
|
507
|
+
console.log(err_9);
|
|
470
508
|
return [2 /*return*/, null];
|
|
471
509
|
case 6: return [2 /*return*/];
|
|
472
510
|
}
|
|
@@ -474,9 +512,9 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
474
512
|
});
|
|
475
513
|
};
|
|
476
514
|
this.processWalkIn = function (_a) {
|
|
477
|
-
var accommodationId = _a.accommodationId, roomTypeCode = _a.roomTypeCode, startDate = _a.startDate, endDate = _a.endDate, nights = _a.nights, salesDate = _a.salesDate, guestName = _a.guestName, adultCount = _a.adultCount, childCount = _a.childCount, dailyRoomFees = _a.dailyRoomFees, carNumber = _a.carNumber;
|
|
515
|
+
var accommodationId = _a.accommodationId, roomTypeCode = _a.roomTypeCode, startDate = _a.startDate, endDate = _a.endDate, nights = _a.nights, salesDate = _a.salesDate, guestName = _a.guestName, adultCount = _a.adultCount, childCount = _a.childCount, dailyRoomFees = _a.dailyRoomFees, carNumber = _a.carNumber, mobileNumber = _a.mobileNumber;
|
|
478
516
|
return __awaiter(_this, void 0, void 0, function () {
|
|
479
|
-
var authInfo, response, resultData,
|
|
517
|
+
var authInfo, response, resultData, err_10;
|
|
480
518
|
return __generator(this, function (_b) {
|
|
481
519
|
switch (_b.label) {
|
|
482
520
|
case 0: return [4 /*yield*/, this.getAccommodationAuthInfo({ accommodationId: accommodationId })];
|
|
@@ -498,6 +536,7 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
498
536
|
ADULT_CNT: adultCount,
|
|
499
537
|
CHILD_CNT: childCount,
|
|
500
538
|
CAR_NO: carNumber,
|
|
539
|
+
MOBILE_NO: mobileNumber,
|
|
501
540
|
INHS_GEST_NAME: guestName,
|
|
502
541
|
BSNS_CODE: authInfo.credential.BSNS_CODE,
|
|
503
542
|
},
|
|
@@ -509,8 +548,8 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
509
548
|
resultData = response.resultData;
|
|
510
549
|
return [2 /*return*/, resultData];
|
|
511
550
|
case 4:
|
|
512
|
-
|
|
513
|
-
console.log(
|
|
551
|
+
err_10 = _b.sent();
|
|
552
|
+
console.log(err_10);
|
|
514
553
|
return [2 /*return*/, null];
|
|
515
554
|
case 5: return [2 /*return*/];
|
|
516
555
|
}
|
|
@@ -520,7 +559,7 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
520
559
|
this.getCheckOutInfo = function (_a) {
|
|
521
560
|
var accommodationId = _a.accommodationId, folioNumber = _a.folioNumber, roomKey = _a.roomKey;
|
|
522
561
|
return __awaiter(_this, void 0, void 0, function () {
|
|
523
|
-
var authInfo, response, resultData,
|
|
562
|
+
var authInfo, response, resultData, err_11;
|
|
524
563
|
return __generator(this, function (_b) {
|
|
525
564
|
switch (_b.label) {
|
|
526
565
|
case 0: return [4 /*yield*/, this.getAccommodationAuthInfo({ accommodationId: accommodationId })];
|
|
@@ -539,8 +578,8 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
539
578
|
resultData = response.resultData;
|
|
540
579
|
return [2 /*return*/, resultData];
|
|
541
580
|
case 4:
|
|
542
|
-
|
|
543
|
-
console.log(
|
|
581
|
+
err_11 = _b.sent();
|
|
582
|
+
console.log(err_11);
|
|
544
583
|
return [2 /*return*/, null];
|
|
545
584
|
case 5: return [2 /*return*/];
|
|
546
585
|
}
|
|
@@ -550,7 +589,7 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
550
589
|
this.processCheckOut = function (_a) {
|
|
551
590
|
var accommodationId = _a.accommodationId, folioNumber = _a.folioNumber;
|
|
552
591
|
return __awaiter(_this, void 0, void 0, function () {
|
|
553
|
-
var authInfo, response, resultData,
|
|
592
|
+
var authInfo, response, resultData, err_12;
|
|
554
593
|
return __generator(this, function (_b) {
|
|
555
594
|
switch (_b.label) {
|
|
556
595
|
case 0: return [4 /*yield*/, this.getAccommodationAuthInfo({ accommodationId: accommodationId })];
|
|
@@ -572,8 +611,8 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
572
611
|
resultData = response.resultData;
|
|
573
612
|
return [2 /*return*/, resultData];
|
|
574
613
|
case 4:
|
|
575
|
-
|
|
576
|
-
console.log(
|
|
614
|
+
err_12 = _b.sent();
|
|
615
|
+
console.log(err_12);
|
|
577
616
|
return [2 /*return*/, null];
|
|
578
617
|
case 5: return [2 /*return*/];
|
|
579
618
|
}
|
|
@@ -583,7 +622,7 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
583
622
|
this.reportKeyIssue = function (_a) {
|
|
584
623
|
var accommodationId = _a.accommodationId, folioNumber = _a.folioNumber, roomNumber = _a.roomNumber, registerDate = _a.registerDate, issuedCount = _a.issuedCount, resultMessage = _a.resultMessage;
|
|
585
624
|
return __awaiter(_this, void 0, void 0, function () {
|
|
586
|
-
var authInfo, response, resultData,
|
|
625
|
+
var authInfo, response, resultData, err_13;
|
|
587
626
|
return __generator(this, function (_b) {
|
|
588
627
|
switch (_b.label) {
|
|
589
628
|
case 0: return [4 /*yield*/, this.getAccommodationAuthInfo({ accommodationId: accommodationId })];
|
|
@@ -612,8 +651,8 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
612
651
|
}
|
|
613
652
|
return [2 /*return*/, resultData];
|
|
614
653
|
case 4:
|
|
615
|
-
|
|
616
|
-
console.log(
|
|
654
|
+
err_13 = _b.sent();
|
|
655
|
+
console.log(err_13);
|
|
617
656
|
return [2 /*return*/, null];
|
|
618
657
|
case 5: return [2 /*return*/];
|
|
619
658
|
}
|
|
@@ -623,7 +662,7 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
623
662
|
this.reportKeyRetrieve = function (_a) {
|
|
624
663
|
var accommodationId = _a.accommodationId, folioNumber = _a.folioNumber;
|
|
625
664
|
return __awaiter(_this, void 0, void 0, function () {
|
|
626
|
-
var authInfo, response, resultData,
|
|
665
|
+
var authInfo, response, resultData, err_14;
|
|
627
666
|
return __generator(this, function (_b) {
|
|
628
667
|
switch (_b.label) {
|
|
629
668
|
case 0: return [4 /*yield*/, this.getAccommodationAuthInfo({ accommodationId: accommodationId })];
|
|
@@ -650,8 +689,8 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
650
689
|
}
|
|
651
690
|
return [2 /*return*/, resultData];
|
|
652
691
|
case 4:
|
|
653
|
-
|
|
654
|
-
console.log(
|
|
692
|
+
err_14 = _b.sent();
|
|
693
|
+
console.log(err_14);
|
|
655
694
|
return [2 /*return*/, null];
|
|
656
695
|
case 5: return [2 /*return*/];
|
|
657
696
|
}
|
|
@@ -661,7 +700,7 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
661
700
|
this.savePayment = function (_a) {
|
|
662
701
|
var accommodationId = _a.accommodationId, folioNumber = _a.folioNumber, paymentAmount = _a.paymentAmount, saleDate = _a.saleDate, paymentInfo = _a.paymentInfo;
|
|
663
702
|
return __awaiter(_this, void 0, void 0, function () {
|
|
664
|
-
var authInfo, parsedData, refinedData, response, resultData,
|
|
703
|
+
var authInfo, parsedData, refinedData, response, resultData, err_15;
|
|
665
704
|
return __generator(this, function (_b) {
|
|
666
705
|
switch (_b.label) {
|
|
667
706
|
case 0: return [4 /*yield*/, this.getAccommodationAuthInfo({ accommodationId: accommodationId })];
|
|
@@ -669,7 +708,7 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
669
708
|
authInfo = _b.sent();
|
|
670
709
|
parsedData = JSON.parse(paymentInfo);
|
|
671
710
|
switch (parsedData.vanType) {
|
|
672
|
-
case
|
|
711
|
+
case 'KSNET': {
|
|
673
712
|
refinedData = {
|
|
674
713
|
// KSNET data
|
|
675
714
|
APPR_TYPE_CODE: parsedData.APPR_TYPE_CODE || '11',
|
|
@@ -692,12 +731,13 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
692
731
|
APPR_LINE_TYPE_CODE: parsedData.APPR_LINE_TYPE_CODE || 'A',
|
|
693
732
|
KEY_IN_TYPE_CODE: parsedData.KEY_IN_TYPE_CODE || 'S',
|
|
694
733
|
SPC_UNIQUE_ALIAS: parsedData.SPC_UNIQUE_ALIAS || 'SEND_GB_APP',
|
|
695
|
-
CARD_READING_DATA: parsedData.CARD_READING_DATA ||
|
|
734
|
+
CARD_READING_DATA: parsedData.CARD_READING_DATA ||
|
|
735
|
+
'0000000000000000:00000000000000000000',
|
|
696
736
|
SPC_TYPE_CODE: parsedData.SPC_TYPE_CODE,
|
|
697
737
|
};
|
|
698
738
|
break;
|
|
699
739
|
}
|
|
700
|
-
case
|
|
740
|
+
case 'CASH': {
|
|
701
741
|
refinedData = {
|
|
702
742
|
CRDT_CARD_NO: 'KICASH',
|
|
703
743
|
COMT: 'KISOK_CASH_PURCHASE',
|
|
@@ -729,8 +769,8 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
729
769
|
console.log(resultData);
|
|
730
770
|
return [2 /*return*/, resultData];
|
|
731
771
|
case 4:
|
|
732
|
-
|
|
733
|
-
console.log(
|
|
772
|
+
err_15 = _b.sent();
|
|
773
|
+
console.log(err_15);
|
|
734
774
|
return [2 /*return*/, false];
|
|
735
775
|
case 5: return [2 /*return*/];
|
|
736
776
|
}
|
|
@@ -740,7 +780,7 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
740
780
|
this.savePaymentWithPaymentId = function (_a) {
|
|
741
781
|
var paymentId = _a.paymentId, folioNumber = _a.folioNumber;
|
|
742
782
|
return __awaiter(_this, void 0, void 0, function () {
|
|
743
|
-
var foundPaymentInfo, parsedPayment,
|
|
783
|
+
var foundPaymentInfo, parsedPayment, err_16;
|
|
744
784
|
return __generator(this, function (_b) {
|
|
745
785
|
switch (_b.label) {
|
|
746
786
|
case 0: return [4 /*yield*/, this.redis.get("SanhaWings|" + paymentId)];
|
|
@@ -763,8 +803,8 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
763
803
|
_b.sent();
|
|
764
804
|
return [3 /*break*/, 5];
|
|
765
805
|
case 4:
|
|
766
|
-
|
|
767
|
-
console.log(
|
|
806
|
+
err_16 = _b.sent();
|
|
807
|
+
console.log(err_16);
|
|
768
808
|
throw new Error('FAILED_TO_SAVE_PAYMENT');
|
|
769
809
|
case 5: return [2 /*return*/];
|
|
770
810
|
}
|
|
@@ -773,7 +813,11 @@ var WingsAdapter = /** @class */ (function () {
|
|
|
773
813
|
};
|
|
774
814
|
this.authenticator = authenticator;
|
|
775
815
|
this.redis = redis;
|
|
776
|
-
this.mutexLock = new mutex_1.default({
|
|
816
|
+
this.mutexLock = new mutex_1.default({
|
|
817
|
+
hashPrefix: 'RES_WINGS_MUTEX_',
|
|
818
|
+
mutexLockInterval: 50,
|
|
819
|
+
redis: redis,
|
|
820
|
+
});
|
|
777
821
|
}
|
|
778
822
|
WingsAdapter.indexAccommodation = function (_a) {
|
|
779
823
|
var accommodationId = _a.accommodationId;
|
|
@@ -203,14 +203,12 @@ var SmartAccessAdapter = /** @class */ (function () {
|
|
|
203
203
|
_j.label = 2;
|
|
204
204
|
case 2:
|
|
205
205
|
requestArgs = __assign.apply(void 0, _c.concat([(_d.headers = __assign.apply(void 0, [__assign.apply(void 0, _e.concat([(_f)])), headers]), _d)]));
|
|
206
|
-
console.log(requestArgs);
|
|
207
206
|
return [4 /*yield*/, node_fetch_1.default(this.API_HOST + "/sa/oauth/" + route, requestArgs)];
|
|
208
207
|
case 3:
|
|
209
208
|
response = _j.sent();
|
|
210
209
|
return [4 /*yield*/, response.json()];
|
|
211
210
|
case 4:
|
|
212
211
|
jsonResponse = _j.sent();
|
|
213
|
-
console.log(jsonResponse);
|
|
214
212
|
return [2 /*return*/, jsonResponse];
|
|
215
213
|
}
|
|
216
214
|
});
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { UserServiceGrpcCaller } from '@vendit-dev/utility-modules';
|
|
2
|
+
import MutexLock from '../utils/mutex';
|
|
3
|
+
declare type VenditThemrIoTAuthInfo = {
|
|
4
|
+
scope: string;
|
|
5
|
+
credential: {
|
|
6
|
+
hotel_id: string;
|
|
7
|
+
user_id: string;
|
|
8
|
+
accessToken: string;
|
|
9
|
+
refreshToken: string;
|
|
10
|
+
expiresAt: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
declare type DoorlockListResponse = {
|
|
14
|
+
code: number;
|
|
15
|
+
message: string;
|
|
16
|
+
count?: number;
|
|
17
|
+
list?: {
|
|
18
|
+
roomNm: string;
|
|
19
|
+
lockMac: string;
|
|
20
|
+
buildingNo: number;
|
|
21
|
+
floorNo: number;
|
|
22
|
+
lockId: number;
|
|
23
|
+
batteryState: number;
|
|
24
|
+
gatewayState: number;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
declare type DoorlockDetailResponse = [{
|
|
28
|
+
code: number;
|
|
29
|
+
message: string;
|
|
30
|
+
}, {
|
|
31
|
+
date: number;
|
|
32
|
+
lockAlias: string;
|
|
33
|
+
lockSound: number;
|
|
34
|
+
modelNum: string;
|
|
35
|
+
lockMac: string;
|
|
36
|
+
privacyLock: number;
|
|
37
|
+
deletePwd: string;
|
|
38
|
+
featureValue: string;
|
|
39
|
+
adminPwd: string;
|
|
40
|
+
soundVolume: number;
|
|
41
|
+
hasGateway: number;
|
|
42
|
+
autoLockTime: number;
|
|
43
|
+
wirelessKeypadFeatureValue: string;
|
|
44
|
+
floorNumber: number;
|
|
45
|
+
buildingNumber: number;
|
|
46
|
+
lockKey: string;
|
|
47
|
+
isFrozen: number;
|
|
48
|
+
lockName: string;
|
|
49
|
+
sector: string;
|
|
50
|
+
resetButton: number;
|
|
51
|
+
firmwareRevision: string;
|
|
52
|
+
tamperAlert: number;
|
|
53
|
+
specialValue: number;
|
|
54
|
+
displayPasscode: number;
|
|
55
|
+
noKeyPwd: string;
|
|
56
|
+
passageMode: number;
|
|
57
|
+
passageModeAutoUnlock: number;
|
|
58
|
+
timezoneRawOffset: number;
|
|
59
|
+
lockId: number;
|
|
60
|
+
electricQuantity: number;
|
|
61
|
+
lockFlagPos: number;
|
|
62
|
+
lockUpdateDate: number;
|
|
63
|
+
keyboardPwdVersion: number;
|
|
64
|
+
aesKeyStr: string;
|
|
65
|
+
hardwareRevision: string;
|
|
66
|
+
openDirection: number;
|
|
67
|
+
lockVersion: {
|
|
68
|
+
groupId: number;
|
|
69
|
+
protocolVersion: number;
|
|
70
|
+
protocolType: number;
|
|
71
|
+
orgId: number;
|
|
72
|
+
scene: number;
|
|
73
|
+
};
|
|
74
|
+
sensitivity: number;
|
|
75
|
+
}];
|
|
76
|
+
declare type GetOTPPassCodeResponse = {
|
|
77
|
+
code: number;
|
|
78
|
+
message: string;
|
|
79
|
+
passcode: string;
|
|
80
|
+
passcodeId: number;
|
|
81
|
+
};
|
|
82
|
+
declare type writeAsyncRFCardRes = {
|
|
83
|
+
code: string;
|
|
84
|
+
issue_cd: string;
|
|
85
|
+
message: string;
|
|
86
|
+
data: string;
|
|
87
|
+
cardnum: string;
|
|
88
|
+
client_id: string;
|
|
89
|
+
call_api: string;
|
|
90
|
+
call_id: string;
|
|
91
|
+
method: string | 'rfcardwrite';
|
|
92
|
+
hotel_id: string;
|
|
93
|
+
};
|
|
94
|
+
export default class ThemrIoTAdapter {
|
|
95
|
+
API_HOST: string;
|
|
96
|
+
mutexLock: MutexLock;
|
|
97
|
+
authenticator: UserServiceGrpcCaller;
|
|
98
|
+
redis: any;
|
|
99
|
+
timeFormat: string;
|
|
100
|
+
PROVIDER_KEY: string;
|
|
101
|
+
constructor({ authenticator, redis, apiHost, }: {
|
|
102
|
+
authenticator: UserServiceGrpcCaller;
|
|
103
|
+
redis: any;
|
|
104
|
+
apiHost: string;
|
|
105
|
+
});
|
|
106
|
+
callTheMRApi: ({ route, params, }: {
|
|
107
|
+
route: string;
|
|
108
|
+
params: Record<string, any>;
|
|
109
|
+
}) => Promise<any>;
|
|
110
|
+
static indexAccommodation: ({ accommodationId, }: {
|
|
111
|
+
accommodationId: string;
|
|
112
|
+
}) => string;
|
|
113
|
+
checkTheMRIoTIntegration: ({ accommodationId, }: {
|
|
114
|
+
accommodationId: string;
|
|
115
|
+
}) => Promise<boolean>;
|
|
116
|
+
getAccommodationAuthInfo: ({ accommodationId, }: {
|
|
117
|
+
accommodationId: string;
|
|
118
|
+
}) => Promise<VenditThemrIoTAuthInfo>;
|
|
119
|
+
getDefaultCheckInDate: () => string;
|
|
120
|
+
getDefaultCheckOutDate: () => string;
|
|
121
|
+
doorlockList: ({ accommodationId, roomAlias, }: {
|
|
122
|
+
accommodationId: string;
|
|
123
|
+
roomAlias?: string | undefined;
|
|
124
|
+
}) => Promise<DoorlockListResponse>;
|
|
125
|
+
doorlockDetail: ({ accommodationId, lockId, }: {
|
|
126
|
+
accommodationId: string;
|
|
127
|
+
lockId: string;
|
|
128
|
+
}) => Promise<DoorlockDetailResponse>;
|
|
129
|
+
getOTPPassCode: ({ accommodationId, lockId, checkinDate, checkoutDate, }: {
|
|
130
|
+
accommodationId: string;
|
|
131
|
+
lockId: string;
|
|
132
|
+
checkinDate?: string | undefined;
|
|
133
|
+
checkoutDate?: string | undefined;
|
|
134
|
+
}) => Promise<GetOTPPassCodeResponse>;
|
|
135
|
+
writeAsyncRFCard: ({ accommodationId, checkinDate, checkoutDate, build_no, floor_no, lock_mac, agent_id, }: {
|
|
136
|
+
accommodationId: string;
|
|
137
|
+
checkinDate?: string | undefined;
|
|
138
|
+
checkoutDate?: string | undefined;
|
|
139
|
+
build_no?: string | undefined;
|
|
140
|
+
floor_no?: string | undefined;
|
|
141
|
+
lock_mac: string;
|
|
142
|
+
agent_id: string;
|
|
143
|
+
}) => Promise<writeAsyncRFCardRes>;
|
|
144
|
+
}
|
|
145
|
+
export {};
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
/* eslint-disable camelcase */
|
|
54
|
+
/* eslint-disable indent */
|
|
55
|
+
/* eslint-disable no-mixed-spaces-and-tabs */
|
|
56
|
+
/* eslint-disable no-tabs */
|
|
57
|
+
var node_fetch_1 = __importDefault(require("node-fetch"));
|
|
58
|
+
var moment_1 = __importDefault(require("moment"));
|
|
59
|
+
var mutex_1 = __importDefault(require("../utils/mutex"));
|
|
60
|
+
var ThemrIoTAdapter = /** @class */ (function () {
|
|
61
|
+
function ThemrIoTAdapter(_a) {
|
|
62
|
+
var _this = this;
|
|
63
|
+
var authenticator = _a.authenticator, redis = _a.redis, apiHost = _a.apiHost;
|
|
64
|
+
this.API_HOST = 'http://api.hotel-lock.co.kr';
|
|
65
|
+
this.timeFormat = 'YYYY-MM-DD HH:mm:ss';
|
|
66
|
+
this.PROVIDER_KEY = 'TheMR';
|
|
67
|
+
this.callTheMRApi = function (_a) {
|
|
68
|
+
var route = _a.route, _b = _a.params, params = _b === void 0 ? {} : _b;
|
|
69
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
70
|
+
var requestOptions, res, data;
|
|
71
|
+
return __generator(this, function (_c) {
|
|
72
|
+
switch (_c.label) {
|
|
73
|
+
case 0:
|
|
74
|
+
requestOptions = {
|
|
75
|
+
method: 'POST',
|
|
76
|
+
headers: { 'Content-Type': 'application/json' },
|
|
77
|
+
body: JSON.stringify(__assign({}, params)),
|
|
78
|
+
};
|
|
79
|
+
return [4 /*yield*/, node_fetch_1.default("" + this.API_HOST + route, requestOptions)];
|
|
80
|
+
case 1:
|
|
81
|
+
res = _c.sent();
|
|
82
|
+
return [4 /*yield*/, res.json()];
|
|
83
|
+
case 2:
|
|
84
|
+
data = _c.sent();
|
|
85
|
+
return [2 /*return*/, data];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
this.checkTheMRIoTIntegration = function (_a) {
|
|
91
|
+
var accommodationId = _a.accommodationId;
|
|
92
|
+
return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) {
|
|
93
|
+
return [2 /*return*/, !!this.getAccommodationAuthInfo({ accommodationId: accommodationId })];
|
|
94
|
+
}); });
|
|
95
|
+
};
|
|
96
|
+
this.getAccommodationAuthInfo = function (_a) {
|
|
97
|
+
var accommodationId = _a.accommodationId;
|
|
98
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
99
|
+
var existingAuth, lockId, lockHash, newAuth, err_1;
|
|
100
|
+
return __generator(this, function (_b) {
|
|
101
|
+
switch (_b.label) {
|
|
102
|
+
case 0: return [4 /*yield*/, this.redis.get(ThemrIoTAdapter.indexAccommodation({ accommodationId: accommodationId }))];
|
|
103
|
+
case 1:
|
|
104
|
+
existingAuth = _b.sent();
|
|
105
|
+
if (existingAuth) {
|
|
106
|
+
if (existingAuth === 'NOT_FOUND') {
|
|
107
|
+
throw new Error('THIRDPARTY_AUTH_NOT_FOUND');
|
|
108
|
+
}
|
|
109
|
+
return [2 /*return*/, JSON.parse(existingAuth)];
|
|
110
|
+
}
|
|
111
|
+
lockId = "THEMR-HKEY|" + accommodationId;
|
|
112
|
+
return [4 /*yield*/, this.mutexLock.getMutexLock(lockId)];
|
|
113
|
+
case 2:
|
|
114
|
+
lockHash = _b.sent();
|
|
115
|
+
return [4 /*yield*/, this.redis.get(ThemrIoTAdapter.indexAccommodation({ accommodationId: accommodationId }))];
|
|
116
|
+
case 3:
|
|
117
|
+
existingAuth = _b.sent();
|
|
118
|
+
_b.label = 4;
|
|
119
|
+
case 4:
|
|
120
|
+
_b.trys.push([4, 9, 10, 12]);
|
|
121
|
+
if (existingAuth) {
|
|
122
|
+
if (existingAuth === 'NOT_FOUND') {
|
|
123
|
+
throw new Error('THIRDPARTY_AUTH_NOT_FOUND');
|
|
124
|
+
}
|
|
125
|
+
return [2 /*return*/, JSON.parse(existingAuth)];
|
|
126
|
+
}
|
|
127
|
+
return [4 /*yield*/, this.authenticator.getThirdPartyCredential({
|
|
128
|
+
accommodationId: accommodationId,
|
|
129
|
+
provider: this.PROVIDER_KEY,
|
|
130
|
+
})];
|
|
131
|
+
case 5:
|
|
132
|
+
newAuth = _b.sent();
|
|
133
|
+
if (!!newAuth) return [3 /*break*/, 7];
|
|
134
|
+
return [4 /*yield*/, this.redis.set(ThemrIoTAdapter.indexAccommodation({ accommodationId: accommodationId }), 'NOT_FOUND', 'EX', 60 * 10)];
|
|
135
|
+
case 6:
|
|
136
|
+
_b.sent();
|
|
137
|
+
throw new Error('THIRDPARTY_AUTH_NOT_FOUND');
|
|
138
|
+
case 7:
|
|
139
|
+
newAuth.credential = JSON.parse(newAuth.credential);
|
|
140
|
+
return [4 /*yield*/, this.redis.set(ThemrIoTAdapter.indexAccommodation({ accommodationId: accommodationId }), JSON.stringify(newAuth), 'EX', 60 * 10)];
|
|
141
|
+
case 8:
|
|
142
|
+
_b.sent();
|
|
143
|
+
return [2 /*return*/, newAuth];
|
|
144
|
+
case 9:
|
|
145
|
+
err_1 = _b.sent();
|
|
146
|
+
console.log(err_1);
|
|
147
|
+
throw err_1;
|
|
148
|
+
case 10: return [4 /*yield*/, this.mutexLock.unlockMutexLock(lockId, lockHash)];
|
|
149
|
+
case 11:
|
|
150
|
+
_b.sent();
|
|
151
|
+
return [7 /*endfinally*/];
|
|
152
|
+
case 12: return [2 /*return*/];
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
this.getDefaultCheckInDate = function () { return moment_1.default().format(_this.timeFormat); };
|
|
158
|
+
this.getDefaultCheckOutDate = function () { return moment_1.default().add(3, 'd').format(_this.timeFormat); };
|
|
159
|
+
// 3.3. 전체 객실/도어 정보 요청
|
|
160
|
+
this.doorlockList = function (_a) {
|
|
161
|
+
var accommodationId = _a.accommodationId, _b = _a.roomAlias, roomAlias = _b === void 0 ? '' : _b;
|
|
162
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
163
|
+
var authInfo, credential, data;
|
|
164
|
+
return __generator(this, function (_c) {
|
|
165
|
+
switch (_c.label) {
|
|
166
|
+
case 0: return [4 /*yield*/, this.getAccommodationAuthInfo({ accommodationId: accommodationId })];
|
|
167
|
+
case 1:
|
|
168
|
+
authInfo = _c.sent();
|
|
169
|
+
credential = authInfo.credential;
|
|
170
|
+
return [4 /*yield*/, this.callTheMRApi({
|
|
171
|
+
route: '/sc/v1/doorlocklist',
|
|
172
|
+
params: __assign({ token: credential.accessToken }, (roomAlias && { roomAlias: roomAlias })),
|
|
173
|
+
})];
|
|
174
|
+
case 2:
|
|
175
|
+
data = _c.sent();
|
|
176
|
+
console.log('doorlockList', data);
|
|
177
|
+
if (data.code !== 0) {
|
|
178
|
+
throw new Error('ERR_DOOR_LOCK_LIST_NOT_LOAD');
|
|
179
|
+
}
|
|
180
|
+
return [2 /*return*/, data];
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
// 3.4. 상세 도어정보 요청
|
|
186
|
+
this.doorlockDetail = function (_a) {
|
|
187
|
+
var accommodationId = _a.accommodationId, lockId = _a.lockId;
|
|
188
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
189
|
+
var authInfo, credential, data;
|
|
190
|
+
return __generator(this, function (_b) {
|
|
191
|
+
switch (_b.label) {
|
|
192
|
+
case 0: return [4 /*yield*/, this.getAccommodationAuthInfo({ accommodationId: accommodationId })];
|
|
193
|
+
case 1:
|
|
194
|
+
authInfo = _b.sent();
|
|
195
|
+
credential = authInfo.credential;
|
|
196
|
+
return [4 /*yield*/, this.callTheMRApi({
|
|
197
|
+
route: '/sc/v1/doorlockdetail',
|
|
198
|
+
params: {
|
|
199
|
+
token: credential.accessToken,
|
|
200
|
+
lockId: lockId,
|
|
201
|
+
},
|
|
202
|
+
})];
|
|
203
|
+
case 2:
|
|
204
|
+
data = _b.sent();
|
|
205
|
+
console.log('doorlockDetail', data);
|
|
206
|
+
return [2 /*return*/, data];
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
// 3.5. OTP Passcode(번호키) 요청
|
|
212
|
+
this.getOTPPassCode = function (_a) {
|
|
213
|
+
var accommodationId = _a.accommodationId, lockId = _a.lockId, _b = _a.checkinDate, checkinDate = _b === void 0 ? _this.getDefaultCheckInDate() : _b, _c = _a.checkoutDate, checkoutDate = _c === void 0 ? _this.getDefaultCheckOutDate() : _c;
|
|
214
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
215
|
+
var authInfo, credential, data;
|
|
216
|
+
return __generator(this, function (_d) {
|
|
217
|
+
switch (_d.label) {
|
|
218
|
+
case 0: return [4 /*yield*/, this.getAccommodationAuthInfo({ accommodationId: accommodationId })];
|
|
219
|
+
case 1:
|
|
220
|
+
authInfo = _d.sent();
|
|
221
|
+
credential = authInfo.credential;
|
|
222
|
+
return [4 /*yield*/, this.callTheMRApi({
|
|
223
|
+
route: '/sc/v1/getpasscode',
|
|
224
|
+
params: {
|
|
225
|
+
token: credential.accessToken,
|
|
226
|
+
lockId: lockId,
|
|
227
|
+
checkinDate: checkinDate,
|
|
228
|
+
checkoutDate: checkoutDate,
|
|
229
|
+
},
|
|
230
|
+
})];
|
|
231
|
+
case 2:
|
|
232
|
+
data = _d.sent();
|
|
233
|
+
console.log('getOTPPassCode', data);
|
|
234
|
+
return [2 /*return*/, data];
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
// 3.18. async RF Card Key 발급 요청
|
|
240
|
+
this.writeAsyncRFCard = function (_a) {
|
|
241
|
+
var accommodationId = _a.accommodationId, _b = _a.checkinDate, checkinDate = _b === void 0 ? _this.getDefaultCheckInDate() : _b, _c = _a.checkoutDate, checkoutDate = _c === void 0 ? _this.getDefaultCheckOutDate() : _c, _d = _a.build_no, build_no = _d === void 0 ? '1' : _d, _e = _a.floor_no, floor_no = _e === void 0 ? '1' : _e, lock_mac = _a.lock_mac, agent_id = _a.agent_id;
|
|
242
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
243
|
+
var authInfo, credential, data;
|
|
244
|
+
return __generator(this, function (_f) {
|
|
245
|
+
switch (_f.label) {
|
|
246
|
+
case 0: return [4 /*yield*/, this.getAccommodationAuthInfo({ accommodationId: accommodationId })];
|
|
247
|
+
case 1:
|
|
248
|
+
authInfo = _f.sent();
|
|
249
|
+
credential = authInfo.credential;
|
|
250
|
+
return [4 /*yield*/, this.callTheMRApi({
|
|
251
|
+
route: '/sc/v1/rfcardwritecall',
|
|
252
|
+
params: {
|
|
253
|
+
token: credential.accessToken,
|
|
254
|
+
checkinDate: checkinDate,
|
|
255
|
+
checkoutDate: checkoutDate,
|
|
256
|
+
build_no: build_no,
|
|
257
|
+
floor_no: floor_no,
|
|
258
|
+
lock_mac: lock_mac,
|
|
259
|
+
clientId: agent_id,
|
|
260
|
+
},
|
|
261
|
+
})];
|
|
262
|
+
case 2:
|
|
263
|
+
data = _f.sent();
|
|
264
|
+
console.log('writeAsyncRFCard', data);
|
|
265
|
+
return [2 /*return*/, data];
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
};
|
|
270
|
+
this.authenticator = authenticator;
|
|
271
|
+
this.API_HOST = apiHost;
|
|
272
|
+
this.redis = redis;
|
|
273
|
+
this.mutexLock = new mutex_1.default({
|
|
274
|
+
hashPrefix: 'RES_THEMR_MUTEX_',
|
|
275
|
+
mutexLockInterval: 50,
|
|
276
|
+
redis: redis,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
ThemrIoTAdapter.indexAccommodation = function (_a) {
|
|
280
|
+
var accommodationId = _a.accommodationId;
|
|
281
|
+
return "AUTH|THEMR-IOT-API|" + accommodationId;
|
|
282
|
+
};
|
|
283
|
+
return ThemrIoTAdapter;
|
|
284
|
+
}());
|
|
285
|
+
exports.default = ThemrIoTAdapter;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import SanhaWingsAdapter from './adapters/sanhaWings';
|
|
2
2
|
import SmartAccessAdapter from './adapters/smartAccess';
|
|
3
|
-
|
|
3
|
+
import ThemrIoTAdapter from './adapters/themrIoT';
|
|
4
|
+
export { SanhaWingsAdapter, SmartAccessAdapter, ThemrIoTAdapter as TheMRIoTAdapter, };
|
package/lib/index.js
CHANGED
|
@@ -3,8 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SmartAccessAdapter = exports.SanhaWingsAdapter = void 0;
|
|
6
|
+
exports.TheMRIoTAdapter = exports.SmartAccessAdapter = exports.SanhaWingsAdapter = void 0;
|
|
7
7
|
var sanhaWings_1 = __importDefault(require("./adapters/sanhaWings"));
|
|
8
8
|
exports.SanhaWingsAdapter = sanhaWings_1.default;
|
|
9
9
|
var smartAccess_1 = __importDefault(require("./adapters/smartAccess"));
|
|
10
10
|
exports.SmartAccessAdapter = smartAccess_1.default;
|
|
11
|
+
var themrIoT_1 = __importDefault(require("./adapters/themrIoT"));
|
|
12
|
+
exports.TheMRIoTAdapter = themrIoT_1.default;
|