@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,80 @@
|
|
|
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
|
+
// notify module APIs
|
|
41
|
+
var NotifyAPIs = /** @class */ (function () {
|
|
42
|
+
function NotifyAPIs() {
|
|
43
|
+
}
|
|
44
|
+
NotifyAPIs.notify = function (recipient, context, metadata) {
|
|
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 + "/notifications", {
|
|
49
|
+
recipient: recipient,
|
|
50
|
+
context: context,
|
|
51
|
+
metadata: metadata
|
|
52
|
+
}, {
|
|
53
|
+
headers: {
|
|
54
|
+
'Content-Type': 'application/json'
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
.then(function (response) {
|
|
58
|
+
return Right(undefined);
|
|
59
|
+
})
|
|
60
|
+
.catch(function (error) {
|
|
61
|
+
if (error.response.status == 400) {
|
|
62
|
+
// we put in left side only expected errors:
|
|
63
|
+
// invalid_email_format
|
|
64
|
+
// invalid_phone_format
|
|
65
|
+
var response = error.response.data;
|
|
66
|
+
return (Left(Error(response.code)));
|
|
67
|
+
}
|
|
68
|
+
else
|
|
69
|
+
throw new Error('internal_error', error);
|
|
70
|
+
})];
|
|
71
|
+
case 1:
|
|
72
|
+
// Send the data to the server in JSON format.
|
|
73
|
+
return [2 /*return*/, _a.sent()];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
return NotifyAPIs;
|
|
79
|
+
}());
|
|
80
|
+
export { NotifyAPIs };
|
|
@@ -0,0 +1,58 @@
|
|
|
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 (_) 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 "../contants";
|
|
39
|
+
// others module APIs
|
|
40
|
+
var OthersAPIs = /** @class */ (function () {
|
|
41
|
+
function OthersAPIs() {
|
|
42
|
+
}
|
|
43
|
+
OthersAPIs.getSitemap = function () {
|
|
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 + "/sitemap")
|
|
48
|
+
.then(function (response) {
|
|
49
|
+
return response.data;
|
|
50
|
+
})];
|
|
51
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
return OthersAPIs;
|
|
57
|
+
}());
|
|
58
|
+
export { OthersAPIs };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReservationStatus } from "../enum";
|
|
2
|
+
import { GetTransitionsRequest } from "../reservations/types/admin/get-available-transitions";
|
|
3
|
+
import { GetByIdRequest } from "./types/admin/get-id";
|
|
4
|
+
import { GetPageRequest } from "./types/admin/get-page";
|
|
5
|
+
import { PatchStatusRequest } from "./types/admin/patch-status";
|
|
6
|
+
import { Reservation } from "./types/shared";
|
|
7
|
+
export declare class ReservationsAdminAPIs {
|
|
8
|
+
static getPage({ token, page, size, direction }: GetPageRequest): Promise<Reservation[]>;
|
|
9
|
+
static getById({ token, id }: GetByIdRequest): Promise<Reservation>;
|
|
10
|
+
static getAvailableTransitions({ token, reservationId }: GetTransitionsRequest): Promise<ReservationStatus[]>;
|
|
11
|
+
static patchStatus({ token, id, status }: PatchStatusRequest): Promise<any>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
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
|
+
var ReservationsAdminAPIs = /** @class */ (function () {
|
|
40
|
+
function ReservationsAdminAPIs() {
|
|
41
|
+
}
|
|
42
|
+
ReservationsAdminAPIs.getPage = function (_a) {
|
|
43
|
+
var token = _a.token, _b = _a.page, page = _b === void 0 ? 1 : _b, _c = _a.size, size = _c === void 0 ? 10 : _c, direction = _a.direction;
|
|
44
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
+
return __generator(this, function (_d) {
|
|
46
|
+
switch (_d.label) {
|
|
47
|
+
case 0:
|
|
48
|
+
if (!token) return [3 /*break*/, 2];
|
|
49
|
+
return [4 /*yield*/, axios.get(base + "/business/reservations?page=".concat(page, "&size=").concat(size, "&direction=").concat(direction), {
|
|
50
|
+
headers: {
|
|
51
|
+
'Authorization': "".concat(token)
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
.then(function (response) { return response.data; })
|
|
55
|
+
.catch(function (error) {
|
|
56
|
+
// handle error
|
|
57
|
+
throw new Error('internal_error', error);
|
|
58
|
+
})];
|
|
59
|
+
case 1: return [2 /*return*/, _d.sent()];
|
|
60
|
+
case 2: throw Error('unauthorized');
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
ReservationsAdminAPIs.getById = function (_a) {
|
|
66
|
+
var token = _a.token, id = _a.id;
|
|
67
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
68
|
+
return __generator(this, function (_b) {
|
|
69
|
+
switch (_b.label) {
|
|
70
|
+
case 0:
|
|
71
|
+
if (!token) return [3 /*break*/, 2];
|
|
72
|
+
return [4 /*yield*/, axios.get(base + "/business/reservations/".concat(id), {
|
|
73
|
+
headers: {
|
|
74
|
+
'Authorization': "".concat(token),
|
|
75
|
+
'Content-Type': 'application/json'
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
.then(function (response) { return response.data; })
|
|
79
|
+
.catch(function (error) {
|
|
80
|
+
// handle error
|
|
81
|
+
if (error.response.status == 404)
|
|
82
|
+
throw new Error("offer_not_found");
|
|
83
|
+
else
|
|
84
|
+
throw new Error('internal_error', error);
|
|
85
|
+
})];
|
|
86
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
87
|
+
case 2: throw new Error("unauthorized");
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
ReservationsAdminAPIs.getAvailableTransitions = function (_a) {
|
|
93
|
+
var token = _a.token, reservationId = _a.reservationId;
|
|
94
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
95
|
+
return __generator(this, function (_b) {
|
|
96
|
+
switch (_b.label) {
|
|
97
|
+
case 0:
|
|
98
|
+
if (!token) return [3 /*break*/, 2];
|
|
99
|
+
return [4 /*yield*/, axios.get(base + "/business/reservations/".concat(reservationId, "/available-status"), {
|
|
100
|
+
headers: {
|
|
101
|
+
'Authorization': "".concat(token)
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
.then(function (response) { return response.data; })
|
|
105
|
+
.catch(function (error) {
|
|
106
|
+
// handle error
|
|
107
|
+
throw new Error('internal_error', error);
|
|
108
|
+
})];
|
|
109
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
110
|
+
case 2: throw new Error("unauthorized");
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
ReservationsAdminAPIs.patchStatus = function (_a) {
|
|
116
|
+
var token = _a.token, id = _a.id, status = _a.status;
|
|
117
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
+
return __generator(this, function (_b) {
|
|
119
|
+
switch (_b.label) {
|
|
120
|
+
case 0: return [4 /*yield*/, axios.patch(base + "/business/reservations/".concat(id, "/").concat(status), {}, {
|
|
121
|
+
headers: {
|
|
122
|
+
'Authorization': "".concat(token)
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
.then(function (response) { return response.data; })
|
|
126
|
+
.catch(function (error) {
|
|
127
|
+
// handle error
|
|
128
|
+
if (error.response.status == 404)
|
|
129
|
+
throw new Error("booking_not_found");
|
|
130
|
+
else if (error.response.status == 400) {
|
|
131
|
+
// unauthorized_action
|
|
132
|
+
var response = error.response.data;
|
|
133
|
+
throw new Error(response.code);
|
|
134
|
+
}
|
|
135
|
+
else
|
|
136
|
+
throw new Error('internal_error');
|
|
137
|
+
})];
|
|
138
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
return ReservationsAdminAPIs;
|
|
144
|
+
}());
|
|
145
|
+
export { ReservationsAdminAPIs };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ReservationStatus } from "../../enum";
|
|
2
|
+
export interface Business {
|
|
3
|
+
id: string;
|
|
4
|
+
identifier: string;
|
|
5
|
+
name: string;
|
|
6
|
+
phones: string[];
|
|
7
|
+
address: string;
|
|
8
|
+
}
|
|
9
|
+
export interface User {
|
|
10
|
+
id: string;
|
|
11
|
+
firstname: string;
|
|
12
|
+
lastname: string;
|
|
13
|
+
phone?: string;
|
|
14
|
+
verifiedPhone: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface GuestDetails {
|
|
17
|
+
number: number;
|
|
18
|
+
price: number;
|
|
19
|
+
priceBeforeDeal?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface OnMenuCommand {
|
|
22
|
+
id: string;
|
|
23
|
+
onmenuId: string;
|
|
24
|
+
title: string;
|
|
25
|
+
adults: GuestDetails;
|
|
26
|
+
children?: GuestDetails;
|
|
27
|
+
deal: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ReservationEvent {
|
|
30
|
+
status: string;
|
|
31
|
+
at: string;
|
|
32
|
+
message?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface Reservation {
|
|
35
|
+
id: string;
|
|
36
|
+
createdAt: string;
|
|
37
|
+
business: Business;
|
|
38
|
+
user: User;
|
|
39
|
+
datetime: string;
|
|
40
|
+
status: ReservationStatus;
|
|
41
|
+
total: number;
|
|
42
|
+
totalBeforeDeal?: number;
|
|
43
|
+
onMenuCommands: OnMenuCommand[];
|
|
44
|
+
deposit?: number;
|
|
45
|
+
events?: ReservationEvent[];
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DealKind } from "../../../enum";
|
|
2
|
+
export interface ReserveOnMenuResponse {
|
|
3
|
+
id: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ReserveOnMenuRequest {
|
|
6
|
+
token?: string;
|
|
7
|
+
id: string;
|
|
8
|
+
date: Date;
|
|
9
|
+
time: Date;
|
|
10
|
+
children: number;
|
|
11
|
+
adults: number;
|
|
12
|
+
dealKind?: DealKind;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Reservation } from "./types/shared";
|
|
2
|
+
import { GetByIdRequest } from "./types/user/get-id";
|
|
3
|
+
import { GetPageRequest } from "./types/user/get-page";
|
|
4
|
+
import { ReserveOnMenuRequest, ReserveOnMenuResponse } from "./types/user/reserve-onmenu";
|
|
5
|
+
export declare class ReservationsUserAPIs {
|
|
6
|
+
static getPage({ token, page, size, direction }: GetPageRequest): Promise<Reservation[]>;
|
|
7
|
+
static get({ id, token }: GetByIdRequest): Promise<Reservation>;
|
|
8
|
+
static cancel(id: string, token?: string): Promise<any>;
|
|
9
|
+
static reserveOnMenu({ token, id, date, time, children, adults, dealKind }: ReserveOnMenuRequest): Promise<ReserveOnMenuResponse>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
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 { format } from "date-fns";
|
|
39
|
+
import { base } from "../constants";
|
|
40
|
+
var ReservationsUserAPIs = /** @class */ (function () {
|
|
41
|
+
function ReservationsUserAPIs() {
|
|
42
|
+
}
|
|
43
|
+
ReservationsUserAPIs.getPage = function (_a) {
|
|
44
|
+
var token = _a.token, _b = _a.page, page = _b === void 0 ? 1 : _b, _c = _a.size, size = _c === void 0 ? 10 : _c, direction = _a.direction;
|
|
45
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
46
|
+
return __generator(this, function (_d) {
|
|
47
|
+
switch (_d.label) {
|
|
48
|
+
case 0:
|
|
49
|
+
if (!token) return [3 /*break*/, 2];
|
|
50
|
+
return [4 /*yield*/, axios.get(base + "/user/reservations?page=".concat(page, "&size=").concat(size, "&direction=").concat(direction), {
|
|
51
|
+
headers: {
|
|
52
|
+
'Authorization': "".concat(token)
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
.then(function (response) { return response.data; })
|
|
56
|
+
.catch(function (error) {
|
|
57
|
+
// handle error
|
|
58
|
+
throw new Error('internal_error', error);
|
|
59
|
+
})];
|
|
60
|
+
case 1: return [2 /*return*/, _d.sent()];
|
|
61
|
+
case 2:
|
|
62
|
+
console.log('unauthorized');
|
|
63
|
+
return [2 /*return*/, []];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
ReservationsUserAPIs.get = function (_a) {
|
|
69
|
+
var id = _a.id, token = _a.token;
|
|
70
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
71
|
+
return __generator(this, function (_b) {
|
|
72
|
+
switch (_b.label) {
|
|
73
|
+
case 0:
|
|
74
|
+
if (!token) return [3 /*break*/, 2];
|
|
75
|
+
return [4 /*yield*/, axios.get(base + "/user/reservations/".concat(id), {
|
|
76
|
+
headers: {
|
|
77
|
+
'Authorization': "".concat(token),
|
|
78
|
+
'Content-Type': 'application/json'
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
.then(function (response) { return response.data; })
|
|
82
|
+
.catch(function (error) {
|
|
83
|
+
// handle error
|
|
84
|
+
if (error.response.status == 404)
|
|
85
|
+
throw new Error("offer_not_found");
|
|
86
|
+
else
|
|
87
|
+
throw new Error('internal_error');
|
|
88
|
+
})];
|
|
89
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
90
|
+
case 2: throw new Error("unauthorized");
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
ReservationsUserAPIs.cancel = function (id, token) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
switch (_a.label) {
|
|
99
|
+
case 0: return [4 /*yield*/, axios.patch(base + "/user/reservations/".concat(id, "/cancel"), {}, {
|
|
100
|
+
headers: {
|
|
101
|
+
'Authorization': "".concat(token)
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
.then(function (response) { return response.data; })
|
|
105
|
+
.catch(function (error) {
|
|
106
|
+
// handle error
|
|
107
|
+
if (error.response.status == 404)
|
|
108
|
+
throw new Error("reservation_not_found");
|
|
109
|
+
else if (error.response.status == 400) {
|
|
110
|
+
//unauthorized_action
|
|
111
|
+
//reservation_not_found
|
|
112
|
+
var response = error.response.data;
|
|
113
|
+
throw new Error(response.code);
|
|
114
|
+
}
|
|
115
|
+
else
|
|
116
|
+
throw new Error('internal_error', error);
|
|
117
|
+
})];
|
|
118
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
ReservationsUserAPIs.reserveOnMenu = function (_a) {
|
|
124
|
+
var token = _a.token, id = _a.id, date = _a.date, time = _a.time, children = _a.children, adults = _a.adults, dealKind = _a.dealKind;
|
|
125
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
126
|
+
var datetime;
|
|
127
|
+
return __generator(this, function (_b) {
|
|
128
|
+
switch (_b.label) {
|
|
129
|
+
case 0:
|
|
130
|
+
if (!token) return [3 /*break*/, 2];
|
|
131
|
+
datetime = new Date(date);
|
|
132
|
+
datetime.setHours(time.getHours(), time.getMinutes());
|
|
133
|
+
return [4 /*yield*/, axios.post(base + "/user/reservations/onmenu", {
|
|
134
|
+
id: id,
|
|
135
|
+
datetime: format(datetime, "yyyy-MM-dd'T'HH:mm"),
|
|
136
|
+
children: children,
|
|
137
|
+
adults: adults,
|
|
138
|
+
dealKind: dealKind
|
|
139
|
+
}, {
|
|
140
|
+
headers: {
|
|
141
|
+
'Authorization': "".concat(token),
|
|
142
|
+
'Content-Type': 'application/json'
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
.then(function (response) { return response.data; })
|
|
146
|
+
.catch(function (error) {
|
|
147
|
+
// handle error
|
|
148
|
+
if (error.response.status == 404)
|
|
149
|
+
throw new Error("service_not_found");
|
|
150
|
+
else if (error.response.status == 400) {
|
|
151
|
+
//banned_user
|
|
152
|
+
//unavailable_day
|
|
153
|
+
//unavailable_deal
|
|
154
|
+
//min_booking_amount
|
|
155
|
+
//date_already_used
|
|
156
|
+
var response = error.response.data;
|
|
157
|
+
throw new Error(response.code);
|
|
158
|
+
}
|
|
159
|
+
else
|
|
160
|
+
throw new Error('internal_error', error);
|
|
161
|
+
})];
|
|
162
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
163
|
+
case 2: throw new Error("unauthorized");
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
return ReservationsUserAPIs;
|
|
169
|
+
}());
|
|
170
|
+
export { ReservationsUserAPIs };
|