@kiminix/tp-client 1.36.0 → 1.38.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.
@@ -1,4 +1,18 @@
1
1
  import { Business } from "./types/get-id";
2
2
  export declare class BusinessAdminAPIs {
3
+ /**
4
+ *
5
+ * @param token
6
+ * @throws unauthorized, internal_error
7
+ * @returns
8
+ */
3
9
  static get(token?: string): Promise<Business>;
10
+ static subscription(props: {
11
+ name: string;
12
+ firstName: string;
13
+ lastName: string;
14
+ phone: string;
15
+ address: string;
16
+ socialNetwork?: string;
17
+ }): Promise<any>;
4
18
  }
@@ -37,15 +37,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  import axios from "axios";
38
38
  import { base } from "../constants";
39
39
  import { parseISO } from "date-fns";
40
+ import { RequestUtils } from "../utils/request-utils";
40
41
  // business module admin APIs
41
42
  var BusinessAdminAPIs = /** @class */ (function () {
42
43
  function BusinessAdminAPIs() {
43
44
  }
45
+ /**
46
+ *
47
+ * @param token
48
+ * @throws unauthorized, internal_error
49
+ * @returns
50
+ */
44
51
  BusinessAdminAPIs.get = function (token) {
45
52
  return __awaiter(this, void 0, void 0, function () {
46
53
  return __generator(this, function (_a) {
47
- switch (_a.label) {
48
- case 0: return [4 /*yield*/, axios.get(base + "/business/admin", {
54
+ return [2 /*return*/, RequestUtils.send(function () {
55
+ return axios.get(base + "/business/admin", {
49
56
  headers: {
50
57
  'Authorization': "".concat(token)
51
58
  }
@@ -55,16 +62,25 @@ var BusinessAdminAPIs = /** @class */ (function () {
55
62
  // to fix the date format
56
63
  data.createdAt = parseISO("".concat(data.createdAt));
57
64
  return data;
58
- })
59
- .catch(function (error) {
60
- // handle error
61
- if (error.response.status == 401)
62
- throw new Error("unauthorized");
63
- else
64
- throw new Error('internal_error', error);
65
- })];
66
- case 1: return [2 /*return*/, _a.sent()];
67
- }
65
+ });
66
+ })];
67
+ });
68
+ });
69
+ };
70
+ BusinessAdminAPIs.subscription = function (props) {
71
+ return __awaiter(this, void 0, void 0, function () {
72
+ return __generator(this, function (_a) {
73
+ return [2 /*return*/, RequestUtils.send(function () {
74
+ return axios.post(base + "/business/subscriptions", {
75
+ name: props.name,
76
+ firstName: props.firstName,
77
+ lastName: props.lastName,
78
+ phone: props.phone,
79
+ address: props.address,
80
+ socialNetwork: props.socialNetwork
81
+ }, {})
82
+ .then(function (response) { return response.data; });
83
+ })];
68
84
  });
69
85
  });
70
86
  };
@@ -104,7 +104,11 @@ var ReservationsUserAPIs = /** @class */ (function () {
104
104
  return __awaiter(this, void 0, void 0, function () {
105
105
  return __generator(this, function (_a) {
106
106
  return [2 /*return*/, RequestUtils.send(function () {
107
- return axios.patch(base + "/reservations/user/".concat(id, "/cancel"), {}, {})
107
+ return axios.patch(base + "/reservations/user/".concat(id, "/cancel"), {}, {
108
+ headers: {
109
+ 'Authorization': "".concat(token)
110
+ }
111
+ })
108
112
  .then(function (response) { return response.data; });
109
113
  })];
110
114
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiminix/tp-client",
3
- "version": "1.36.0",
3
+ "version": "1.38.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [