washday-sdk 0.0.64 → 0.0.66

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/api/index.js CHANGED
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  const delete_1 = require("./cashierbox/delete");
4
27
  const get_1 = require("./cashierbox/get");
@@ -13,20 +36,21 @@ const get_5 = require("./discounts/get");
13
36
  const post_3 = require("./discounts/post");
14
37
  const put_3 = require("./discounts/put");
15
38
  const put_4 = require("./products/put");
16
- const get_6 = require("./sections/get");
17
39
  const delete_2 = require("./staff/delete");
18
- const get_7 = require("./staff/get");
40
+ const get_6 = require("./staff/get");
19
41
  const post_4 = require("./staff/post");
20
42
  const put_5 = require("./staff/put");
21
- const get_8 = require("./stores/get");
43
+ const get_7 = require("./stores/get");
22
44
  const post_5 = require("./stores/post");
23
45
  const put_6 = require("./stores/put");
24
46
  const post_6 = require("./stripe/post");
25
47
  const delete_3 = require("./supplies/delete");
26
- const get_9 = require("./supplies/get");
48
+ const get_8 = require("./supplies/get");
27
49
  const post_7 = require("./supplies/post");
28
50
  const put_7 = require("./supplies/put");
29
51
  const put_8 = require("./users/put");
52
+ const inventoryEndpoints = __importStar(require("./inventory"));
53
+ const sectionsEndpoints = __importStar(require("./sections"));
30
54
  const WashdayClient = function WashdayClient(apiToken) {
31
55
  this.apiToken = apiToken;
32
56
  WashdayClient.prototype.customers.apiToken = apiToken;
@@ -42,22 +66,20 @@ const WashdayClient = function WashdayClient(apiToken) {
42
66
  WashdayClient.prototype.automaticDiscount.apiToken = apiToken;
43
67
  WashdayClient.prototype.sections.apiToken = apiToken;
44
68
  WashdayClient.prototype.supplies.apiToken = apiToken;
45
- };
46
- WashdayClient.prototype.sections = {
47
- getSections: get_6.getSections,
69
+ WashdayClient.prototype.inventory.apiToken = apiToken;
48
70
  };
49
71
  WashdayClient.prototype.customers = {
50
72
  getCustomerById: get_4.getCustomerById,
51
73
  getCustomerHighlightsById: get_4.getCustomerHighlightsById
52
74
  };
53
75
  WashdayClient.prototype.stores = {
54
- getStores: get_8.getStores,
55
- getStoreById: get_8.getStoreById,
76
+ getStores: get_7.getStores,
77
+ getStoreById: get_7.getStoreById,
56
78
  createStore: post_5.createStore,
57
79
  copyStore: post_5.copyStore,
58
80
  updateStoreById: put_6.updateStoreById,
59
81
  createStoreImage: post_5.createStoreImage,
60
- getStoreReviewLink: get_8.getStoreReviewLink,
82
+ getStoreReviewLink: get_7.getStoreReviewLink,
61
83
  deleteStoreById: put_6.deleteStoreById,
62
84
  };
63
85
  WashdayClient.prototype.products = {
@@ -70,14 +92,30 @@ WashdayClient.prototype.countries = {
70
92
  getCountries: get_3.getCountries,
71
93
  };
72
94
  WashdayClient.prototype.supplies = {
73
- getSupplies: get_9.getSupplies,
74
- getSupplyById: get_9.getSupplyById,
75
- getSupplyHistory: get_9.getSupplyHistory,
95
+ getSupplies: get_8.getSupplies,
96
+ getSupplyById: get_8.getSupplyById,
97
+ getSupplyHistory: get_8.getSupplyHistory,
76
98
  createSupply: post_7.createSupply,
77
99
  updateSupplyById: put_7.updateSupplyById,
78
100
  addSupplyStock: put_7.addSupplyStock,
79
101
  deleteSupplyById: delete_3.deleteSupplyById,
80
102
  };
103
+ WashdayClient.prototype.sections = {
104
+ getSections: sectionsEndpoints.getModule.getList,
105
+ getById: sectionsEndpoints.getModule.getById,
106
+ create: sectionsEndpoints.postModule.create,
107
+ deleteById: sectionsEndpoints.deleteModule.deleteById,
108
+ updateById: sectionsEndpoints.putModule.updateById,
109
+ };
110
+ WashdayClient.prototype.inventory = {
111
+ getInventory: inventoryEndpoints.getModule.getInventory,
112
+ getById: inventoryEndpoints.getModule.getInventoryById,
113
+ getHistoryById: inventoryEndpoints.getModule.getHistoryById,
114
+ create: inventoryEndpoints.postModule.create,
115
+ deleteById: inventoryEndpoints.deleteModule.deleteById,
116
+ updateById: inventoryEndpoints.putModule.updateById,
117
+ addStock: inventoryEndpoints.putModule.addStock,
118
+ };
81
119
  WashdayClient.prototype.cashierboxes = {
82
120
  getCashierboxesByStoreId: get_1.getCashierboxesByStoreId,
83
121
  getCashierboxesById: get_1.getCashierboxesById,
@@ -101,8 +139,8 @@ WashdayClient.prototype.stripe = {
101
139
  createCustomerPortalSession: post_6.createCustomerPortalSession
102
140
  };
103
141
  WashdayClient.prototype.staff = {
104
- getStoreStaff: get_7.getStoreStaff,
105
- getStoreStaffById: get_7.getStoreStaffById,
142
+ getStoreStaff: get_6.getStoreStaff,
143
+ getStoreStaffById: get_6.getStoreStaffById,
106
144
  updateStoreStaffById: put_5.updateStoreStaffById,
107
145
  createStoreStaff: post_4.createStoreStaff,
108
146
  deleteStoreStaffById: delete_2.deleteStoreStaffById,
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.deleteById = void 0;
16
+ const axiosInstance_1 = __importDefault(require("../axiosInstance"));
17
+ const GET_SET_INVENTORY = (storeId) => `api/store/${storeId}/inventory`;
18
+ const deleteById = function (storeId, id) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ try {
21
+ const config = {
22
+ headers: { Authorization: `Bearer ${this.apiToken}` }
23
+ };
24
+ const response = yield axiosInstance_1.default.delete(`${GET_SET_INVENTORY(storeId)}/${id}`, config);
25
+ return response;
26
+ }
27
+ catch (error) {
28
+ console.error('Error fetching deleteById:', error);
29
+ throw error;
30
+ }
31
+ });
32
+ };
33
+ exports.deleteById = deleteById;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getHistoryById = exports.getInventoryById = exports.getInventory = void 0;
16
+ const axiosInstance_1 = __importDefault(require("../axiosInstance"));
17
+ const GET_SET_INVENTORY = (storeId) => `api/store/${storeId}/inventory`;
18
+ const getInventory = function (storeId, queryParams) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ try {
21
+ const config = {
22
+ headers: { Authorization: `Bearer ${this.apiToken}` }
23
+ };
24
+ const response = yield axiosInstance_1.default.get(`${GET_SET_INVENTORY(storeId)}?${queryParams}`, config);
25
+ return response;
26
+ }
27
+ catch (error) {
28
+ console.error('Error fetching getInventory:', error);
29
+ throw error;
30
+ }
31
+ });
32
+ };
33
+ exports.getInventory = getInventory;
34
+ const getInventoryById = function (storeId, id) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ try {
37
+ const config = {
38
+ headers: { Authorization: `Bearer ${this.apiToken}` }
39
+ };
40
+ return yield axiosInstance_1.default.get(`${GET_SET_INVENTORY(storeId)}/${id}`, config);
41
+ }
42
+ catch (error) {
43
+ console.error('Error fetching getInventoryById:', error);
44
+ throw error;
45
+ }
46
+ });
47
+ };
48
+ exports.getInventoryById = getInventoryById;
49
+ const getHistoryById = function (storeId, id, params) {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ try {
52
+ const config = {
53
+ headers: { Authorization: `Bearer ${this.apiToken}` }
54
+ };
55
+ let queryParams = '';
56
+ if (params === null || params === void 0 ? void 0 : params.hasOwnProperty('pageNum')) {
57
+ queryParams += `pageNum=${params === null || params === void 0 ? void 0 : params.pageNum}`;
58
+ }
59
+ if (params === null || params === void 0 ? void 0 : params.hasOwnProperty('limit')) {
60
+ queryParams += `&limit=${params === null || params === void 0 ? void 0 : params.limit}`;
61
+ }
62
+ const response = yield axiosInstance_1.default.get(`${GET_SET_INVENTORY(storeId)}/${id}/history?${queryParams}`, config);
63
+ return response;
64
+ }
65
+ catch (error) {
66
+ console.error('Error fetching getInventoryHistory:', error);
67
+ throw error;
68
+ }
69
+ });
70
+ };
71
+ exports.getHistoryById = getHistoryById;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.putModule = exports.postModule = exports.getModule = exports.deleteModule = void 0;
27
+ exports.deleteModule = __importStar(require("./delete"));
28
+ exports.getModule = __importStar(require("./get"));
29
+ exports.postModule = __importStar(require("./post"));
30
+ exports.putModule = __importStar(require("./put"));
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.create = void 0;
16
+ const axiosInstance_1 = __importDefault(require("../axiosInstance"));
17
+ const GET_SET_INVENTORY = (storeId) => `api/store/${storeId}/inventory`;
18
+ const create = function (storeId, data) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ try {
21
+ const config = {
22
+ headers: { Authorization: `Bearer ${this.apiToken}` }
23
+ };
24
+ const response = yield axiosInstance_1.default.post(`${GET_SET_INVENTORY(storeId)}`, data, config);
25
+ return response;
26
+ }
27
+ catch (error) {
28
+ console.error('Error fetching create:', error);
29
+ throw error;
30
+ }
31
+ });
32
+ };
33
+ exports.create = create;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.addStock = exports.updateById = void 0;
16
+ const axiosInstance_1 = __importDefault(require("../axiosInstance"));
17
+ const GET_SET_INVENTORY = (storeId) => `api/store/${storeId}/inventory`;
18
+ const updateById = function (storeId, id, data) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ try {
21
+ const config = {
22
+ headers: { Authorization: `Bearer ${this.apiToken}` }
23
+ };
24
+ const response = yield axiosInstance_1.default.put(`${GET_SET_INVENTORY(storeId)}/${id}`, data, config);
25
+ return response;
26
+ }
27
+ catch (error) {
28
+ console.error('Error fetching updateById:', error);
29
+ throw error;
30
+ }
31
+ });
32
+ };
33
+ exports.updateById = updateById;
34
+ const addStock = function (storeId, id, data) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ try {
37
+ const config = {
38
+ headers: { Authorization: `Bearer ${this.apiToken}` }
39
+ };
40
+ const response = yield axiosInstance_1.default.put(`${GET_SET_INVENTORY(storeId)}/${id}/add-stock`, data, config);
41
+ return response;
42
+ }
43
+ catch (error) {
44
+ console.error('Error fetching addStock:', error);
45
+ throw error;
46
+ }
47
+ });
48
+ };
49
+ exports.addStock = addStock;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const GET_SET_SECTIONS = 'api/section';
4
+ // export const deleteById = async function (this: WashdayClientInstance, id: string): Promise<any> {
5
+ // try {
6
+ // const config = {
7
+ // headers: { Authorization: `Bearer ${this.apiToken}` }
8
+ // };
9
+ // return await axiosInstance.delete(`${GET_SET_SECTIONS}/${id}`, config);
10
+ // } catch (error) {
11
+ // console.error('Error fetching deleteById:', error);
12
+ // throw error;
13
+ // }
14
+ // };
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.putModule = exports.postModule = exports.getModule = exports.deleteModule = void 0;
27
+ exports.deleteModule = __importStar(require("./delete"));
28
+ exports.getModule = __importStar(require("./get"));
29
+ exports.postModule = __importStar(require("./post"));
30
+ exports.putModule = __importStar(require("./put"));
@@ -1,16 +1,32 @@
1
1
  "use strict";
