@vendit-dev/thirdparty-adapters 0.4.0-beta.13 β 0.4.0-beta.15
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/amanoKorea.js +32 -40
- package/package.json +1 -1
|
@@ -84,21 +84,23 @@ 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, _b, authorization, apiHost,
|
|
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 =
|
|
92
|
+
existingAuth = _c.sent();
|
|
93
93
|
console.log('π ~ file: amanoKorea.ts:113 ~ AmanoKoreaAdapter ~ existingAuth:', existingAuth);
|
|
94
94
|
if (existingAuth) {
|
|
95
95
|
parsedCredential = this.parseJSONSafe(existingAuth);
|
|
96
96
|
console.log('π ~ file: amanoKorea.ts:111 ~ AmanoKoreaAdapter ~ parsedCredential:', parsedCredential);
|
|
97
|
-
if (parsedCredential === null || parsedCredential === void 0 ? void 0 : parsedCredential.
|
|
98
|
-
_b = this.parseJSONSafe(parsedCredential), authorization = _b.authorization, apiHost = _b.apiHost;
|
|
97
|
+
if (parsedCredential === null || parsedCredential === void 0 ? void 0 : parsedCredential.credential) {
|
|
98
|
+
_b = this.parseJSONSafe(parsedCredential.credential), authorization = _b.authorization, apiHost = _b.apiHost, lotAreaNo = _b.lotAreaNo, discCodeNo = _b.discCodeNo;
|
|
99
99
|
this.setAuthorization({
|
|
100
100
|
authorization: authorization,
|
|
101
101
|
});
|
|
102
|
+
this.lotAreaNo = lotAreaNo;
|
|
103
|
+
this.discCodeNo = discCodeNo;
|
|
102
104
|
this.API_HOST = apiHost;
|
|
103
105
|
}
|
|
104
106
|
return [2 /*return*/, this.parseJSONSafe(existingAuth)];
|
|
@@ -106,61 +108,48 @@ var AmanoKoreaAdapter = /** @class */ (function () {
|
|
|
106
108
|
lockId = "AMANO-HKEY|" + accommodationId;
|
|
107
109
|
return [4 /*yield*/, this.mutexLock.getMutexLock(lockId)];
|
|
108
110
|
case 2:
|
|
109
|
-
lockHash =
|
|
110
|
-
|
|
111
|
+
lockHash = _c.sent();
|
|
112
|
+
_c.label = 3;
|
|
111
113
|
case 3:
|
|
112
|
-
|
|
113
|
-
_d.label = 4;
|
|
114
|
-
case 4:
|
|
115
|
-
_d.trys.push([4, 9, 10, 12]);
|
|
116
|
-
if (existingAuth) {
|
|
117
|
-
parsedCredential_1 = this.parseJSONSafe(existingAuth);
|
|
118
|
-
console.log('π ~ file: amanoKorea.ts:124 ~ AmanoKoreaAdapter ~ parsedCredential:', parsedCredential_1);
|
|
119
|
-
if (parsedCredential_1) {
|
|
120
|
-
_c = this.parseJSONSafe(parsedCredential_1), authorization = _c.authorization, apiHost = _c.apiHost;
|
|
121
|
-
this.setAuthorization({
|
|
122
|
-
authorization: authorization,
|
|
123
|
-
});
|
|
124
|
-
this.API_HOST = apiHost;
|
|
125
|
-
}
|
|
126
|
-
return [2 /*return*/, this.parseJSONSafe(existingAuth)];
|
|
127
|
-
}
|
|
114
|
+
_c.trys.push([3, 8, 9, 11]);
|
|
128
115
|
return [4 /*yield*/, this.authenticator.getThirdPartyCredential({
|
|
129
116
|
accommodationId: accommodationId,
|
|
130
117
|
provider: this.PROVIDER_KEY,
|
|
131
118
|
})];
|
|
132
|
-
case
|
|
133
|
-
newAuth =
|
|
134
|
-
if (!(!newAuth || !(newAuth === null || newAuth === void 0 ? void 0 : newAuth.credential))) return [3 /*break*/,
|
|
119
|
+
case 4:
|
|
120
|
+
newAuth = _c.sent();
|
|
121
|
+
if (!(!newAuth || !(newAuth === null || newAuth === void 0 ? void 0 : newAuth.credential))) return [3 /*break*/, 6];
|
|
135
122
|
return [4 /*yield*/, this.redis.set(AmanoKoreaAdapter.indexAccommodation({ accommodationId: accommodationId }), 'NOT_FOUND', 'EX', 60 * 5)];
|
|
136
|
-
case
|
|
137
|
-
|
|
123
|
+
case 5:
|
|
124
|
+
_c.sent();
|
|
138
125
|
return [2 /*return*/, false];
|
|
139
|
-
case
|
|
126
|
+
case 6:
|
|
140
127
|
parsedCredential = this.parseJSONSafe(newAuth.credential);
|
|
141
128
|
console.log('π ~ file: amanoKorea.ts:151 ~ AmanoKoreaAdapter ~ parsedCredential:', parsedCredential);
|
|
142
129
|
if (parsedCredential === null || parsedCredential === void 0 ? void 0 : parsedCredential.authorization) {
|
|
143
130
|
this.setAuthorization({
|
|
144
131
|
authorization: parsedCredential.authorization,
|
|
145
132
|
});
|
|
133
|
+
this.lotAreaNo = parsedCredential.lotAreaNo;
|
|
134
|
+
this.discCodeNo = parsedCredential.discCodeNo;
|
|
146
135
|
this.API_HOST = parsedCredential.apiHost;
|
|
147
136
|
}
|
|
148
137
|
else {
|
|
149
138
|
throw new Error('Authorization is not found');
|
|
150
139
|
}
|
|
151
140
|
return [4 /*yield*/, this.redis.set(AmanoKoreaAdapter.indexAccommodation({ accommodationId: accommodationId }), JSON.stringify(newAuth), 'EX', 60 * 5)];
|
|
152
|
-
case
|
|
153
|
-
|
|
141
|
+
case 7:
|
|
142
|
+
_c.sent();
|
|
154
143
|
return [2 /*return*/, parsedCredential];
|
|
155
|
-
case
|
|
156
|
-
err_1 =
|
|
144
|
+
case 8:
|
|
145
|
+
err_1 = _c.sent();
|
|
157
146
|
console.log(err_1);
|
|
158
147
|
throw err_1;
|
|
159
|
-
case
|
|
160
|
-
case
|
|
161
|
-
|
|
148
|
+
case 9: return [4 /*yield*/, this.mutexLock.unlockMutexLock(lockId, lockHash)];
|
|
149
|
+
case 10:
|
|
150
|
+
_c.sent();
|
|
162
151
|
return [7 /*endfinally*/];
|
|
163
|
-
case
|
|
152
|
+
case 11: return [2 /*return*/];
|
|
164
153
|
}
|
|
165
154
|
});
|
|
166
155
|
});
|
|
@@ -222,10 +211,13 @@ var AmanoKoreaAdapter = /** @class */ (function () {
|
|
|
222
211
|
// };
|
|
223
212
|
// λ°©λ¬Έμ°¨λ λ±λ‘ λ΄μ μ‘°ν
|
|
224
213
|
this.getPreDiscountListInfo = function (resources) { return __awaiter(_this, void 0, void 0, function () {
|
|
225
|
-
|
|
214
|
+
var _a, lotAreaNo, discCodeNo;
|
|
215
|
+
return __generator(this, function (_b) {
|
|
216
|
+
_a = this, lotAreaNo = _a.lotAreaNo, discCodeNo = _a.discCodeNo;
|
|
226
217
|
return [2 /*return*/, this.callAPI({
|
|
227
218
|
directory: 'getPreDiscountListInfo.do',
|
|
228
|
-
resources: resources,
|
|
219
|
+
resources: __assign(__assign({}, resources), { lotAreaNo: lotAreaNo,
|
|
220
|
+
discCodeNo: discCodeNo }),
|
|
229
221
|
})];
|
|
230
222
|
});
|
|
231
223
|
}); };
|