@kiminix/tp-client 1.0.0 → 1.2.0
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/business/apis.d.ts +6 -0
- package/dist/business/apis.js +82 -0
- package/dist/business/get-all/cache/client.d.ts +2 -0
- package/dist/business/get-all/cache/client.js +58 -0
- package/dist/business/get-all/client.d.ts +2 -0
- package/dist/business/get-all/client.js +53 -0
- package/dist/business/get-all/no-cache/client.d.ts +7 -0
- package/dist/business/get-all/no-cache/client.js +64 -0
- package/dist/business/get-all/types.d.ts +13 -0
- package/dist/business/get-all/types.js +1 -0
- package/dist/business/types/get-all.d.ts +13 -0
- package/dist/business/types/get-all.js +1 -0
- package/dist/business/types/get-id.d.ts +28 -0
- package/dist/business/types/get-id.js +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +3 -0
- package/dist/contants.d.ts +2 -0
- package/dist/contants.js +3 -0
- package/dist/deals/apis.d.ts +7 -0
- package/dist/deals/apis.js +96 -0
- package/dist/deals/types/get-id.d.ts +49 -0
- package/dist/deals/types/get-id.js +1 -0
- package/dist/deals/types/get-pages.d.ts +40 -0
- package/dist/deals/types/get-pages.js +1 -0
- package/dist/enum.d.ts +15 -0
- package/dist/enum.js +18 -0
- package/dist/iam/admin-apis.d.ts +4 -0
- package/dist/iam/admin-apis.js +66 -0
- package/dist/iam/types/business-signin.d.ts +11 -0
- package/dist/iam/types/business-signin.js +1 -0
- package/dist/iam/types/me.d.ts +12 -0
- package/dist/iam/types/me.js +1 -0
- package/dist/iam/types/reset-password.d.ts +5 -0
- package/dist/iam/types/reset-password.js +1 -0
- package/dist/iam/types/update-profile.d.ts +29 -0
- package/dist/iam/types/update-profile.js +1 -0
- package/dist/iam/types/user-signin.d.ts +12 -0
- package/dist/iam/types/user-signin.js +1 -0
- package/dist/iam/types/user-signup-validate.d.ts +5 -0
- package/dist/iam/types/user-signup-validate.js +1 -0
- package/dist/iam/types/user-signup.d.ts +20 -0
- package/dist/iam/types/user-signup.js +1 -0
- package/dist/iam/user-apis.d.ts +16 -0
- package/dist/iam/user-apis.js +279 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +15 -0
- package/dist/menus/apis.d.ts +4 -0
- package/dist/menus/apis.js +61 -0
- package/dist/menus/types/get-menus.d.ts +20 -0
- package/dist/menus/types/get-menus.js +1 -0
- package/dist/notify/apis.d.ts +4 -0
- package/dist/notify/apis.js +80 -0
- package/dist/others/apis.d.ts +3 -0
- package/dist/others/apis.js +58 -0
- package/dist/reservations/admin-apis.d.ts +12 -0
- package/dist/reservations/admin-apis.js +145 -0
- package/dist/reservations/types/admin/get-available-transitions.d.ts +4 -0
- package/dist/reservations/types/admin/get-available-transitions.js +1 -0
- package/dist/reservations/types/admin/get-id.d.ts +4 -0
- package/dist/reservations/types/admin/get-id.js +1 -0
- package/dist/reservations/types/admin/get-page.d.ts +7 -0
- package/dist/reservations/types/admin/get-page.js +1 -0
- package/dist/reservations/types/admin/patch-status.d.ts +6 -0
- package/dist/reservations/types/admin/patch-status.js +1 -0
- package/dist/reservations/types/get-id.d.ts +4 -0
- package/dist/reservations/types/get-id.js +1 -0
- package/dist/reservations/types/shared.d.ts +46 -0
- package/dist/reservations/types/shared.js +1 -0
- package/dist/reservations/types/user/get-id.d.ts +4 -0
- package/dist/reservations/types/user/get-id.js +1 -0
- package/dist/reservations/types/user/get-page.d.ts +7 -0
- package/dist/reservations/types/user/get-page.js +1 -0
- package/dist/reservations/types/user/reserve-onmenu.d.ts +13 -0
- package/dist/reservations/types/user/reserve-onmenu.js +1 -0
- package/dist/reservations/user-apis.d.ts +10 -0
- package/dist/reservations/user-apis.js +170 -0
- package/dist/sitemap/apis.d.ts +3 -0
- package/dist/sitemap/apis.js +58 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.js +1 -0
- package/dist/utils/date-utils.d.ts +29 -0
- package/dist/utils/date-utils.js +101 -0
- package/dist/utils/menu-utils.d.ts +10 -0
- package/dist/utils/menu-utils.js +76 -0
- package/package.json +20 -3
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import axios from "axios";
|
|
38
|
+
import { base } from "../constants";
|
|
39
|
+
// iam module APIs
|
|
40
|
+
var IamAdminAPIs = /** @class */ (function () {
|
|
41
|
+
function IamAdminAPIs() {
|
|
42
|
+
}
|
|
43
|
+
IamAdminAPIs.signIn = function (identifier, password) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0: return [4 /*yield*/, axios.post(base + "/iam/business/sign-in", { identifier: identifier, password: password }, {
|
|
48
|
+
headers: {
|
|
49
|
+
// 'Authorization': `${user.token}`,
|
|
50
|
+
'Content-Type': 'application/json'
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
.then(function (response) {
|
|
54
|
+
return response.data;
|
|
55
|
+
})
|
|
56
|
+
.catch(function (error) {
|
|
57
|
+
throw Error('failed_login');
|
|
58
|
+
})];
|
|
59
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
return IamAdminAPIs;
|
|
65
|
+
}());
|
|
66
|
+
export { IamAdminAPIs };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface UpdateProfileRequest {
|
|
2
|
+
token?: string;
|
|
3
|
+
firstName?: string;
|
|
4
|
+
lastName?: string;
|
|
5
|
+
phone?: string;
|
|
6
|
+
email?: string;
|
|
7
|
+
birthday?: string;
|
|
8
|
+
gender?: string;
|
|
9
|
+
password?: UpdatePassword;
|
|
10
|
+
}
|
|
11
|
+
export interface UpdatePassword {
|
|
12
|
+
actual: string;
|
|
13
|
+
updated: string;
|
|
14
|
+
}
|
|
15
|
+
export interface UpdateProfileResponse {
|
|
16
|
+
token: string;
|
|
17
|
+
id: string;
|
|
18
|
+
firstName: string;
|
|
19
|
+
lastName: string;
|
|
20
|
+
email: string;
|
|
21
|
+
phone?: string;
|
|
22
|
+
verifiedEmail: boolean;
|
|
23
|
+
verifiedPhone: boolean;
|
|
24
|
+
gender?: string;
|
|
25
|
+
birthday?: string;
|
|
26
|
+
lastSignIn: Date;
|
|
27
|
+
createdAt: Date;
|
|
28
|
+
updatedAt?: Date;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface SignUpRequest {
|
|
2
|
+
code: string;
|
|
3
|
+
firstName: string;
|
|
4
|
+
lastName: string;
|
|
5
|
+
phone: string;
|
|
6
|
+
email: string;
|
|
7
|
+
password: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SignUpResponse {
|
|
10
|
+
token: string;
|
|
11
|
+
id: string;
|
|
12
|
+
firstName: string;
|
|
13
|
+
lastName: string;
|
|
14
|
+
email: string;
|
|
15
|
+
phone?: string;
|
|
16
|
+
verifiedEmail: boolean;
|
|
17
|
+
verifiedPhone: boolean;
|
|
18
|
+
gender?: string;
|
|
19
|
+
birthday?: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Either } from "purify-ts";
|
|
2
|
+
import { MeResponse } from "./types/me";
|
|
3
|
+
import { ResetPasswordRequest } from "./types/reset-password";
|
|
4
|
+
import { UpdateProfileRequest, UpdateProfileResponse } from "./types/update-profile";
|
|
5
|
+
import { SignInResponse } from "./types/user-signin";
|
|
6
|
+
import { SignUpRequest, SignUpResponse } from "./types/user-signup";
|
|
7
|
+
import { SignUpValidateRequest } from "./types/user-signup-validate";
|
|
8
|
+
export declare class IamUserAPIs {
|
|
9
|
+
static signIn(identifier: string, password: string): Promise<SignInResponse>;
|
|
10
|
+
static signUp({ code, firstName, lastName, phone, email, password }: SignUpRequest): Promise<Either<Error, SignUpResponse>>;
|
|
11
|
+
static signUpValidate({ phone, email, password }: SignUpValidateRequest): Promise<Either<Error, void>>;
|
|
12
|
+
static me(token?: string): Promise<MeResponse>;
|
|
13
|
+
static resetPassword({ code, email, password }: ResetPasswordRequest): Promise<Either<Error, void>>;
|
|
14
|
+
static updateProfile({ token, firstName, lastName, phone, email, birthday, gender, password: UpdatePassword }: UpdateProfileRequest): Promise<Either<Error, UpdateProfileResponse>>;
|
|
15
|
+
static validatePhone(token: string | undefined, phone: string, code: string): Promise<Either<Error, void>>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import axios from "axios";
|
|
38
|
+
import { Left, Right } from "purify-ts";
|
|
39
|
+
import { base } from "../constants";
|
|
40
|
+
// iam module APIs
|
|
41
|
+
var IamUserAPIs = /** @class */ (function () {
|
|
42
|
+
function IamUserAPIs() {
|
|
43
|
+
}
|
|
44
|
+
IamUserAPIs.signIn = function (identifier, password) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
46
|
+
return __generator(this, function (_a) {
|
|
47
|
+
switch (_a.label) {
|
|
48
|
+
case 0: return [4 /*yield*/, axios.post(base + "/iam/users/sign-in", { identifier: identifier, password: password }, {
|
|
49
|
+
headers: {
|
|
50
|
+
// 'Authorization': `${user.token}`,
|
|
51
|
+
'Content-Type': 'application/json'
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
.then(function (response) {
|
|
55
|
+
return response.data;
|
|
56
|
+
})
|
|
57
|
+
.catch(function (error) {
|
|
58
|
+
throw Error('failed_login');
|
|
59
|
+
})];
|
|
60
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
IamUserAPIs.signUp = function (_a) {
|
|
66
|
+
var code = _a.code, firstName = _a.firstName, lastName = _a.lastName, phone = _a.phone, email = _a.email, password = _a.password;
|
|
67
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
68
|
+
return __generator(this, function (_b) {
|
|
69
|
+
switch (_b.label) {
|
|
70
|
+
case 0: return [4 /*yield*/, axios.post(base + "/iam/users/signup", {
|
|
71
|
+
code: code,
|
|
72
|
+
firstName: firstName,
|
|
73
|
+
lastName: lastName,
|
|
74
|
+
phone: phone,
|
|
75
|
+
email: email,
|
|
76
|
+
password: password
|
|
77
|
+
}, {
|
|
78
|
+
headers: {
|
|
79
|
+
// 'Authorization': `${user.token}`,
|
|
80
|
+
'Content-Type': 'application/json'
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
.then(function (response) {
|
|
84
|
+
return Right(response.data);
|
|
85
|
+
})
|
|
86
|
+
.catch(function (error) {
|
|
87
|
+
if (error.response.status == 400) {
|
|
88
|
+
//invalid_code
|
|
89
|
+
//invalid_email_format
|
|
90
|
+
//email_already_used
|
|
91
|
+
//phone_already_used
|
|
92
|
+
//weak_password
|
|
93
|
+
var response = error.response.data;
|
|
94
|
+
return Left(new Error(response.code));
|
|
95
|
+
}
|
|
96
|
+
else
|
|
97
|
+
throw new Error('internal_error', error);
|
|
98
|
+
})];
|
|
99
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
IamUserAPIs.signUpValidate = function (_a) {
|
|
105
|
+
var phone = _a.phone, email = _a.email, password = _a.password;
|
|
106
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
107
|
+
return __generator(this, function (_b) {
|
|
108
|
+
switch (_b.label) {
|
|
109
|
+
case 0: return [4 /*yield*/, axios.post(base + "/iam/users/signup/validate", {
|
|
110
|
+
phone: phone,
|
|
111
|
+
email: email,
|
|
112
|
+
password: password
|
|
113
|
+
}, {
|
|
114
|
+
headers: {
|
|
115
|
+
// 'Authorization': `${user.token}`,
|
|
116
|
+
'Content-Type': 'application/json'
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
.then(function (response) {
|
|
120
|
+
return Right(undefined);
|
|
121
|
+
})
|
|
122
|
+
.catch(function (error) {
|
|
123
|
+
if (error.response.status == 400) {
|
|
124
|
+
//invalid_email_format
|
|
125
|
+
//email_already_used
|
|
126
|
+
//phone_already_used
|
|
127
|
+
//weak_password
|
|
128
|
+
var response = error.response.data;
|
|
129
|
+
return Left(new Error(response.code));
|
|
130
|
+
}
|
|
131
|
+
else
|
|
132
|
+
throw new Error('internal_error', error);
|
|
133
|
+
})];
|
|
134
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
IamUserAPIs.me = function (token) {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
141
|
+
return __generator(this, function (_a) {
|
|
142
|
+
switch (_a.label) {
|
|
143
|
+
case 0:
|
|
144
|
+
if (!token) return [3 /*break*/, 2];
|
|
145
|
+
return [4 /*yield*/, axios.get(base + "/iam/users/me", {
|
|
146
|
+
headers: {
|
|
147
|
+
'Authorization': "".concat(token)
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
.then(function (response) { return response.data; })
|
|
151
|
+
.catch(function (error) {
|
|
152
|
+
throw new Error("internal_error");
|
|
153
|
+
})];
|
|
154
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
155
|
+
case 2: throw new Error("unauthorized");
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
IamUserAPIs.resetPassword = function (_a) {
|
|
161
|
+
var code = _a.code, email = _a.email, password = _a.password;
|
|
162
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
163
|
+
return __generator(this, function (_b) {
|
|
164
|
+
switch (_b.label) {
|
|
165
|
+
case 0: return [4 /*yield*/, axios.post(base + "/iam/users/reset-password ", {
|
|
166
|
+
code: code,
|
|
167
|
+
email: email,
|
|
168
|
+
password: password
|
|
169
|
+
}, {
|
|
170
|
+
headers: {
|
|
171
|
+
// 'Authorization': `${user.token}`,
|
|
172
|
+
'Content-Type': 'application/json'
|
|
173
|
+
}
|
|
174
|
+
})
|
|
175
|
+
.then(function (response) {
|
|
176
|
+
return Right(undefined);
|
|
177
|
+
})
|
|
178
|
+
.catch(function (error) {
|
|
179
|
+
if (error.response.status == 400) {
|
|
180
|
+
//invalid_code
|
|
181
|
+
//account_not_found
|
|
182
|
+
//invalid_password
|
|
183
|
+
var response = error.response.data;
|
|
184
|
+
return Left(new Error(response.code));
|
|
185
|
+
}
|
|
186
|
+
else
|
|
187
|
+
throw new Error('internal_error', error);
|
|
188
|
+
})];
|
|
189
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
IamUserAPIs.updateProfile = function (_a) {
|
|
195
|
+
var token = _a.token, firstName = _a.firstName, lastName = _a.lastName, phone = _a.phone, email = _a.email, birthday = _a.birthday, gender = _a.gender, UpdatePassword = _a.password;
|
|
196
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
197
|
+
return __generator(this, function (_b) {
|
|
198
|
+
switch (_b.label) {
|
|
199
|
+
case 0:
|
|
200
|
+
if (!token) return [3 /*break*/, 2];
|
|
201
|
+
return [4 /*yield*/, axios.patch(base + "/iam/users/me", {
|
|
202
|
+
firstName: firstName,
|
|
203
|
+
lastName: lastName,
|
|
204
|
+
phone: phone,
|
|
205
|
+
email: email,
|
|
206
|
+
birthday: birthday,
|
|
207
|
+
gender: gender,
|
|
208
|
+
password: UpdatePassword
|
|
209
|
+
}, {
|
|
210
|
+
headers: {
|
|
211
|
+
'Authorization': "".concat(token),
|
|
212
|
+
'Content-Type': 'application/json'
|
|
213
|
+
}
|
|
214
|
+
})
|
|
215
|
+
.then(function (response) {
|
|
216
|
+
return Right(response.data);
|
|
217
|
+
})
|
|
218
|
+
.catch(function (error) {
|
|
219
|
+
if (error.response.status == 400) {
|
|
220
|
+
//email_already_used
|
|
221
|
+
//phone_already_used
|
|
222
|
+
//invalid_email_format
|
|
223
|
+
//invalid_phone_format
|
|
224
|
+
//user_not_found
|
|
225
|
+
//invalid_actual_password
|
|
226
|
+
//weak_password
|
|
227
|
+
var response = error.response.data.code;
|
|
228
|
+
return Left(Error(response));
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
console.error(error);
|
|
232
|
+
return Left(Error('internal_error'));
|
|
233
|
+
}
|
|
234
|
+
})];
|
|
235
|
+
case 1:
|
|
236
|
+
// Send the data to the server in JSON format.
|
|
237
|
+
return [2 /*return*/, _b.sent()];
|
|
238
|
+
case 2: return [2 /*return*/, Left(Error("unauthorized"))];
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
IamUserAPIs.validatePhone = function (token, phone, code) {
|
|
244
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
245
|
+
return __generator(this, function (_a) {
|
|
246
|
+
if (token) {
|
|
247
|
+
// Send the data to the server in JSON format.
|
|
248
|
+
return [2 /*return*/, axios.post(base + "/iam/users/phone/validation", {
|
|
249
|
+
phone: phone,
|
|
250
|
+
code: code
|
|
251
|
+
}, {
|
|
252
|
+
headers: {
|
|
253
|
+
'Authorization': "".concat(token),
|
|
254
|
+
'Content-Type': 'application/json'
|
|
255
|
+
}
|
|
256
|
+
})
|
|
257
|
+
.then(function (response) {
|
|
258
|
+
return Right(undefined);
|
|
259
|
+
})
|
|
260
|
+
.catch(function (error) {
|
|
261
|
+
if (error.response.status == 400) {
|
|
262
|
+
//invalid_code
|
|
263
|
+
var response = error.response.data;
|
|
264
|
+
return (Left(Error(response.code)));
|
|
265
|
+
}
|
|
266
|
+
else
|
|
267
|
+
throw new Error('internal_error', error);
|
|
268
|
+
})];
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
throw new Error("unauthorized");
|
|
272
|
+
}
|
|
273
|
+
return [2 /*return*/];
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
return IamUserAPIs;
|
|
278
|
+
}());
|
|
279
|
+
export { IamUserAPIs };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { BusinessAPIs } from './business/apis';
|
|
2
|
+
export { DealsAPIs } from './deals/apis';
|
|
3
|
+
export { IamAdminAPIs } from './iam/admin-apis';
|
|
4
|
+
export { IamUserAPIs } from './iam/user-apis';
|
|
5
|
+
export { NotifyAPIs } from './notify/apis';
|
|
6
|
+
export { SitemapAPIs } from './sitemap/apis';
|
|
7
|
+
export { MenusAPIs } from './menus/apis';
|
|
8
|
+
export { ReservationsUserAPIs } from './reservations/user-apis';
|
|
9
|
+
export { ReservationsAdminAPIs } from './reservations/admin-apis';
|
|
10
|
+
export { MenuUtils } from './utils/menu-utils';
|
|
11
|
+
export * from './utils/date-utils';
|
|
12
|
+
export * from './enum';
|
|
13
|
+
export * from './types';
|
|
14
|
+
export * from './constants';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { BusinessAPIs } from './business/apis';
|
|
2
|
+
export { DealsAPIs } from './deals/apis';
|
|
3
|
+
export { IamAdminAPIs } from './iam/admin-apis';
|
|
4
|
+
export { IamUserAPIs } from './iam/user-apis';
|
|
5
|
+
export { NotifyAPIs } from './notify/apis';
|
|
6
|
+
export { SitemapAPIs } from './sitemap/apis';
|
|
7
|
+
export { MenusAPIs } from './menus/apis';
|
|
8
|
+
export { ReservationsUserAPIs } from './reservations/user-apis';
|
|
9
|
+
export { ReservationsAdminAPIs } from './reservations/admin-apis';
|
|
10
|
+
//
|
|
11
|
+
export { MenuUtils } from './utils/menu-utils';
|
|
12
|
+
export * from './utils/date-utils';
|
|
13
|
+
export * from './enum';
|
|
14
|
+
export * from './types';
|
|
15
|
+
export * from './constants';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import axios from "axios";
|
|
38
|
+
import { base } from "../constants";
|
|
39
|
+
// menus module APIs
|
|
40
|
+
var MenusAPIs = /** @class */ (function () {
|
|
41
|
+
function MenusAPIs() {
|
|
42
|
+
}
|
|
43
|
+
MenusAPIs.getByBusiness = function (businessId) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0: return [4 /*yield*/, axios.get(base + "/business/".concat(businessId, "/onmenu"))
|
|
48
|
+
.then(function (response) {
|
|
49
|
+
return response.data;
|
|
50
|
+
})
|
|
51
|
+
.catch(function (error) {
|
|
52
|
+
throw new Error('internal_error', error);
|
|
53
|
+
})];
|
|
54
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
return MenusAPIs;
|
|
60
|
+
}());
|
|
61
|
+
export { MenusAPIs };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type LocalDate = string;
|
|
2
|
+
export interface Price {
|
|
3
|
+
adult: number;
|
|
4
|
+
child?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface DailyDiscount {
|
|
7
|
+
isAvailable: boolean;
|
|
8
|
+
price: Price;
|
|
9
|
+
minBookingTotal?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface PresetMenu {
|
|
12
|
+
id: string;
|
|
13
|
+
availableUntil?: LocalDate;
|
|
14
|
+
excludedDays?: LocalDate[];
|
|
15
|
+
title: string;
|
|
16
|
+
description: string;
|
|
17
|
+
price: Price;
|
|
18
|
+
minBookingTotal?: number;
|
|
19
|
+
discount?: Map<LocalDate, DailyDiscount>;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|