@kiminix/tp-client 1.5.0 → 1.6.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/iam/user-apis.d.ts +1 -1
- package/dist/iam/user-apis.js +2 -2
- package/dist/menus/preset/admin-apis.d.ts +4 -0
- package/dist/menus/preset/admin-apis.js +75 -2
- package/dist/menus/preset/types/update-preset-menu.d.ts +12 -0
- package/dist/menus/preset/types/update-preset-menu.js +1 -0
- package/package.json +1 -1
package/dist/iam/user-apis.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ export declare class IamUserAPIs {
|
|
|
11
11
|
static signUpValidate({ phone, email, password }: SignUpValidateRequest): Promise<Either<Error, void>>;
|
|
12
12
|
static me(token?: string): Promise<MeResponse>;
|
|
13
13
|
static resetPassword({ code, email, password }: ResetPasswordRequest): Promise<Either<Error, void>>;
|
|
14
|
-
static updateProfile({ token, firstName, lastName, phone, email, birthday, gender, password
|
|
14
|
+
static updateProfile({ token, firstName, lastName, phone, email, birthday, gender, password }: UpdateProfileRequest): Promise<Either<Error, UpdateProfileResponse>>;
|
|
15
15
|
static validatePhone(token: string | undefined, phone: string, code: string): Promise<Either<Error, void>>;
|
|
16
16
|
}
|
package/dist/iam/user-apis.js
CHANGED
|
@@ -192,7 +192,7 @@ var IamUserAPIs = /** @class */ (function () {
|
|
|
192
192
|
});
|
|
193
193
|
};
|
|
194
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,
|
|
195
|
+
var token = _a.token, firstName = _a.firstName, lastName = _a.lastName, phone = _a.phone, email = _a.email, birthday = _a.birthday, gender = _a.gender, password = _a.password;
|
|
196
196
|
return __awaiter(this, void 0, void 0, function () {
|
|
197
197
|
return __generator(this, function (_b) {
|
|
198
198
|
switch (_b.label) {
|
|
@@ -205,7 +205,7 @@ var IamUserAPIs = /** @class */ (function () {
|
|
|
205
205
|
email: email,
|
|
206
206
|
birthday: birthday,
|
|
207
207
|
gender: gender,
|
|
208
|
-
password:
|
|
208
|
+
password: password
|
|
209
209
|
}, {
|
|
210
210
|
headers: {
|
|
211
211
|
'Authorization': "".concat(token),
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { PresetMenu } from "./types/get-by-business";
|
|
2
|
+
import { UpdatePresetMenuRequest } from "./types/update-preset-menu";
|
|
3
|
+
import { Either } from "purify-ts";
|
|
2
4
|
export declare class PresetMenusAdminAPIs {
|
|
3
5
|
static getByBusiness(token?: string): Promise<PresetMenu[]>;
|
|
6
|
+
static getByMenuID(menuId: string, token?: string): Promise<PresetMenu>;
|
|
7
|
+
static update({ token, id, availability, minBookingTotal, title }: UpdatePresetMenuRequest): Promise<Either<Error, PresetMenu>>;
|
|
4
8
|
}
|
|
@@ -36,6 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
};
|
|
37
37
|
import axios from "axios";
|
|
38
38
|
import { base } from "../../constants";
|
|
39
|
+
import { Left, Right } from "purify-ts";
|
|
39
40
|
// preset-menus module admin APIs
|
|
40
41
|
var PresetMenusAdminAPIs = /** @class */ (function () {
|
|
41
42
|
function PresetMenusAdminAPIs() {
|
|
@@ -53,9 +54,13 @@ var PresetMenusAdminAPIs = /** @class */ (function () {
|
|
|
53
54
|
return response.data;
|
|
54
55
|
})
|
|
55
56
|
.catch(function (error) {
|
|
57
|
+
var _a;
|
|
56
58
|
// handle error
|
|
57
|
-
if (error.response.status == 401)
|
|
58
|
-
|
|
59
|
+
if (error.response.status == 401) {
|
|
60
|
+
// unauthorized
|
|
61
|
+
// unauthenticated
|
|
62
|
+
throw ((new Error((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.code)));
|
|
63
|
+
}
|
|
59
64
|
else
|
|
60
65
|
throw new Error('internal_error', error);
|
|
61
66
|
})];
|
|
@@ -64,6 +69,74 @@ var PresetMenusAdminAPIs = /** @class */ (function () {
|
|
|
64
69
|
});
|
|
65
70
|
});
|
|
66
71
|
};
|
|
72
|
+
PresetMenusAdminAPIs.getByMenuID = function (menuId, token) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
+
return __generator(this, function (_a) {
|
|
75
|
+
switch (_a.label) {
|
|
76
|
+
case 0: return [4 /*yield*/, axios.get(base + "/preset-menus/admin/id/".concat(menuId), {
|
|
77
|
+
headers: {
|
|
78
|
+
'Authorization': "".concat(token)
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
.then(function (response) {
|
|
82
|
+
return response.data;
|
|
83
|
+
})
|
|
84
|
+
.catch(function (error) {
|
|
85
|
+
var _a;
|
|
86
|
+
// handle error
|
|
87
|
+
if (error.response.status == 401) {
|
|
88
|
+
// unauthorized
|
|
89
|
+
// unauthenticated
|
|
90
|
+
throw ((new Error((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.code)));
|
|
91
|
+
}
|
|
92
|
+
else
|
|
93
|
+
throw new Error('internal_error', error);
|
|
94
|
+
})];
|
|
95
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
PresetMenusAdminAPIs.update = function (_a) {
|
|
101
|
+
var token = _a.token, id = _a.id, availability = _a.availability, minBookingTotal = _a.minBookingTotal, title = _a.title;
|
|
102
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
+
return __generator(this, function (_b) {
|
|
104
|
+
switch (_b.label) {
|
|
105
|
+
case 0: return [4 /*yield*/, axios.patch(base + "/preset-menus/admin", {
|
|
106
|
+
id: id,
|
|
107
|
+
availability: availability,
|
|
108
|
+
minBookingTotal: minBookingTotal,
|
|
109
|
+
title: title
|
|
110
|
+
}, {
|
|
111
|
+
headers: {
|
|
112
|
+
'Authorization': "".concat(token)
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
.then(function (response) {
|
|
116
|
+
return Right(response.data);
|
|
117
|
+
})
|
|
118
|
+
.catch(function (error) {
|
|
119
|
+
var _a;
|
|
120
|
+
// handled error
|
|
121
|
+
if (error.response.status == 401) {
|
|
122
|
+
// unavailable_business
|
|
123
|
+
// unauthorized
|
|
124
|
+
// unauthenticated
|
|
125
|
+
return (Left(new Error((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.code)));
|
|
126
|
+
}
|
|
127
|
+
else if (error.response.status == 404)
|
|
128
|
+
return (Left(new Error("not_found")));
|
|
129
|
+
else if (error.response.status == 400) {
|
|
130
|
+
return (Left(new Error("invalid_input")));
|
|
131
|
+
}
|
|
132
|
+
else
|
|
133
|
+
throw new Error('internal_error', error);
|
|
134
|
+
})];
|
|
135
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
};
|
|
67
140
|
return PresetMenusAdminAPIs;
|
|
68
141
|
}());
|
|
69
142
|
export { PresetMenusAdminAPIs };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type LocalDate = string;
|
|
2
|
+
export interface UpdatePresetMenuRequest {
|
|
3
|
+
id: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
minBookingTotal?: number;
|
|
6
|
+
availability?: Availability;
|
|
7
|
+
token?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Availability {
|
|
10
|
+
isAvailable: boolean;
|
|
11
|
+
date: LocalDate;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|