2
- // import { WashdayClientInstance } from "../../interfaces/Api";
3
- // import axiosInstance from "../axiosInstance";
4
- // const GET_SET_STAFF = (storeId: string) => `api/store/${storeId}/staff`;
5
- // export const deleteStoreStaffById = async function (this: WashdayClientInstance, storeId: string, staffId: string): Promise<any> {
6
- // try {
7
- // const config = {
8
- // headers: { Authorization: `Bearer ${this.apiToken}` }
9
- // };
10
- // const response = await axiosInstance.delete(`${GET_SET_STAFF(storeId)}/${staffId}`, config);
11
- // return response;
12
- // } catch (error) {
13
- // console.error('Error fetching getStoreStaff:', error);
14
- // throw error;
15
- // }
16
- // };
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.deleteById = void 0;
16
+ const axiosInstance_1 = __importDefault(require("../axiosInstance"));
17
+ const GET_SET_SECTIONS = 'api/section';
18
+ const deleteById = function (id) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ try {
21
+ const config = {
22
+ headers: { Authorization: `Bearer ${this.apiToken}` }
23
+ };
24
+ return yield axiosInstance_1.default.delete(`${GET_SET_SECTIONS}/${id}`, config);
25
+ }
26
+ catch (error) {
27
+ console.error('Error fetching deleteById:', error);
28
+ throw error;
29
+ }
30
+ });
31
+ };
32
+ exports.deleteById = deleteById;
@@ -12,10 +12,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getSections = void 0;
15
+ exports.getById = exports.getList = void 0;
16
16
  const axiosInstance_1 = __importDefault(require("../axiosInstance"));
