washday-sdk 0.0.64 → 0.0.65
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 +34 -0
- package/dist/api/inventory/delete.js +33 -0
- package/dist/api/inventory/get.js +71 -0
- package/dist/api/inventory/index.js +30 -0
- package/dist/api/inventory/post.js +33 -0
- package/dist/api/inventory/put.js +49 -0
- package/package.json +1 -1
- package/src/api/index.ts +12 -1
- package/src/api/inventory/delete.ts +16 -0
- package/src/api/inventory/get.ts +53 -0
- package/src/api/inventory/index.ts +4 -0
- package/src/api/inventory/post.ts +22 -0
- package/src/api/inventory/put.ts +35 -0
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");
|
|
@@ -27,6 +50,7 @@ const get_9 = require("./supplies/get");
|
|
|
27
50
|
const post_7 = require("./supplies/post");
|
|
28
51
|
const put_7 = require("./supplies/put");
|
|
29
52
|
const put_8 = require("./users/put");
|
|
53
|
+
const inventoryEndpoints = __importStar(require("./inventory"));
|
|
30
54
|
const WashdayClient = function WashdayClient(apiToken) {
|
|
31
55
|
this.apiToken = apiToken;
|
|
32
56
|
WashdayClient.prototype.customers.apiToken = apiToken;
|
|
@@ -42,6 +66,7 @@ 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;
|
|
69
|
+
WashdayClient.prototype.inventory.apiToken = apiToken;
|
|
45
70
|
};
|
|
46
71
|
WashdayClient.prototype.sections = {
|
|
47
72
|
getSections: get_6.getSections,
|
|
@@ -78,6 +103,15 @@ WashdayClient.prototype.supplies = {
|
|
|
78
103
|
addSupplyStock: put_7.addSupplyStock,
|
|
79
104
|
deleteSupplyById: delete_3.deleteSupplyById,
|
|
80
105
|
};
|
|
106
|
+
WashdayClient.prototype.inventory = {
|
|
107
|
+
getInventory: inventoryEndpoints.getModule.getInventory,
|
|
108
|
+
getById: inventoryEndpoints.getModule.getInventoryById,
|
|
109
|
+
getHistoryById: inventoryEndpoints.getModule.getHistoryById,
|
|
110
|
+
create: inventoryEndpoints.postModule.create,
|
|
111
|
+
deleteById: inventoryEndpoints.deleteModule.deleteById,
|
|
112
|
+
updateById: inventoryEndpoints.putModule.updateById,
|
|
113
|
+
addStock: inventoryEndpoints.putModule.addStock,
|
|
114
|
+
};
|
|
81
115
|
WashdayClient.prototype.cashierboxes = {
|
|
82
116
|
getCashierboxesByStoreId: get_1.getCashierboxesByStoreId,
|
|
83
117
|
getCashierboxesById: get_1.getCashierboxesById,
|
|
@@ -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;
|
package/package.json
CHANGED
package/src/api/index.ts
CHANGED
|
@@ -8,7 +8,7 @@ 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
|
|
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";
|
|
@@ -26,6 +26,7 @@ import { getSupplies, getSupplyById, getSupplyHistory } from "./supplies/get";
|
|
|
26
26
|
import { createSupply } from "./supplies/post";
|
|
27
27
|
import { addSupplyStock, updateSupplyById } from "./supplies/put";
|
|
28
28
|
import { updateUserById } from "./users/put";
|
|
29
|
+
import * as inventoryEndpoints from './inventory';
|
|
29
30
|
|
|
30
31
|
type WashdayClientConstructor = {
|
|
31
32
|
new(apiToken: string): {
|
|
@@ -48,6 +49,7 @@ 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
55
|
WashdayClient.prototype.sections = {
|
|
@@ -93,6 +95,15 @@ WashdayClient.prototype.supplies = {
|
|
|
93
95
|
deleteSupplyById: deleteSupplyById,
|
|
94
96
|
};
|
|
95
97
|
|
|
98
|
+
WashdayClient.prototype.inventory = {
|
|
99
|
+
getInventory: inventoryEndpoints.getModule.getInventory,
|
|
100
|
+
getById: inventoryEndpoints.getModule.getInventoryById,
|
|
101
|
+
getHistoryById: inventoryEndpoints.getModule.getHistoryById,
|
|
102
|
+
create: inventoryEndpoints.postModule.create,
|
|
103
|
+
deleteById: inventoryEndpoints.deleteModule.deleteById,
|
|
104
|
+
updateById: inventoryEndpoints.putModule.updateById,
|
|
105
|
+
addStock: inventoryEndpoints.putModule.addStock,
|
|
106
|
+
};
|
|
96
107
|
|
|
97
108
|
WashdayClient.prototype.cashierboxes = {
|
|
98
109
|
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,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
|
+
};
|