washday-sdk 0.0.74 → 0.0.75
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 +41 -32
- package/package.json +1 -1
- package/src/api/index.ts +41 -32
package/dist/api/index.js
CHANGED
|
@@ -28,17 +28,26 @@ 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
|
+
function bindMethods(instance, methods) {
|
|
32
|
+
const boundMethods = {};
|
|
33
|
+
for (const key in methods) {
|
|
34
|
+
if (methods.hasOwnProperty(key) && typeof methods[key] === 'function') {
|
|
35
|
+
boundMethods[key] = methods[key].bind(instance);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return boundMethods;
|
|
39
|
+
}
|
|
31
40
|
const WashdayClient = function WashdayClient(apiToken) {
|
|
32
41
|
this.apiToken = apiToken;
|
|
33
|
-
this.orders = {
|
|
42
|
+
this.orders = bindMethods(this, {
|
|
34
43
|
getList: ordersEndpoints.getModule.getList,
|
|
35
44
|
getById: ordersEndpoints.getModule.getById,
|
|
36
45
|
updateById: ordersEndpoints.putModule.updateById,
|
|
37
46
|
updatePaymentLineById: ordersEndpoints.putModule.updatePaymentLineById,
|
|
38
47
|
createPaymentLine: ordersEndpoints.postModule.createPaymentLine,
|
|
39
48
|
deletePaymentLineById: ordersEndpoints.deleteModule.deletePaymentLineById,
|
|
40
|
-
};
|
|
41
|
-
this.customers = {
|
|
49
|
+
});
|
|
50
|
+
this.customers = bindMethods(this, {
|
|
42
51
|
getCustomers: customersEndpoints.getModule.getList,
|
|
43
52
|
getCustomerById: customersEndpoints.getModule.getCustomerById,
|
|
44
53
|
getCustomerHighlightsById: customersEndpoints.getModule.getCustomerHighlightsById,
|
|
@@ -46,8 +55,8 @@ const WashdayClient = function WashdayClient(apiToken) {
|
|
|
46
55
|
create: customersEndpoints.postModule.create,
|
|
47
56
|
updateById: customersEndpoints.putModule.updateById,
|
|
48
57
|
deleteById: customersEndpoints.deleteModule.deleteById,
|
|
49
|
-
};
|
|
50
|
-
this.stores = {
|
|
58
|
+
});
|
|
59
|
+
this.stores = bindMethods(this, {
|
|
51
60
|
getStores: getStores,
|
|
52
61
|
getStoreById: getStoreById,
|
|
53
62
|
getStoreImages: getStoreImages,
|
|
@@ -57,8 +66,8 @@ const WashdayClient = function WashdayClient(apiToken) {
|
|
|
57
66
|
createStoreImage: createStoreImage,
|
|
58
67
|
getStoreReviewLink: getStoreReviewLink,
|
|
59
68
|
deleteStoreById: deleteStoreById,
|
|
60
|
-
};
|
|
61
|
-
this.products = {
|
|
69
|
+
});
|
|
70
|
+
this.products = bindMethods(this, {
|
|
62
71
|
getById: productsEndpoints.getModule.getById,
|
|
63
72
|
create: productsEndpoints.postModule.create,
|
|
64
73
|
createProductSupply: productsEndpoints.postModule.createProductSupply,
|
|
@@ -66,14 +75,14 @@ const WashdayClient = function WashdayClient(apiToken) {
|
|
|
66
75
|
deleteProductSupplyById: productsEndpoints.deleteModule.deleteProductSupplyById,
|
|
67
76
|
updateById: productsEndpoints.putModule.updateById,
|
|
68
77
|
bulkUpdate: productsEndpoints.putModule.bulkUpdate
|
|
69
|
-
};
|
|
70
|
-
this.users = {
|
|
78
|
+
});
|
|
79
|
+
this.users = bindMethods(this, {
|
|
71
80
|
updateUserById: updateUserById,
|
|
72
|
-
};
|
|
73
|
-
this.countries = {
|
|
81
|
+
});
|
|
82
|
+
this.countries = bindMethods(this, {
|
|
74
83
|
getCountries: getCountries,
|
|
75
|
-
};
|
|
76
|
-
this.supplies = {
|
|
84
|
+
});
|
|
85
|
+
this.supplies = bindMethods(this, {
|
|
77
86
|
getSupplies: getSupplies,
|
|
78
87
|
getSupplyById: getSupplyById,
|
|
79
88
|
getSupplyHistory: getSupplyHistory,
|
|
@@ -81,15 +90,15 @@ const WashdayClient = function WashdayClient(apiToken) {
|
|
|
81
90
|
updateSupplyById: updateSupplyById,
|
|
82
91
|
addSupplyStock: addSupplyStock,
|
|
83
92
|
deleteSupplyById: deleteSupplyById,
|
|
84
|
-
};
|
|
85
|
-
this.sections = {
|
|
93
|
+
});
|
|
94
|
+
this.sections = bindMethods(this, {
|
|
86
95
|
getSections: sectionsEndpoints.getModule.getList,
|
|
87
96
|
getById: sectionsEndpoints.getModule.getById,
|
|
88
97
|
create: sectionsEndpoints.postModule.create,
|
|
89
98
|
deleteById: sectionsEndpoints.deleteModule.deleteById,
|
|
90
99
|
updateById: sectionsEndpoints.putModule.updateById,
|
|
91
|
-
};
|
|
92
|
-
this.inventory = {
|
|
100
|
+
});
|
|
101
|
+
this.inventory = bindMethods(this, {
|
|
93
102
|
getInventory: inventoryEndpoints.getModule.getInventory,
|
|
94
103
|
getById: inventoryEndpoints.getModule.getInventoryById,
|
|
95
104
|
getHistoryById: inventoryEndpoints.getModule.getHistoryById,
|
|
@@ -97,8 +106,8 @@ const WashdayClient = function WashdayClient(apiToken) {
|
|
|
97
106
|
deleteById: inventoryEndpoints.deleteModule.deleteById,
|
|
98
107
|
updateById: inventoryEndpoints.putModule.updateById,
|
|
99
108
|
addStock: inventoryEndpoints.putModule.addStock,
|
|
100
|
-
};
|
|
101
|
-
this.cashierboxes = {
|
|
109
|
+
});
|
|
110
|
+
this.cashierboxes = bindMethods(this, {
|
|
102
111
|
getCashierboxesByStoreId: getCashierboxesByStoreId,
|
|
103
112
|
getCashierboxesById: getCashierboxesById,
|
|
104
113
|
getCashierBoxMovementsHistory: getCashierBoxMovementsHistory,
|
|
@@ -106,42 +115,42 @@ const WashdayClient = function WashdayClient(apiToken) {
|
|
|
106
115
|
updateCashierBoxById: updateCashierBoxById,
|
|
107
116
|
deleteCashierBoxById: deleteCashierBoxById,
|
|
108
117
|
addCashierBoxMovement: addCashierBoxMovement,
|
|
109
|
-
};
|
|
110
|
-
this.companies = {
|
|
118
|
+
});
|
|
119
|
+
this.companies = bindMethods(this, {
|
|
111
120
|
getCompanyById: getCompanyById,
|
|
112
121
|
updateCompanyById: updateCompanyById,
|
|
113
122
|
updateCompanyLogoById: updateCompanyLogoById,
|
|
114
123
|
updateCompanyTaxInfoById: updateCompanyTaxInfoById,
|
|
115
124
|
updateCompanyTaxInfoCertificates: updateCompanyTaxInfoCertificates,
|
|
116
125
|
updateCFDIOrgLogo: updateCFDIOrgLogo
|
|
117
|
-
};
|
|
118
|
-
this.stripe = {
|
|
126
|
+
});
|
|
127
|
+
this.stripe = bindMethods(this, {
|
|
119
128
|
createCreateSuscriptionCheckoutSession: createCreateSuscriptionCheckoutSession,
|
|
120
129
|
createCFDISuscrptionCheckoutSession: createCFDISuscrptionCheckoutSession,
|
|
121
130
|
createCustomerPortalSession: createCustomerPortalSession
|
|
122
|
-
};
|
|
123
|
-
this.staff = {
|
|
131
|
+
});
|
|
132
|
+
this.staff = bindMethods(this, {
|
|
124
133
|
getStoreStaff: getStoreStaff,
|
|
125
134
|
getStoreStaffById: getStoreStaffById,
|
|
126
135
|
updateStoreStaffById: updateStoreStaffById,
|
|
127
136
|
createStoreStaff: createStoreStaff,
|
|
128
137
|
deleteStoreStaffById: deleteStoreStaffById,
|
|
129
|
-
};
|
|
130
|
-
this.discountCodes = {
|
|
138
|
+
});
|
|
139
|
+
this.discountCodes = bindMethods(this, {
|
|
131
140
|
getDiscountCodes: getDiscountCodes,
|
|
132
141
|
getDiscountCodeById: getDiscountCodeById,
|
|
133
142
|
verifyDiscountCode: verifyDiscountCode,
|
|
134
143
|
createDiscountCode: createDiscountCode,
|
|
135
144
|
deleteDiscountCodeById: deleteDiscountCodeById,
|
|
136
|
-
};
|
|
137
|
-
this.automaticDiscount = {
|
|
145
|
+
});
|
|
146
|
+
this.automaticDiscount = bindMethods(this, {
|
|
138
147
|
getAutomaticDiscounts: getAutomaticDiscounts,
|
|
139
148
|
getAutomaticDiscountById: getAutomaticDiscountById,
|
|
140
149
|
createAutomaticDiscount: createAutomaticDiscount,
|
|
141
150
|
deleteAutomaticDiscountById: deleteAutomaticDiscountById,
|
|
142
|
-
};
|
|
143
|
-
this.csv = {
|
|
151
|
+
});
|
|
152
|
+
this.csv = bindMethods(this, {
|
|
144
153
|
exportCustomersList: csvExportEndpoints.getModule.exportCustomersList,
|
|
145
|
-
};
|
|
154
|
+
});
|
|
146
155
|
};
|
|
147
156
|
export default WashdayClient;
|
package/package.json
CHANGED
package/src/api/index.ts
CHANGED
|
@@ -33,18 +33,27 @@ import * as ordersEndpoints from './order';
|
|
|
33
33
|
type WashdayClientConstructor = {
|
|
34
34
|
new(apiToken: string): WashdayClientInstance
|
|
35
35
|
};
|
|
36
|
+
function bindMethods<T>(instance: any, methods: any): T {
|
|
37
|
+
const boundMethods: any = {};
|
|
38
|
+
for (const key in methods) {
|
|
39
|
+
if (methods.hasOwnProperty(key) && typeof methods[key] === 'function') {
|
|
40
|
+
boundMethods[key] = methods[key].bind(instance);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return boundMethods;
|
|
44
|
+
}
|
|
36
45
|
|
|
37
46
|
const WashdayClient: WashdayClientConstructor = function WashdayClient(this: WashdayClientInstance, apiToken: string) {
|
|
38
47
|
this.apiToken = apiToken;
|
|
39
|
-
this.orders = {
|
|
48
|
+
this.orders = bindMethods(this, {
|
|
40
49
|
getList: ordersEndpoints.getModule.getList,
|
|
41
50
|
getById: ordersEndpoints.getModule.getById,
|
|
42
51
|
updateById: ordersEndpoints.putModule.updateById,
|
|
43
52
|
updatePaymentLineById: ordersEndpoints.putModule.updatePaymentLineById,
|
|
44
53
|
createPaymentLine: ordersEndpoints.postModule.createPaymentLine,
|
|
45
54
|
deletePaymentLineById: ordersEndpoints.deleteModule.deletePaymentLineById,
|
|
46
|
-
};
|
|
47
|
-
this.customers = {
|
|
55
|
+
});
|
|
56
|
+
this.customers = bindMethods(this, {
|
|
48
57
|
getCustomers: customersEndpoints.getModule.getList,
|
|
49
58
|
getCustomerById: customersEndpoints.getModule.getCustomerById,
|
|
50
59
|
getCustomerHighlightsById: customersEndpoints.getModule.getCustomerHighlightsById,
|
|
@@ -52,8 +61,8 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
52
61
|
create: customersEndpoints.postModule.create,
|
|
53
62
|
updateById: customersEndpoints.putModule.updateById,
|
|
54
63
|
deleteById: customersEndpoints.deleteModule.deleteById,
|
|
55
|
-
};
|
|
56
|
-
this.stores = {
|
|
64
|
+
});
|
|
65
|
+
this.stores = bindMethods(this, {
|
|
57
66
|
getStores: getStores,
|
|
58
67
|
getStoreById: getStoreById,
|
|
59
68
|
getStoreImages: getStoreImages,
|
|
@@ -63,8 +72,8 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
63
72
|
createStoreImage: createStoreImage,
|
|
64
73
|
getStoreReviewLink: getStoreReviewLink,
|
|
65
74
|
deleteStoreById: deleteStoreById,
|
|
66
|
-
};
|
|
67
|
-
this.products = {
|
|
75
|
+
});
|
|
76
|
+
this.products = bindMethods(this, {
|
|
68
77
|
getById: productsEndpoints.getModule.getById,
|
|
69
78
|
create: productsEndpoints.postModule.create,
|
|
70
79
|
createProductSupply: productsEndpoints.postModule.createProductSupply,
|
|
@@ -72,14 +81,14 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
72
81
|
deleteProductSupplyById: productsEndpoints.deleteModule.deleteProductSupplyById,
|
|
73
82
|
updateById: productsEndpoints.putModule.updateById,
|
|
74
83
|
bulkUpdate: productsEndpoints.putModule.bulkUpdate
|
|
75
|
-
};
|
|
76
|
-
this.users = {
|
|
84
|
+
});
|
|
85
|
+
this.users = bindMethods(this, {
|
|
77
86
|
updateUserById: updateUserById,
|
|
78
|
-
};
|
|
79
|
-
this.countries = {
|
|
87
|
+
});
|
|
88
|
+
this.countries = bindMethods(this, {
|
|
80
89
|
getCountries: getCountries,
|
|
81
|
-
};
|
|
82
|
-
this.supplies = {
|
|
90
|
+
});
|
|
91
|
+
this.supplies = bindMethods(this, {
|
|
83
92
|
getSupplies: getSupplies,
|
|
84
93
|
getSupplyById: getSupplyById,
|
|
85
94
|
getSupplyHistory: getSupplyHistory,
|
|
@@ -87,15 +96,15 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
87
96
|
updateSupplyById: updateSupplyById,
|
|
88
97
|
addSupplyStock: addSupplyStock,
|
|
89
98
|
deleteSupplyById: deleteSupplyById,
|
|
90
|
-
};
|
|
91
|
-
this.sections = {
|
|
99
|
+
});
|
|
100
|
+
this.sections = bindMethods(this, {
|
|
92
101
|
getSections: sectionsEndpoints.getModule.getList,
|
|
93
102
|
getById: sectionsEndpoints.getModule.getById,
|
|
94
103
|
create: sectionsEndpoints.postModule.create,
|
|
95
104
|
deleteById: sectionsEndpoints.deleteModule.deleteById,
|
|
96
105
|
updateById: sectionsEndpoints.putModule.updateById,
|
|
97
|
-
};
|
|
98
|
-
this.inventory = {
|
|
106
|
+
});
|
|
107
|
+
this.inventory = bindMethods(this, {
|
|
99
108
|
getInventory: inventoryEndpoints.getModule.getInventory,
|
|
100
109
|
getById: inventoryEndpoints.getModule.getInventoryById,
|
|
101
110
|
getHistoryById: inventoryEndpoints.getModule.getHistoryById,
|
|
@@ -103,8 +112,8 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
103
112
|
deleteById: inventoryEndpoints.deleteModule.deleteById,
|
|
104
113
|
updateById: inventoryEndpoints.putModule.updateById,
|
|
105
114
|
addStock: inventoryEndpoints.putModule.addStock,
|
|
106
|
-
};
|
|
107
|
-
this.cashierboxes = {
|
|
115
|
+
});
|
|
116
|
+
this.cashierboxes = bindMethods(this, {
|
|
108
117
|
getCashierboxesByStoreId: getCashierboxesByStoreId,
|
|
109
118
|
getCashierboxesById: getCashierboxesById,
|
|
110
119
|
getCashierBoxMovementsHistory: getCashierBoxMovementsHistory,
|
|
@@ -112,43 +121,43 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
112
121
|
updateCashierBoxById: updateCashierBoxById,
|
|
113
122
|
deleteCashierBoxById: deleteCashierBoxById,
|
|
114
123
|
addCashierBoxMovement: addCashierBoxMovement,
|
|
115
|
-
};
|
|
116
|
-
this.companies = {
|
|
124
|
+
});
|
|
125
|
+
this.companies = bindMethods(this, {
|
|
117
126
|
getCompanyById: getCompanyById,
|
|
118
127
|
updateCompanyById: updateCompanyById,
|
|
119
128
|
updateCompanyLogoById: updateCompanyLogoById,
|
|
120
129
|
updateCompanyTaxInfoById: updateCompanyTaxInfoById,
|
|
121
130
|
updateCompanyTaxInfoCertificates: updateCompanyTaxInfoCertificates,
|
|
122
131
|
updateCFDIOrgLogo: updateCFDIOrgLogo
|
|
123
|
-
};
|
|
124
|
-
this.stripe = {
|
|
132
|
+
});
|
|
133
|
+
this.stripe = bindMethods(this, {
|
|
125
134
|
createCreateSuscriptionCheckoutSession: createCreateSuscriptionCheckoutSession,
|
|
126
135
|
createCFDISuscrptionCheckoutSession: createCFDISuscrptionCheckoutSession,
|
|
127
136
|
createCustomerPortalSession: createCustomerPortalSession
|
|
128
|
-
};
|
|
129
|
-
this.staff = {
|
|
137
|
+
});
|
|
138
|
+
this.staff = bindMethods(this, {
|
|
130
139
|
getStoreStaff: getStoreStaff,
|
|
131
140
|
getStoreStaffById: getStoreStaffById,
|
|
132
141
|
updateStoreStaffById: updateStoreStaffById,
|
|
133
142
|
createStoreStaff: createStoreStaff,
|
|
134
143
|
deleteStoreStaffById: deleteStoreStaffById,
|
|
135
|
-
};
|
|
136
|
-
this.discountCodes = {
|
|
144
|
+
});
|
|
145
|
+
this.discountCodes = bindMethods(this, {
|
|
137
146
|
getDiscountCodes: getDiscountCodes,
|
|
138
147
|
getDiscountCodeById: getDiscountCodeById,
|
|
139
148
|
verifyDiscountCode: verifyDiscountCode,
|
|
140
149
|
createDiscountCode: createDiscountCode,
|
|
141
150
|
deleteDiscountCodeById: deleteDiscountCodeById,
|
|
142
|
-
};
|
|
143
|
-
this.automaticDiscount = {
|
|
151
|
+
});
|
|
152
|
+
this.automaticDiscount = bindMethods(this, {
|
|
144
153
|
getAutomaticDiscounts: getAutomaticDiscounts,
|
|
145
154
|
getAutomaticDiscountById: getAutomaticDiscountById,
|
|
146
155
|
createAutomaticDiscount: createAutomaticDiscount,
|
|
147
156
|
deleteAutomaticDiscountById: deleteAutomaticDiscountById,
|
|
148
|
-
};
|
|
149
|
-
this.csv = {
|
|
157
|
+
});
|
|
158
|
+
this.csv = bindMethods(this, {
|
|
150
159
|
exportCustomersList: csvExportEndpoints.getModule.exportCustomersList,
|
|
151
|
-
};
|
|
160
|
+
});
|
|
152
161
|
} as any;
|
|
153
162
|
|
|
154
163
|
export default WashdayClient;
|