17
17
  const GET_SET_SECTIONS = 'api/section';
18
- const getSections = function (params) {
18
+ const getList = function (params) {
19
19
  return __awaiter(this, void 0, void 0, function* () {
20
20
  try {
21
21
  const config = {
@@ -42,4 +42,19 @@ const getSections = function (params) {
42
42
  }
43
43
  });
44
44
  };
45
- exports.getSections = getSections;
45
+ exports.getList = getList;
46
+ const getById = function (id) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ try {
49
+ const config = {
50
+ headers: { Authorization: `Bearer ${this.apiToken}` }
51
+ };
52
+ return yield axiosInstance_1.default.get(`${GET_SET_SECTIONS}/${id}`, config);
53
+ }
54
+ catch (error) {
55
+ console.error('Error fetching getSectionById:', error);
56
+ throw error;
57
+ }
58
+ });
59
+ };
60
+ exports.getById = getById;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.putModule = exports.postModule = exports.getModule = exports.deleteModule = void 0;
27
+ exports.deleteModule = __importStar(require("./delete"));
28
+ exports.getModule = __importStar(require("./get"));
29
+ exports.postModule = __importStar(require("./post"));
30
+ exports.putModule = __importStar(require("./put"));
@@ -1,16 +1,33 @@
1
1
  "use strict";
