washday-sdk 1.6.26 → 1.6.28
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/babel.config.cjs +6 -0
- package/dist/api/index.js +3 -1
- package/dist/api/products/get.js +17 -0
- package/dist/api/stores/get.js +18 -0
- package/package.json +1 -1
- package/src/api/index.ts +3 -1
- package/src/api/products/get.ts +21 -1
- package/src/api/stores/get.ts +26 -2
- package/src/interfaces/Api.ts +3 -1
- package/src/interfaces/Store.ts +7 -0
- package/test/products.getByIdCustomersApp.test.ts +30 -0
- package/babel.config.js +0 -8
package/babel.config.cjs
ADDED
package/dist/api/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { deleteStoreStaffById } from "./staff/delete";
|
|
|
13
13
|
import { getStoreStaff, getStoreStaffById } from "./staff/get";
|
|
14
14
|
import { createStoreStaff } from "./staff/post";
|
|
15
15
|
import { updateStoreStaffById, updateStoreStaffStores } from "./staff/put";
|
|
16
|
-
import { getOrderSequence, getPaymentFees, getStoreById, getStoreImages, getStoreReviewLink, getStores, getStoresByIdCustomersApp, getStoresByName } from "./stores/get";
|
|
16
|
+
import { getOrderSequence, getPaymentFees, getPickupScheduleCustomersApp, getStoreById, getStoreImages, getStoreReviewLink, getStores, getStoresByIdCustomersApp, getStoresByName } from "./stores/get";
|
|
17
17
|
import { copyStore, createStore, createStoreImage } from "./stores/post";
|
|
18
18
|
import { deleteStoreById, setOrderSequence, updatePaymentFees, updateStoreById } from "./stores/put";
|
|
19
19
|
import { createCFDISuscrptionCheckoutSession, createCreateSuscriptionCheckoutSession, createCustomerPortalSession, createGetMoreCheckoutSession } from "./stripe/post";
|
|
@@ -170,6 +170,7 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD', clientId, c
|
|
|
170
170
|
getStoreImages: getStoreImages,
|
|
171
171
|
getStoresByName: getStoresByName,
|
|
172
172
|
getStoresByIdCustomersApp: getStoresByIdCustomersApp,
|
|
173
|
+
getPickupScheduleCustomersApp: getPickupScheduleCustomersApp,
|
|
173
174
|
createStore: createStore,
|
|
174
175
|
copyStore: copyStore,
|
|
175
176
|
updateStoreById: updateStoreById,
|
|
@@ -183,6 +184,7 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD', clientId, c
|
|
|
183
184
|
});
|
|
184
185
|
this.products = bindMethods(this, {
|
|
185
186
|
getById: productsEndpoints.getModule.getById,
|
|
187
|
+
getByIdCustomersApp: productsEndpoints.getModule.getByIdCustomersApp,
|
|
186
188
|
create: productsEndpoints.postModule.create,
|
|
187
189
|
createProductSupply: productsEndpoints.postModule.createProductSupply,
|
|
188
190
|
bulkCreate: productsEndpoints.postModule.bulkCreate,
|
package/dist/api/products/get.js
CHANGED
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
const GET_SET_PRODUCTS = 'api/product';
|
|
11
|
+
const GET_SET_PRODUCTS_CUSTOMERS_APP = 'api/v2/washdayapp/products';
|
|
11
12
|
export const getById = function (id) {
|
|
12
13
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13
14
|
try {
|
|
@@ -22,3 +23,19 @@ export const getById = function (id) {
|
|
|
22
23
|
}
|
|
23
24
|
});
|
|
24
25
|
};
|
|
26
|
+
export const getByIdCustomersApp = function (id) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
try {
|
|
30
|
+
const config = {
|
|
31
|
+
headers: { Authorization: `Bearer ${this.apiToken}` },
|
|
32
|
+
};
|
|
33
|
+
const response = yield this.axiosInstance.get(`${GET_SET_PRODUCTS_CUSTOMERS_APP}/${id}`, config);
|
|
34
|
+
return ((_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.product) || {};
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.error("Error fetching getByIdCustomersApp:", error);
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
};
|
package/dist/api/stores/get.js
CHANGED
|
@@ -11,6 +11,7 @@ import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
|
11
11
|
const GET_SET_STORES = 'api/store';
|
|
12
12
|
const GET_SET_STORES_V2 = 'api/v2/stores';
|
|
13
13
|
const GET_SET_STORE_IMAGE = 'api/store-image';
|
|
14
|
+
const GET_PICKUP_SCHEDULE_CUSTOMERS_APP = (storeId) => `${GET_STORES_WASHDAY_APP}/${storeId}/pickup-schedule`;
|
|
14
15
|
const REQUEST_PARAMS = {
|
|
15
16
|
token: 'LOGGED_USER_TOKEN',
|
|
16
17
|
};
|
|
@@ -108,6 +109,23 @@ export const getStoresByIdCustomersApp = function (id) {
|
|
|
108
109
|
}
|
|
109
110
|
});
|
|
110
111
|
};
|
|
112
|
+
export const getPickupScheduleCustomersApp = function (storeId, query) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
var _a, _b;
|
|
115
|
+
try {
|
|
116
|
+
const config = {
|
|
117
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
118
|
+
};
|
|
119
|
+
const queryParams = generateQueryParamsStr(["date"], query);
|
|
120
|
+
const response = yield this.axiosInstance.get(`${GET_PICKUP_SCHEDULE_CUSTOMERS_APP(storeId)}?${queryParams}`, config);
|
|
121
|
+
return ((_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.pickupSchedule) || [];
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
console.error('Error fetching getPickupScheduleCustomersApp:', error);
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
};
|
|
111
129
|
export const getOrderSequence = function (storeId) {
|
|
112
130
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
131
|
try {
|
package/package.json
CHANGED
package/src/api/index.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { deleteStoreStaffById } from "./staff/delete";
|
|
|
14
14
|
import { getStoreStaff, getStoreStaffById } from "./staff/get";
|
|
15
15
|
import { createStoreStaff } from "./staff/post";
|
|
16
16
|
import { updateStoreStaffById, updateStoreStaffStores } from "./staff/put";
|
|
17
|
-
import { getOrderSequence, getPaymentFees, getStoreById, getStoreImages, getStoreReviewLink, getStores, getStoresByIdCustomersApp, getStoresByName } from "./stores/get";
|
|
17
|
+
import { getOrderSequence, getPaymentFees, getPickupScheduleCustomersApp, getStoreById, getStoreImages, getStoreReviewLink, getStores, getStoresByIdCustomersApp, getStoresByName } from "./stores/get";
|
|
18
18
|
import { copyStore, createStore, createStoreImage } from "./stores/post";
|
|
19
19
|
import { deleteStoreById, setOrderSequence, updatePaymentFees, updateStoreById } from "./stores/put";
|
|
20
20
|
import { createCFDISuscrptionCheckoutSession, createCreateSuscriptionCheckoutSession, createCustomerPortalSession, createGetMoreCheckoutSession } from "./stripe/post";
|
|
@@ -177,6 +177,7 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
177
177
|
getStoreImages: getStoreImages,
|
|
178
178
|
getStoresByName: getStoresByName,
|
|
179
179
|
getStoresByIdCustomersApp: getStoresByIdCustomersApp,
|
|
180
|
+
getPickupScheduleCustomersApp: getPickupScheduleCustomersApp,
|
|
180
181
|
createStore: createStore,
|
|
181
182
|
copyStore: copyStore,
|
|
182
183
|
updateStoreById: updateStoreById,
|
|
@@ -190,6 +191,7 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
190
191
|
});
|
|
191
192
|
this.products = bindMethods(this, {
|
|
192
193
|
getById: productsEndpoints.getModule.getById,
|
|
194
|
+
getByIdCustomersApp: productsEndpoints.getModule.getByIdCustomersApp,
|
|
193
195
|
create: productsEndpoints.postModule.create,
|
|
194
196
|
createProductSupply: productsEndpoints.postModule.createProductSupply,
|
|
195
197
|
bulkCreate: productsEndpoints.postModule.bulkCreate,
|
package/src/api/products/get.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { WashdayClientInstance } from "../../interfaces/Api";
|
|
|
2
2
|
import { IStore } from "../../interfaces/Store";
|
|
3
3
|
import axiosInstance from "../axiosInstance";
|
|
4
4
|
const GET_SET_PRODUCTS = 'api/product';
|
|
5
|
+
const GET_SET_PRODUCTS_CUSTOMERS_APP = 'api/v2/washdayapp/products';
|
|
5
6
|
|
|
6
7
|
export const getById = async function (this: WashdayClientInstance, id: string): Promise<any> {
|
|
7
8
|
try {
|
|
@@ -13,4 +14,23 @@ export const getById = async function (this: WashdayClientInstance, id: string):
|
|
|
13
14
|
console.error('Error fetching getById:', error);
|
|
14
15
|
throw error;
|
|
15
16
|
}
|
|
16
|
-
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const getByIdCustomersApp = async function (
|
|
20
|
+
this: WashdayClientInstance,
|
|
21
|
+
id: string
|
|
22
|
+
): Promise<any> {
|
|
23
|
+
try {
|
|
24
|
+
const config = {
|
|
25
|
+
headers: { Authorization: `Bearer ${this.apiToken}` },
|
|
26
|
+
};
|
|
27
|
+
const response = await this.axiosInstance.get(
|
|
28
|
+
`${GET_SET_PRODUCTS_CUSTOMERS_APP}/${id}`,
|
|
29
|
+
config
|
|
30
|
+
);
|
|
31
|
+
return response.data?.data?.product || {};
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error("Error fetching getByIdCustomersApp:", error);
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
};
|
package/src/api/stores/get.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
-
import { IStore } from "../../interfaces/Store";
|
|
2
|
+
import { IPickupScheduleSlot, IStore } from "../../interfaces/Store";
|
|
3
3
|
import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
4
4
|
import axiosInstance from "../axiosInstance";
|
|
5
5
|
|
|
6
6
|
const GET_SET_STORES = 'api/store';
|
|
7
7
|
const GET_SET_STORES_V2 = 'api/v2/stores';
|
|
8
8
|
const GET_SET_STORE_IMAGE = 'api/store-image';
|
|
9
|
+
const GET_PICKUP_SCHEDULE_CUSTOMERS_APP = (storeId: string) => `${GET_STORES_WASHDAY_APP}/${storeId}/pickup-schedule`;
|
|
9
10
|
const REQUEST_PARAMS = {
|
|
10
11
|
token: 'LOGGED_USER_TOKEN',
|
|
11
12
|
};
|
|
@@ -93,6 +94,29 @@ export const getStoresByIdCustomersApp = async function (this: WashdayClientInst
|
|
|
93
94
|
}
|
|
94
95
|
};
|
|
95
96
|
|
|
97
|
+
export const getPickupScheduleCustomersApp = async function (
|
|
98
|
+
this: WashdayClientInstance,
|
|
99
|
+
storeId: string,
|
|
100
|
+
query: {
|
|
101
|
+
date: string;
|
|
102
|
+
}
|
|
103
|
+
): Promise<IPickupScheduleSlot[]> {
|
|
104
|
+
try {
|
|
105
|
+
const config = {
|
|
106
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
107
|
+
};
|
|
108
|
+
const queryParams = generateQueryParamsStr(["date"], query);
|
|
109
|
+
const response = await this.axiosInstance.get(
|
|
110
|
+
`${GET_PICKUP_SCHEDULE_CUSTOMERS_APP(storeId)}?${queryParams}`,
|
|
111
|
+
config
|
|
112
|
+
);
|
|
113
|
+
return response.data?.data?.pickupSchedule || [];
|
|
114
|
+
} catch (error) {
|
|
115
|
+
console.error('Error fetching getPickupScheduleCustomersApp:', error);
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
96
120
|
export const getOrderSequence = async function (this: WashdayClientInstance, storeId: string): Promise<any> {
|
|
97
121
|
try {
|
|
98
122
|
const config = {
|
|
@@ -117,4 +141,4 @@ export const getPaymentFees = async function (this: WashdayClientInstance, store
|
|
|
117
141
|
console.error('Error fetching getPaymentFees:', error);
|
|
118
142
|
throw error;
|
|
119
143
|
}
|
|
120
|
-
};
|
|
144
|
+
};
|
package/src/interfaces/Api.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { deleteStoreStaffById } from "../api/staff/delete";
|
|
|
13
13
|
import { getStoreStaff, getStoreStaffById } from "../api/staff/get";
|
|
14
14
|
import { createStoreStaff } from "../api/staff/post";
|
|
15
15
|
import { updateStoreStaffById, updateStoreStaffStores } from "../api/staff/put";
|
|
16
|
-
import { getOrderSequence, getPaymentFees, getStoreById, getStoreImages, getStoreReviewLink, getStores, getStoresByIdCustomersApp, getStoresByName } from "../api/stores/get";
|
|
16
|
+
import { getOrderSequence, getPaymentFees, getPickupScheduleCustomersApp, getStoreById, getStoreImages, getStoreReviewLink, getStores, getStoresByIdCustomersApp, getStoresByName } from "../api/stores/get";
|
|
17
17
|
import { copyStore, createStore, createStoreImage } from "../api/stores/post";
|
|
18
18
|
import { deleteStoreById, setOrderSequence, updatePaymentFees, updateStoreById } from "../api/stores/put";
|
|
19
19
|
import { createCFDISuscrptionCheckoutSession, createCreateSuscriptionCheckoutSession, createCustomerPortalSession, createGetMoreCheckoutSession } from "../api/stripe/post";
|
|
@@ -162,6 +162,7 @@ export interface WashdayClientInstance {
|
|
|
162
162
|
getStoreImages: typeof getStoreImages;
|
|
163
163
|
getStoresByName: typeof getStoresByName;
|
|
164
164
|
getStoresByIdCustomersApp: typeof getStoresByIdCustomersApp;
|
|
165
|
+
getPickupScheduleCustomersApp: typeof getPickupScheduleCustomersApp;
|
|
165
166
|
createStore: typeof createStore;
|
|
166
167
|
copyStore: typeof copyStore;
|
|
167
168
|
updateStoreById: typeof updateStoreById;
|
|
@@ -175,6 +176,7 @@ export interface WashdayClientInstance {
|
|
|
175
176
|
};
|
|
176
177
|
products: {
|
|
177
178
|
getById: typeof productsEndpoints.getModule.getById;
|
|
179
|
+
getByIdCustomersApp: typeof productsEndpoints.getModule.getByIdCustomersApp;
|
|
178
180
|
create: typeof productsEndpoints.postModule.create;
|
|
179
181
|
createProductSupply: typeof productsEndpoints.postModule.createProductSupply;
|
|
180
182
|
bulkCreate: typeof productsEndpoints.postModule.bulkCreate;
|
package/src/interfaces/Store.ts
CHANGED
|
@@ -9,6 +9,11 @@ export interface ITimeSlot {
|
|
|
9
9
|
end: string; // Representing the end time in the same format as start
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export interface IPickupScheduleSlot {
|
|
13
|
+
fromTime: string;
|
|
14
|
+
toTime: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
// Define the Availability type for each day
|
|
13
18
|
export interface IAvailability {
|
|
14
19
|
monday: ITimeSlot[]; // Array of time slots for Monday
|
|
@@ -26,6 +31,8 @@ export interface ICustomersAppConfig {
|
|
|
26
31
|
notifyOrderRequestedByEmail: boolean,
|
|
27
32
|
notifyOrderRequestedByPushNotification: boolean,
|
|
28
33
|
requestedOrderNotificationEmails: string;
|
|
34
|
+
blockPickupScheduleOnOrderCreated?: boolean;
|
|
35
|
+
pickupScheduleCapacityPerSlot?: number;
|
|
29
36
|
availability: IAvailability; // Reference the IAvailability type
|
|
30
37
|
homeCards: {
|
|
31
38
|
type: 'redirect' | 'copyText' | 'openModal',
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getByIdCustomersApp } from "../src/api/products/get";
|
|
2
|
+
|
|
3
|
+
describe("getByIdCustomersApp", () => {
|
|
4
|
+
it("calls the customer-app product endpoint and unwraps the product payload", async () => {
|
|
5
|
+
const get = jest.fn().mockResolvedValue({
|
|
6
|
+
data: {
|
|
7
|
+
data: {
|
|
8
|
+
product: {
|
|
9
|
+
_id: "prod-1",
|
|
10
|
+
name: "Dry Clean Shirt",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
const client = {
|
|
16
|
+
apiToken: "customer-token",
|
|
17
|
+
axiosInstance: { get },
|
|
18
|
+
} as any;
|
|
19
|
+
|
|
20
|
+
const result = await getByIdCustomersApp.call(client, "prod-1");
|
|
21
|
+
|
|
22
|
+
expect(get).toHaveBeenCalledWith("api/v2/washdayapp/products/prod-1", {
|
|
23
|
+
headers: { Authorization: "Bearer customer-token" },
|
|
24
|
+
});
|
|
25
|
+
expect(result).toEqual({
|
|
26
|
+
_id: "prod-1",
|
|
27
|
+
name: "Dry Clean Shirt",
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|