washday-sdk 0.0.74 → 0.0.76
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 +45 -32
- package/dist/api/reviews/delete.js +15 -0
- package/dist/api/reviews/get.js +25 -0
- package/dist/api/reviews/index.js +4 -0
- package/dist/api/reviews/post.js +20 -0
- package/dist/api/reviews/put.js +52 -0
- package/package.json +1 -1
- package/src/api/index.ts +45 -32
- package/src/api/reviews/delete.ts +15 -0
- package/src/api/reviews/get.ts +17 -0
- package/src/api/reviews/index.ts +4 -0
- package/src/api/reviews/post.ts +20 -0
- package/src/api/reviews/put.ts +53 -0
- package/src/interfaces/Api.ts +4 -0
package/dist/api/index.js
CHANGED
|
@@ -28,17 +28,30 @@ import * as productsEndpoints from './products';
|
|
|
28
28
|
import * as customersEndpoints from './customers';
|
|
29
29
|
import * as csvExportEndpoints from './csv';
|
|
30
30
|
import * as ordersEndpoints from './order';
|
|
31
|
+
import * as reviewsEndpoints from './reviews';
|
|
32
|
+
function bindMethods(instance, methods) {
|
|
33
|
+
const boundMethods = {};
|
|
34
|
+
for (const key in methods) {
|
|
35
|
+
if (methods.hasOwnProperty(key) && typeof methods[key] === 'function') {
|
|
36
|
+
boundMethods[key] = methods[key].bind(instance);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return boundMethods;
|
|
40
|
+
}
|
|
31
41
|
const WashdayClient = function WashdayClient(apiToken) {
|
|
32
42
|
this.apiToken = apiToken;
|
|
33
|
-
this.
|
|
43
|
+
this.review = bindMethods(this, {
|
|
44
|
+
requestStoreReviewByCustomerId: reviewsEndpoints.getModule.requestStoreReviewByCustomerId,
|
|
45
|
+
});
|
|
46
|
+
this.orders = bindMethods(this, {
|
|
34
47
|
getList: ordersEndpoints.getModule.getList,
|
|
35
48
|
getById: ordersEndpoints.getModule.getById,
|
|
36
49
|
updateById: ordersEndpoints.putModule.updateById,
|
|
37
50
|
updatePaymentLineById: ordersEndpoints.putModule.updatePaymentLineById,
|
|
38
51
|
createPaymentLine: ordersEndpoints.postModule.createPaymentLine,
|
|
39
52
|
deletePaymentLineById: ordersEndpoints.deleteModule.deletePaymentLineById,
|
|
40
|
-
};
|
|
41
|
-
this.customers = {
|
|
53
|
+
});
|
|
54
|
+
this.customers = bindMethods(this, {
|
|
42
55
|
getCustomers: customersEndpoints.getModule.getList,
|
|
43
56
|
getCustomerById: customersEndpoints.getModule.getCustomerById,
|
|
44
57
|
getCustomerHighlightsById: customersEndpoints.getModule.getCustomerHighlightsById,
|
|
@@ -46,8 +59,8 @@ const WashdayClient = function WashdayClient(apiToken) {
|
|
|
46
59
|
create: customersEndpoints.postModule.create,
|
|
47
60
|
updateById: customersEndpoints.putModule.updateById,
|
|
48
61
|
deleteById: customersEndpoints.deleteModule.deleteById,
|
|
49
|
-
};
|
|
50
|
-
this.stores = {
|
|
62
|
+
});
|
|
63
|
+
this.stores = bindMethods(this, {
|
|
51
64
|
getStores: getStores,
|
|
52
65
|
getStoreById: getStoreById,
|
|
53
66
|
getStoreImages: getStoreImages,
|
|
@@ -57,8 +70,8 @@ const WashdayClient = function WashdayClient(apiToken) {
|
|
|
57
70
|
createStoreImage: createStoreImage,
|
|
58
71
|
getStoreReviewLink: getStoreReviewLink,
|
|
59
72
|
deleteStoreById: deleteStoreById,
|
|
60
|
-
};
|
|
61
|
-
this.products = {
|
|
73
|
+
});
|
|
74
|
+
this.products = bindMethods(this, {
|
|
62
75
|
getById: productsEndpoints.getModule.getById,
|
|
63
76
|
create: productsEndpoints.postModule.create,
|
|
64
77
|
createProductSupply: productsEndpoints.postModule.createProductSupply,
|
|
@@ -66,14 +79,14 @@ const WashdayClient = function WashdayClient(apiToken) {
|
|
|
66
79
|
deleteProductSupplyById: productsEndpoints.deleteModule.deleteProductSupplyById,
|
|
67
80
|
updateById: productsEndpoints.putModule.updateById,
|
|
68
81
|
bulkUpdate: productsEndpoints.putModule.bulkUpdate
|
|
69
|
-
};
|
|
70
|
-
this.users = {
|
|
82
|
+
});
|
|
83
|
+
this.users = bindMethods(this, {
|
|
71
84
|
updateUserById: updateUserById,
|
|
72
|
-
};
|
|
73
|
-
this.countries = {
|
|
85
|
+
});
|
|
86
|
+
this.countries = bindMethods(this, {
|
|
74
87
|
getCountries: getCountries,
|
|
75
|
-
};
|
|
76
|
-
this.supplies = {
|
|
88
|
+
});
|
|
89
|
+
this.supplies = bindMethods(this, {
|
|
77
90
|
getSupplies: getSupplies,
|
|
78
91
|
getSupplyById: getSupplyById,
|
|
79
92
|
getSupplyHistory: getSupplyHistory,
|
|
@@ -81,15 +94,15 @@ const WashdayClient = function WashdayClient(apiToken) {
|
|
|
81
94
|
updateSupplyById: updateSupplyById,
|
|
82
95
|
addSupplyStock: addSupplyStock,
|
|
83
96
|
deleteSupplyById: deleteSupplyById,
|
|
84
|
-
};
|
|
85
|
-
this.sections = {
|
|
97
|
+
});
|
|
98
|
+
this.sections = bindMethods(this, {
|
|
86
99
|
getSections: sectionsEndpoints.getModule.getList,
|
|
87
100
|
getById: sectionsEndpoints.getModule.getById,
|
|
88
101
|
create: sectionsEndpoints.postModule.create,
|
|
89
102
|
deleteById: sectionsEndpoints.deleteModule.deleteById,
|
|
90
103
|
updateById: sectionsEndpoints.putModule.updateById,
|
|
91
|
-
};
|
|
92
|
-
this.inventory = {
|
|
104
|
+
});
|
|
105
|
+
this.inventory = bindMethods(this, {
|
|
93
106
|
getInventory: inventoryEndpoints.getModule.getInventory,
|
|
94
107
|
getById: inventoryEndpoints.getModule.getInventoryById,
|
|
95
108
|
getHistoryById: inventoryEndpoints.getModule.getHistoryById,
|
|
@@ -97,8 +110,8 @@ const WashdayClient = function WashdayClient(apiToken) {
|
|
|
97
110
|
deleteById: inventoryEndpoints.deleteModule.deleteById,
|
|
98
111
|
updateById: inventoryEndpoints.putModule.updateById,
|
|
99
112
|
addStock: inventoryEndpoints.putModule.addStock,
|
|
100
|
-
};
|
|
101
|
-
this.cashierboxes = {
|
|
113
|
+
});
|
|
114
|
+
this.cashierboxes = bindMethods(this, {
|
|
102
115
|
getCashierboxesByStoreId: getCashierboxesByStoreId,
|
|
103
116
|
getCashierboxesById: getCashierboxesById,
|
|
104
117
|
getCashierBoxMovementsHistory: getCashierBoxMovementsHistory,
|
|
@@ -106,42 +119,42 @@ const WashdayClient = function WashdayClient(apiToken) {
|
|
|
106
119
|
updateCashierBoxById: updateCashierBoxById,
|
|
107
120
|
deleteCashierBoxById: deleteCashierBoxById,
|
|
108
121
|
addCashierBoxMovement: addCashierBoxMovement,
|
|
109
|
-
};
|
|
110
|
-
this.companies = {
|
|
122
|
+
});
|
|
123
|
+
this.companies = bindMethods(this, {
|
|
111
124
|
getCompanyById: getCompanyById,
|
|
112
125
|
updateCompanyById: updateCompanyById,
|
|
113
126
|
updateCompanyLogoById: updateCompanyLogoById,
|
|
114
127
|
updateCompanyTaxInfoById: updateCompanyTaxInfoById,
|
|
115
128
|
updateCompanyTaxInfoCertificates: updateCompanyTaxInfoCertificates,
|
|
116
129
|
updateCFDIOrgLogo: updateCFDIOrgLogo
|
|
117
|
-
};
|
|
118
|
-
this.stripe = {
|
|
130
|
+
});
|
|
131
|
+
this.stripe = bindMethods(this, {
|
|
119
132
|
createCreateSuscriptionCheckoutSession: createCreateSuscriptionCheckoutSession,
|
|
120
133
|
createCFDISuscrptionCheckoutSession: createCFDISuscrptionCheckoutSession,
|
|
121
134
|
createCustomerPortalSession: createCustomerPortalSession
|
|
122
|
-
};
|
|
123
|
-
this.staff = {
|
|
135
|
+
});
|
|
136
|
+
this.staff = bindMethods(this, {
|
|
124
137
|
getStoreStaff: getStoreStaff,
|
|
125
138
|
getStoreStaffById: getStoreStaffById,
|
|
126
139
|
updateStoreStaffById: updateStoreStaffById,
|
|
127
140
|
createStoreStaff: createStoreStaff,
|
|
128
141
|
deleteStoreStaffById: deleteStoreStaffById,
|
|
129
|
-
};
|
|
130
|
-
this.discountCodes = {
|
|
142
|
+
});
|
|
143
|
+
this.discountCodes = bindMethods(this, {
|
|
131
144
|
getDiscountCodes: getDiscountCodes,
|
|
132
145
|
getDiscountCodeById: getDiscountCodeById,
|
|
133
146
|
verifyDiscountCode: verifyDiscountCode,
|
|
134
147
|
createDiscountCode: createDiscountCode,
|
|
135
148
|
deleteDiscountCodeById: deleteDiscountCodeById,
|
|
136
|
-
};
|
|
137
|
-
this.automaticDiscount = {
|
|
149
|
+
});
|
|
150
|
+
this.automaticDiscount = bindMethods(this, {
|
|
138
151
|
getAutomaticDiscounts: getAutomaticDiscounts,
|
|
139
152
|
getAutomaticDiscountById: getAutomaticDiscountById,
|
|
140
153
|
createAutomaticDiscount: createAutomaticDiscount,
|
|
141
154
|
deleteAutomaticDiscountById: deleteAutomaticDiscountById,
|
|
142
|
-
};
|
|
143
|
-
this.csv = {
|
|
155
|
+
});
|
|
156
|
+
this.csv = bindMethods(this, {
|
|
144
157
|
exportCustomersList: csvExportEndpoints.getModule.exportCustomersList,
|
|
145
|
-
};
|
|
158
|
+
});
|
|
146
159
|
};
|
|
147
160
|
export default WashdayClient;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import { WashdayClientInstance } from "../../interfaces/Api";
|
|
3
|
+
// import axiosInstance from "../axiosInstance";
|
|
4
|
+
// const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
|
|
5
|
+
// export const deletePaymentLineById = async function (this: WashdayClientInstance, orderId: string, id: string): Promise<any> {
|
|
6
|
+
// try {
|
|
7
|
+
// const config = {
|
|
8
|
+
// headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
9
|
+
// };
|
|
10
|
+
// return await axiosInstance.delete(`${GET_SET_ORDER_PAYMENTLINES(orderId)}/${id}`, config);
|
|
11
|
+
// } catch (error) {
|
|
12
|
+
// console.error('Error fetching deleteById:', error);
|
|
13
|
+
// throw error;
|
|
14
|
+
// }
|
|
15
|
+
// };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import axiosInstance from "../axiosInstance";
|
|
11
|
+
const GET_SET_REVIEWS = 'api/review';
|
|
12
|
+
export const requestStoreReviewByCustomerId = function (storeId, customerId) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
try {
|
|
15
|
+
const config = {
|
|
16
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
17
|
+
};
|
|
18
|
+
return yield axiosInstance.get(`${GET_SET_REVIEWS}/${storeId}/${customerId}`, config);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.error('Error fetching:', error);
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import { WashdayClientInstance } from "../../interfaces/Api";
|
|
3
|
+
// import axiosInstance from "../axiosInstance";
|
|
4
|
+
// const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
|
|
5
|
+
// export const createPaymentLine = async function (this: WashdayClientInstance, id: string, data: {
|
|
6
|
+
// amountPaid: number,
|
|
7
|
+
// cashierBox: string,
|
|
8
|
+
// paymentMethod: string
|
|
9
|
+
// paymentDate: Date
|
|
10
|
+
// }): Promise<any> {
|
|
11
|
+
// try {
|
|
12
|
+
// const config = {
|
|
13
|
+
// headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
14
|
+
// };
|
|
15
|
+
// return await axiosInstance.post(`${GET_SET_ORDER_PAYMENTLINES(id)}`, data, config);
|
|
16
|
+
// } catch (error) {
|
|
17
|
+
// console.error('Error fetching create:', error);
|
|
18
|
+
// throw error;
|
|
19
|
+
// }
|
|
20
|
+
// };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import { WashdayClientInstance } from "../../interfaces/Api";
|
|
3
|
+
// import axiosInstance from "../axiosInstance";
|
|
4
|
+
// const GET_SET_ORDER = 'api/v2/order';
|
|
5
|
+
// const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
|
|
6
|
+
// export const updateById = async function (this: WashdayClientInstance, id: string, data: {
|
|
7
|
+
// status?: string,
|
|
8
|
+
// products?: any[],
|
|
9
|
+
// buyAndGetProducts?: any[],
|
|
10
|
+
// customer?: string,
|
|
11
|
+
// discountCode?: string | null,
|
|
12
|
+
// notes?: string,
|
|
13
|
+
// privateNotes?: string,
|
|
14
|
+
// delivery?: boolean,
|
|
15
|
+
// pickup?: boolean,
|
|
16
|
+
// express?: boolean,
|
|
17
|
+
// deliveryInfo?: {
|
|
18
|
+
// date: Date,
|
|
19
|
+
// fromTime: string,
|
|
20
|
+
// toTime?: string
|
|
21
|
+
// },
|
|
22
|
+
// pickupInfo?: {
|
|
23
|
+
// date: Date,
|
|
24
|
+
// fromTime: string,
|
|
25
|
+
// toTime?: string
|
|
26
|
+
// },
|
|
27
|
+
// notifyBy?: string,
|
|
28
|
+
// }): Promise<any> {
|
|
29
|
+
// try {
|
|
30
|
+
// const config = {
|
|
31
|
+
// headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
32
|
+
// };
|
|
33
|
+
// return await axiosInstance.put(`${GET_SET_ORDER}/${id}`, data, config);
|
|
34
|
+
// } catch (error) {
|
|
35
|
+
// console.error('Error fetching updateById:', error);
|
|
36
|
+
// throw error;
|
|
37
|
+
// }
|
|
38
|
+
// };
|
|
39
|
+
// export const updatePaymentLineById = async function (this: WashdayClientInstance, orderId: string, id: string, data: {
|
|
40
|
+
// amountPaid: number
|
|
41
|
+
// updatedDate: Date
|
|
42
|
+
// }): Promise<any> {
|
|
43
|
+
// try {
|
|
44
|
+
// const config = {
|
|
45
|
+
// headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
46
|
+
// };
|
|
47
|
+
// return await axiosInstance.put(`${GET_SET_ORDER_PAYMENTLINES(orderId)}/${id}`, data, config);
|
|
48
|
+
// } catch (error) {
|
|
49
|
+
// console.error('Error fetching updateById:', error);
|
|
50
|
+
// throw error;
|
|
51
|
+
// }
|
|
52
|
+
// };
|
package/package.json
CHANGED
package/src/api/index.ts
CHANGED
|
@@ -29,22 +29,35 @@ import * as productsEndpoints from './products';
|
|
|
29
29
|
import * as customersEndpoints from './customers';
|
|
30
30
|
import * as csvExportEndpoints from './csv';
|
|
31
31
|
import * as ordersEndpoints from './order';
|
|
32
|
+
import * as reviewsEndpoints from './reviews';
|
|
32
33
|
|
|
33
34
|
type WashdayClientConstructor = {
|
|
34
35
|
new(apiToken: string): WashdayClientInstance
|
|
35
36
|
};
|
|
37
|
+
function bindMethods<T>(instance: any, methods: any): T {
|
|
38
|
+
const boundMethods: any = {};
|
|
39
|
+
for (const key in methods) {
|
|
40
|
+
if (methods.hasOwnProperty(key) && typeof methods[key] === 'function') {
|
|
41
|
+
boundMethods[key] = methods[key].bind(instance);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return boundMethods;
|
|
45
|
+
}
|
|
36
46
|
|
|
37
47
|
const WashdayClient: WashdayClientConstructor = function WashdayClient(this: WashdayClientInstance, apiToken: string) {
|
|
38
48
|
this.apiToken = apiToken;
|
|
39
|
-
this.
|
|
49
|
+
this.review = bindMethods(this, {
|
|
50
|
+
requestStoreReviewByCustomerId: reviewsEndpoints.getModule.requestStoreReviewByCustomerId,
|
|
51
|
+
});
|
|
52
|
+
this.orders = bindMethods(this, {
|
|
40
53
|
getList: ordersEndpoints.getModule.getList,
|
|
41
54
|
getById: ordersEndpoints.getModule.getById,
|
|
42
55
|
updateById: ordersEndpoints.putModule.updateById,
|
|
43
56
|
updatePaymentLineById: ordersEndpoints.putModule.updatePaymentLineById,
|
|
44
57
|
createPaymentLine: ordersEndpoints.postModule.createPaymentLine,
|
|
45
58
|
deletePaymentLineById: ordersEndpoints.deleteModule.deletePaymentLineById,
|
|
46
|
-
};
|
|
47
|
-
this.customers = {
|
|
59
|
+
});
|
|
60
|
+
this.customers = bindMethods(this, {
|
|
48
61
|
getCustomers: customersEndpoints.getModule.getList,
|
|
49
62
|
getCustomerById: customersEndpoints.getModule.getCustomerById,
|
|
50
63
|
getCustomerHighlightsById: customersEndpoints.getModule.getCustomerHighlightsById,
|
|
@@ -52,8 +65,8 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
52
65
|
create: customersEndpoints.postModule.create,
|
|
53
66
|
updateById: customersEndpoints.putModule.updateById,
|
|
54
67
|
deleteById: customersEndpoints.deleteModule.deleteById,
|
|
55
|
-
};
|
|
56
|
-
this.stores = {
|
|
68
|
+
});
|
|
69
|
+
this.stores = bindMethods(this, {
|
|
57
70
|
getStores: getStores,
|
|
58
71
|
getStoreById: getStoreById,
|
|
59
72
|
getStoreImages: getStoreImages,
|
|
@@ -63,8 +76,8 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
63
76
|
createStoreImage: createStoreImage,
|
|
64
77
|
getStoreReviewLink: getStoreReviewLink,
|
|
65
78
|
deleteStoreById: deleteStoreById,
|
|
66
|
-
};
|
|
67
|
-
this.products = {
|
|
79
|
+
});
|
|
80
|
+
this.products = bindMethods(this, {
|
|
68
81
|
getById: productsEndpoints.getModule.getById,
|
|
69
82
|
create: productsEndpoints.postModule.create,
|
|
70
83
|
createProductSupply: productsEndpoints.postModule.createProductSupply,
|
|
@@ -72,14 +85,14 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
72
85
|
deleteProductSupplyById: productsEndpoints.deleteModule.deleteProductSupplyById,
|
|
73
86
|
updateById: productsEndpoints.putModule.updateById,
|
|
74
87
|
bulkUpdate: productsEndpoints.putModule.bulkUpdate
|
|
75
|
-
};
|
|
76
|
-
this.users = {
|
|
88
|
+
});
|
|
89
|
+
this.users = bindMethods(this, {
|
|
77
90
|
updateUserById: updateUserById,
|
|
78
|
-
};
|
|
79
|
-
this.countries = {
|
|
91
|
+
});
|
|
92
|
+
this.countries = bindMethods(this, {
|
|
80
93
|
getCountries: getCountries,
|
|
81
|
-
};
|
|
82
|
-
this.supplies = {
|
|
94
|
+
});
|
|
95
|
+
this.supplies = bindMethods(this, {
|
|
83
96
|
getSupplies: getSupplies,
|
|
84
97
|
getSupplyById: getSupplyById,
|
|
85
98
|
getSupplyHistory: getSupplyHistory,
|
|
@@ -87,15 +100,15 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
87
100
|
updateSupplyById: updateSupplyById,
|
|
88
101
|
addSupplyStock: addSupplyStock,
|
|
89
102
|
deleteSupplyById: deleteSupplyById,
|
|
90
|
-
};
|
|
91
|
-
this.sections = {
|
|
103
|
+
});
|
|
104
|
+
this.sections = bindMethods(this, {
|
|
92
105
|
getSections: sectionsEndpoints.getModule.getList,
|
|
93
106
|
getById: sectionsEndpoints.getModule.getById,
|
|
94
107
|
create: sectionsEndpoints.postModule.create,
|
|
95
108
|
deleteById: sectionsEndpoints.deleteModule.deleteById,
|
|
96
109
|
updateById: sectionsEndpoints.putModule.updateById,
|
|
97
|
-
};
|
|
98
|
-
this.inventory = {
|
|
110
|
+
});
|
|
111
|
+
this.inventory = bindMethods(this, {
|
|
99
112
|
getInventory: inventoryEndpoints.getModule.getInventory,
|
|
100
113
|
getById: inventoryEndpoints.getModule.getInventoryById,
|
|
101
114
|
getHistoryById: inventoryEndpoints.getModule.getHistoryById,
|
|
@@ -103,8 +116,8 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
103
116
|
deleteById: inventoryEndpoints.deleteModule.deleteById,
|
|
104
117
|
updateById: inventoryEndpoints.putModule.updateById,
|
|
105
118
|
addStock: inventoryEndpoints.putModule.addStock,
|
|
106
|
-
};
|
|
107
|
-
this.cashierboxes = {
|
|
119
|
+
});
|
|
120
|
+
this.cashierboxes = bindMethods(this, {
|
|
108
121
|
getCashierboxesByStoreId: getCashierboxesByStoreId,
|
|
109
122
|
getCashierboxesById: getCashierboxesById,
|
|
110
123
|
getCashierBoxMovementsHistory: getCashierBoxMovementsHistory,
|
|
@@ -112,43 +125,43 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
112
125
|
updateCashierBoxById: updateCashierBoxById,
|
|
113
126
|
deleteCashierBoxById: deleteCashierBoxById,
|
|
114
127
|
addCashierBoxMovement: addCashierBoxMovement,
|
|
115
|
-
};
|
|
116
|
-
this.companies = {
|
|
128
|
+
});
|
|
129
|
+
this.companies = bindMethods(this, {
|
|
117
130
|
getCompanyById: getCompanyById,
|
|
118
131
|
updateCompanyById: updateCompanyById,
|
|
119
132
|
updateCompanyLogoById: updateCompanyLogoById,
|
|
120
133
|
updateCompanyTaxInfoById: updateCompanyTaxInfoById,
|
|
121
134
|
updateCompanyTaxInfoCertificates: updateCompanyTaxInfoCertificates,
|
|
122
135
|
updateCFDIOrgLogo: updateCFDIOrgLogo
|
|
123
|
-
};
|
|
124
|
-
this.stripe = {
|
|
136
|
+
});
|
|
137
|
+
this.stripe = bindMethods(this, {
|
|
125
138
|
createCreateSuscriptionCheckoutSession: createCreateSuscriptionCheckoutSession,
|
|
126
139
|
createCFDISuscrptionCheckoutSession: createCFDISuscrptionCheckoutSession,
|
|
127
140
|
createCustomerPortalSession: createCustomerPortalSession
|
|
128
|
-
};
|
|
129
|
-
this.staff = {
|
|
141
|
+
});
|
|
142
|
+
this.staff = bindMethods(this, {
|
|
130
143
|
getStoreStaff: getStoreStaff,
|
|
131
144
|
getStoreStaffById: getStoreStaffById,
|
|
132
145
|
updateStoreStaffById: updateStoreStaffById,
|
|
133
146
|
createStoreStaff: createStoreStaff,
|
|
134
147
|
deleteStoreStaffById: deleteStoreStaffById,
|
|
135
|
-
};
|
|
136
|
-
this.discountCodes = {
|
|
148
|
+
});
|
|
149
|
+
this.discountCodes = bindMethods(this, {
|
|
137
150
|
getDiscountCodes: getDiscountCodes,
|
|
138
151
|
getDiscountCodeById: getDiscountCodeById,
|
|
139
152
|
verifyDiscountCode: verifyDiscountCode,
|
|
140
153
|
createDiscountCode: createDiscountCode,
|
|
141
154
|
deleteDiscountCodeById: deleteDiscountCodeById,
|
|
142
|
-
};
|
|
143
|
-
this.automaticDiscount = {
|
|
155
|
+
});
|
|
156
|
+
this.automaticDiscount = bindMethods(this, {
|
|
144
157
|
getAutomaticDiscounts: getAutomaticDiscounts,
|
|
145
158
|
getAutomaticDiscountById: getAutomaticDiscountById,
|
|
146
159
|
createAutomaticDiscount: createAutomaticDiscount,
|
|
147
160
|
deleteAutomaticDiscountById: deleteAutomaticDiscountById,
|
|
148
|
-
};
|
|
149
|
-
this.csv = {
|
|
161
|
+
});
|
|
162
|
+
this.csv = bindMethods(this, {
|
|
150
163
|
exportCustomersList: csvExportEndpoints.getModule.exportCustomersList,
|
|
151
|
-
};
|
|
164
|
+
});
|
|
152
165
|
} as any;
|
|
153
166
|
|
|
154
167
|
export default WashdayClient;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
// import axiosInstance from "../axiosInstance";
|
|
3
|
+
// const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
|
|
4
|
+
|
|
5
|
+
// export const deletePaymentLineById = async function (this: WashdayClientInstance, orderId: string, id: string): Promise<any> {
|
|
6
|
+
// try {
|
|
7
|
+
// const config = {
|
|
8
|
+
// headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
9
|
+
// };
|
|
10
|
+
// return await axiosInstance.delete(`${GET_SET_ORDER_PAYMENTLINES(orderId)}/${id}`, config);
|
|
11
|
+
// } catch (error) {
|
|
12
|
+
// console.error('Error fetching deleteById:', error);
|
|
13
|
+
// throw error;
|
|
14
|
+
// }
|
|
15
|
+
// };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { IOrder } from "../../interfaces/Order";
|
|
3
|
+
import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
4
|
+
import axiosInstance from "../axiosInstance";
|
|
5
|
+
const GET_SET_REVIEWS = 'api/review';
|
|
6
|
+
|
|
7
|
+
export const requestStoreReviewByCustomerId = async function (this: WashdayClientInstance, storeId: string, customerId: string): Promise<any> {
|
|
8
|
+
try {
|
|
9
|
+
const config = {
|
|
10
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
11
|
+
};
|
|
12
|
+
return await axiosInstance.get(`${GET_SET_REVIEWS}/${storeId}/${customerId}`, config);
|
|
13
|
+
} catch (error) {
|
|
14
|
+
console.error('Error fetching:', error);
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
// import axiosInstance from "../axiosInstance";
|
|
3
|
+
// const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
|
|
4
|
+
|
|
5
|
+
// export const createPaymentLine = async function (this: WashdayClientInstance, id: string, data: {
|
|
6
|
+
// amountPaid: number,
|
|
7
|
+
// cashierBox: string,
|
|
8
|
+
// paymentMethod: string
|
|
9
|
+
// paymentDate: Date
|
|
10
|
+
// }): Promise<any> {
|
|
11
|
+
// try {
|
|
12
|
+
// const config = {
|
|
13
|
+
// headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
14
|
+
// };
|
|
15
|
+
// return await axiosInstance.post(`${GET_SET_ORDER_PAYMENTLINES(id)}`, data, config);
|
|
16
|
+
// } catch (error) {
|
|
17
|
+
// console.error('Error fetching create:', error);
|
|
18
|
+
// throw error;
|
|
19
|
+
// }
|
|
20
|
+
// };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
// import axiosInstance from "../axiosInstance";
|
|
3
|
+
// const GET_SET_ORDER = 'api/v2/order';
|
|
4
|
+
// const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
|
|
5
|
+
|
|
6
|
+
// export const updateById = async function (this: WashdayClientInstance, id: string, data: {
|
|
7
|
+
// status?: string,
|
|
8
|
+
// products?: any[],
|
|
9
|
+
// buyAndGetProducts?: any[],
|
|
10
|
+
// customer?: string,
|
|
11
|
+
// discountCode?: string | null,
|
|
12
|
+
// notes?: string,
|
|
13
|
+
// privateNotes?: string,
|
|
14
|
+
// delivery?: boolean,
|
|
15
|
+
// pickup?: boolean,
|
|
16
|
+
// express?: boolean,
|
|
17
|
+
// deliveryInfo?: {
|
|
18
|
+
// date: Date,
|
|
19
|
+
// fromTime: string,
|
|
20
|
+
// toTime?: string
|
|
21
|
+
// },
|
|
22
|
+
// pickupInfo?: {
|
|
23
|
+
// date: Date,
|
|
24
|
+
// fromTime: string,
|
|
25
|
+
// toTime?: string
|
|
26
|
+
// },
|
|
27
|
+
// notifyBy?: string,
|
|
28
|
+
// }): Promise<any> {
|
|
29
|
+
// try {
|
|
30
|
+
// const config = {
|
|
31
|
+
// headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
32
|
+
// };
|
|
33
|
+
// return await axiosInstance.put(`${GET_SET_ORDER}/${id}`, data, config);
|
|
34
|
+
// } catch (error) {
|
|
35
|
+
// console.error('Error fetching updateById:', error);
|
|
36
|
+
// throw error;
|
|
37
|
+
// }
|
|
38
|
+
// };
|
|
39
|
+
|
|
40
|
+
// export const updatePaymentLineById = async function (this: WashdayClientInstance, orderId: string, id: string, data: {
|
|
41
|
+
// amountPaid: number
|
|
42
|
+
// updatedDate: Date
|
|
43
|
+
// }): Promise<any> {
|
|
44
|
+
// try {
|
|
45
|
+
// const config = {
|
|
46
|
+
// headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
47
|
+
// };
|
|
48
|
+
// return await axiosInstance.put(`${GET_SET_ORDER_PAYMENTLINES(orderId)}/${id}`, data, config);
|
|
49
|
+
// } catch (error) {
|
|
50
|
+
// console.error('Error fetching updateById:', error);
|
|
51
|
+
// throw error;
|
|
52
|
+
// }
|
|
53
|
+
// };
|
package/src/interfaces/Api.ts
CHANGED
|
@@ -28,9 +28,13 @@ import * as productsEndpoints from '../api/products';
|
|
|
28
28
|
import * as customersEndpoints from '../api/customers';
|
|
29
29
|
import * as csvExportEndpoints from '../api/csv';
|
|
30
30
|
import * as ordersEndpoints from '../api/order';
|
|
31
|
+
import * as reviewsEndpoints from '../api/reviews';
|
|
31
32
|
|
|
32
33
|
export interface WashdayClientInstance {
|
|
33
34
|
apiToken: string;
|
|
35
|
+
review: {
|
|
36
|
+
requestStoreReviewByCustomerId: typeof reviewsEndpoints.getModule.requestStoreReviewByCustomerId;
|
|
37
|
+
}
|
|
34
38
|
orders: {
|
|
35
39
|
getList: typeof ordersEndpoints.getModule.getList;
|
|
36
40
|
getById: typeof ordersEndpoints.getModule.getById;
|