2
- // import { WashdayClientInstance } from "../../interfaces/Api";
3
- // import axiosInstance from "../axiosInstance";
4
- // const GET_SET_STAFF = (storeId: string) => `api/store/${storeId}/staff`;
5
- // export const createStoreStaff = async function (this: WashdayClientInstance, storeId: string, data: any): Promise<any> {
6
- // try {
7
- // const config = {
8
- // headers: { Authorization: `Bearer ${this.apiToken}` }
9
- // };
10
- // const response = await axiosInstance.post(`${GET_SET_STAFF(storeId)}`, data, config);
11
- // return response;
12
- // } catch (error) {
13
- // console.error('Error fetching createStoreImage:', error);
14
- // throw error;
15
- // }
16
- // };
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.create = void 0;
16
+ const axiosInstance_1 = __importDefault(require("../axiosInstance"));
17
+ const GET_SET_SECTIONS = 'api/section';
18
+ const create = function (data) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ try {
21
+ const config = {
22
+ headers: { Authorization: `Bearer ${this.apiToken}` }
23
+ };
24
+ const response = yield axiosInstance_1.default.post(`${GET_SET_SECTIONS}`, data, config);
25
+ return response;
26
+ }
27
+ catch (error) {
28
+ console.error('Error fetching create:', error);
29
+ throw error;
30
+ }
31
+ });
32
+ };
33
+ exports.create = create;
@@ -1,16 +1,32 @@
1
1
  "use strict";
