@vendit-dev/thirdparty-adapters 0.7.6-beta.1 → 0.7.6-beta.2

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.
@@ -15,5 +15,6 @@ export declare class AmanoThirdParty implements ParkingThirdParty {
15
15
  deregisterParkingDiscount(command: DeregisterParkingDiscountCommand): Promise<boolean>;
16
16
  registerParkingPass(command: RegisterParkingPassCommand): Promise<boolean>;
17
17
  deregisterParkingPass(command: DeregisterParkingPassCommand): Promise<boolean>;
18
+ getRegisteredVehicles(criteria: any): Promise<any[]>;
18
19
  }
19
20
  export {};
@@ -20,6 +20,9 @@ var AmanoThirdParty = /** @class */ (function () {
20
20
  AmanoThirdParty.prototype.deregisterParkingPass = function (command) {
21
21
  throw new Error('Method not implemented in Amano yet.');
22
22
  };
23
+ AmanoThirdParty.prototype.getRegisteredVehicles = function (criteria) {
24
+ throw new Error('Method not implemented in Amano yet.');
25
+ };
23
26
  return AmanoThirdParty;
24
27
  }());
25
28
  exports.AmanoThirdParty = AmanoThirdParty;
@@ -1,4 +1,4 @@
1
- import { DeregisterParkingDiscountCommand, DeregisterParkingPassCommand, ParkingThirdParty, RegisterParkingDiscountCommand, RegisterParkingPassCommand, SearchVehiclesByNumberCriteria, SearchVehiclesByNumberResult } from './parkingThirdParty.type';
1
+ import { DeregisterParkingDiscountCommand, DeregisterParkingPassCommand, GetRegisteredVehiclesCriteria, ParkingThirdParty, RegisteredVehicleResult, RegisterParkingDiscountCommand, RegisterParkingPassCommand, SearchVehiclesByNumberCriteria, SearchVehiclesByNumberResult } from './parkingThirdParty.type';
2
2
  export interface NiceParkingConfig {
3
3
  dbHost: string;
4
4
  dbPort: string;
@@ -19,4 +19,5 @@ export declare class NiceParkThirdParty implements ParkingThirdParty {
19
19
  deregisterParkingDiscount(command: DeregisterParkingDiscountCommand): Promise<boolean>;
20
20
  registerParkingPass(command: RegisterParkingPassCommand): Promise<boolean>;
21
21
  deregisterParkingPass(command: DeregisterParkingPassCommand): Promise<boolean>;
22
+ getRegisteredVehicles(criteria: GetRegisteredVehiclesCriteria): Promise<RegisteredVehicleResult[]>;
22
23
  }
@@ -165,6 +165,37 @@ var NiceParkThirdParty = /** @class */ (function () {
165
165
  NiceParkThirdParty.prototype.deregisterParkingPass = function (command) {
166
166
  throw new Error('Method not implemented in NicePark yet.');
167
167
  };
168
+ NiceParkThirdParty.prototype.getRegisteredVehicles = function (criteria) {
169
+ return __awaiter(this, void 0, void 0, function () {
170
+ var startDate, endDate, startDateString, endDateString, result, refinedResult, err_4;
171
+ return __generator(this, function (_a) {
172
+ switch (_a.label) {
173
+ case 0:
174
+ startDate = criteria.startDate, endDate = criteria.endDate;
175
+ startDateString = (0, moment_1.default)(startDate).format('YYYYMMDD');
176
+ endDateString = (0, moment_1.default)(endDate).format('YYYYMMDD');
177
+ _a.label = 1;
178
+ case 1:
179
+ _a.trys.push([1, 3, , 4]);
180
+ return [4 /*yield*/, this.sequelize.query("select regularTkCarNo as vehicleNumber, regularTkStartDt as startDate, regularTkEndDt as endDate from View_RegRegularList_CODEIN where rgTkGrpCd = '".concat(this.configuration.groupCode, "' and regularTkStartDt >= '").concat(startDateString, "' and regularTkEndDt <= '").concat(endDateString, "' ").concat(criteria.vehicleNumber ? "and regularTkCarNo like '%".concat(criteria.vehicleNumber, "%'") : ''))];
181
+ case 2:
182
+ result = _a.sent();
183
+ refinedResult = result[0].map(function (item) { return ({
184
+ vehicleNumber: item.vehicleNumber,
185
+ startDate: new Date(item.startDate),
186
+ endDate: new Date(item.endDate),
187
+ }); });
188
+ console.log('NiceParkThirdParty#getRegisteredVehicles result: ', refinedResult);
189
+ return [2 /*return*/, refinedResult];
190
+ case 3:
191
+ err_4 = _a.sent();
192
+ console.error('NiceParkThirdParty#getRegisteredVehicles failed error: ', err_4);
193
+ return [3 /*break*/, 4];
194
+ case 4: return [2 /*return*/, []];
195
+ }
196
+ });
197
+ });
198
+ };
168
199
  return NiceParkThirdParty;
169
200
  }());
170
201
  exports.NiceParkThirdParty = NiceParkThirdParty;
@@ -27,10 +27,21 @@ export interface SearchVehiclesByNumberResult {
27
27
  vehicleNumber: string;
28
28
  enteredAt?: Date;
29
29
  }
30
+ export interface RegisteredVehicleResult {
31
+ vehicleNumber: string;
32
+ startDate: Date;
33
+ endDate: Date;
34
+ }
35
+ export interface GetRegisteredVehiclesCriteria {
36
+ startDate: Date;
37
+ endDate: Date;
38
+ vehicleNumber?: string;
39
+ }
30
40
  export declare abstract class ParkingThirdParty {
31
41
  abstract searchVehiclesByNumber(criteria: SearchVehiclesByNumberCriteria): Promise<SearchVehiclesByNumberResult[]>;
32
42
  abstract registerParkingDiscount(command: RegisterParkingDiscountCommand): Promise<boolean>;
33
43
  abstract deregisterParkingDiscount(command: DeregisterParkingDiscountCommand): Promise<boolean>;
34
44
  abstract registerParkingPass(command: RegisterParkingPassCommand): Promise<boolean>;
35
45
  abstract deregisterParkingPass(command: DeregisterParkingPassCommand): Promise<boolean>;
46
+ abstract getRegisteredVehicles(criteria: GetRegisteredVehiclesCriteria): Promise<RegisteredVehicleResult[]>;
36
47
  }
@@ -9,4 +9,5 @@ export default class ParkingThirdPartyCaller implements BaseParkingThirdPartyCal
9
9
  deregisterParkingDiscount(command: DeregisterParkingDiscountCommand): Promise<boolean>;
10
10
  registerParkingPass(command: RegisterParkingPassCommand): Promise<boolean>;
11
11
  deregisterParkingPass(command: DeregisterParkingPassCommand): Promise<boolean>;
12
+ getRegisteredVehicles(criteria: any): Promise<any[]>;
12
13
  }
