@vendit-dev/thirdparty-adapters 0.4.0-beta.9 → 0.4.1-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.
|
@@ -84,81 +84,69 @@ var AmanoKoreaAdapter = /** @class */ (function () {
|
|
|
84
84
|
this.getAccommodationAuthInfo = function (_a) {
|
|
85
85
|
var accommodationId = _a.accommodationId;
|
|
86
86
|
return __awaiter(_this, void 0, void 0, function () {
|
|
87
|
-
var existingAuth, parsedCredential, lockId, lockHash,
|
|
88
|
-
return __generator(this, function (
|
|
89
|
-
switch (
|
|
87
|
+
var existingAuth, parsedCredential, _b, authorization, apiHost, lotAreaNo, discCodeNo, lockId, lockHash, newAuth, parsedCredential, err_1;
|
|
88
|
+
return __generator(this, function (_c) {
|
|
89
|
+
switch (_c.label) {
|
|
90
90
|
case 0: return [4 /*yield*/, this.redis.get(AmanoKoreaAdapter.indexAccommodation({ accommodationId: accommodationId }))];
|
|
91
91
|
case 1:
|
|
92
|
-
existingAuth =
|
|
93
|
-
console.log('🚀 ~ file: amanoKorea.ts:113 ~ AmanoKoreaAdapter ~ existingAuth:', existingAuth);
|
|
92
|
+
existingAuth = _c.sent();
|
|
94
93
|
if (existingAuth) {
|
|
95
94
|
parsedCredential = this.parseJSONSafe(existingAuth);
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
if (parsedCredential === null || parsedCredential === void 0 ? void 0 : parsedCredential.credential) {
|
|
96
|
+
_b = this.parseJSONSafe(parsedCredential.credential), authorization = _b.authorization, apiHost = _b.apiHost, lotAreaNo = _b.lotAreaNo, discCodeNo = _b.discCodeNo;
|
|
98
97
|
this.setAuthorization({
|
|
99
|
-
authorization:
|
|
98
|
+
authorization: authorization,
|
|
100
99
|
});
|
|
101
|
-
this.
|
|
100
|
+
this.lotAreaNo = lotAreaNo;
|
|
101
|
+
this.discCodeNo = discCodeNo;
|
|
102
|
+
this.API_HOST = apiHost;
|
|
102
103
|
}
|
|
103
104
|
return [2 /*return*/, this.parseJSONSafe(existingAuth)];
|
|
104
105
|
}
|
|
105
106
|
lockId = "AMANO-HKEY|" + accommodationId;
|
|
106
107
|
return [4 /*yield*/, this.mutexLock.getMutexLock(lockId)];
|
|
107
108
|
case 2:
|
|
108
|
-
lockHash =
|
|
109
|
-
|
|
109
|
+
lockHash = _c.sent();
|
|
110
|
+
_c.label = 3;
|
|
110
111
|
case 3:
|
|
111
|
-
|
|
112
|
-
_b.label = 4;
|
|
113
|
-
case 4:
|
|
114
|
-
_b.trys.push([4, 9, 10, 12]);
|
|
115
|
-
if (existingAuth) {
|
|
116
|
-
parsedCredential_1 = this.parseJSONSafe(existingAuth);
|
|
117
|
-
console.log('🚀 ~ file: amanoKorea.ts:124 ~ AmanoKoreaAdapter ~ parsedCredential:', parsedCredential_1);
|
|
118
|
-
if (parsedCredential_1 === null || parsedCredential_1 === void 0 ? void 0 : parsedCredential_1.authorization) {
|
|
119
|
-
this.setAuthorization({
|
|
120
|
-
authorization: parsedCredential_1.authorization,
|
|
121
|
-
});
|
|
122
|
-
this.API_HOST = parsedCredential_1.apiHost;
|
|
123
|
-
}
|
|
124
|
-
return [2 /*return*/, this.parseJSONSafe(existingAuth)];
|
|
125
|
-
}
|
|
112
|
+
_c.trys.push([3, 8, 9, 11]);
|
|
126
113
|
return [4 /*yield*/, this.authenticator.getThirdPartyCredential({
|
|
127
114
|
accommodationId: accommodationId,
|
|
128
115
|
provider: this.PROVIDER_KEY,
|
|
129
116
|
})];
|
|
130
|
-
case
|
|
131
|
-
newAuth =
|
|
132
|
-
if (!(!newAuth || !(newAuth === null || newAuth === void 0 ? void 0 : newAuth.credential))) return [3 /*break*/,
|
|
117
|
+
case 4:
|
|
118
|
+
newAuth = _c.sent();
|
|
119
|
+
if (!(!newAuth || !(newAuth === null || newAuth === void 0 ? void 0 : newAuth.credential))) return [3 /*break*/, 6];
|
|
133
120
|
return [4 /*yield*/, this.redis.set(AmanoKoreaAdapter.indexAccommodation({ accommodationId: accommodationId }), 'NOT_FOUND', 'EX', 60 * 5)];
|
|
134
|
-
case
|
|
135
|
-
|
|
121
|
+
case 5:
|
|
122
|
+
_c.sent();
|
|
136
123
|
return [2 /*return*/, false];
|
|
137
|
-
case
|
|
124
|
+
case 6:
|
|
138
125
|
parsedCredential = this.parseJSONSafe(newAuth.credential);
|
|
139
|
-
console.log('🚀 ~ file: amanoKorea.ts:151 ~ AmanoKoreaAdapter ~ parsedCredential:', parsedCredential);
|
|
140
126
|
if (parsedCredential === null || parsedCredential === void 0 ? void 0 : parsedCredential.authorization) {
|
|
141
127
|
this.setAuthorization({
|
|
142
128
|
authorization: parsedCredential.authorization,
|
|
143
129
|
});
|
|
130
|
+
this.lotAreaNo = parsedCredential.lotAreaNo;
|
|
131
|
+
this.discCodeNo = parsedCredential.discCodeNo;
|
|
144
132
|
this.API_HOST = parsedCredential.apiHost;
|
|
145
133
|
}
|
|
146
134
|
else {
|
|
147
135
|
throw new Error('Authorization is not found');
|
|
148
136
|
}
|
|
149
137
|
return [4 /*yield*/, this.redis.set(AmanoKoreaAdapter.indexAccommodation({ accommodationId: accommodationId }), JSON.stringify(newAuth), 'EX', 60 * 5)];
|
|
150
|
-
case
|
|
151
|
-
|
|
138
|
+
case 7:
|
|
139
|
+
_c.sent();
|
|
152
140
|
return [2 /*return*/, parsedCredential];
|
|
153
|
-
case
|
|
154
|
-
err_1 =
|
|
141
|
+
case 8:
|
|
142
|
+
err_1 = _c.sent();
|
|
155
143
|
console.log(err_1);
|
|
156
144
|
throw err_1;
|
|
157
|
-
case
|
|
158
|
-
case
|
|
159
|
-
|
|
145
|
+
case 9: return [4 /*yield*/, this.mutexLock.unlockMutexLock(lockId, lockHash)];
|
|
146
|
+
case 10:
|
|
147
|
+
_c.sent();
|
|
160
148
|
return [7 /*endfinally*/];
|
|
161
|
-
case
|
|
149
|
+
case 11: return [2 /*return*/];
|
|
162
150
|
}
|
|
163
151
|
});
|
|
164
152
|
});
|
|
@@ -170,7 +158,7 @@ var AmanoKoreaAdapter = /** @class */ (function () {
|
|
|
170
158
|
this.callAPI = function (_a) {
|
|
171
159
|
var directory = _a.directory, resources = _a.resources;
|
|
172
160
|
return __awaiter(_this, void 0, void 0, function () {
|
|
173
|
-
var fetchResult, fetchResultJson,
|
|
161
|
+
var fetchResult, fetchResultJson, err_2;
|
|
174
162
|
return __generator(this, function (_b) {
|
|
175
163
|
switch (_b.label) {
|
|
176
164
|
case 0:
|
|
@@ -192,8 +180,7 @@ var AmanoKoreaAdapter = /** @class */ (function () {
|
|
|
192
180
|
return [4 /*yield*/, (fetchResult === null || fetchResult === void 0 ? void 0 : fetchResult.json())];
|
|
193
181
|
case 3:
|
|
194
182
|
fetchResultJson = _b.sent();
|
|
195
|
-
|
|
196
|
-
return [2 /*return*/, data];
|
|
183
|
+
return [2 /*return*/, fetchResultJson];
|
|
197
184
|
case 4:
|
|
198
185
|
err_2 = _b.sent();
|
|
199
186
|
console.error('err', err_2);
|
|
@@ -220,10 +207,13 @@ var AmanoKoreaAdapter = /** @class */ (function () {
|
|
|
220
207
|
// };
|
|
221
208
|
// 방문차량 등록 내역 조회
|
|
222
209
|
this.getPreDiscountListInfo = function (resources) { return __awaiter(_this, void 0, void 0, function () {
|
|
223
|
-
|
|
210
|
+
var _a, lotAreaNo, discCodeNo;
|
|
211
|
+
return __generator(this, function (_b) {
|
|
212
|
+
_a = this, lotAreaNo = _a.lotAreaNo, discCodeNo = _a.discCodeNo;
|
|
224
213
|
return [2 /*return*/, this.callAPI({
|
|
225
214
|
directory: 'getPreDiscountListInfo.do',
|
|
226
|
-
resources: resources,
|
|
215
|
+
resources: __assign(__assign({}, resources), { lotAreaNo: lotAreaNo,
|
|
216
|
+
discCodeNo: discCodeNo }),
|
|
227
217
|
})];
|
|
228
218
|
});
|
|
229
219
|
}); };
|
|
@@ -17,6 +17,22 @@ declare type SmartAccessRoom = {
|
|
|
17
17
|
roomNumber: string;
|
|
18
18
|
path: string;
|
|
19
19
|
};
|
|
20
|
+
declare type SmartAccessRoomKey = {
|
|
21
|
+
deviceId: string;
|
|
22
|
+
deviceName: string;
|
|
23
|
+
keyList: {
|
|
24
|
+
keyId: string;
|
|
25
|
+
accessStartDate: string;
|
|
26
|
+
accessEndDate: string;
|
|
27
|
+
pinCode: string;
|
|
28
|
+
userType: string;
|
|
29
|
+
keyType: string;
|
|
30
|
+
allowDayofWeek: string;
|
|
31
|
+
allowTime: string;
|
|
32
|
+
issuedDate: string;
|
|
33
|
+
issuedStatus: 'SCHEDULED' | 'COMPLETED' | 'CANCELED' | 'FAILED';
|
|
34
|
+
}[];
|
|
35
|
+
};
|
|
20
36
|
export default class SmartAccessAdapter {
|
|
21
37
|
static indexAccommodation: ({ accommodationId, }: {
|
|
22
38
|
accommodationId: string;
|
|
@@ -53,6 +69,9 @@ export default class SmartAccessAdapter {
|
|
|
53
69
|
}) => Promise<SmartAccessRoom>;
|
|
54
70
|
getRooms: (accommodationId: string) => Promise<SmartAccessRoom[]>;
|
|
55
71
|
getDevices: (accommodationId: string) => Promise<any>;
|
|
72
|
+
getRoomsKey: (accommodationId: string, roomId: string) => Promise<{
|
|
73
|
+
lockList: SmartAccessRoomKey[];
|
|
74
|
+
}>;
|
|
56
75
|
getRoomsWithDevices: (accommodationId: string) => Promise<SmartAccessRoom[]>;
|
|
57
76
|
createPinCodeForRoom: ({ roomId, accommodationId, userType, keyType, startDate, endDate, }: {
|
|
58
77
|
roomId: string;
|
|
@@ -231,6 +231,21 @@ var SmartAccessAdapter = /** @class */ (function () {
|
|
|
231
231
|
}
|
|
232
232
|
});
|
|
233
233
|
}); };
|
|
234
|
+
this.getRoomsKey = function (accommodationId, roomId) { return __awaiter(_this, void 0, void 0, function () {
|
|
235
|
+
var roomKeyResponse;
|
|
236
|
+
return __generator(this, function (_a) {
|
|
237
|
+
switch (_a.label) {
|
|
238
|
+
case 0: return [4 /*yield*/, this.callSmartAccessApi({
|
|
239
|
+
accommodationId: accommodationId,
|
|
240
|
+
method: 'get',
|
|
241
|
+
route: "v1/room/" + roomId + "/keyinfo",
|
|
242
|
+
})];
|
|
243
|
+
case 1:
|
|
244
|
+
roomKeyResponse = _a.sent();
|
|
245
|
+
return [2 /*return*/, roomKeyResponse];
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}); };
|
|
234
249
|
this.getRoomsWithDevices = function (accommodationId) { return __awaiter(_this, void 0, void 0, function () {
|
|
235
250
|
var rooms, devices, devicesRoomIdMap, roomsWithDevices;
|
|
236
251
|
return __generator(this, function (_a) {
|