@vendit-dev/thirdparty-adapters 0.4.0-beta.12 → 0.4.0-beta.13
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 +20 -18
- package/package.json +1 -1
|
@@ -84,42 +84,44 @@ 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, parsedCredential_1, newAuth, parsedCredential, err_1;
|
|
88
|
-
return __generator(this, function (
|
|
89
|
-
switch (
|
|
87
|
+
var existingAuth, parsedCredential, _b, authorization, apiHost, lockId, lockHash, parsedCredential_1, _c, authorization, apiHost, newAuth, parsedCredential, err_1;
|
|
88
|
+
return __generator(this, function (_d) {
|
|
89
|
+
switch (_d.label) {
|
|
90
90
|
case 0: return [4 /*yield*/, this.redis.get(AmanoKoreaAdapter.indexAccommodation({ accommodationId: accommodationId }))];
|
|
91
91
|
case 1:
|
|
92
|
-
existingAuth =
|
|
92
|
+
existingAuth = _d.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
97
|
if (parsedCredential === null || parsedCredential === void 0 ? void 0 : parsedCredential.authorization) {
|
|
98
|
+
_b = this.parseJSONSafe(parsedCredential), authorization = _b.authorization, apiHost = _b.apiHost;
|
|
98
99
|
this.setAuthorization({
|
|
99
|
-
authorization:
|
|
100
|
+
authorization: authorization,
|
|
100
101
|
});
|
|
101
|
-
this.API_HOST =
|
|
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
|
+
lockHash = _d.sent();
|
|
109
110
|
return [4 /*yield*/, this.redis.get(AmanoKoreaAdapter.indexAccommodation({ accommodationId: accommodationId }))];
|
|
110
111
|
case 3:
|
|
111
|
-
existingAuth =
|
|
112
|
-
|
|
112
|
+
existingAuth = _d.sent();
|
|
113
|
+
_d.label = 4;
|
|
113
114
|
case 4:
|
|
114
|
-
|
|
115
|
+
_d.trys.push([4, 9, 10, 12]);
|
|
115
116
|
if (existingAuth) {
|
|
116
117
|
parsedCredential_1 = this.parseJSONSafe(existingAuth);
|
|
117
118
|
console.log('🚀 ~ file: amanoKorea.ts:124 ~ AmanoKoreaAdapter ~ parsedCredential:', parsedCredential_1);
|
|
118
|
-
if (parsedCredential_1
|
|
119
|
+
if (parsedCredential_1) {
|
|
120
|
+
_c = this.parseJSONSafe(parsedCredential_1), authorization = _c.authorization, apiHost = _c.apiHost;
|
|
119
121
|
this.setAuthorization({
|
|
120
|
-
authorization:
|
|
122
|
+
authorization: authorization,
|
|
121
123
|
});
|
|
122
|
-
this.API_HOST =
|
|
124
|
+
this.API_HOST = apiHost;
|
|
123
125
|
}
|
|
124
126
|
return [2 /*return*/, this.parseJSONSafe(existingAuth)];
|
|
125
127
|
}
|
|
@@ -128,11 +130,11 @@ var AmanoKoreaAdapter = /** @class */ (function () {
|
|
|
128
130
|
provider: this.PROVIDER_KEY,
|
|
129
131
|
})];
|
|
130
132
|
case 5:
|
|
131
|
-
newAuth =
|
|
133
|
+
newAuth = _d.sent();
|
|
132
134
|
if (!(!newAuth || !(newAuth === null || newAuth === void 0 ? void 0 : newAuth.credential))) return [3 /*break*/, 7];
|
|
133
135
|
return [4 /*yield*/, this.redis.set(AmanoKoreaAdapter.indexAccommodation({ accommodationId: accommodationId }), 'NOT_FOUND', 'EX', 60 * 5)];
|
|
134
136
|
case 6:
|
|
135
|
-
|
|
137
|
+
_d.sent();
|
|
136
138
|
return [2 /*return*/, false];
|
|
137
139
|
case 7:
|
|
138
140
|
parsedCredential = this.parseJSONSafe(newAuth.credential);
|
|
@@ -148,15 +150,15 @@ var AmanoKoreaAdapter = /** @class */ (function () {
|
|
|
148
150
|
}
|
|
149
151
|
return [4 /*yield*/, this.redis.set(AmanoKoreaAdapter.indexAccommodation({ accommodationId: accommodationId }), JSON.stringify(newAuth), 'EX', 60 * 5)];
|
|
150
152
|
case 8:
|
|
151
|
-
|
|
153
|
+
_d.sent();
|
|
152
154
|
return [2 /*return*/, parsedCredential];
|
|
153
155
|
case 9:
|
|
154
|
-
err_1 =
|
|
156
|
+
err_1 = _d.sent();
|
|
155
157
|
console.log(err_1);
|
|
156
158
|
throw err_1;
|
|
157
159
|
case 10: return [4 /*yield*/, this.mutexLock.unlockMutexLock(lockId, lockHash)];
|
|
158
160
|
case 11:
|
|
159
|
-
|
|
161
|
+
_d.sent();
|
|
160
162
|
return [7 /*endfinally*/];
|
|
161
163
|
case 12: return [2 /*return*/];
|
|
162
164
|
}
|