@kiminix/tp-client 2.4.0 → 2.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/enum.d.ts CHANGED
@@ -39,3 +39,8 @@ export declare enum CancellationReason {
39
39
  ForceMajeur = "force_majeur",
40
40
  Other = "other"
41
41
  }
42
+ export declare enum VoucherStatus {
43
+ InProgress = "in_progress",
44
+ Succeeded = "succeeded",
45
+ Failed = "failed"
46
+ }
package/dist/enum.js CHANGED
@@ -46,3 +46,9 @@ export var CancellationReason;
46
46
  CancellationReason["ForceMajeur"] = "force_majeur";
47
47
  CancellationReason["Other"] = "other";
48
48
  })(CancellationReason || (CancellationReason = {}));
49
+ export var VoucherStatus;
50
+ (function (VoucherStatus) {
51
+ VoucherStatus["InProgress"] = "in_progress";
52
+ VoucherStatus["Succeeded"] = "succeeded";
53
+ VoucherStatus["Failed"] = "failed";
54
+ })(VoucherStatus || (VoucherStatus = {}));
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from './business/index';
8
8
  export * from './reservations/index';
9
9
  export * from './cashback/index';
10
10
  export * from './discounts/index';
11
+ export * from './vouchers/index';
11
12
  export * from './utils/business-utils';
12
13
  export * from './utils/date-utils';
13
14
  export * from './enum';
package/dist/index.js CHANGED
@@ -14,6 +14,8 @@ export * from './reservations/index';
14
14
  export * from './cashback/index';
15
15
  //discounts module
16
16
  export * from './discounts/index';
17
+ //vouchers module
18
+ export * from './vouchers/index';
17
19
  //utils
18
20
  export * from './utils/business-utils';
19
21
  export * from './utils/date-utils';
@@ -0,0 +1,3 @@
1
+ export * from "./user/types/voucher-booking-response";
2
+ export * from './user/types/voucher-response';
3
+ export { VouchersGuestAPIs } from './user/guest-apis';
@@ -0,0 +1,6 @@
1
+ // user module
2
+ export * from "./user/types/voucher-booking-response";
3
+ export * from './user/types/voucher-response';
4
+ export { VouchersGuestAPIs } from './user/guest-apis';
5
+ // admin module
6
+ // shared module
@@ -0,0 +1,30 @@
1
+ import { VoucherBookingResponse } from "./types/voucher-booking-response";
2
+ import { Voucher } from "./types/voucher-response";
3
+ export declare class VouchersGuestAPIs {
4
+ /**
5
+ *
6
+ * @param props
7
+ * @throws invalid_persons, closed_hour, unavailable_datetime, internal_error
8
+ *
9
+ * @returns
10
+ */
11
+ static reserve(props: {
12
+ businessId: string;
13
+ datetime: Date;
14
+ persons: number;
15
+ firstname: string;
16
+ lastname: string;
17
+ phone: string;
18
+ email: string | undefined;
19
+ notes: string | undefined;
20
+ }): Promise<VoucherBookingResponse>;
21
+ /**
22
+ *
23
+ * @param props
24
+ * @throws voucher_not_found, internal_error
25
+ * @returns
26
+ */
27
+ static get(props: {
28
+ id: string;
29
+ }): Promise<Voucher>;
30
+ }
@@ -0,0 +1,99 @@
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
+ import { RequestUtils } from "../../utils/request-utils";
41
+ // GUEST APIS
42
+ var VouchersGuestAPIs = /** @class */ (function () {
43
+ function VouchersGuestAPIs() {
44
+ }
45
+ /**
46
+ *
47
+ * @param props
48
+ * @throws invalid_persons, closed_hour, unavailable_datetime, internal_error
49
+ *
50
+ * @returns
51
+ */
52
+ VouchersGuestAPIs.reserve = function (props) {
53
+ return __awaiter(this, void 0, void 0, function () {
54
+ return __generator(this, function (_a) {
55
+ return [2 /*return*/, RequestUtils.send(function () {
56
+ return axios.post(base + "/vouchers/guest", {
57
+ businessId: props.businessId,
58
+ datetime: format(props.datetime, "yyyy-MM-dd'T'HH:mm"),
59
+ persons: props.persons,
60
+ firstname: props.firstname,
61
+ lastname: props.lastname,
62
+ phone: props.phone,
63
+ email: props.email,
64
+ notes: props.notes
65
+ }, {
66
+ headers: {
67
+ 'Content-Type': 'application/json'
68
+ }
69
+ })
70
+ .then(function (response) { return response.data; });
71
+ })];
72
+ });
73
+ });
74
+ };
75
+ /**
76
+ *
77
+ * @param props
78
+ * @throws voucher_not_found, internal_error
79
+ * @returns
80
+ */
81
+ VouchersGuestAPIs.get = function (props) {
82
+ return __awaiter(this, void 0, void 0, function () {
83
+ return __generator(this, function (_a) {
84
+ return [2 /*return*/, RequestUtils.send(function () {
85
+ return axios.get(base + "/vouchers/guest/".concat(props.id), {
86
+ headers: {
87
+ 'Content-Type': 'application/json'
88
+ }
89
+ })
90
+ .then(function (response) {
91
+ return response.data;
92
+ });
93
+ })];
94
+ });
95
+ });
96
+ };
97
+ return VouchersGuestAPIs;
98
+ }());
99
+ export { VouchersGuestAPIs };
@@ -0,0 +1,4 @@
1
+ export interface VoucherBookingResponse {
2
+ id: string;
3
+ paymentLink: string;
4
+ }
@@ -0,0 +1,23 @@
1
+ import { VoucherStatus } from "../../../enum";
2
+ export interface VoucherBusiness {
3
+ id: string;
4
+ identifier: string;
5
+ name: string;
6
+ phones: string[];
7
+ address: string;
8
+ googleMapUrl: string;
9
+ }
10
+ export interface Voucher {
11
+ id: string;
12
+ status: VoucherStatus;
13
+ business: VoucherBusiness;
14
+ datetime: string;
15
+ persons: number;
16
+ createdAt: string;
17
+ firstname: string;
18
+ lastname: string;
19
+ phone: string;
20
+ email: string | undefined;
21
+ notesAdmin: string | undefined;
22
+ notesUser: string | undefined;
23
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiminix/tp-client",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [