washday-sdk 0.0.59 → 0.0.61
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/discounts/get.js +101 -0
- package/dist/api/discounts/post.js +48 -0
- package/dist/api/discounts/put.js +48 -0
- package/dist/api/index.js +49 -26
- package/dist/api/sections/delete.js +16 -0
- package/dist/api/sections/get.js +45 -0
- package/dist/api/sections/post.js +16 -0
- package/dist/api/sections/put.js +16 -0
- package/package.json +1 -1
- package/src/api/discounts/get.ts +73 -0
- package/src/api/discounts/post.ts +35 -0
- package/src/api/discounts/put.ts +30 -0
- package/src/api/index.ts +37 -0
- package/src/api/sections/delete.ts +16 -0
- package/src/api/sections/get.ts +33 -0
- package/src/api/sections/post.ts +17 -0
- package/src/api/sections/put.ts +16 -0
|
@@ -0,0 +1,101 @@
|
|
|
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.verifyDiscountCode = exports.getAutomaticDiscountById = exports.getDiscountCodeById = exports.getAutomaticDiscounts = exports.getDiscountCodes = void 0;
|
|
16
|
+
const axiosInstance_1 = __importDefault(require("../axiosInstance"));
|
|
17
|
+
const GET_SET_DISCOUNT_CODES = 'api/v2/discountCodes';
|
|
18
|
+
const GET_SET_AUTOMATIC_DISCOUNTS = 'api/discounts';
|
|
19
|
+
const getDiscountCodes = function (storeId, params) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
try {
|
|
22
|
+
let queryParams = '';
|
|
23
|
+
// if (params.isActive) {
|
|
24
|
+
// queryParams += `isActive=${params.isActive}`
|
|
25
|
+
// }
|
|
26
|
+
const config = {
|
|
27
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
28
|
+
};
|
|
29
|
+
return yield axiosInstance_1.default.get(`${GET_SET_DISCOUNT_CODES}/${storeId}?${queryParams}`, config);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error('Error fetching getStores:', error);
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
exports.getDiscountCodes = getDiscountCodes;
|
|
38
|
+
const getAutomaticDiscounts = function (storeId, params) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
try {
|
|
41
|
+
let queryParams = '';
|
|
42
|
+
// if (params.isActive) {
|
|
43
|
+
// queryParams += `isActive=${params.isActive}`
|
|
44
|
+
// }
|
|
45
|
+
const config = {
|
|
46
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
47
|
+
};
|
|
48
|
+
return yield axiosInstance_1.default.get(`${GET_SET_AUTOMATIC_DISCOUNTS}/${storeId}?${queryParams}`, config);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.error('Error fetching getStores:', error);
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
exports.getAutomaticDiscounts = getAutomaticDiscounts;
|
|
57
|
+
const getDiscountCodeById = function (storeId, discountId) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
try {
|
|
60
|
+
const config = {
|
|
61
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
62
|
+
};
|
|
63
|
+
return yield axiosInstance_1.default.get(`${GET_SET_DISCOUNT_CODES}/${storeId}/${discountId}`, config);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
console.error('Error fetching getDiscountCodeById:', error);
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
exports.getDiscountCodeById = getDiscountCodeById;
|
|
72
|
+
const getAutomaticDiscountById = function (storeId, discountId) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
try {
|
|
75
|
+
const config = {
|
|
76
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
77
|
+
};
|
|
78
|
+
return yield axiosInstance_1.default.get(`${GET_SET_AUTOMATIC_DISCOUNTS}/${storeId}/${discountId}`, config);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
console.error('Error fetching getDiscountCodeById:', error);
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
exports.getAutomaticDiscountById = getAutomaticDiscountById;
|
|
87
|
+
const verifyDiscountCode = function (storeId, code) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
try {
|
|
90
|
+
const config = {
|
|
91
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
92
|
+
};
|
|
93
|
+
return yield axiosInstance_1.default.get(`${GET_SET_DISCOUNT_CODES}/${storeId}/${code}/verify`, config);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
console.error('Error fetching getDiscountCodeById:', error);
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
exports.verifyDiscountCode = verifyDiscountCode;
|
|
@@ -0,0 +1,48 @@
|
|
|
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.createDiscountCode = exports.createAutomaticDiscount = void 0;
|
|
16
|
+
const axiosInstance_1 = __importDefault(require("../axiosInstance"));
|
|
17
|
+
const GET_SET_DISCOUNT_CODES = 'api/v2/discountCodes';
|
|
18
|
+
const GET_SET_AUTOMATIC_DISCOUNTS = 'api/discounts';
|
|
19
|
+
const createAutomaticDiscount = function (storeId, data) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
try {
|
|
22
|
+
const config = {
|
|
23
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
24
|
+
};
|
|
25
|
+
return yield axiosInstance_1.default.post(`${GET_SET_AUTOMATIC_DISCOUNTS}/${storeId}`, data, config);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
console.error('Error fetching createAutomaticDiscount:', error);
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.createAutomaticDiscount = createAutomaticDiscount;
|
|
34
|
+
const createDiscountCode = function (storeId, data) {
|
|
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.post(`${GET_SET_DISCOUNT_CODES}/${storeId}`, data, config);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.error('Error fetching createAutomaticDiscount:', error);
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
exports.createDiscountCode = createDiscountCode;
|
|
@@ -0,0 +1,48 @@
|
|
|
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.deleteAutomaticDiscountById = exports.deleteDiscountCodeById = void 0;
|
|
16
|
+
const axiosInstance_1 = __importDefault(require("../axiosInstance"));
|
|
17
|
+
const GET_SET_DISCOUNT_CODES = 'api/v2/discountCodes';
|
|
18
|
+
const GET_SET_AUTOMATIC_DISCOUNTS = 'api/discounts';
|
|
19
|
+
const deleteDiscountCodeById = function (storeId, discountId) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
try {
|
|
22
|
+
const config = {
|
|
23
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
24
|
+
};
|
|
25
|
+
return yield axiosInstance_1.default.delete(`${GET_SET_DISCOUNT_CODES}/${storeId}/${discountId}`, config);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
console.error('Error fetching deleteDiscountCodeById:', error);
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.deleteDiscountCodeById = deleteDiscountCodeById;
|
|
34
|
+
const deleteAutomaticDiscountById = function (storeId, discountId) {
|
|
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.delete(`${GET_SET_AUTOMATIC_DISCOUNTS}/${storeId}/${discountId}`, config);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.error('Error fetching deleteAutomaticDiscountById:', error);
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
exports.deleteAutomaticDiscountById = deleteAutomaticDiscountById;
|
package/dist/api/index.js
CHANGED
|
@@ -6,16 +6,20 @@ const post_1 = require("./companies/post");
|
|
|
6
6
|
const put_1 = require("./companies/put");
|
|
7
7
|
const get_3 = require("./countries/get");
|
|
8
8
|
const get_4 = require("./customers/get");
|
|
9
|
-
const
|
|
9
|
+
const get_5 = require("./discounts/get");
|
|
10
|
+
const post_2 = require("./discounts/post");
|
|
11
|
+
const put_2 = require("./discounts/put");
|
|
12
|
+
const put_3 = require("./products/put");
|
|
13
|
+
const get_6 = require("./sections/get");
|
|
10
14
|
const delete_1 = require("./staff/delete");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
15
|
+
const get_7 = require("./staff/get");
|
|
16
|
+
const post_3 = require("./staff/post");
|
|
17
|
+
const put_4 = require("./staff/put");
|
|
18
|
+
const get_8 = require("./stores/get");
|
|
19
|
+
const post_4 = require("./stores/post");
|
|
20
|
+
const put_5 = require("./stores/put");
|
|
21
|
+
const post_5 = require("./stripe/post");
|
|
22
|
+
const put_6 = require("./users/put");
|
|
19
23
|
const WashdayClient = function WashdayClient(apiToken) {
|
|
20
24
|
this.apiToken = apiToken;
|
|
21
25
|
WashdayClient.prototype.customers.apiToken = apiToken;
|
|
@@ -27,26 +31,32 @@ const WashdayClient = function WashdayClient(apiToken) {
|
|
|
27
31
|
WashdayClient.prototype.stripe.apiToken = apiToken;
|
|
28
32
|
WashdayClient.prototype.staff.apiToken = apiToken;
|
|
29
33
|
WashdayClient.prototype.cashierboxes.apiToken = apiToken;
|
|
34
|
+
WashdayClient.prototype.discountCodes.apiToken = apiToken;
|
|
35
|
+
WashdayClient.prototype.automaticDiscount.apiToken = apiToken;
|
|
36
|
+
WashdayClient.prototype.sections.apiToken = apiToken;
|
|
37
|
+
};
|
|
38
|
+
WashdayClient.prototype.sections = {
|
|
39
|
+
getSections: get_6.getSections,
|
|
30
40
|
};
|
|
31
41
|
WashdayClient.prototype.customers = {
|
|
32
42
|
getCustomerById: get_4.getCustomerById,
|
|
33
43
|
getCustomerHighlightsById: get_4.getCustomerHighlightsById
|
|
34
44
|
};
|
|
35
45
|
WashdayClient.prototype.stores = {
|
|
36
|
-
getStores:
|
|
37
|
-
getStoreById:
|
|
38
|
-
createStore:
|
|
39
|
-
copyStore:
|
|
40
|
-
updateStoreById:
|
|
41
|
-
createStoreImage:
|
|
42
|
-
getStoreReviewLink:
|
|
43
|
-
deleteStoreById:
|
|
46
|
+
getStores: get_8.getStores,
|
|
47
|
+
getStoreById: get_8.getStoreById,
|
|
48
|
+
createStore: post_4.createStore,
|
|
49
|
+
copyStore: post_4.copyStore,
|
|
50
|
+
updateStoreById: put_5.updateStoreById,
|
|
51
|
+
createStoreImage: post_4.createStoreImage,
|
|
52
|
+
getStoreReviewLink: get_8.getStoreReviewLink,
|
|
53
|
+
deleteStoreById: put_5.deleteStoreById,
|
|
44
54
|
};
|
|
45
55
|
WashdayClient.prototype.products = {
|
|
46
|
-
bulkUpdate:
|
|
56
|
+
bulkUpdate: put_3.bulkUpdate,
|
|
47
57
|
};
|
|
48
58
|
WashdayClient.prototype.users = {
|
|
49
|
-
updateUserById:
|
|
59
|
+
updateUserById: put_6.updateUserById,
|
|
50
60
|
};
|
|
51
61
|
WashdayClient.prototype.countries = {
|
|
52
62
|
getCountries: get_3.getCountries,
|
|
@@ -63,15 +73,28 @@ WashdayClient.prototype.companies = {
|
|
|
63
73
|
updateCFDIOrgLogo: post_1.updateCFDIOrgLogo
|
|
64
74
|
};
|
|
65
75
|
WashdayClient.prototype.stripe = {
|
|
66
|
-
createCreateSuscriptionCheckoutSession:
|
|
67
|
-
createCFDISuscrptionCheckoutSession:
|
|
68
|
-
createCustomerPortalSession:
|
|
76
|
+
createCreateSuscriptionCheckoutSession: post_5.createCreateSuscriptionCheckoutSession,
|
|
77
|
+
createCFDISuscrptionCheckoutSession: post_5.createCFDISuscrptionCheckoutSession,
|
|
78
|
+
createCustomerPortalSession: post_5.createCustomerPortalSession
|
|
69
79
|
};
|
|
70
80
|
WashdayClient.prototype.staff = {
|
|
71
|
-
getStoreStaff:
|
|
72
|
-
getStoreStaffById:
|
|
73
|
-
updateStoreStaffById:
|
|
74
|
-
createStoreStaff:
|
|
81
|
+
getStoreStaff: get_7.getStoreStaff,
|
|
82
|
+
getStoreStaffById: get_7.getStoreStaffById,
|
|
83
|
+
updateStoreStaffById: put_4.updateStoreStaffById,
|
|
84
|
+
createStoreStaff: post_3.createStoreStaff,
|
|
75
85
|
deleteStoreStaffById: delete_1.deleteStoreStaffById,
|
|
76
86
|
};
|
|
87
|
+
WashdayClient.prototype.discountCodes = {
|
|
88
|
+
getDiscountCodes: get_5.getDiscountCodes,
|
|
89
|
+
getDiscountCodeById: get_5.getDiscountCodeById,
|
|
90
|
+
verifyDiscountCode: get_5.verifyDiscountCode,
|
|
91
|
+
createDiscountCode: post_2.createDiscountCode,
|
|
92
|
+
deleteDiscountCodeById: put_2.deleteDiscountCodeById,
|
|
93
|
+
};
|
|
94
|
+
WashdayClient.prototype.automaticDiscount = {
|
|
95
|
+
getAutomaticDiscounts: get_5.getAutomaticDiscounts,
|
|
96
|
+
getAutomaticDiscountById: get_5.getAutomaticDiscountById,
|
|
97
|
+
createAutomaticDiscount: post_2.createAutomaticDiscount,
|
|
98
|
+
deleteAutomaticDiscountById: put_2.deleteAutomaticDiscountById,
|
|
99
|
+
};
|
|
77
100
|
exports.default = WashdayClient;
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
// };
|
|
@@ -0,0 +1,45 @@
|
|
|
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.getSections = void 0;
|
|
16
|
+
const axiosInstance_1 = __importDefault(require("../axiosInstance"));
|
|
17
|
+
const GET_SET_SECTIONS = 'api/section';
|
|
18
|
+
const getSections = function (params) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
try {
|
|
21
|
+
const config = {
|
|
22
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
23
|
+
};
|
|
24
|
+
let queryParams = '';
|
|
25
|
+
if (params === null || params === void 0 ? void 0 : params.hasOwnProperty('storeId')) {
|
|
26
|
+
queryParams += `store=${params === null || params === void 0 ? void 0 : params.storeId}`;
|
|
27
|
+
}
|
|
28
|
+
if (params === null || params === void 0 ? void 0 : params.hasOwnProperty('isActive')) {
|
|
29
|
+
queryParams += `&isActive=${params === null || params === void 0 ? void 0 : params.isActive}`;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
queryParams += `&isActive=true`;
|
|
33
|
+
}
|
|
34
|
+
if (params === null || params === void 0 ? void 0 : params.hasOwnProperty('products')) {
|
|
35
|
+
queryParams += `&products=${params === null || params === void 0 ? void 0 : params.products}`;
|
|
36
|
+
}
|
|
37
|
+
return yield axiosInstance_1.default.get(`${GET_SET_SECTIONS}?${queryParams}`, config);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
console.error('Error fetching getStoreStaff:', error);
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
exports.getSections = getSections;
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
// };
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
// };
|
package/package.json
CHANGED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
|
|
4
|
+
const GET_SET_DISCOUNT_CODES = 'api/v2/discountCodes';
|
|
5
|
+
const GET_SET_AUTOMATIC_DISCOUNTS = 'api/discounts';
|
|
6
|
+
|
|
7
|
+
export const getDiscountCodes = async function (this: WashdayClientInstance, storeId: string, params?: string): Promise<any> {
|
|
8
|
+
try {
|
|
9
|
+
let queryParams = '';
|
|
10
|
+
// if (params.isActive) {
|
|
11
|
+
// queryParams += `isActive=${params.isActive}`
|
|
12
|
+
// }
|
|
13
|
+
const config = {
|
|
14
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
15
|
+
};
|
|
16
|
+
return await axiosInstance.get(`${GET_SET_DISCOUNT_CODES}/${storeId}?${queryParams}`, config);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error('Error fetching getStores:', error);
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const getAutomaticDiscounts = async function (this: WashdayClientInstance, storeId: string, params?: string): Promise<any> {
|
|
24
|
+
try {
|
|
25
|
+
let queryParams = '';
|
|
26
|
+
// if (params.isActive) {
|
|
27
|
+
// queryParams += `isActive=${params.isActive}`
|
|
28
|
+
// }
|
|
29
|
+
const config = {
|
|
30
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
31
|
+
};
|
|
32
|
+
return await axiosInstance.get(`${GET_SET_AUTOMATIC_DISCOUNTS}/${storeId}?${queryParams}`, config);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
console.error('Error fetching getStores:', error);
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const getDiscountCodeById = async function (this: WashdayClientInstance, storeId: string, discountId: string,): Promise<any> {
|
|
40
|
+
try {
|
|
41
|
+
const config = {
|
|
42
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
43
|
+
};
|
|
44
|
+
return await axiosInstance.get(`${GET_SET_DISCOUNT_CODES}/${storeId}/${discountId}`, config);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error('Error fetching getDiscountCodeById:', error);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const getAutomaticDiscountById = async function (this: WashdayClientInstance, storeId: string, discountId: string,): Promise<any> {
|
|
52
|
+
try {
|
|
53
|
+
const config = {
|
|
54
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
55
|
+
};
|
|
56
|
+
return await axiosInstance.get(`${GET_SET_AUTOMATIC_DISCOUNTS}/${storeId}/${discountId}`, config);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error('Error fetching getDiscountCodeById:', error);
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const verifyDiscountCode = async function (this: WashdayClientInstance, storeId: string, code: string,): Promise<any> {
|
|
64
|
+
try {
|
|
65
|
+
const config = {
|
|
66
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
67
|
+
};
|
|
68
|
+
return await axiosInstance.get(`${GET_SET_DISCOUNT_CODES}/${storeId}/${code}/verify`, config);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error('Error fetching getDiscountCodeById:', error);
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { IStore } from "../../interfaces/Store";
|
|
3
|
+
import axiosInstance from "../axiosInstance";
|
|
4
|
+
|
|
5
|
+
const GET_SET_DISCOUNT_CODES = 'api/v2/discountCodes';
|
|
6
|
+
const GET_SET_AUTOMATIC_DISCOUNTS = 'api/discounts';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export const createAutomaticDiscount = async function (this: WashdayClientInstance, storeId: string, data: any): Promise<any> {
|
|
10
|
+
try {
|
|
11
|
+
const config = {
|
|
12
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
13
|
+
};
|
|
14
|
+
return await axiosInstance.post(`${GET_SET_AUTOMATIC_DISCOUNTS}/${storeId}`, data, config);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error('Error fetching createAutomaticDiscount:', error);
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export const createDiscountCode = async function (this: WashdayClientInstance, storeId: string, data: any): Promise<any> {
|
|
23
|
+
try {
|
|
24
|
+
const config = {
|
|
25
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
26
|
+
};
|
|
27
|
+
return await axiosInstance.post(`${GET_SET_DISCOUNT_CODES}/${storeId}`, data, config);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error('Error fetching createAutomaticDiscount:', error);
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { IStore } from "../../interfaces/Store";
|
|
3
|
+
import axiosInstance from "../axiosInstance";
|
|
4
|
+
|
|
5
|
+
const GET_SET_DISCOUNT_CODES = 'api/v2/discountCodes';
|
|
6
|
+
const GET_SET_AUTOMATIC_DISCOUNTS = 'api/discounts';
|
|
7
|
+
|
|
8
|
+
export const deleteDiscountCodeById = async function (this: WashdayClientInstance, storeId: string, discountId: string): Promise<any> {
|
|
9
|
+
try {
|
|
10
|
+
const config = {
|
|
11
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
12
|
+
};
|
|
13
|
+
return await axiosInstance.delete(`${GET_SET_DISCOUNT_CODES}/${storeId}/${discountId}`, config);
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.error('Error fetching deleteDiscountCodeById:', error);
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const deleteAutomaticDiscountById = async function (this: WashdayClientInstance, storeId: string, discountId: string): Promise<any> {
|
|
21
|
+
try {
|
|
22
|
+
const config = {
|
|
23
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
24
|
+
};
|
|
25
|
+
return await axiosInstance.delete(`${GET_SET_AUTOMATIC_DISCOUNTS}/${storeId}/${discountId}`, config);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error('Error fetching deleteAutomaticDiscountById:', error);
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
};
|
package/src/api/index.ts
CHANGED
|
@@ -5,7 +5,11 @@ import { updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "./companies
|
|
|
5
5
|
import { updateCompanyById, updateCompanyLogoById, updateCompanyTaxInfoById } from "./companies/put";
|
|
6
6
|
import { getCountries } from "./countries/get";
|
|
7
7
|
import { getCustomerById, getCustomerHighlightsById } from "./customers/get";
|
|
8
|
+
import { getAutomaticDiscountById, getAutomaticDiscounts, getDiscountCodeById, getDiscountCodes, verifyDiscountCode } from "./discounts/get";
|
|
9
|
+
import { createAutomaticDiscount, createDiscountCode } from "./discounts/post";
|
|
10
|
+
import { deleteAutomaticDiscountById, deleteDiscountCodeById } from "./discounts/put";
|
|
8
11
|
import { bulkUpdate } from "./products/put";
|
|
12
|
+
import { getSections } from "./sections/get";
|
|
9
13
|
import { deleteStoreStaffById } from "./staff/delete";
|
|
10
14
|
import { getStoreStaff, getStoreStaffById } from "./staff/get";
|
|
11
15
|
import { createStoreStaff } from "./staff/post";
|
|
@@ -33,8 +37,15 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
33
37
|
WashdayClient.prototype.stripe.apiToken = apiToken;
|
|
34
38
|
WashdayClient.prototype.staff.apiToken = apiToken;
|
|
35
39
|
WashdayClient.prototype.cashierboxes.apiToken = apiToken;
|
|
40
|
+
WashdayClient.prototype.discountCodes.apiToken = apiToken;
|
|
41
|
+
WashdayClient.prototype.automaticDiscount.apiToken = apiToken;
|
|
42
|
+
WashdayClient.prototype.sections.apiToken = apiToken;
|
|
36
43
|
} as any;
|
|
37
44
|
|
|
45
|
+
WashdayClient.prototype.sections = {
|
|
46
|
+
getSections: getSections,
|
|
47
|
+
};
|
|
48
|
+
|
|
38
49
|
WashdayClient.prototype.customers = {
|
|
39
50
|
getCustomerById: getCustomerById,
|
|
40
51
|
getCustomerHighlightsById: getCustomerHighlightsById
|
|
@@ -91,4 +102,30 @@ WashdayClient.prototype.staff = {
|
|
|
91
102
|
deleteStoreStaffById: deleteStoreStaffById,
|
|
92
103
|
};
|
|
93
104
|
|
|
105
|
+
WashdayClient.prototype.discountCodes = {
|
|
106
|
+
getDiscountCodes: getDiscountCodes,
|
|
107
|
+
getDiscountCodeById: getDiscountCodeById,
|
|
108
|
+
verifyDiscountCode: verifyDiscountCode,
|
|
109
|
+
createDiscountCode: createDiscountCode,
|
|
110
|
+
deleteDiscountCodeById: deleteDiscountCodeById,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
WashdayClient.prototype.automaticDiscount = {
|
|
114
|
+
getAutomaticDiscounts: getAutomaticDiscounts,
|
|
115
|
+
getAutomaticDiscountById: getAutomaticDiscountById,
|
|
116
|
+
createAutomaticDiscount: createAutomaticDiscount,
|
|
117
|
+
deleteAutomaticDiscountById: deleteAutomaticDiscountById,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
94
131
|
export default WashdayClient;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
// import axiosInstance from "../axiosInstance";
|
|
3
|
+
// const GET_SET_STAFF = (storeId: string) => `api/store/${storeId}/staff`;
|
|
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
|
+
// };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
|
|
4
|
+
const GET_SET_SECTIONS = 'api/section';
|
|
5
|
+
|
|
6
|
+
export const getSections = async function (this: WashdayClientInstance, params?: {
|
|
7
|
+
storeId?: string
|
|
8
|
+
isActive?: string
|
|
9
|
+
products?: boolean
|
|
10
|
+
}): Promise<any> {
|
|
11
|
+
try {
|
|
12
|
+
const config = {
|
|
13
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
14
|
+
};
|
|
15
|
+
let queryParams = '';
|
|
16
|
+
if (params?.hasOwnProperty('storeId')) {
|
|
17
|
+
queryParams += `store=${params?.storeId}`
|
|
18
|
+
}
|
|
19
|
+
if (params?.hasOwnProperty('isActive')) {
|
|
20
|
+
queryParams += `&isActive=${params?.isActive}`
|
|
21
|
+
} else {
|
|
22
|
+
queryParams += `&isActive=true`
|
|
23
|
+
}
|
|
24
|
+
if (params?.hasOwnProperty('products')) {
|
|
25
|
+
queryParams += `&products=${params?.products}`
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return await axiosInstance.get(`${GET_SET_SECTIONS}?${queryParams}`, config);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error('Error fetching getStoreStaff:', error);
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
// import axiosInstance from "../axiosInstance";
|
|
3
|
+
|
|
4
|
+
// const GET_SET_STAFF = (storeId: string) => `api/store/${storeId}/staff`;
|
|
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
|
+
// };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
// import { IStore } from "../../interfaces/Store";
|
|
3
|
+
// import axiosInstance from "../axiosInstance";
|
|
4
|
+
|
|
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
|
+
// };
|