whitelabel-db 1.0.54 → 1.0.55
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/dist/libs/liteapiuser.d.ts +21 -0
- package/dist/libs/liteapiuser.js +81 -0
- package/dist/models/Hotel.d.ts +2 -1
- package/dist/models/Hotel.js +10 -3
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface LiteApiUserRequest {
|
|
2
|
+
country: string;
|
|
3
|
+
created_by?: number;
|
|
4
|
+
email: string;
|
|
5
|
+
firstName: string;
|
|
6
|
+
goals?: string;
|
|
7
|
+
lastName: string;
|
|
8
|
+
password: string;
|
|
9
|
+
role?: string;
|
|
10
|
+
size?: string;
|
|
11
|
+
margin: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class LiteApiUser {
|
|
14
|
+
private keyBaseUrl;
|
|
15
|
+
private token;
|
|
16
|
+
private tokenExpiresAt;
|
|
17
|
+
constructor(useProduction?: boolean);
|
|
18
|
+
private login;
|
|
19
|
+
private getToken;
|
|
20
|
+
registerLiteAPIUser(options: LiteApiUserRequest): Promise<any>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.LiteApiUser = void 0;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
class LiteApiUser {
|
|
18
|
+
constructor(useProduction = true) {
|
|
19
|
+
this.token = null;
|
|
20
|
+
this.tokenExpiresAt = null;
|
|
21
|
+
console.log('LiteApiClientV3 constructor', useProduction);
|
|
22
|
+
this.keyBaseUrl = 'https://da.liteapi.travel';
|
|
23
|
+
}
|
|
24
|
+
login(email, password) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
try {
|
|
27
|
+
console.log('login:', email, password);
|
|
28
|
+
const response = yield (0, axios_1.default)({
|
|
29
|
+
method: 'post',
|
|
30
|
+
url: `${this.keyBaseUrl}/login`,
|
|
31
|
+
data: {
|
|
32
|
+
email,
|
|
33
|
+
password,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
console.log('response:', response);
|
|
37
|
+
const tokenData = response.data.token;
|
|
38
|
+
this.token = tokenData.token;
|
|
39
|
+
this.tokenExpiresAt = new Date(tokenData.expires_at);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
console.error('Failed to log in:', error);
|
|
43
|
+
throw new Error('Login failed. Please check your credentials.');
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
getToken(email, password) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
if (!this.token ||
|
|
50
|
+
!this.tokenExpiresAt ||
|
|
51
|
+
new Date() >= this.tokenExpiresAt) {
|
|
52
|
+
// Token is either missing or expired, so we need to log in again
|
|
53
|
+
yield this.login(email, password);
|
|
54
|
+
}
|
|
55
|
+
return this.token;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
registerLiteAPIUser(options) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
options.role = 'admin';
|
|
61
|
+
options.size = '';
|
|
62
|
+
options.goals = ',,';
|
|
63
|
+
const email = 'aneri@wl.ml';
|
|
64
|
+
const password = '997M7dXJ8FwUV5akq6!';
|
|
65
|
+
console.log('email:', email);
|
|
66
|
+
console.log('password:', password);
|
|
67
|
+
console.log('options:', options);
|
|
68
|
+
const token = yield this.getToken(email, password);
|
|
69
|
+
console.log('token:', token);
|
|
70
|
+
return (yield (0, axios_1.default)({
|
|
71
|
+
method: 'post',
|
|
72
|
+
url: `${this.keyBaseUrl}/signup`,
|
|
73
|
+
data: options,
|
|
74
|
+
headers: {
|
|
75
|
+
Authorization: `Bearer ${token}`,
|
|
76
|
+
},
|
|
77
|
+
})).data;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.LiteApiUser = LiteApiUser;
|
package/dist/models/Hotel.d.ts
CHANGED
package/dist/models/Hotel.js
CHANGED
|
@@ -107,11 +107,18 @@ __decorate([
|
|
|
107
107
|
], Hotel.prototype, "thumbnail", void 0);
|
|
108
108
|
__decorate([
|
|
109
109
|
(0, sequelize_typescript_1.Column)({
|
|
110
|
-
type: sequelize_typescript_1.DataType.
|
|
110
|
+
type: sequelize_typescript_1.DataType.INTEGER,
|
|
111
111
|
allowNull: false,
|
|
112
112
|
}),
|
|
113
|
-
__metadata("design:type",
|
|
114
|
-
], Hotel.prototype, "
|
|
113
|
+
__metadata("design:type", Number)
|
|
114
|
+
], Hotel.prototype, "hotelTypeId", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
(0, sequelize_typescript_1.Column)({
|
|
117
|
+
type: sequelize_typescript_1.DataType.INTEGER,
|
|
118
|
+
allowNull: false,
|
|
119
|
+
}),
|
|
120
|
+
__metadata("design:type", Number)
|
|
121
|
+
], Hotel.prototype, "chainId", void 0);
|
|
115
122
|
__decorate([
|
|
116
123
|
(0, sequelize_typescript_1.Column)({
|
|
117
124
|
type: sequelize_typescript_1.DataType.STRING,
|