@vendit-dev/thirdparty-adapters 0.3.9 → 0.3.11
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/themrIoT.js +10 -1
- package/package.json +1 -1
package/lib/adapters/themrIoT.js
CHANGED
|
@@ -63,7 +63,7 @@ var ThemrIoTAdapter = /** @class */ (function () {
|
|
|
63
63
|
var authenticator = _a.authenticator, redis = _a.redis, apiHost = _a.apiHost;
|
|
64
64
|
this.API_HOST = 'http://api.hotel-lock.co.kr';
|
|
65
65
|
this.timeFormat = 'YYYY-MM-DD HH:mm:ss';
|
|
66
|
-
this.PROVIDER_KEY = '
|
|
66
|
+
this.PROVIDER_KEY = 'TheMRIoT';
|
|
67
67
|
this.callTheMRApi = function (_a) {
|
|
68
68
|
var route = _a.route, _b = _a.params, params = _b === void 0 ? {} : _b;
|
|
69
69
|
return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -102,19 +102,23 @@ var ThemrIoTAdapter = /** @class */ (function () {
|
|
|
102
102
|
case 0: return [4 /*yield*/, this.redis.get(ThemrIoTAdapter.indexAccommodation({ accommodationId: accommodationId }))];
|
|
103
103
|
case 1:
|
|
104
104
|
existingAuth = _b.sent();
|
|
105
|
+
console.log('FIRST', existingAuth);
|
|
105
106
|
if (existingAuth) {
|
|
106
107
|
if (existingAuth === 'NOT_FOUND') {
|
|
107
108
|
throw new Error('THIRDPARTY_AUTH_NOT_FOUND');
|
|
108
109
|
}
|
|
109
110
|
return [2 /*return*/, JSON.parse(existingAuth)];
|
|
110
111
|
}
|
|
112
|
+
console.log('SECOND', existingAuth);
|
|
111
113
|
lockId = "THEMR-HKEY|" + accommodationId;
|
|
112
114
|
return [4 /*yield*/, this.mutexLock.getMutexLock(lockId)];
|
|
113
115
|
case 2:
|
|
114
116
|
lockHash = _b.sent();
|
|
117
|
+
console.log('THIRD', existingAuth);
|
|
115
118
|
return [4 /*yield*/, this.redis.get(ThemrIoTAdapter.indexAccommodation({ accommodationId: accommodationId }))];
|
|
116
119
|
case 3:
|
|
117
120
|
existingAuth = _b.sent();
|
|
121
|
+
console.log('FOURTH', existingAuth);
|
|
118
122
|
_b.label = 4;
|
|
119
123
|
case 4:
|
|
120
124
|
_b.trys.push([4, 9, 10, 12]);
|
|
@@ -124,22 +128,27 @@ var ThemrIoTAdapter = /** @class */ (function () {
|
|
|
124
128
|
}
|
|
125
129
|
return [2 /*return*/, JSON.parse(existingAuth)];
|
|
126
130
|
}
|
|
131
|
+
console.log('FIFTH', existingAuth);
|
|
127
132
|
return [4 /*yield*/, this.authenticator.getThirdPartyCredential({
|
|
128
133
|
accommodationId: accommodationId,
|
|
129
134
|
provider: this.PROVIDER_KEY,
|
|
130
135
|
})];
|
|
131
136
|
case 5:
|
|
132
137
|
newAuth = _b.sent();
|
|
138
|
+
console.log('SIXTH', newAuth);
|
|
133
139
|
if (!!newAuth) return [3 /*break*/, 7];
|
|
134
140
|
return [4 /*yield*/, this.redis.set(ThemrIoTAdapter.indexAccommodation({ accommodationId: accommodationId }), 'NOT_FOUND', 'EX', 60 * 10)];
|
|
135
141
|
case 6:
|
|
136
142
|
_b.sent();
|
|
137
143
|
throw new Error('THIRDPARTY_AUTH_NOT_FOUND');
|
|
138
144
|
case 7:
|
|
145
|
+
console.log('SEVENTH', newAuth);
|
|
139
146
|
newAuth.credential = JSON.parse(newAuth.credential);
|
|
147
|
+
console.log('EIGHTH', newAuth);
|
|
140
148
|
return [4 /*yield*/, this.redis.set(ThemrIoTAdapter.indexAccommodation({ accommodationId: accommodationId }), JSON.stringify(newAuth), 'EX', 60 * 10)];
|
|
141
149
|
case 8:
|
|
142
150
|
_b.sent();
|
|
151
|
+
console.log('NINETH', newAuth);
|
|
143
152
|
return [2 /*return*/, newAuth];
|
|
144
153
|
case 9:
|
|
145
154
|
err_1 = _b.sent();
|