2
- // import { WashdayClientInstance } from "../../interfaces/Api";
3
- // import { IStore } from "../../interfaces/Store";
4
- // import axiosInstance from "../axiosInstance";
5
- // export const updateStoreStaffById = async function (this: WashdayClientInstance, storeId: string, staffId: string, data: IStore): Promise<any> {
6
- // try {
7
- // const config = {
8
- // headers: { Authorization: `Bearer ${this.apiToken}` }
9
- // };
10
- // const response = await axiosInstance.put(`api/store/${storeId}/staff/${staffId}`, data, config);
11
- // return response;
12
- // } catch (error) {
13
- // console.error('Error fetching getStoreById:', error);
14
- // throw error;
15
- // }
16
- // };
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.updateById = void 0;
16
+ const axiosInstance_1 = __importDefault(require("../axiosInstance"));
17
+ const GET_SET_SECTIONS = 'api/section';
18
+ const updateById = function (id, data) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ try {
21
+ const config = {
22
+ headers: { Authorization: `Bearer ${this.apiToken}` }
23
+ };
24
+ return yield axiosInstance_1.default.put(`${GET_SET_SECTIONS}/${id}`, data, config);
25
+ }
26
+ catch (error) {
27
+ console.error('Error fetching updateById:', error);
28
+ throw error;
29
+ }
30
+ });
31
+ };
32
+ exports.updateById = updateById;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "0.0.64",
3
+ "version": "0.0.66",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/api/index.ts CHANGED
@@ -8,11 +8,10 @@ import { updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "./companies
8
8
  import { updateCompanyById, updateCompanyLogoById, updateCompanyTaxInfoById } from "./companies/put";
9
9
  import { getCountries } from "./countries/get";
10
10
  import { getCustomerById, getCustomerHighlightsById } from "./customers/get";
11
- import { getAutomaticDiscountById, getAutomaticDiscounts, getDiscountCodeById, getDiscountCodes, verifyDiscountCode } from "./discounts/get";
11
+ import { getAutomaticDiscountById, getAutomaticDiscounts, getDiscountCodeById, getDiscountCodes, verifyDiscountCode } from './discounts/get';
12
12
  import { createAutomaticDiscount, createDiscountCode } from "./discounts/post";
13
13
  import { deleteAutomaticDiscountById, deleteDiscountCodeById } from "./discounts/put";
14
14
  import { bulkUpdate } from "./products/put";
15
- import { getSections } from "./sections/get";
16
15
  import { deleteStoreStaffById } from "./staff/delete";
17
16
  import { getStoreStaff, getStoreStaffById } from "./staff/get";
18
17
  import { createStoreStaff } from "./staff/post";
@@ -26,6 +25,8 @@ import { getSupplies, getSupplyById, getSupplyHistory } from "./supplies/get";
26
25
  import { createSupply } from "./supplies/post";
27
26
  import { addSupplyStock, updateSupplyById } from "./supplies/put";
28
27
  import { updateUserById } from "./users/put";
28
+ import * as inventoryEndpoints from './inventory';
29
+ import * as sectionsEndpoints from './sections';
29
30
 
30
31
  type WashdayClientConstructor = {
31
32
  new(apiToken: string): {
@@ -48,12 +49,9 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
48
49
  WashdayClient.prototype.automaticDiscount.apiToken = apiToken;
49
50
  WashdayClient.prototype.sections.apiToken = apiToken;
50
51
  WashdayClient.prototype.supplies.apiToken = apiToken;
52
+ WashdayClient.prototype.inventory.apiToken = apiToken;
51
53
  } as any;
52
54
 
53
- WashdayClient.prototype.sections = {
54
- getSections: getSections,
55
- };
56
-
57
55
  WashdayClient.prototype.customers = {
58
56
  getCustomerById: getCustomerById,
59
57
  getCustomerHighlightsById: getCustomerHighlightsById
@@ -93,6 +91,23 @@ WashdayClient.prototype.supplies = {
93
91
  deleteSupplyById: deleteSupplyById,
94
92
  };
95
93
 
94
+ WashdayClient.prototype.sections = {
95
+ getSections: sectionsEndpoints.getModule.getList,
96
+ getById: sectionsEndpoints.getModule.getById,
97
+ create: sectionsEndpoints.postModule.create,
98
+ deleteById: sectionsEndpoints.deleteModule.deleteById,
99
+ updateById: sectionsEndpoints.putModule.updateById,
100
+ };
101
+
102
+ WashdayClient.prototype.inventory = {
103
+ getInventory: inventoryEndpoints.getModule.getInventory,
104
+ getById: inventoryEndpoints.getModule.getInventoryById,
105
+ getHistoryById: inventoryEndpoints.getModule.getHistoryById,
106
+ create: inventoryEndpoints.postModule.create,
107
+ deleteById: inventoryEndpoints.deleteModule.deleteById,
108
+ updateById: inventoryEndpoints.putModule.updateById,
109
+ addStock: inventoryEndpoints.putModule.addStock,
110
+ };
96
111
 
97
112
  WashdayClient.prototype.cashierboxes = {
98
113
  getCashierboxesByStoreId: getCashierboxesByStoreId,
@@ -0,0 +1,16 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import axiosInstance from "../axiosInstance";
3
+ const GET_SET_INVENTORY = (storeId: string) => `api/store/${storeId}/inventory`;
4
+
5
+ export const deleteById = async function (this: WashdayClientInstance, storeId: string, id: string): Promise<any> {
6
+ try {
7
+ const config = {
8
+ headers: { Authorization: `Bearer ${this.apiToken}` }
9
+ };
10
+ const response = await axiosInstance.delete(`${GET_SET_INVENTORY(storeId)}/${id}`, config);
11
+ return response;
12
+ } catch (error) {
13
+ console.error('Error fetching deleteById:', error);
14
+ throw error;
15
+ }
16
+ };
@@ -0,0 +1,53 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import axiosInstance from "../axiosInstance";
3
+
4
+ const GET_SET_INVENTORY = (storeId: string) => `api/store/${storeId}/inventory`;
5
+
6
+ export const getInventory = async function (this: WashdayClientInstance, storeId: string, queryParams?: string): Promise<any> {
7
+ try {
8
+ const config = {
9
+ headers: { Authorization: `Bearer ${this.apiToken}` }
10
+ };
11
+ const response = await axiosInstance.get(`${GET_SET_INVENTORY(storeId)}?${queryParams}`, config);
12
+ return response;
13
+ } catch (error) {
14
+ console.error('Error fetching getInventory:', error);
15
+ throw error;
16
+ }
17
+ };
18
+
19
+ export const getInventoryById = async function (this: WashdayClientInstance, storeId: string, id: string): Promise<any> {
20
+ try {
21
+ const config = {
22
+ headers: { Authorization: `Bearer ${this.apiToken}` }
23
+ };
24
+ return await axiosInstance.get(`${GET_SET_INVENTORY(storeId)}/${id}`, config);
25
+ } catch (error) {
26
+ console.error('Error fetching getInventoryById:', error);
27
+ throw error;
28
+ }
29
+ };
30
+
31
+ export const getHistoryById = async function (this: WashdayClientInstance, storeId: string, id: string, params?: {
32
+ pageNum: number;
33
+ limit: number
34
+ }): Promise<any> {
35
+ try {
36
+ const config = {
37
+ headers: { Authorization: `Bearer ${this.apiToken}` }
38
+ };
39
+ let queryParams = '';
40
+ if (params?.hasOwnProperty('pageNum')) {
41
+ queryParams += `pageNum=${params?.pageNum}`
42
+ }
43
+ if (params?.hasOwnProperty('limit')) {
44
+ queryParams += `&limit=${params?.limit}`
45
+ }
46
+ const response = await axiosInstance.get(`${GET_SET_INVENTORY(storeId)}/${id}/history?${queryParams}`, config);
47
+ return response;
48
+ } catch (error) {
49
+ console.error('Error fetching getInventoryHistory:', error);
50
+ throw error;
51
+ }
52
+ };
53
+
@@ -0,0 +1,4 @@
1
+ export * as deleteModule from './delete';
2
+ export * as getModule from './get';
3
+ export * as postModule from './post';
4
+ export * as putModule from './put';
@@ -0,0 +1,22 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import axiosInstance from "../axiosInstance";
3
+
4
+ const GET_SET_INVENTORY = (storeId: string) => `api/store/${storeId}/inventory`;
5
+
6
+ export const create = async function (this: WashdayClientInstance, storeId: string, data: {
7
+ product: string;
8
+ stock: number;
9
+ alertOnStock: number;
10
+ stockActivityHistory: Array<any>
11
+ }): Promise<any> {
12
+ try {
13
+ const config = {
14
+ headers: { Authorization: `Bearer ${this.apiToken}` }
15
+ };
16
+ const response = await axiosInstance.post(`${GET_SET_INVENTORY(storeId)}`, data, config);
17
+ return response;
18
+ } catch (error) {
19
+ console.error('Error fetching create:', error);
20
+ throw error;
21
+ }
22
+ };
@@ -0,0 +1,35 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import axiosInstance from "../axiosInstance";
3
+
4
+ const GET_SET_INVENTORY = (storeId: string) => `api/store/${storeId}/inventory`;
5
+
6
+ export const updateById = async function (this: WashdayClientInstance, storeId: string, id: string, data: {
7
+ alertOnStock: number;
8
+ }): Promise<any> {
9
+ try {
10
+ const config = {
11
+ headers: { Authorization: `Bearer ${this.apiToken}` }
12
+ };
13
+ const response = await axiosInstance.put(`${GET_SET_INVENTORY(storeId)}/${id}`, data, config);
14
+ return response;
15
+ } catch (error) {
16
+ console.error('Error fetching updateById:', error);
17
+ throw error;
18
+ }
19
+ };
20
+
21
+ export const addStock = async function (this: WashdayClientInstance, storeId: string, id: string, data: {
22
+ newStock: number;
23
+ date: string;
24
+ }): Promise<any> {
25
+ try {
26
+ const config = {
27
+ headers: { Authorization: `Bearer ${this.apiToken}` }
28
+ };
29
+ const response = await axiosInstance.put(`${GET_SET_INVENTORY(storeId)}/${id}/add-stock`, data, config);
30
+ return response;
31
+ } catch (error) {
32
+ console.error('Error fetching addStock:', error);
33
+ throw error;
34
+ }
35
+ };
@@ -0,0 +1,15 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import axiosInstance from "../axiosInstance";
3
+ const GET_SET_SECTIONS = 'api/section';
4
+
5
+ // export const deleteById = async function (this: WashdayClientInstance, id: string): Promise<any> {
6
+ // try {
7
+ // const config = {
8
+ // headers: { Authorization: `Bearer ${this.apiToken}` }
9
+ // };
10
+ // return await axiosInstance.delete(`${GET_SET_SECTIONS}/${id}`, config);
11
+ // } catch (error) {
12
+ // console.error('Error fetching deleteById:', error);
13
+ // throw error;
14
+ // }
15
+ // };
@@ -0,0 +1,4 @@
1
+ export * as deleteModule from './delete';
2
+ export * as getModule from './get';
3
+ export * as postModule from './post';
4
+ export * as putModule from './put';
@@ -1,16 +1,15 @@
1
- // import { WashdayClientInstance } from "../../interfaces/Api";
2
- // import axiosInstance from "../axiosInstance";
3
- // const GET_SET_STAFF = (storeId: string) => `api/store/${storeId}/staff`;
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import axiosInstance from "../axiosInstance";
3
+ const GET_SET_SECTIONS = 'api/section';
4
4
 
5
- // export const deleteStoreStaffById = async function (this: WashdayClientInstance, storeId: string, staffId: string): Promise<any> {
6
- // try {
7
- // const config = {
8
- // headers: { Authorization: `Bearer ${this.apiToken}` }
9
- // };
10
- // const response = await axiosInstance.delete(`${GET_SET_STAFF(storeId)}/${staffId}`, config);
11
- // return response;
12
- // } catch (error) {
13
- // console.error('Error fetching getStoreStaff:', error);
14
- // throw error;
15
- // }
16
- // };
5
+ export const deleteById = async function (this: WashdayClientInstance, id: string): Promise<any> {
6
+ try {
7
+ const config = {
8
+ headers: { Authorization: `Bearer ${this.apiToken}` }
9
+ };
10
+ return await axiosInstance.delete(`${GET_SET_SECTIONS}/${id}`, config);
11
+ } catch (error) {
12
+ console.error('Error fetching deleteById:', error);
13
+ throw error;
14
+ }
15
+ };
@@ -1,9 +1,10 @@
1
1
  import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import { ISection } from "../../interfaces/Section";
2
3
  import axiosInstance from "../axiosInstance";
3
4
 
4
5
  const GET_SET_SECTIONS = 'api/section';
5
6
 
6
- export const getSections = async function (this: WashdayClientInstance, params?: {
7
+ export const getList = async function (this: WashdayClientInstance, params?: {
7
8
  storeId?: string
8
9
  isActive?: string
9
10
  products?: boolean
@@ -30,4 +31,16 @@ export const getSections = async function (this: WashdayClientInstance, params?:
30
31
  console.error('Error fetching getStoreStaff:', error);
31
32
  throw error;
32
33
  }
34
+ };
35
+
36
+ export const getById = async function (this: WashdayClientInstance, id: string): Promise<any> {
37
+ try {
38
+ const config = {
39
+ headers: { Authorization: `Bearer ${this.apiToken}` }
40
+ };
41
+ return await axiosInstance.get(`${GET_SET_SECTIONS}/${id}`, config);
42
+ } catch (error) {
43
+ console.error('Error fetching getSectionById:', error);
44
+ throw error;
45
+ }
33
46
  };
@@ -0,0 +1,4 @@
1
+ export * as deleteModule from './delete';
2
+ export * as getModule from './get';
3
+ export * as postModule from './post';
4
+ export * as putModule from './put';
@@ -1,17 +1,22 @@
1
- // import { WashdayClientInstance } from "../../interfaces/Api";
2
- // import axiosInstance from "../axiosInstance";
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import axiosInstance from "../axiosInstance";
3
3
 
4
- // const GET_SET_STAFF = (storeId: string) => `api/store/${storeId}/staff`;
4
+ const GET_SET_SECTIONS = 'api/section';
5
5
 
6
- // export const createStoreStaff = async function (this: WashdayClientInstance, storeId: string, data: any): Promise<any> {
7
- // try {
8
- // const config = {
9
- // headers: { Authorization: `Bearer ${this.apiToken}` }
10
- // };
11
- // const response = await axiosInstance.post(`${GET_SET_STAFF(storeId)}`, data, config);
12
- // return response;
13
- // } catch (error) {
14
- // console.error('Error fetching createStoreImage:', error);
15
- // throw error;
16
- // }
17
- // };
6
+ export const create = async function (this: WashdayClientInstance, data: {
7
+ name: string;
8
+ order: number;
9
+ boxColor: string;
10
+ store: string;
11
+ }): Promise<any> {
12
+ try {
13
+ const config = {
14
+ headers: { Authorization: `Bearer ${this.apiToken}` }
15
+ };
16
+ const response = await axiosInstance.post(`${GET_SET_SECTIONS}`, data, config);
17
+ return response;
18
+ } catch (error) {
19
+ console.error('Error fetching create:', error);
20
+ throw error;
21
+ }
22
+ };
@@ -1,16 +1,23 @@
1
- // import { WashdayClientInstance } from "../../interfaces/Api";
2
- // import { IStore } from "../../interfaces/Store";
3
- // import axiosInstance from "../axiosInstance";
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import axiosInstance from "../axiosInstance";
3
+
4
+ const GET_SET_SECTIONS = 'api/section';
5
+
6
+ export const updateById = async function (this: WashdayClientInstance, id: string, data: {
7
+ name?: string;
8
+ order?: number;
9
+ boxColor?: string;
10
+ showInApp?: boolean,
11
+ product?: any
12
+ }): Promise<any> {
13
+ try {
14
+ const config = {
15
+ headers: { Authorization: `Bearer ${this.apiToken}` }
16
+ };
17
+ return await axiosInstance.put(`${GET_SET_SECTIONS}/${id}`, data, config);
18
+ } catch (error) {
19
+ console.error('Error fetching updateById:', error);
20
+ throw error;
21
+ }
22
+ };
4
23
 
5
- // export const updateStoreStaffById = async function (this: WashdayClientInstance, storeId: string, staffId: string, data: IStore): Promise<any> {
6
- // try {
7
- // const config = {
8
- // headers: { Authorization: `Bearer ${this.apiToken}` }
9
- // };
10
- // const response = await axiosInstance.put(`api/store/${storeId}/staff/${staffId}`, data, config);
11
- // return response;
12
- // } catch (error) {
13
- // console.error('Error fetching getStoreById:', error);
14
- // throw error;
15
- // }
16
- // };
@@ -3,7 +3,7 @@ import { IStore } from "../../interfaces/Store";
3
3
  import axiosInstance from "../axiosInstance";
4
4
  const GET_SET_STAFF = (storeId: string) => `api/store/${storeId}/staff`;
5
5
 
6
- export const updateStoreStaffById = async function (this: WashdayClientInstance, storeId: string, staffId: string, data: IStore): Promise<any> {
6
+ export const updateStoreStaffById = async function (this: WashdayClientInstance, storeId: string, staffId: string, data: any): Promise<any> {
7
7
  try {
8
8
  const config = {
9
9
  headers: { Authorization: `Bearer ${this.apiToken}` }