@@ -143,6 +143,26 @@ var ParkingThirdPartyCaller = /** @class */ (function () {
143
143
  });
144
144
  });
145
145
  };
146
+ ParkingThirdPartyCaller.prototype.getRegisteredVehicles = function (criteria) {
147
+ return __awaiter(this, void 0, void 0, function () {
148
+ var result, err_6;
149
+ return __generator(this, function (_a) {
150
+ switch (_a.label) {
151
+ case 0:
152
+ _a.trys.push([0, 2, , 3]);
153
+ return [4 /*yield*/, this.parkingThirdParty.getRegisteredVehicles(criteria)];
154
+ case 1:
155
+ result = _a.sent();
156
+ return [2 /*return*/, result];
157
+ case 2:
158
+ err_6 = _a.sent();
159
+ console.error("getRegisteredVehicles failed: ".concat(err_6));
160
+ return [2 /*return*/, []];
161
+ case 3: return [2 /*return*/];
162
+ }
163
+ });
164
+ });
165
+ };
146
166
  return ParkingThirdPartyCaller;
147
167
  }());
148
168
  exports.default = ParkingThirdPartyCaller;
@@ -348,8 +348,9 @@ var SmartAccessAdapter = /** @class */ (function () {
348
348
  var keyId = _a.keyId, accommodationId = _a.accommodationId, userType = _a.userType, keyType = _a.keyType, startDate = _a.startDate, endDate = _a.endDate, pinCode = _a.pinCode;
349
349
  return __awaiter(_this, void 0, void 0, function () {
350
350
  var pinCodeResult, newKeyId, pinCodeQuery;
351
- return __generator(this, function (_b) {
352
- switch (_b.label) {
351
+ var _b;
352
+ return __generator(this, function (_c) {
353
+ switch (_c.label) {
353
354
  case 0: return [4 /*yield*/, this.callSmartAccessApi({
354
355
  accommodationId: accommodationId,
355
356
  method: 'put',
@@ -361,16 +362,16 @@ var SmartAccessAdapter = /** @class */ (function () {
361
362
  })),
362
363
  })];
363
364
  case 1:
364
- pinCodeResult = _b.sent();
365
+ pinCodeResult = _c.sent();
365
366
  newKeyId = pinCodeResult.keyId;
366
367
  return [4 /*yield*/, this.callSmartAccessApi({
367
368
  accommodationId: accommodationId,
368
369
  method: 'get',
369
- route: "v1/key/".concat(keyId, "/pincode"),
370
+ route: "v1/key/".concat(newKeyId || keyId, "/pincode"),
370
371
  })];
371
372
  case 2:
372
- pinCodeQuery = _b.sent();
373
- return [2 /*return*/, __assign(__assign({}, pinCodeQuery.lockList[0]), { keyId: newKeyId })];
373
+ pinCodeQuery = _c.sent();
374
+ return [2 /*return*/, __assign(__assign({}, (_b = pinCodeQuery.lockList) === null || _b === void 0 ? void 0 : _b[0]), { keyId: newKeyId })];
374
375
  }
375
376
  });
376
377
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendit-dev/thirdparty-adapters",
3
- "version": "0.7.6-beta.1",
3
+ "version": "0.7.6-beta.2",
4
4
  "description": "Third party adapters between v-cloud and other PMS/CMS providers.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {