@vendit-dev/thirdparty-adapters 0.3.5 → 0.3.7
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.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
|
@@ -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;
|