washday-sdk 1.1.3 → 1.1.5

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 CHANGED
@@ -173,7 +173,10 @@ const WashdayClient = function WashdayClient(apiToken) {
173
173
  deleteById: productsEndpoints.deleteModule.deleteById,
174
174
  deleteProductSupplyById: productsEndpoints.deleteModule.deleteProductSupplyById,
175
175
  updateById: productsEndpoints.putModule.updateById,
176
- bulkUpdate: productsEndpoints.putModule.bulkUpdate
176
+ bulkUpdate: productsEndpoints.putModule.bulkUpdate,
177
+ createPriceOption: productsEndpoints.postModule.createPriceOption,
178
+ updatePriceOption: productsEndpoints.putModule.updatePriceOption,
179
+ deletePriceOption: productsEndpoints.deleteModule.deletePriceOption,
177
180
  });
178
181
  this.users = bindMethods(this, {
179
182
  updateUserById: updateUserById,
@@ -38,3 +38,19 @@ export const deleteProductSupplyById = function (id, productSupplyId) {
38
38
  }
39
39
  });
40
40
  };
41
+ // New: delete (inactivate) product price option
42
+ export const deletePriceOption = function (productId, optionId) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ try {
45
+ const config = {
46
+ headers: { Authorization: `Bearer ${this.apiToken}` }
47
+ };
48
+ const response = yield axiosInstance.delete(`${GET_SET_PRODUCTS}/${productId}/price-options/${optionId}`, config);
49
+ return response.data || {};
50
+ }
51
+ catch (error) {
52
+ console.error('Error deleting price option:', error);
53
+ throw error;
54
+ }
55
+ });
56
+ };
@@ -58,3 +58,19 @@ export const bulkCreate = function (storeId, data) {
58
58
  }
59
59
  });
60
60
  };
61
+ // New: create price option for a product
62
+ export const createPriceOption = function (productId, data) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ try {
65
+ const config = {
66
+ headers: { Authorization: `Bearer ${this.apiToken}` }
67
+ };
68
+ const response = yield axiosInstance.post(`${GET_SET_PRODUCTS}/${productId}/price-options`, data, config);
69
+ return response.data || {};
70
+ }
71
+ catch (error) {
72
+ console.error('Error creating price option:', error);
73
+ throw error;
74
+ }
75
+ });
76
+ };
@@ -38,3 +38,19 @@ export const updateById = function (id, data) {
38
38
  }
39
39
  });
40
40
  };
41
+ // New: update product price option
42
+ export const updatePriceOption = function (productId, optionId, data) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ try {
45
+ const config = {
46
+ headers: { Authorization: `Bearer ${this.apiToken}` }
47
+ };
48
+ const response = yield axiosInstance.put(`${GET_SET_PRODUCTS}/${productId}/price-options/${optionId}`, data, config);
49
+ return response.data || {};
50
+ }
51
+ catch (error) {
52
+ console.error('Error updating price option:', error);
53
+ throw error;
54
+ }
55
+ });
56
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
package/src/api/index.ts CHANGED
@@ -180,7 +180,10 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
180
180
  deleteById: productsEndpoints.deleteModule.deleteById,
181
181
  deleteProductSupplyById: productsEndpoints.deleteModule.deleteProductSupplyById,
182
182
  updateById: productsEndpoints.putModule.updateById,
183
- bulkUpdate: productsEndpoints.putModule.bulkUpdate
183
+ bulkUpdate: productsEndpoints.putModule.bulkUpdate,
184
+ createPriceOption: productsEndpoints.postModule.createPriceOption,
185
+ updatePriceOption: productsEndpoints.putModule.updatePriceOption,
186
+ deletePriceOption: productsEndpoints.deleteModule.deletePriceOption,
184
187
  });
185
188
  this.users = bindMethods(this, {
186
189
  updateUserById: updateUserById,
@@ -26,3 +26,17 @@ export const deleteProductSupplyById = async function (this: WashdayClientInstan
26
26
  throw error;
27
27
  }
28
28
  };
29
+
30
+ // New: delete (inactivate) product price option
31
+ export const deletePriceOption = async function (this: WashdayClientInstance, productId: string, optionId: string): Promise<any> {
32
+ try {
33
+ const config = {
34
+ headers: { Authorization: `Bearer ${this.apiToken}` }
35
+ };
36
+ const response = await axiosInstance.delete(`${GET_SET_PRODUCTS}/${productId}/price-options/${optionId}`, config);
37
+ return response.data || {};
38
+ } catch (error) {
39
+ console.error('Error deleting price option:', error);
40
+ throw error;
41
+ }
42
+ };
@@ -70,4 +70,24 @@ export const bulkCreate = async function (this: WashdayClientInstance, storeId:
70
70
  console.error('Error fetching products bulkCreate:', error);
71
71
  throw error;
72
72
  }
73
+ };
74
+
75
+ // New: create price option for a product
76
+ export const createPriceOption = async function (this: WashdayClientInstance, productId: string, data: {
77
+ label: string;
78
+ price: number;
79
+ expressPrice: number;
80
+ isDefault?: boolean;
81
+ isActive?: boolean;
82
+ }): Promise<any> {
83
+ try {
84
+ const config = {
85
+ headers: { Authorization: `Bearer ${this.apiToken}` }
86
+ };
87
+ const response = await axiosInstance.post(`${GET_SET_PRODUCTS}/${productId}/price-options`, data, config);
88
+ return response.data || {};
89
+ } catch (error) {
90
+ console.error('Error creating price option:', error);
91
+ throw error;
92
+ }
73
93
  };
@@ -47,3 +47,23 @@ export const updateById = async function (this: WashdayClientInstance, id: strin
47
47
  throw error;
48
48
  }
49
49
  };
50
+
51
+ // New: update product price option
52
+ export const updatePriceOption = async function (this: WashdayClientInstance, productId: string, optionId: string, data: {
53
+ label?: string;
54
+ price?: number;
55
+ expressPrice?: number;
56
+ isDefault?: boolean;
57
+ isActive?: boolean;
58
+ }): Promise<any> {
59
+ try {
60
+ const config = {
61
+ headers: { Authorization: `Bearer ${this.apiToken}` }
62
+ };
63
+ const response = await axiosInstance.put(`${GET_SET_PRODUCTS}/${productId}/price-options/${optionId}`, data, config);
64
+ return response.data || {};
65
+ } catch (error) {
66
+ console.error('Error updating price option:', error);
67
+ throw error;
68
+ }
69
+ };
@@ -166,6 +166,9 @@ export interface WashdayClientInstance {
166
166
  deleteProductSupplyById: typeof productsEndpoints.deleteModule.deleteProductSupplyById;
167
167
  updateById: typeof productsEndpoints.putModule.updateById;
168
168
  bulkUpdate: typeof productsEndpoints.putModule.bulkUpdate;
169
+ createPriceOption: typeof productsEndpoints.postModule.createPriceOption;
170
+ updatePriceOption: typeof productsEndpoints.putModule.updatePriceOption;
171
+ deletePriceOption: typeof productsEndpoints.deleteModule.deletePriceOption;
169
172
  };
170
173
  users: {
171
174
  updateUserById: typeof updateUserById;