washday-sdk 0.0.69 → 0.0.70
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/csv/get.js +41 -0
- package/dist/api/csv/index.js +27 -0
- package/dist/api/customers/delete.js +32 -0
- package/dist/api/customers/get.js +40 -7
- package/dist/api/customers/index.js +29 -0
- package/dist/api/customers/post.js +33 -0
- package/dist/api/customers/put.js +44 -0
- package/dist/api/index.js +31 -21
- package/dist/utils/apiUtils.js +13 -0
- package/package.json +1 -1
- package/src/api/csv/get.ts +34 -0
- package/src/api/csv/index.ts +1 -0
- package/src/api/customers/delete.ts +15 -0
- package/src/api/customers/get.ts +45 -7
- package/src/api/customers/index.ts +4 -0
- package/src/api/customers/post.ts +32 -0
- package/src/api/customers/put.ts +44 -0
- package/src/api/index.ts +14 -2
- package/src/utils/apiUtils.ts +11 -0
|
@@ -0,0 +1,41 @@
|
|
|
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.exportCustomersList = void 0;
|
|
16
|
+
const apiUtils_1 = require("../../utils/apiUtils");
|
|
17
|
+
const axiosInstance_1 = __importDefault(require("../axiosInstance"));
|
|
18
|
+
const GENERATE_EXPORT = 'api/export';
|
|
19
|
+
const exportCustomersList = function (params) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
try {
|
|
22
|
+
const config = {
|
|
23
|
+
headers: {
|
|
24
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
25
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
26
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
27
|
+
},
|
|
28
|
+
params: {
|
|
29
|
+
responseType: 'blob'
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const queryParams = (0, apiUtils_1.generateQueryParamsStr)(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum'], params);
|
|
33
|
+
return yield axiosInstance_1.default.get(`${GENERATE_EXPORT}/export-all-customers?${queryParams}`, config);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error('Error fetching exportCustomersList:', error);
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
exports.exportCustomersList = exportCustomersList;
|
|
@@ -0,0 +1,27 @@
|
|
|
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.getModule = void 0;
|
|
27
|
+
exports.getModule = __importStar(require("./get"));
|
|
@@ -0,0 +1,32 @@
|
|
|
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_CUSTOMERS = 'api/customer';
|
|
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_CUSTOMERS}/${id}`, config);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.error('Error fetching deleteById:', error);
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
exports.deleteById = deleteById;
|
|
@@ -12,17 +12,33 @@ 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.getCustomerHighlightsById = exports.getCustomerById = void 0;
|
|
15
|
+
exports.getCustomerOrders = exports.getCustomerHighlightsById = exports.getCustomerById = exports.getList = void 0;
|
|
16
|
+
const apiUtils_1 = require("../../utils/apiUtils");
|
|
16
17
|
const axiosInstance_1 = __importDefault(require("../axiosInstance"));
|
|
17
18
|
const GET_SET_CUSTOMERS = 'api/customer';
|
|
18
|
-
const
|
|
19
|
-
|
|
19
|
+
const getList = function (params) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
try {
|
|
22
|
+
const config = {
|
|
23
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
24
|
+
};
|
|
25
|
+
const queryParams = (0, apiUtils_1.generateQueryParamsStr)(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum'], params);
|
|
26
|
+
return yield axiosInstance_1.default.get(`${GET_SET_CUSTOMERS}?${queryParams}`, config);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
console.error('Error fetching getStoreStaff:', error);
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
20
33
|
};
|
|
34
|
+
exports.getList = getList;
|
|
21
35
|
const getCustomerById = function (customerId) {
|
|
22
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
37
|
try {
|
|
24
|
-
|
|
25
|
-
|
|
38
|
+
const config = {
|
|
39
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
40
|
+
};
|
|
41
|
+
const response = yield axiosInstance_1.default.get(`${GET_SET_CUSTOMERS}/${customerId}`, config);
|
|
26
42
|
return response.data;
|
|
27
43
|
}
|
|
28
44
|
catch (error) {
|
|
@@ -35,8 +51,10 @@ exports.getCustomerById = getCustomerById;
|
|
|
35
51
|
const getCustomerHighlightsById = function (customerId) {
|
|
36
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
53
|
try {
|
|
38
|
-
|
|
39
|
-
|
|
54
|
+
const config = {
|
|
55
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
56
|
+
};
|
|
57
|
+
const response = yield axiosInstance_1.default.get(`${GET_SET_CUSTOMERS}/${customerId}/highlights`, config);
|
|
40
58
|
return response.data;
|
|
41
59
|
}
|
|
42
60
|
catch (error) {
|
|
@@ -46,3 +64,18 @@ const getCustomerHighlightsById = function (customerId) {
|
|
|
46
64
|
});
|
|
47
65
|
};
|
|
48
66
|
exports.getCustomerHighlightsById = getCustomerHighlightsById;
|
|
67
|
+
const getCustomerOrders = function (customerId, params) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
try {
|
|
70
|
+
const config = {
|
|
71
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
72
|
+
};
|
|
73
|
+
return yield axiosInstance_1.default.get(`${GET_SET_CUSTOMERS}/${customerId}/orders`, config);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error('Error fetching getCustomerHighlightsById:', error);
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
exports.getCustomerOrders = getCustomerOrders;
|
|
@@ -1 +1,30 @@
|
|
|
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
|
+
};
|
|
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_CUSTOMERS = 'api/customer';
|
|
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_CUSTOMERS}`, 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,44 @@
|
|
|
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.updateById = void 0;
|
|
16
|
+
const axiosInstance_1 = __importDefault(require("../axiosInstance"));
|
|
17
|
+
const GET_SET_CUSTOMERS = 'api/customer';
|
|
18
|
+
// export const bulkUpdate = async function (this: WashdayClientInstance, storeId: string, data: any): Promise<any> {
|
|
19
|
+
// try {
|
|
20
|
+
// const config = {
|
|
21
|
+
// headers: { Authorization: `Bearer ${this.apiToken}`, 'Content-Type': false }
|
|
22
|
+
// };
|
|
23
|
+
// const response = await axiosInstance.put(`${GET_SET_PRODUCTS}/${storeId}/bulk`, data, config);
|
|
24
|
+
// return response.data || {}
|
|
25
|
+
// } catch (error) {
|
|
26
|
+
// console.error('Error fetching getStoreById:', error);
|
|
27
|
+
// throw error;
|
|
28
|
+
// }
|
|
29
|
+
// };
|
|
30
|
+
const updateById = function (id, data) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
try {
|
|
33
|
+
const config = {
|
|
34
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
35
|
+
};
|
|
36
|
+
return yield axiosInstance_1.default.put(`${GET_SET_CUSTOMERS}/${id}`, data, config);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.error('Error fetching updateById:', error);
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
exports.updateById = updateById;
|
package/dist/api/index.js
CHANGED
|
@@ -31,26 +31,27 @@ const get_2 = require("./companies/get");
|
|
|
31
31
|
const post_2 = require("./companies/post");
|
|
32
32
|
const put_2 = require("./companies/put");
|
|
33
33
|
const get_3 = require("./countries/get");
|
|
34
|
-
const get_4 = require("./
|
|
35
|
-
const get_5 = require("./discounts/get");
|
|
34
|
+
const get_4 = require("./discounts/get");
|
|
36
35
|
const post_3 = require("./discounts/post");
|
|
37
36
|
const put_3 = require("./discounts/put");
|
|
38
37
|
const delete_2 = require("./staff/delete");
|
|
39
|
-
const
|
|
38
|
+
const get_5 = require("./staff/get");
|
|
40
39
|
const post_4 = require("./staff/post");
|
|
41
40
|
const put_4 = require("./staff/put");
|
|
42
|
-
const
|
|
41
|
+
const get_6 = require("./stores/get");
|
|
43
42
|
const post_5 = require("./stores/post");
|
|
44
43
|
const put_5 = require("./stores/put");
|
|
45
44
|
const post_6 = require("./stripe/post");
|
|
46
45
|
const delete_3 = require("./supplies/delete");
|
|
47
|
-
const
|
|
46
|
+
const get_7 = require("./supplies/get");
|
|
48
47
|
const post_7 = require("./supplies/post");
|
|
49
48
|
const put_6 = require("./supplies/put");
|
|
50
49
|
const put_7 = require("./users/put");
|
|
51
50
|
const inventoryEndpoints = __importStar(require("./inventory"));
|
|
52
51
|
const sectionsEndpoints = __importStar(require("./sections"));
|
|
53
52
|
const productsEndpoints = __importStar(require("./products"));
|
|
53
|
+
const customersEndpoints = __importStar(require("./customers"));
|
|
54
|
+
const csvExportEndpoints = __importStar(require("./csv"));
|
|
54
55
|
const WashdayClient = function WashdayClient(apiToken) {
|
|
55
56
|
this.apiToken = apiToken;
|
|
56
57
|
WashdayClient.prototype.customers.apiToken = apiToken;
|
|
@@ -67,20 +68,26 @@ const WashdayClient = function WashdayClient(apiToken) {
|
|
|
67
68
|
WashdayClient.prototype.sections.apiToken = apiToken;
|
|
68
69
|
WashdayClient.prototype.supplies.apiToken = apiToken;
|
|
69
70
|
WashdayClient.prototype.inventory.apiToken = apiToken;
|
|
71
|
+
WashdayClient.prototype.csv.apiToken = apiToken;
|
|
70
72
|
};
|
|
71
73
|
WashdayClient.prototype.customers = {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
getCustomers: customersEndpoints.getModule.getList,
|
|
75
|
+
getCustomerById: customersEndpoints.getModule.getCustomerById,
|
|
76
|
+
getCustomerHighlightsById: customersEndpoints.getModule.getCustomerHighlightsById,
|
|
77
|
+
getCustomerOrders: customersEndpoints.getModule.getCustomerOrders,
|
|
78
|
+
create: customersEndpoints.postModule.create,
|
|
79
|
+
updateById: customersEndpoints.putModule.updateById,
|
|
80
|
+
deleteById: customersEndpoints.deleteModule.deleteById,
|
|
74
81
|
};
|
|
75
82
|
WashdayClient.prototype.stores = {
|
|
76
|
-
getStores:
|
|
77
|
-
getStoreById:
|
|
78
|
-
getStoreImages:
|
|
83
|
+
getStores: get_6.getStores,
|
|
84
|
+
getStoreById: get_6.getStoreById,
|
|
85
|
+
getStoreImages: get_6.getStoreImages,
|
|
79
86
|
createStore: post_5.createStore,
|
|
80
87
|
copyStore: post_5.copyStore,
|
|
81
88
|
updateStoreById: put_5.updateStoreById,
|
|
82
89
|
createStoreImage: post_5.createStoreImage,
|
|
83
|
-
getStoreReviewLink:
|
|
90
|
+
getStoreReviewLink: get_6.getStoreReviewLink,
|
|
84
91
|
deleteStoreById: put_5.deleteStoreById,
|
|
85
92
|
};
|
|
86
93
|
WashdayClient.prototype.products = {
|
|
@@ -99,9 +106,9 @@ WashdayClient.prototype.countries = {
|
|
|
99
106
|
getCountries: get_3.getCountries,
|
|
100
107
|
};
|
|
101
108
|
WashdayClient.prototype.supplies = {
|
|
102
|
-
getSupplies:
|
|
103
|
-
getSupplyById:
|
|
104
|
-
getSupplyHistory:
|
|
109
|
+
getSupplies: get_7.getSupplies,
|
|
110
|
+
getSupplyById: get_7.getSupplyById,
|
|
111
|
+
getSupplyHistory: get_7.getSupplyHistory,
|
|
105
112
|
createSupply: post_7.createSupply,
|
|
106
113
|
updateSupplyById: put_6.updateSupplyById,
|
|
107
114
|
addSupplyStock: put_6.addSupplyStock,
|
|
@@ -146,23 +153,26 @@ WashdayClient.prototype.stripe = {
|
|
|
146
153
|
createCustomerPortalSession: post_6.createCustomerPortalSession
|
|
147
154
|
};
|
|
148
155
|
WashdayClient.prototype.staff = {
|
|
149
|
-
getStoreStaff:
|
|
150
|
-
getStoreStaffById:
|
|
156
|
+
getStoreStaff: get_5.getStoreStaff,
|
|
157
|
+
getStoreStaffById: get_5.getStoreStaffById,
|
|
151
158
|
updateStoreStaffById: put_4.updateStoreStaffById,
|
|
152
159
|
createStoreStaff: post_4.createStoreStaff,
|
|
153
160
|
deleteStoreStaffById: delete_2.deleteStoreStaffById,
|
|
154
161
|
};
|
|
155
162
|
WashdayClient.prototype.discountCodes = {
|
|
156
|
-
getDiscountCodes:
|
|
157
|
-
getDiscountCodeById:
|
|
158
|
-
verifyDiscountCode:
|
|
163
|
+
getDiscountCodes: get_4.getDiscountCodes,
|
|
164
|
+
getDiscountCodeById: get_4.getDiscountCodeById,
|
|
165
|
+
verifyDiscountCode: get_4.verifyDiscountCode,
|
|
159
166
|
createDiscountCode: post_3.createDiscountCode,
|
|
160
167
|
deleteDiscountCodeById: put_3.deleteDiscountCodeById,
|
|
161
168
|
};
|
|
162
169
|
WashdayClient.prototype.automaticDiscount = {
|
|
163
|
-
getAutomaticDiscounts:
|
|
164
|
-
getAutomaticDiscountById:
|
|
170
|
+
getAutomaticDiscounts: get_4.getAutomaticDiscounts,
|
|
171
|
+
getAutomaticDiscountById: get_4.getAutomaticDiscountById,
|
|
165
172
|
createAutomaticDiscount: post_3.createAutomaticDiscount,
|
|
166
173
|
deleteAutomaticDiscountById: put_3.deleteAutomaticDiscountById,
|
|
167
174
|
};
|
|
175
|
+
WashdayClient.prototype.csv = {
|
|
176
|
+
exportCustomersList: csvExportEndpoints.getModule.exportCustomersList,
|
|
177
|
+
};
|
|
168
178
|
exports.default = WashdayClient;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateQueryParamsStr = void 0;
|
|
4
|
+
const generateQueryParamsStr = (availableQueryParamsList = [], receivedParamsObj = {}) => {
|
|
5
|
+
let queryParams = [];
|
|
6
|
+
for (let availableParam in availableQueryParamsList) {
|
|
7
|
+
if (receivedParamsObj.hasOwnProperty(availableParam)) {
|
|
8
|
+
queryParams.push(`${availableParam}=${receivedParamsObj[availableParam]}`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return queryParams.join('&');
|
|
12
|
+
};
|
|
13
|
+
exports.generateQueryParamsStr = generateQueryParamsStr;
|
package/package.json
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
3
|
+
import axiosInstance from "../axiosInstance";
|
|
4
|
+
|
|
5
|
+
const GENERATE_EXPORT = 'api/export';
|
|
6
|
+
|
|
7
|
+
export const exportCustomersList = async function (this: WashdayClientInstance, params: {
|
|
8
|
+
searchTerm?: string
|
|
9
|
+
name?: string
|
|
10
|
+
phone?: string
|
|
11
|
+
email?: string
|
|
12
|
+
fromDate?: string
|
|
13
|
+
toDate?: string
|
|
14
|
+
limit: string
|
|
15
|
+
pageNum: string
|
|
16
|
+
}): Promise<any> {
|
|
17
|
+
try {
|
|
18
|
+
const config = {
|
|
19
|
+
headers: {
|
|
20
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
21
|
+
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
22
|
+
'Content-disposition': 'attachment; filename=[file.csv]'
|
|
23
|
+
},
|
|
24
|
+
params: {
|
|
25
|
+
responseType: 'blob'
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const queryParams = generateQueryParamsStr(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum'], params)
|
|
29
|
+
return await axiosInstance.get(`${GENERATE_EXPORT}/export-all-customers?${queryParams}`, config);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error('Error fetching exportCustomersList:', error);
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as getModule from './get';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_SET_CUSTOMERS = 'api/customer';
|
|
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_CUSTOMERS}/${id}`, config);
|
|
11
|
+
} catch (error) {
|
|
12
|
+
console.error('Error fetching deleteById:', error);
|
|
13
|
+
throw error;
|
|
14
|
+
}
|
|
15
|
+
};
|
package/src/api/customers/get.ts
CHANGED
|
@@ -1,18 +1,39 @@
|
|
|
1
1
|
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
2
|
import { ICustomer } from "../../interfaces/Customer";
|
|
3
3
|
import { IOrderInfo } from "../../interfaces/Order";
|
|
4
|
+
import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
4
5
|
import axiosInstance from "../axiosInstance";
|
|
5
6
|
|
|
6
7
|
const GET_SET_CUSTOMERS = 'api/customer';
|
|
7
|
-
const REQUEST_PARAMS = {
|
|
8
|
-
token: 'LOGGED_USER_TOKEN',
|
|
9
|
-
};
|
|
10
8
|
|
|
9
|
+
export const getList = async function (this: WashdayClientInstance, params: {
|
|
10
|
+
searchTerm?: string
|
|
11
|
+
name?: string
|
|
12
|
+
phone?: string
|
|
13
|
+
email?: string
|
|
14
|
+
fromDate?: string
|
|
15
|
+
toDate?: string
|
|
16
|
+
limit: string
|
|
17
|
+
pageNum: string
|
|
18
|
+
}): Promise<any> {
|
|
19
|
+
try {
|
|
20
|
+
const config = {
|
|
21
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
22
|
+
};
|
|
23
|
+
const queryParams = generateQueryParamsStr(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum'], params)
|
|
24
|
+
return await axiosInstance.get(`${GET_SET_CUSTOMERS}?${queryParams}`, config);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error('Error fetching getStoreStaff:', error);
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
11
30
|
|
|
12
31
|
export const getCustomerById = async function (this: WashdayClientInstance, customerId: string): Promise<{ customer: ICustomer, orderInfo: IOrderInfo }> {
|
|
13
32
|
try {
|
|
14
|
-
|
|
15
|
-
|
|
33
|
+
const config = {
|
|
34
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
35
|
+
};
|
|
36
|
+
const response = await axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}`, config);
|
|
16
37
|
return response.data;
|
|
17
38
|
} catch (error) {
|
|
18
39
|
console.error('Error fetching customer:', error);
|
|
@@ -22,11 +43,28 @@ export const getCustomerById = async function (this: WashdayClientInstance, cust
|
|
|
22
43
|
|
|
23
44
|
export const getCustomerHighlightsById = async function (this: WashdayClientInstance, customerId: string): Promise<{ customer: ICustomer, orderInfo: IOrderInfo }> {
|
|
24
45
|
try {
|
|
25
|
-
|
|
26
|
-
|
|
46
|
+
const config = {
|
|
47
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
48
|
+
};
|
|
49
|
+
const response = await axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}/highlights`, config);
|
|
27
50
|
return response.data;
|
|
28
51
|
} catch (error) {
|
|
29
52
|
console.error('Error fetching getCustomerHighlightsById:', error);
|
|
30
53
|
throw error;
|
|
31
54
|
}
|
|
32
55
|
};
|
|
56
|
+
|
|
57
|
+
export const getCustomerOrders = async function (this: WashdayClientInstance, customerId: string, params: {
|
|
58
|
+
limit: string
|
|
59
|
+
pageNum: string
|
|
60
|
+
}): Promise<{ orders: any, totalRowsCount: any }> {
|
|
61
|
+
try {
|
|
62
|
+
const config = {
|
|
63
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
64
|
+
};
|
|
65
|
+
return await axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}/orders`, config);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error('Error fetching getCustomerHighlightsById:', error);
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_SET_CUSTOMERS = 'api/customer';
|
|
4
|
+
|
|
5
|
+
export const create = async function (this: WashdayClientInstance, data: {
|
|
6
|
+
name: string;
|
|
7
|
+
phone?: string;
|
|
8
|
+
email?: string;
|
|
9
|
+
address?: string;
|
|
10
|
+
notes?: string;
|
|
11
|
+
privateNotes?: string;
|
|
12
|
+
discount: number;
|
|
13
|
+
credit: number;
|
|
14
|
+
rfc?: string;
|
|
15
|
+
invoiceInfo?: {
|
|
16
|
+
legal_name?: string;
|
|
17
|
+
tax_system?: string;
|
|
18
|
+
zipCode?: string;
|
|
19
|
+
};
|
|
20
|
+
isActive: boolean;
|
|
21
|
+
}): Promise<any> {
|
|
22
|
+
try {
|
|
23
|
+
const config = {
|
|
24
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
25
|
+
};
|
|
26
|
+
const response = await axiosInstance.post(`${GET_SET_CUSTOMERS}`, data, config);
|
|
27
|
+
return response;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error('Error fetching create:', error);
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_SET_CUSTOMERS = 'api/customer';
|
|
4
|
+
|
|
5
|
+
// export const bulkUpdate = async function (this: WashdayClientInstance, storeId: string, data: any): Promise<any> {
|
|
6
|
+
// try {
|
|
7
|
+
// const config = {
|
|
8
|
+
// headers: { Authorization: `Bearer ${this.apiToken}`, 'Content-Type': false }
|
|
9
|
+
// };
|
|
10
|
+
// const response = await axiosInstance.put(`${GET_SET_PRODUCTS}/${storeId}/bulk`, data, config);
|
|
11
|
+
// return response.data || {}
|
|
12
|
+
// } catch (error) {
|
|
13
|
+
// console.error('Error fetching getStoreById:', error);
|
|
14
|
+
// throw error;
|
|
15
|
+
// }
|
|
16
|
+
// };
|
|
17
|
+
|
|
18
|
+
export const updateById = async function (this: WashdayClientInstance, id: string, data: {
|
|
19
|
+
name?: string;
|
|
20
|
+
phone?: string;
|
|
21
|
+
email?: string;
|
|
22
|
+
address?: string;
|
|
23
|
+
notes?: string;
|
|
24
|
+
privateNotes?: string;
|
|
25
|
+
discount?: number;
|
|
26
|
+
credit?: number;
|
|
27
|
+
rfc?: string;
|
|
28
|
+
invoiceInfo?: {
|
|
29
|
+
legal_name?: string;
|
|
30
|
+
tax_system?: string;
|
|
31
|
+
zipCode?: string;
|
|
32
|
+
};
|
|
33
|
+
isActive?: boolean;
|
|
34
|
+
}): Promise<any> {
|
|
35
|
+
try {
|
|
36
|
+
const config = {
|
|
37
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
38
|
+
};
|
|
39
|
+
return await axiosInstance.put(`${GET_SET_CUSTOMERS}/${id}`, data, config);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error('Error fetching updateById:', error);
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
};
|
package/src/api/index.ts
CHANGED
|
@@ -27,6 +27,8 @@ import { updateUserById } from "./users/put";
|
|
|
27
27
|
import * as inventoryEndpoints from './inventory';
|
|
28
28
|
import * as sectionsEndpoints from './sections';
|
|
29
29
|
import * as productsEndpoints from './products';
|
|
30
|
+
import * as customersEndpoints from './customers';
|
|
31
|
+
import * as csvExportEndpoints from './csv';
|
|
30
32
|
|
|
31
33
|
type WashdayClientConstructor = {
|
|
32
34
|
new(apiToken: string): {
|
|
@@ -50,11 +52,17 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
50
52
|
WashdayClient.prototype.sections.apiToken = apiToken;
|
|
51
53
|
WashdayClient.prototype.supplies.apiToken = apiToken;
|
|
52
54
|
WashdayClient.prototype.inventory.apiToken = apiToken;
|
|
55
|
+
WashdayClient.prototype.csv.apiToken = apiToken;
|
|
53
56
|
} as any;
|
|
54
57
|
|
|
55
58
|
WashdayClient.prototype.customers = {
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
getCustomers: customersEndpoints.getModule.getList,
|
|
60
|
+
getCustomerById: customersEndpoints.getModule.getCustomerById,
|
|
61
|
+
getCustomerHighlightsById: customersEndpoints.getModule.getCustomerHighlightsById,
|
|
62
|
+
getCustomerOrders: customersEndpoints.getModule.getCustomerOrders,
|
|
63
|
+
create: customersEndpoints.postModule.create,
|
|
64
|
+
updateById: customersEndpoints.putModule.updateById,
|
|
65
|
+
deleteById: customersEndpoints.deleteModule.deleteById,
|
|
58
66
|
};
|
|
59
67
|
|
|
60
68
|
WashdayClient.prototype.stores = {
|
|
@@ -165,6 +173,10 @@ WashdayClient.prototype.automaticDiscount = {
|
|
|
165
173
|
};
|
|
166
174
|
|
|
167
175
|
|
|
176
|
+
WashdayClient.prototype.csv = {
|
|
177
|
+
exportCustomersList: csvExportEndpoints.getModule.exportCustomersList,
|
|
178
|
+
};
|
|
179
|
+
|
|
168
180
|
|
|
169
181
|
|
|
170
182
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const generateQueryParamsStr = (availableQueryParamsList: Array<string> = [], receivedParamsObj: {
|
|
2
|
+
[key: string]: any
|
|
3
|
+
} = {}) => {
|
|
4
|
+
let queryParams = [];
|
|
5
|
+
for (let availableParam in availableQueryParamsList) {
|
|
6
|
+
if (receivedParamsObj.hasOwnProperty(availableParam)) {
|
|
7
|
+
queryParams.push(`${availableParam}=${receivedParamsObj[availableParam]}`)
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return queryParams.join('&');
|
|
11
|
+
}
|