@kiminix/tp-client 1.8.0 → 1.9.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/menus/discounts/admin-apis.d.ts +7 -0
- package/dist/menus/discounts/admin-apis.js +90 -0
- package/dist/menus/discounts/types/update-discount.d.ts +9 -0
- package/dist/menus/discounts/types/update-discount.js +1 -0
- package/dist/menus/preset/admin-apis.d.ts +1 -1
- package/dist/menus/preset/discounts/admin-apis.d.ts +7 -0
- package/dist/menus/preset/discounts/admin-apis.js +90 -0
- package/dist/menus/preset/discounts/types/update-discount.d.ts +9 -0
- package/dist/menus/preset/discounts/types/update-discount.js +1 -0
- package/dist/menus/preset/types/preset-menu.d.ts +2 -0
- package/dist/menus/types/preset-menu.d.ts +22 -0
- package/dist/menus/types/preset-menu.js +1 -0
- package/dist/utils/menu-utils.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Either } from "purify-ts";
|
|
2
|
+
import { PresetMenu } from "../types/preset-menu";
|
|
3
|
+
import { UpdateDiscountRequest } from "./types/update-discount";
|
|
4
|
+
export declare class PresetMenusDiscountAdminAPIs {
|
|
5
|
+
static update({ token, id, // preset menu id
|
|
6
|
+
day, isAvailable, adultPrice, childPrice, minBookingTotal }: UpdateDiscountRequest): Promise<Either<Error, PresetMenu>>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
import { Left, Right } from "purify-ts";
|
|
40
|
+
// preset-menus module admin APIs
|
|
41
|
+
var PresetMenusDiscountAdminAPIs = /** @class */ (function () {
|
|
42
|
+
function PresetMenusDiscountAdminAPIs() {
|
|
43
|
+
}
|
|
44
|
+
PresetMenusDiscountAdminAPIs.update = function (_a) {
|
|
45
|
+
var token = _a.token, id = _a.id, // preset menu id
|
|
46
|
+
day = _a.day, isAvailable = _a.isAvailable, adultPrice = _a.adultPrice, childPrice = _a.childPrice, minBookingTotal = _a.minBookingTotal;
|
|
47
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
+
return __generator(this, function (_b) {
|
|
49
|
+
switch (_b.label) {
|
|
50
|
+
case 0: return [4 /*yield*/, axios.patch(base + "/preset-menus/admin/discounts", {
|
|
51
|
+
id: id,
|
|
52
|
+
day: day,
|
|
53
|
+
isAvailable: isAvailable,
|
|
54
|
+
adultPrice: adultPrice,
|
|
55
|
+
childPrice: childPrice,
|
|
56
|
+
minBookingTotal: minBookingTotal
|
|
57
|
+
}, {
|
|
58
|
+
headers: {
|
|
59
|
+
'Authorization': "".concat(token)
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
.then(function (response) {
|
|
63
|
+
return Right(response.data);
|
|
64
|
+
})
|
|
65
|
+
// handled error
|
|
66
|
+
.catch(function (error) {
|
|
67
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
68
|
+
// unavailable_business
|
|
69
|
+
// unauthorized
|
|
70
|
+
// unauthenticated
|
|
71
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) == 401)
|
|
72
|
+
return (Left(new Error((_c = (_b = error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.code)));
|
|
73
|
+
else if (((_d = error.response) === null || _d === void 0 ? void 0 : _d.status) == 404)
|
|
74
|
+
return (Left(new Error("not_found")));
|
|
75
|
+
//invalid_child_discount
|
|
76
|
+
//invalid_adult_discount
|
|
77
|
+
//unauthorized_disable_discount
|
|
78
|
+
else if (((_e = error.response) === null || _e === void 0 ? void 0 : _e.status) == 400)
|
|
79
|
+
return (Left(new Error((_g = (_f = error.response) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.code)));
|
|
80
|
+
else
|
|
81
|
+
throw new Error('internal_error', error);
|
|
82
|
+
})];
|
|
83
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
return PresetMenusDiscountAdminAPIs;
|
|
89
|
+
}());
|
|
90
|
+
export { PresetMenusDiscountAdminAPIs };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PresetMenu } from "./types/preset-menu";
|
|
2
1
|
import { UpdatePresetMenuRequest } from "./types/update-preset-menu";
|
|
3
2
|
import { Either } from "purify-ts";
|
|
3
|
+
import { PresetMenu } from "./types/preset-menu";
|
|
4
4
|
export declare class PresetMenusAdminAPIs {
|
|
5
5
|
static getByBusiness(token?: string): Promise<PresetMenu[]>;
|
|
6
6
|
static getByMenuID(menuId: string, token?: string): Promise<PresetMenu>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Either } from "purify-ts";
|
|
2
|
+
import { PresetMenu } from "../types/preset-menu";
|
|
3
|
+
import { UpdateDiscountRequest } from "./types/update-discount";
|
|
4
|
+
export declare class PresetMenusDiscountAdminAPIs {
|
|
5
|
+
static update({ token, id, // preset menu id
|
|
6
|
+
day, isAvailable, adultPrice, childPrice, minBookingTotal }: UpdateDiscountRequest): Promise<Either<Error, PresetMenu>>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
import { Left, Right } from "purify-ts";
|
|
40
|
+
// preset-menus module admin APIs
|
|
41
|
+
var PresetMenusDiscountAdminAPIs = /** @class */ (function () {
|
|
42
|
+
function PresetMenusDiscountAdminAPIs() {
|
|
43
|
+
}
|
|
44
|
+
PresetMenusDiscountAdminAPIs.update = function (_a) {
|
|
45
|
+
var token = _a.token, id = _a.id, // preset menu id
|
|
46
|
+
day = _a.day, isAvailable = _a.isAvailable, adultPrice = _a.adultPrice, childPrice = _a.childPrice, minBookingTotal = _a.minBookingTotal;
|
|
47
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
+
return __generator(this, function (_b) {
|
|
49
|
+
switch (_b.label) {
|
|
50
|
+
case 0: return [4 /*yield*/, axios.patch(base + "/preset-menus/admin/discounts", {
|
|
51
|
+
id: id,
|
|
52
|
+
day: day,
|
|
53
|
+
isAvailable: isAvailable,
|
|
54
|
+
adultPrice: adultPrice,
|
|
55
|
+
childPrice: childPrice,
|
|
56
|
+
minBookingTotal: minBookingTotal
|
|
57
|
+
}, {
|
|
58
|
+
headers: {
|
|
59
|
+
'Authorization': "".concat(token)
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
.then(function (response) {
|
|
63
|
+
return Right(response.data);
|
|
64
|
+
})
|
|
65
|
+
// handled error
|
|
66
|
+
.catch(function (error) {
|
|
67
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
68
|
+
// unavailable_business
|
|
69
|
+
// unauthorized
|
|
70
|
+
// unauthenticated
|
|
71
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) == 401)
|
|
72
|
+
return (Left(new Error((_c = (_b = error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.code)));
|
|
73
|
+
else if (((_d = error.response) === null || _d === void 0 ? void 0 : _d.status) == 404)
|
|
74
|
+
return (Left(new Error("not_found")));
|
|
75
|
+
//invalid_child_discount
|
|
76
|
+
//invalid_adult_discount
|
|
77
|
+
//unauthorized_disable_discount
|
|
78
|
+
else if (((_e = error.response) === null || _e === void 0 ? void 0 : _e.status) == 400)
|
|
79
|
+
return (Left(new Error((_g = (_f = error.response) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.code)));
|
|
80
|
+
else
|
|
81
|
+
throw new Error('internal_error', error);
|
|
82
|
+
})];
|
|
83
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
return PresetMenusDiscountAdminAPIs;
|
|
89
|
+
}());
|
|
90
|
+
export { PresetMenusDiscountAdminAPIs };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Available, LocalDate } from "../../types";
|
|
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
|
+
minPublishedDiscount: number;
|
|
11
|
+
canDisableAfter?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface PresetMenu {
|
|
14
|
+
id: string;
|
|
15
|
+
available?: Available;
|
|
16
|
+
excludedDays?: LocalDate[];
|
|
17
|
+
title: string;
|
|
18
|
+
description: string;
|
|
19
|
+
price: Price;
|
|
20
|
+
minBookingTotal?: number;
|
|
21
|
+
discount?: Map<LocalDate, DailyDiscount>;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DailyDiscount, PresetMenu } from "../menus/preset/types/preset-menu";
|
|
2
1
|
import { Available, LocalDate } from "../types";
|
|
2
|
+
import { DailyDiscount, PresetMenu } from "../menus/preset/types/preset-menu";
|
|
3
3
|
export declare class MenuUtils {
|
|
4
4
|
static isBusinessAvailable(available?: Available): boolean;
|
|
5
5
|
static isMenuAvailableByDay(menu: PresetMenu, date: Date): boolean;
|