washday-sdk 1.6.53 → 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 +1 -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 +1 -0
- package/src/index.ts +1 -0
- package/src/interfaces/Api.ts +1 -0
- package/src/interfaces/Customer.ts +23 -0
- package/test/customers.updateAddressCustomersApp.test.ts +77 -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
|
@@ -176,6 +176,7 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD', clientId, c
|
|
|
176
176
|
deleteById: customersEndpoints.deleteModule.deleteById,
|
|
177
177
|
deleteByIdCustomersApp: customersEndpoints.deleteModule.deleteByIdCustomersApp,
|
|
178
178
|
updateByIdCustomersApp: customersEndpoints.putModule.updateByIdCustomersApp,
|
|
179
|
+
updateAddressCustomersApp: customersEndpoints.patchModule.updateAddressCustomersApp,
|
|
179
180
|
});
|
|
180
181
|
this.stores = bindMethods(this, {
|
|
181
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
|
@@ -183,6 +183,7 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
183
183
|
deleteById: customersEndpoints.deleteModule.deleteById,
|
|
184
184
|
deleteByIdCustomersApp: customersEndpoints.deleteModule.deleteByIdCustomersApp,
|
|
185
185
|
updateByIdCustomersApp: customersEndpoints.putModule.updateByIdCustomersApp,
|
|
186
|
+
updateAddressCustomersApp: customersEndpoints.patchModule.updateAddressCustomersApp,
|
|
186
187
|
});
|
|
187
188
|
this.stores = bindMethods(this, {
|
|
188
189
|
getStores: getStores,
|
package/src/index.ts
CHANGED
package/src/interfaces/Api.ts
CHANGED
|
@@ -168,6 +168,7 @@ export interface WashdayClientInstance {
|
|
|
168
168
|
deleteById: typeof customersEndpoints.deleteModule.deleteById;
|
|
169
169
|
deleteByIdCustomersApp: typeof customersEndpoints.deleteModule.deleteByIdCustomersApp;
|
|
170
170
|
updateByIdCustomersApp: typeof customersEndpoints.putModule.updateByIdCustomersApp;
|
|
171
|
+
updateAddressCustomersApp: typeof customersEndpoints.patchModule.updateAddressCustomersApp;
|
|
171
172
|
};
|
|
172
173
|
stores: {
|
|
173
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
|
+
});
|