washday-sdk 0.0.63 → 0.0.64

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.
@@ -64,7 +64,7 @@ const getCashierBoxMovementsHistory = function (storeId, id, params) {
64
64
  return response;
65
65
  }
66
66
  catch (error) {
67
- console.error('Error fetching getCashierboxesById:', error);
67
+ console.error('Error fetching getCashierBoxMovementsHistory:', error);
68
68
  throw error;
69
69
  }
70
70
  });
package/dist/api/index.js CHANGED
@@ -22,7 +22,11 @@ const get_8 = require("./stores/get");
22
22
  const post_5 = require("./stores/post");
23
23
  const put_6 = require("./stores/put");
24
24
  const post_6 = require("./stripe/post");
25
- const put_7 = require("./users/put");
25
+ const delete_3 = require("./supplies/delete");
26
+ const get_9 = require("./supplies/get");
27
+ const post_7 = require("./supplies/post");
28
+ const put_7 = require("./supplies/put");
29
+ const put_8 = require("./users/put");
26
30
  const WashdayClient = function WashdayClient(apiToken) {
27
31
  this.apiToken = apiToken;
28
32
  WashdayClient.prototype.customers.apiToken = apiToken;
@@ -37,6 +41,7 @@ const WashdayClient = function WashdayClient(apiToken) {
37
41
  WashdayClient.prototype.discountCodes.apiToken = apiToken;
38
42
  WashdayClient.prototype.automaticDiscount.apiToken = apiToken;
39
43
  WashdayClient.prototype.sections.apiToken = apiToken;
44
+ WashdayClient.prototype.supplies.apiToken = apiToken;
40
45
  };
41
46
  WashdayClient.prototype.sections = {
42
47
  getSections: get_6.getSections,
@@ -59,11 +64,20 @@ WashdayClient.prototype.products = {
59
64
  bulkUpdate: put_4.bulkUpdate,
60
65
  };
61
66
  WashdayClient.prototype.users = {
62
- updateUserById: put_7.updateUserById,
67
+ updateUserById: put_8.updateUserById,
63
68
  };
64
69
  WashdayClient.prototype.countries = {
65
70
  getCountries: get_3.getCountries,
66
71
  };
72
+ WashdayClient.prototype.supplies = {
73
+ getSupplies: get_9.getSupplies,
74
+ getSupplyById: get_9.getSupplyById,
75
+ getSupplyHistory: get_9.getSupplyHistory,
76
+ createSupply: post_7.createSupply,
77
+ updateSupplyById: put_7.updateSupplyById,
78
+ addSupplyStock: put_7.addSupplyStock,
79
+ deleteSupplyById: delete_3.deleteSupplyById,
80
+ };
67
81
  WashdayClient.prototype.cashierboxes = {
68
82
  getCashierboxesByStoreId: get_1.getCashierboxesByStoreId,
69
83
  getCashierboxesById: get_1.getCashierboxesById,
@@ -14,13 +14,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.updateStoreStaffById = void 0;
16
16
  const axiosInstance_1 = __importDefault(require("../axiosInstance"));
17
+ const GET_SET_STAFF = (storeId) => `api/store/${storeId}/staff`;
17
18
  const updateStoreStaffById = function (storeId, staffId, data) {
18
19
  return __awaiter(this, void 0, void 0, function* () {
19
20
  try {
20
21
  const config = {
21
22
  headers: { Authorization: `Bearer ${this.apiToken}` }
22
23
  };
23
- const response = yield axiosInstance_1.default.put(`api/store/${storeId}/staff/${staffId}`, data, config);
24
+ const response = yield axiosInstance_1.default.put(`${GET_SET_STAFF(storeId)}/${staffId}`, data, config);
24
25
  return response;
25
26
  }
26
27
  catch (error) {
@@ -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.deleteSupplyById = void 0;
16
+ const axiosInstance_1 = __importDefault(require("../axiosInstance"));
17
+ const GET_SET_SUPPLY = (storeId) => `api/store/${storeId}/supply`;
18
+ const deleteSupplyById = 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_SUPPLY(storeId)}/${id}`, config);
25
+ return response;
26
+ }
27
+ catch (error) {
28
+ console.error('Error fetching deleteSupplyById:', error);
29
+ throw error;
30
+ }
31
+ });
32
+ };
33
+ exports.deleteSupplyById = deleteSupplyById;
@@ -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.getSupplyHistory = exports.getSupplyById = exports.getSupplies = void 0;
16
+ const axiosInstance_1 = __importDefault(require("../axiosInstance"));
17
+ const GET_SET_SUPPLY = (storeId) => `api/store/${storeId}/supply`;
18
+ const getSupplies = 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_SUPPLY(storeId)}?${queryParams}`, config);
25
+ return response;
26
+ }
27
+ catch (error) {
28
+ console.error('Error fetching getSupplies:', error);
29
+ throw error;
30
+ }
31
+ });
32
+ };
33
+ exports.getSupplies = getSupplies;
34
+ const getSupplyById = 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_SUPPLY(storeId)}/${id}`, config);
41
+ }
42
+ catch (error) {
43
+ console.error('Error fetching getStoreSupplyById:', error);
44
+ throw error;
45
+ }
46
+ });
47
+ };
48
+ exports.getSupplyById = getSupplyById;
49
+ const getSupplyHistory = 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_SUPPLY(storeId)}/${id}/history?${queryParams}`, config);
63
+ return response;
64
+ }
65
+ catch (error) {
66
+ console.error('Error fetching getCashierBoxMovementsHistory:', error);
67
+ throw error;
68
+ }
69
+ });
70
+ };
71
+ exports.getSupplyHistory = getSupplyHistory;
@@ -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.createSupply = void 0;
16
+ const axiosInstance_1 = __importDefault(require("../axiosInstance"));
17
+ const GET_SET_SUPPLY = (storeId) => `api/store/${storeId}/supply`;
18
+ const createSupply = 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_SUPPLY(storeId)}`, data, config);
25
+ return response;
26
+ }
27
+ catch (error) {
28
+ console.error('Error fetching createSupply:', error);
29
+ throw error;
30
+ }
31
+ });
32
+ };
33
+ exports.createSupply = createSupply;
@@ -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.addSupplyStock = exports.updateSupplyById = void 0;
16
+ const axiosInstance_1 = __importDefault(require("../axiosInstance"));
17
+ const GET_SET_SUPPLY = (storeId) => `api/store/${storeId}/supply`;
18
+ const updateSupplyById = 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_SUPPLY(storeId)}/${id}`, data, config);
25
+ return response;
26
+ }
27
+ catch (error) {
28
+ console.error('Error fetching getStoreById:', error);
29
+ throw error;
30
+ }
31
+ });
32
+ };
33
+ exports.updateSupplyById = updateSupplyById;
34
+ const addSupplyStock = 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_SUPPLY(storeId)}/${id}/addStock`, data, config);
41
+ return response;
42
+ }
43
+ catch (error) {
44
+ console.error('Error fetching addSupplyStock:', error);
45
+ throw error;
46
+ }
47
+ });
48
+ };
49
+ exports.addSupplyStock = addSupplyStock;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "0.0.63",
3
+ "version": "0.0.64",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -47,7 +47,7 @@ export const getCashierBoxMovementsHistory = async function (this: WashdayClient
47
47
  const response = await axiosInstance.get(`${GET_SET_CASHIER_BOX(storeId)}/${id}/history?${queryParams}`, config);
48
48
  return response;
49
49
  } catch (error) {
50
- console.error('Error fetching getCashierboxesById:', error);
50
+ console.error('Error fetching getCashierBoxMovementsHistory:', error);
51
51
  throw error;
52
52
  }
53
53
  };
package/src/api/index.ts CHANGED
@@ -21,6 +21,10 @@ import { getStoreById, getStoreReviewLink, getStores } from "./stores/get";
21
21
  import { copyStore, createStore, createStoreImage } from "./stores/post";
22
22
  import { deleteStoreById, updateStoreById } from "./stores/put";
23
23
  import { createCFDISuscrptionCheckoutSession, createCreateSuscriptionCheckoutSession, createCustomerPortalSession } from "./stripe/post";
24
+ import { deleteSupplyById } from "./supplies/delete";
25
+ import { getSupplies, getSupplyById, getSupplyHistory } from "./supplies/get";
26
+ import { createSupply } from "./supplies/post";
27
+ import { addSupplyStock, updateSupplyById } from "./supplies/put";
24
28
  import { updateUserById } from "./users/put";
25
29
 
26
30
  type WashdayClientConstructor = {
@@ -43,6 +47,7 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
43
47
  WashdayClient.prototype.discountCodes.apiToken = apiToken;
44
48
  WashdayClient.prototype.automaticDiscount.apiToken = apiToken;
45
49
  WashdayClient.prototype.sections.apiToken = apiToken;
50
+ WashdayClient.prototype.supplies.apiToken = apiToken;
46
51
  } as any;
47
52
 
48
53
  WashdayClient.prototype.sections = {
@@ -78,6 +83,17 @@ WashdayClient.prototype.countries = {
78
83
  getCountries: getCountries,
79
84
  };
80
85
 
86
+ WashdayClient.prototype.supplies = {
87
+ getSupplies: getSupplies,
88
+ getSupplyById: getSupplyById,
89
+ getSupplyHistory: getSupplyHistory,
90
+ createSupply: createSupply,
91
+ updateSupplyById: updateSupplyById,
92
+ addSupplyStock: addSupplyStock,
93
+ deleteSupplyById: deleteSupplyById,
94
+ };
95
+
96
+
81
97
  WashdayClient.prototype.cashierboxes = {
82
98
  getCashierboxesByStoreId: getCashierboxesByStoreId,
83
99
  getCashierboxesById: getCashierboxesById,
@@ -1,13 +1,14 @@
1
1
  import { WashdayClientInstance } from "../../interfaces/Api";
2
2
  import { IStore } from "../../interfaces/Store";
3
3
  import axiosInstance from "../axiosInstance";
4
+ const GET_SET_STAFF = (storeId: string) => `api/store/${storeId}/staff`;
4
5
 
5
6
  export const updateStoreStaffById = async function (this: WashdayClientInstance, storeId: string, staffId: string, data: IStore): Promise<any> {
6
7
  try {
7
8
  const config = {
8
9
  headers: { Authorization: `Bearer ${this.apiToken}` }
9
10
  };
10
- const response = await axiosInstance.put(`api/store/${storeId}/staff/${staffId}`, data, config);
11
+ const response = await axiosInstance.put(`${GET_SET_STAFF(storeId)}/${staffId}`, data, config);
11
12
  return response;
12
13
  } catch (error) {
13
14
  console.error('Error fetching getStoreById:', error);
@@ -0,0 +1,16 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import axiosInstance from "../axiosInstance";
3
+ const GET_SET_SUPPLY = (storeId: string) => `api/store/${storeId}/supply`;
4
+
5
+ export const deleteSupplyById = 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_SUPPLY(storeId)}/${id}`, config);
11
+ return response;
12
+ } catch (error) {
13
+ console.error('Error fetching deleteSupplyById:', 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_SUPPLY = (storeId: string) => `api/store/${storeId}/supply`;
5
+
6
+ export const getSupplies = 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_SUPPLY(storeId)}?${queryParams}`, config);
12
+ return response;
13
+ } catch (error) {
14
+ console.error('Error fetching getSupplies:', error);
15
+ throw error;
16
+ }
17
+ };
18
+
19
+ export const getSupplyById = 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_SUPPLY(storeId)}/${id}`, config);
25
+ } catch (error) {
26
+ console.error('Error fetching getStoreSupplyById:', error);
27
+ throw error;
28
+ }
29
+ };
30
+
31
+ export const getSupplyHistory = 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_SUPPLY(storeId)}/${id}/history?${queryParams}`, config);
47
+ return response;
48
+ } catch (error) {
49
+ console.error('Error fetching getCashierBoxMovementsHistory:', error);
50
+ throw error;
51
+ }
52
+ };
53
+
@@ -0,0 +1,26 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import axiosInstance from "../axiosInstance";
3
+
4
+ const GET_SET_SUPPLY = (storeId: string) => `api/store/${storeId}/supply`;
5
+
6
+ export const createSupply = async function (this: WashdayClientInstance, storeId: string, data: {
7
+ name: string;
8
+ code: string;
9
+ purchaseUnit: string;
10
+ usageUnit: string;
11
+ usageFactor: number;
12
+ stock: number;
13
+ alertOnStock: number;
14
+ supplyActivityHistory: []
15
+ }): Promise<any> {
16
+ try {
17
+ const config = {
18
+ headers: { Authorization: `Bearer ${this.apiToken}` }
19
+ };
20
+ const response = await axiosInstance.post(`${GET_SET_SUPPLY(storeId)}`, data, config);
21
+ return response;
22
+ } catch (error) {
23
+ console.error('Error fetching createSupply:', error);
24
+ throw error;
25
+ }
26
+ };
@@ -0,0 +1,33 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import { ISupplies } from "../../interfaces/Store";
3
+ import axiosInstance from "../axiosInstance";
4
+
5
+ const GET_SET_SUPPLY = (storeId: string) => `api/store/${storeId}/supply`;
6
+
7
+ export const updateSupplyById = async function (this: WashdayClientInstance, storeId: string, id: string, data: ISupplies): Promise<any> {
8
+ try {
9
+ const config = {
10
+ headers: { Authorization: `Bearer ${this.apiToken}` }
11
+ };
12
+ const response = await axiosInstance.put(`${GET_SET_SUPPLY(storeId)}/${id}`, data, config);
13
+ return response;
14
+ } catch (error) {
15
+ console.error('Error fetching getStoreById:', error);
16
+ throw error;
17
+ }
18
+ };
19
+
20
+ export const addSupplyStock = async function (this: WashdayClientInstance, storeId: string, id: string, data: {
21
+ newStock: number
22
+ }): Promise<any> {
23
+ try {
24
+ const config = {
25
+ headers: { Authorization: `Bearer ${this.apiToken}` }
26
+ };
27
+ const response = await axiosInstance.put(`${GET_SET_SUPPLY(storeId)}/${id}/addStock`, data, config);
28
+ return response;
29
+ } catch (error) {
30
+ console.error('Error fetching addSupplyStock:', error);
31
+ throw error;
32
+ }
33
+ };