washday-sdk 1.6.52 → 1.6.54
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/customers/index.js +1 -0
- package/dist/api/customers/patch.js +18 -0
- package/dist/api/index.js +2 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
- package/src/api/customers/index.ts +1 -0
- package/src/api/customers/patch.ts +21 -0
- package/src/api/index.ts +2 -0
- package/src/index.ts +1 -0
- package/src/interfaces/Api.ts +2 -0
- package/src/interfaces/Customer.ts +23 -0
- package/test/customers.updateAddressCustomersApp.test.ts +77 -0
- package/test/routes.multistore.test.ts +15 -0
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
const GET_SET_CUSTOMERS_APP = "api/v2/washdayapp/customers";
|
|
11
|
+
export const updateAddressCustomersApp = function (payload) {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
const config = {
|
|
14
|
+
headers: { Authorization: `Bearer ${this.apiToken}` },
|
|
15
|
+
};
|
|
16
|
+
return yield this.axiosInstance.patch(`${GET_SET_CUSTOMERS_APP}/me/address`, payload, config);
|
|
17
|
+
});
|
|
18
|
+
};
|
package/dist/api/index.js
CHANGED
|
@@ -102,6 +102,7 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD', clientId, c
|
|
|
102
102
|
closeRouteByIdV2: routesEndpoints.putModule.closeRouteByIdV2,
|
|
103
103
|
updateRouteById: routesEndpoints.putModule.updateRouteById,
|
|
104
104
|
getRoutesByDriver: routesEndpoints.getModule.getRoutesByDriver,
|
|
105
|
+
getRoutes: routesEndpoints.getModule.getRoutes,
|
|
105
106
|
startRoute: routesEndpoints.postModule.startRoute,
|
|
106
107
|
reorderRouteOrders: routesEndpoints.patchModule.reorderRouteOrders,
|
|
107
108
|
});
|
|
@@ -175,6 +176,7 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD', clientId, c
|
|
|
175
176
|
deleteById: customersEndpoints.deleteModule.deleteById,
|
|
176
177
|
deleteByIdCustomersApp: customersEndpoints.deleteModule.deleteByIdCustomersApp,
|
|
177
178
|
updateByIdCustomersApp: customersEndpoints.putModule.updateByIdCustomersApp,
|
|
179
|
+
updateAddressCustomersApp: customersEndpoints.patchModule.updateAddressCustomersApp,
|
|
178
180
|
});
|
|
179
181
|
this.stores = bindMethods(this, {
|
|
180
182
|
getStores: getStores,
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import {
|
|
3
|
+
UpdateCustomersAppCustomerAddressPayload,
|
|
4
|
+
UpdateCustomersAppCustomerAddressResponse,
|
|
5
|
+
} from "../../interfaces/Customer";
|
|
6
|
+
|
|
7
|
+
const GET_SET_CUSTOMERS_APP = "api/v2/washdayapp/customers";
|
|
8
|
+
|
|
9
|
+
export const updateAddressCustomersApp = async function (
|
|
10
|
+
this: WashdayClientInstance,
|
|
11
|
+
payload: UpdateCustomersAppCustomerAddressPayload
|
|
12
|
+
): Promise<UpdateCustomersAppCustomerAddressResponse> {
|
|
13
|
+
const config = {
|
|
14
|
+
headers: { Authorization: `Bearer ${this.apiToken}` },
|
|
15
|
+
};
|
|
16
|
+
return await this.axiosInstance.patch(
|
|
17
|
+
`${GET_SET_CUSTOMERS_APP}/me/address`,
|
|
18
|
+
payload,
|
|
19
|
+
config
|
|
20
|
+
);
|
|
21
|
+
};
|
package/src/api/index.ts
CHANGED
|
@@ -109,6 +109,7 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
109
109
|
closeRouteByIdV2: routesEndpoints.putModule.closeRouteByIdV2,
|
|
110
110
|
updateRouteById: routesEndpoints.putModule.updateRouteById,
|
|
111
111
|
getRoutesByDriver: routesEndpoints.getModule.getRoutesByDriver,
|
|
112
|
+
getRoutes: routesEndpoints.getModule.getRoutes,
|
|
112
113
|
startRoute: routesEndpoints.postModule.startRoute,
|
|
113
114
|
reorderRouteOrders: routesEndpoints.patchModule.reorderRouteOrders,
|
|
114
115
|
});
|
|
@@ -182,6 +183,7 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
182
183
|
deleteById: customersEndpoints.deleteModule.deleteById,
|
|
183
184
|
deleteByIdCustomersApp: customersEndpoints.deleteModule.deleteByIdCustomersApp,
|
|
184
185
|
updateByIdCustomersApp: customersEndpoints.putModule.updateByIdCustomersApp,
|
|
186
|
+
updateAddressCustomersApp: customersEndpoints.patchModule.updateAddressCustomersApp,
|
|
185
187
|
});
|
|
186
188
|
this.stores = bindMethods(this, {
|
|
187
189
|
getStores: getStores,
|
package/src/index.ts
CHANGED
package/src/interfaces/Api.ts
CHANGED
|
@@ -111,6 +111,7 @@ export interface WashdayClientInstance {
|
|
|
111
111
|
closeRouteByIdV2: typeof routesEndpoints.putModule.closeRouteByIdV2,
|
|
112
112
|
updateRouteById: typeof routesEndpoints.putModule.updateRouteById,
|
|
113
113
|
getRoutesByDriver: typeof routesEndpoints.getModule.getRoutesByDriver,
|
|
114
|
+
getRoutes: typeof routesEndpoints.getModule.getRoutes,
|
|
114
115
|
startRoute: typeof routesEndpoints.postModule.startRoute,
|
|
115
116
|
reorderRouteOrders: typeof routesEndpoints.patchModule.reorderRouteOrders,
|
|
116
117
|
},
|
|
@@ -167,6 +168,7 @@ export interface WashdayClientInstance {
|
|
|
167
168
|
deleteById: typeof customersEndpoints.deleteModule.deleteById;
|
|
168
169
|
deleteByIdCustomersApp: typeof customersEndpoints.deleteModule.deleteByIdCustomersApp;
|
|
169
170
|
updateByIdCustomersApp: typeof customersEndpoints.putModule.updateByIdCustomersApp;
|
|
171
|
+
updateAddressCustomersApp: typeof customersEndpoints.patchModule.updateAddressCustomersApp;
|
|
170
172
|
};
|
|
171
173
|
stores: {
|
|
172
174
|
getStores: typeof getStores;
|
|
@@ -18,17 +18,40 @@ interface IPaymentMethod {
|
|
|
18
18
|
export interface IAddress {
|
|
19
19
|
formattedAddress?: string; // A field to store the full address as a single string
|
|
20
20
|
street?: string;
|
|
21
|
+
number?: string;
|
|
21
22
|
neighborhood?: string;
|
|
22
23
|
postalCode?: string;
|
|
23
24
|
city?: string;
|
|
24
25
|
state?: string;
|
|
25
26
|
country?: string;
|
|
27
|
+
mapLocation?: IMapLocation;
|
|
28
|
+
// TODO: Legacy field. Use address.mapLocation instead.
|
|
29
|
+
// Kept temporarily for backward compatibility while old documents and active clients are migrated.
|
|
26
30
|
coordinates?: {
|
|
27
31
|
lat: number;
|
|
28
32
|
lng: number;
|
|
29
33
|
};
|
|
30
34
|
}
|
|
31
35
|
|
|
36
|
+
export type MapLocationSource = "manual" | "places" | "geocoded" | "imported";
|
|
37
|
+
|
|
38
|
+
export interface IMapLocation {
|
|
39
|
+
type: "Point";
|
|
40
|
+
coordinates: [number, number];
|
|
41
|
+
source?: MapLocationSource;
|
|
42
|
+
formattedAddress?: string;
|
|
43
|
+
placeId?: string;
|
|
44
|
+
updatedAt?: string | Date;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface UpdateCustomersAppCustomerAddressPayload {
|
|
48
|
+
address: IAddress;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface UpdateCustomersAppCustomerAddressResponse {
|
|
52
|
+
customer: ICustomer;
|
|
53
|
+
}
|
|
54
|
+
|
|
32
55
|
export interface ICustomer {
|
|
33
56
|
name: string,
|
|
34
57
|
phone: string,
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import WashdayClient from "../src/api";
|
|
2
|
+
import { updateAddressCustomersApp } from "../src/api/customers/patch";
|
|
3
|
+
import { UpdateCustomersAppCustomerAddressPayload } from "../src/interfaces/Customer";
|
|
4
|
+
|
|
5
|
+
const payload: UpdateCustomersAppCustomerAddressPayload = {
|
|
6
|
+
address: {
|
|
7
|
+
formattedAddress: "Calle 1, Merida",
|
|
8
|
+
street: "Calle 1",
|
|
9
|
+
number: "123",
|
|
10
|
+
neighborhood: "Centro",
|
|
11
|
+
city: "Merida",
|
|
12
|
+
state: "Yucatan",
|
|
13
|
+
postalCode: "97000",
|
|
14
|
+
country: "Mexico",
|
|
15
|
+
mapLocation: {
|
|
16
|
+
type: "Point",
|
|
17
|
+
coordinates: [-89.62, 20.97],
|
|
18
|
+
source: "places",
|
|
19
|
+
formattedAddress: "Calle 1, Merida",
|
|
20
|
+
placeId: "place-123",
|
|
21
|
+
updatedAt: "2026-05-18T12:00:00.000Z",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
describe("updateAddressCustomersApp", () => {
|
|
27
|
+
it("calls the authenticated Customers App address endpoint", async () => {
|
|
28
|
+
const patch = jest.fn().mockResolvedValue({
|
|
29
|
+
data: {
|
|
30
|
+
data: {
|
|
31
|
+
customer: {
|
|
32
|
+
_id: "customer-1",
|
|
33
|
+
address: payload.address,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
const client = {
|
|
39
|
+
apiToken: "customer-token",
|
|
40
|
+
axiosInstance: { patch },
|
|
41
|
+
} as any;
|
|
42
|
+
|
|
43
|
+
await updateAddressCustomersApp.call(client, payload);
|
|
44
|
+
|
|
45
|
+
expect(patch).toHaveBeenCalledWith(
|
|
46
|
+
"api/v2/washdayapp/customers/me/address",
|
|
47
|
+
payload,
|
|
48
|
+
{
|
|
49
|
+
headers: { Authorization: "Bearer customer-token" },
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("exposes updateAddressCustomersApp through wdClient.customers", async () => {
|
|
55
|
+
const client = new (WashdayClient as any)("customer-token", "DEV");
|
|
56
|
+
client.axiosInstance.patch = jest.fn().mockResolvedValue({
|
|
57
|
+
data: {
|
|
58
|
+
data: {
|
|
59
|
+
customer: {
|
|
60
|
+
_id: "customer-1",
|
|
61
|
+
address: payload.address,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
await client.customers.updateAddressCustomersApp(payload);
|
|
68
|
+
|
|
69
|
+
expect(client.axiosInstance.patch).toHaveBeenCalledWith(
|
|
70
|
+
"api/v2/washdayapp/customers/me/address",
|
|
71
|
+
payload,
|
|
72
|
+
{
|
|
73
|
+
headers: { Authorization: "Bearer customer-token" },
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getRoutes, getRoutesByDriver } from "../src/api/routes/get";
|
|
2
2
|
import { createRouteV2 } from "../src/api/routes/post";
|
|
3
|
+
import { WashdayClient } from "../src";
|
|
3
4
|
|
|
4
5
|
describe("routes multi-store api", () => {
|
|
5
6
|
it("creates multi-store routes through the root routes endpoint", async () => {
|
|
@@ -93,4 +94,18 @@ describe("routes multi-store api", () => {
|
|
|
93
94
|
}
|
|
94
95
|
);
|
|
95
96
|
});
|
|
97
|
+
|
|
98
|
+
it("exposes getRoutes through the WashdayClient routes module", async () => {
|
|
99
|
+
const get = jest.fn().mockResolvedValue({ data: { data: [] } });
|
|
100
|
+
const client = new WashdayClient("token-123", "DEV") as any;
|
|
101
|
+
client.axiosInstance = { get };
|
|
102
|
+
|
|
103
|
+
expect(typeof client.routes.getRoutes).toBe("function");
|
|
104
|
+
|
|
105
|
+
await client.routes.getRoutes({ scope: "company" });
|
|
106
|
+
|
|
107
|
+
expect(get).toHaveBeenCalledWith("api/routes?scope=company", {
|
|
108
|
+
headers: { Authorization: "Bearer token-123" },
|
|
109
|
+
});
|
|
110
|
+
});
|
|
96
111
|
});
|