washday-sdk 1.6.45 → 1.6.46
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/companies/get.js +15 -0
- package/dist/api/companies/put.js +15 -0
- package/dist/api/index.js +4 -2
- package/dist/interfaces/Company.garmentAttributeCatalogs.test.js +21 -0
- package/jest.config.cjs +1 -0
- package/package.json +1 -1
- package/src/api/companies/get.ts +14 -1
- package/src/api/companies/put.ts +21 -2
- package/src/api/index.ts +4 -2
- package/src/interfaces/Api.ts +4 -2
- package/src/interfaces/Company.garmentAttributeCatalogs.test.ts +34 -0
- package/src/interfaces/Company.ts +19 -0
- package/test/companies.getGarmentAttributeCatalogs.test.ts +20 -0
- package/test/companies.updateGarmentAttributeCatalogs.test.ts +29 -0
|
@@ -38,3 +38,18 @@ export const getCompanyOrdersMetrics = function () {
|
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
|
+
export const getGarmentAttributeCatalogs = function (companyId) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
try {
|
|
44
|
+
const config = {
|
|
45
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
46
|
+
};
|
|
47
|
+
const response = yield this.axiosInstance.get(`${GET_SET_COMPANIES}/${companyId}/garment-attribute-catalogs`, config);
|
|
48
|
+
return response;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.error('Error fetching getGarmentAttributeCatalogs:', error);
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
};
|
|
@@ -69,3 +69,18 @@ export const updateCompanySubscriptionBillingInfoById = function (companyId, dat
|
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
};
|
|
72
|
+
export const updateGarmentAttributeCatalogsById = function (companyId, data) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
try {
|
|
75
|
+
const config = {
|
|
76
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
77
|
+
};
|
|
78
|
+
const response = yield this.axiosInstance.patch(`${GET_SET_COMPANIES}/${companyId}/garment-attribute-catalogs`, data, config);
|
|
79
|
+
return response;
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
console.error('Error fetching updateGarmentAttributeCatalogsById:', error);
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
};
|
package/dist/api/index.js
CHANGED
|
@@ -2,9 +2,9 @@ import { deleteCashierBoxById, deleteCashierBoxMovementById } from "./cashierbox
|
|
|
2
2
|
import { getCashierBoxMovementsHistory, getCashierboxesById, getCashierboxesByStoreId } from "./cashierbox/get";
|
|
3
3
|
import { addCashierBoxMovement, createCashierBox } from "./cashierbox/post";
|
|
4
4
|
import { updateCashierBoxById, updateCashierBoxMovementById } from "./cashierbox/put";
|
|
5
|
-
import { getCompanyById, getCompanyOrdersMetrics } from "./companies/get";
|
|
5
|
+
import { getCompanyById, getCompanyOrdersMetrics, getGarmentAttributeCatalogs } from "./companies/get";
|
|
6
6
|
import { disableBillingOverage, enableBillingOverage, updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "./companies/post";
|
|
7
|
-
import { updateCompanyById, updateCompanyLogoById, updateCompanySubscriptionBillingInfoById, updateCompanyTaxInfoById } from "./companies/put";
|
|
7
|
+
import { updateCompanyById, updateCompanyLogoById, updateCompanySubscriptionBillingInfoById, updateCompanyTaxInfoById, updateGarmentAttributeCatalogsById } from "./companies/put";
|
|
8
8
|
import { getCountries } from "./countries/get";
|
|
9
9
|
import { getAutomaticDiscountById, getAutomaticDiscounts, getAvailableAutomaticDiscounts, getDiscountCodeById, getDiscountCodes, verifyDiscountCode, verifyDiscountCodeCustomersApp } from './discounts/get';
|
|
10
10
|
import { createAutomaticDiscount, createDiscountCode } from "./discounts/post";
|
|
@@ -256,10 +256,12 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD', clientId, c
|
|
|
256
256
|
this.companies = bindMethods(this, {
|
|
257
257
|
getCompanyById: getCompanyById,
|
|
258
258
|
getCompanyOrdersMetrics: getCompanyOrdersMetrics,
|
|
259
|
+
getGarmentAttributeCatalogs: getGarmentAttributeCatalogs,
|
|
259
260
|
updateCompanyById: updateCompanyById,
|
|
260
261
|
updateCompanyLogoById: updateCompanyLogoById,
|
|
261
262
|
updateCompanySubscriptionBillingInfoById: updateCompanySubscriptionBillingInfoById,
|
|
262
263
|
updateCompanyTaxInfoById: updateCompanyTaxInfoById,
|
|
264
|
+
updateGarmentAttributeCatalogsById: updateGarmentAttributeCatalogsById,
|
|
263
265
|
updateCompanyTaxInfoCertificates: updateCompanyTaxInfoCertificates,
|
|
264
266
|
updateCFDIOrgLogo: updateCFDIOrgLogo,
|
|
265
267
|
enableBillingOverage: enableBillingOverage,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const type = "brand";
|
|
2
|
+
const catalog = {
|
|
3
|
+
type,
|
|
4
|
+
values: ["Nike"],
|
|
5
|
+
};
|
|
6
|
+
const getResponse = {
|
|
7
|
+
garmentAttributeCatalogs: [catalog],
|
|
8
|
+
};
|
|
9
|
+
const updateRequest = {
|
|
10
|
+
garmentAttributeCatalogs: [catalog],
|
|
11
|
+
};
|
|
12
|
+
const updateResponse = {
|
|
13
|
+
garmentAttributeCatalogs: updateRequest.garmentAttributeCatalogs,
|
|
14
|
+
};
|
|
15
|
+
if (getResponse.garmentAttributeCatalogs[0].type !== "brand") {
|
|
16
|
+
throw new Error("Garment attribute catalog type export was not preserved");
|
|
17
|
+
}
|
|
18
|
+
if (updateResponse.garmentAttributeCatalogs[0].values[0] !== "Nike") {
|
|
19
|
+
throw new Error("Garment attribute catalog response export was not preserved");
|
|
20
|
+
}
|
|
21
|
+
export {};
|
package/jest.config.cjs
CHANGED
package/package.json
CHANGED
package/src/api/companies/get.ts
CHANGED
|
@@ -26,4 +26,17 @@ export const getCompanyOrdersMetrics = async function (this: WashdayClientInstan
|
|
|
26
26
|
console.error('Error fetching getCompanyOrdersMetrics:', error);
|
|
27
27
|
throw error;
|
|
28
28
|
}
|
|
29
|
-
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const getGarmentAttributeCatalogs = async function (this: WashdayClientInstance, companyId: string): Promise<any> {
|
|
32
|
+
try {
|
|
33
|
+
const config = {
|
|
34
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
35
|
+
};
|
|
36
|
+
const response = await this.axiosInstance.get(`${GET_SET_COMPANIES}/${companyId}/garment-attribute-catalogs`, config);
|
|
37
|
+
return response;
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error('Error fetching getGarmentAttributeCatalogs:', error);
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
};
|
package/src/api/companies/put.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
UpdateCompanySubscriptionBillingInfoPayload,
|
|
4
|
+
UpdateGarmentAttributeCatalogsRequest,
|
|
5
|
+
} from "../../interfaces/Company";
|
|
4
6
|
const GET_SET_COMPANIES = 'api/company';
|
|
5
7
|
|
|
6
8
|
export const updateCompanyById = async function (this: WashdayClientInstance, companyId: string, data: any): Promise<any> {
|
|
@@ -59,3 +61,20 @@ export const updateCompanySubscriptionBillingInfoById = async function (
|
|
|
59
61
|
throw error;
|
|
60
62
|
}
|
|
61
63
|
};
|
|
64
|
+
|
|
65
|
+
export const updateGarmentAttributeCatalogsById = async function (
|
|
66
|
+
this: WashdayClientInstance,
|
|
67
|
+
companyId: string,
|
|
68
|
+
data: UpdateGarmentAttributeCatalogsRequest,
|
|
69
|
+
): Promise<any> {
|
|
70
|
+
try {
|
|
71
|
+
const config = {
|
|
72
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
73
|
+
};
|
|
74
|
+
const response = await this.axiosInstance.patch(`${GET_SET_COMPANIES}/${companyId}/garment-attribute-catalogs`, data, config);
|
|
75
|
+
return response;
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.error('Error fetching updateGarmentAttributeCatalogsById:', error);
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
};
|
package/src/api/index.ts
CHANGED
|
@@ -3,9 +3,9 @@ import { deleteCashierBoxById, deleteCashierBoxMovementById } from "./cashierbox
|
|
|
3
3
|
import { getCashierBoxMovementsHistory, getCashierboxesById, getCashierboxesByStoreId } from "./cashierbox/get";
|
|
4
4
|
import { addCashierBoxMovement, createCashierBox } from "./cashierbox/post";
|
|
5
5
|
import { updateCashierBoxById, updateCashierBoxMovementById } from "./cashierbox/put";
|
|
6
|
-
import { getCompanyById, getCompanyOrdersMetrics } from "./companies/get";
|
|
6
|
+
import { getCompanyById, getCompanyOrdersMetrics, getGarmentAttributeCatalogs } from "./companies/get";
|
|
7
7
|
import { disableBillingOverage, enableBillingOverage, updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "./companies/post";
|
|
8
|
-
import { updateCompanyById, updateCompanyLogoById, updateCompanySubscriptionBillingInfoById, updateCompanyTaxInfoById } from "./companies/put";
|
|
8
|
+
import { updateCompanyById, updateCompanyLogoById, updateCompanySubscriptionBillingInfoById, updateCompanyTaxInfoById, updateGarmentAttributeCatalogsById } from "./companies/put";
|
|
9
9
|
import { getCountries } from "./countries/get";
|
|
10
10
|
import { getAutomaticDiscountById, getAutomaticDiscounts, getAvailableAutomaticDiscounts, getDiscountCodeById, getDiscountCodes, verifyDiscountCode, verifyDiscountCodeCustomersApp } from './discounts/get';
|
|
11
11
|
import { createAutomaticDiscount, createDiscountCode } from "./discounts/post";
|
|
@@ -263,10 +263,12 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
263
263
|
this.companies = bindMethods(this, {
|
|
264
264
|
getCompanyById: getCompanyById,
|
|
265
265
|
getCompanyOrdersMetrics: getCompanyOrdersMetrics,
|
|
266
|
+
getGarmentAttributeCatalogs: getGarmentAttributeCatalogs,
|
|
266
267
|
updateCompanyById: updateCompanyById,
|
|
267
268
|
updateCompanyLogoById: updateCompanyLogoById,
|
|
268
269
|
updateCompanySubscriptionBillingInfoById: updateCompanySubscriptionBillingInfoById,
|
|
269
270
|
updateCompanyTaxInfoById: updateCompanyTaxInfoById,
|
|
271
|
+
updateGarmentAttributeCatalogsById: updateGarmentAttributeCatalogsById,
|
|
270
272
|
updateCompanyTaxInfoCertificates: updateCompanyTaxInfoCertificates,
|
|
271
273
|
updateCFDIOrgLogo: updateCFDIOrgLogo,
|
|
272
274
|
enableBillingOverage: enableBillingOverage,
|
package/src/interfaces/Api.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { deleteCashierBoxById, deleteCashierBoxMovementById } from "../api/cashi
|
|
|
2
2
|
import { getCashierBoxMovementsHistory, getCashierboxesById, getCashierboxesByStoreId } from "../api/cashierbox/get";
|
|
3
3
|
import { addCashierBoxMovement, createCashierBox } from "../api/cashierbox/post";
|
|
4
4
|
import { updateCashierBoxById, updateCashierBoxMovementById } from "../api/cashierbox/put";
|
|
5
|
-
import { getCompanyById, getCompanyOrdersMetrics } from "../api/companies/get";
|
|
5
|
+
import { getCompanyById, getCompanyOrdersMetrics, getGarmentAttributeCatalogs } from "../api/companies/get";
|
|
6
6
|
import { disableBillingOverage, enableBillingOverage, updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "../api/companies/post";
|
|
7
|
-
import { updateCompanyById, updateCompanyLogoById, updateCompanySubscriptionBillingInfoById, updateCompanyTaxInfoById } from "../api/companies/put";
|
|
7
|
+
import { updateCompanyById, updateCompanyLogoById, updateCompanySubscriptionBillingInfoById, updateCompanyTaxInfoById, updateGarmentAttributeCatalogsById } from "../api/companies/put";
|
|
8
8
|
import { getCountries } from "../api/countries/get";
|
|
9
9
|
import { getAutomaticDiscountById, getAutomaticDiscounts, getAvailableAutomaticDiscounts, getDiscountCodeById, getDiscountCodes, verifyDiscountCode, verifyDiscountCodeCustomersApp } from '../api/discounts/get';
|
|
10
10
|
import { createAutomaticDiscount, createDiscountCode } from "../api/discounts/post";
|
|
@@ -248,10 +248,12 @@ export interface WashdayClientInstance {
|
|
|
248
248
|
companies: {
|
|
249
249
|
getCompanyById: typeof getCompanyById;
|
|
250
250
|
getCompanyOrdersMetrics: typeof getCompanyOrdersMetrics;
|
|
251
|
+
getGarmentAttributeCatalogs: typeof getGarmentAttributeCatalogs;
|
|
251
252
|
updateCompanyById: typeof updateCompanyById;
|
|
252
253
|
updateCompanyLogoById: typeof updateCompanyLogoById;
|
|
253
254
|
updateCompanySubscriptionBillingInfoById: typeof updateCompanySubscriptionBillingInfoById;
|
|
254
255
|
updateCompanyTaxInfoById: typeof updateCompanyTaxInfoById;
|
|
256
|
+
updateGarmentAttributeCatalogsById: typeof updateGarmentAttributeCatalogsById;
|
|
255
257
|
updateCompanyTaxInfoCertificates: typeof updateCompanyTaxInfoCertificates;
|
|
256
258
|
updateCFDIOrgLogo: typeof updateCFDIOrgLogo;
|
|
257
259
|
enableBillingOverage: typeof enableBillingOverage;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GarmentAttributeCatalog,
|
|
3
|
+
GarmentAttributeType,
|
|
4
|
+
GetGarmentAttributeCatalogsResponse,
|
|
5
|
+
UpdateGarmentAttributeCatalogsRequest,
|
|
6
|
+
UpdateGarmentAttributeCatalogsResponse,
|
|
7
|
+
} from "./Company";
|
|
8
|
+
|
|
9
|
+
const type: GarmentAttributeType = "brand";
|
|
10
|
+
|
|
11
|
+
const catalog: GarmentAttributeCatalog = {
|
|
12
|
+
type,
|
|
13
|
+
values: ["Nike"],
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const getResponse: GetGarmentAttributeCatalogsResponse = {
|
|
17
|
+
garmentAttributeCatalogs: [catalog],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const updateRequest: UpdateGarmentAttributeCatalogsRequest = {
|
|
21
|
+
garmentAttributeCatalogs: [catalog],
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const updateResponse: UpdateGarmentAttributeCatalogsResponse = {
|
|
25
|
+
garmentAttributeCatalogs: updateRequest.garmentAttributeCatalogs,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
if (getResponse.garmentAttributeCatalogs[0].type !== "brand") {
|
|
29
|
+
throw new Error("Garment attribute catalog type export was not preserved");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (updateResponse.garmentAttributeCatalogs[0].values[0] !== "Nike") {
|
|
33
|
+
throw new Error("Garment attribute catalog response export was not preserved");
|
|
34
|
+
}
|
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import { GlobalPaymentMethodCfdiSettings } from "./Cfdi";
|
|
2
2
|
|
|
3
|
+
export type GarmentAttributeType = "color" | "damage" | "stain" | "brand";
|
|
4
|
+
|
|
5
|
+
export interface GarmentAttributeCatalog {
|
|
6
|
+
type: GarmentAttributeType;
|
|
7
|
+
values: string[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface GetGarmentAttributeCatalogsResponse {
|
|
11
|
+
garmentAttributeCatalogs: GarmentAttributeCatalog[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface UpdateGarmentAttributeCatalogsRequest {
|
|
15
|
+
garmentAttributeCatalogs: GarmentAttributeCatalog[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface UpdateGarmentAttributeCatalogsResponse {
|
|
19
|
+
garmentAttributeCatalogs: GarmentAttributeCatalog[];
|
|
20
|
+
}
|
|
21
|
+
|
|
3
22
|
export interface ISubscriptionBillingInfo {
|
|
4
23
|
legalName: string;
|
|
5
24
|
rfc: string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getGarmentAttributeCatalogs } from "../src/api/companies/get";
|
|
2
|
+
|
|
3
|
+
describe("getGarmentAttributeCatalogs", () => {
|
|
4
|
+
it("calls the garment attribute catalogs endpoint with auth headers", async () => {
|
|
5
|
+
const get = jest.fn().mockResolvedValue({ data: { data: { garmentAttributeCatalogs: [] } } });
|
|
6
|
+
const client = {
|
|
7
|
+
apiToken: "token-1",
|
|
8
|
+
axiosInstance: { get },
|
|
9
|
+
} as any;
|
|
10
|
+
|
|
11
|
+
await getGarmentAttributeCatalogs.call(client, "company-1");
|
|
12
|
+
|
|
13
|
+
expect(get).toHaveBeenCalledWith(
|
|
14
|
+
"api/company/company-1/garment-attribute-catalogs",
|
|
15
|
+
{
|
|
16
|
+
headers: { Authorization: "Bearer token-1" },
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { updateGarmentAttributeCatalogsById } from "../src/api/companies/put";
|
|
2
|
+
|
|
3
|
+
describe("updateGarmentAttributeCatalogsById", () => {
|
|
4
|
+
it("sends a full replacement payload with PATCH and auth headers", async () => {
|
|
5
|
+
const patch = jest.fn().mockResolvedValue({ data: { data: { garmentAttributeCatalogs: [] } } });
|
|
6
|
+
const client = {
|
|
7
|
+
apiToken: "token-1",
|
|
8
|
+
axiosInstance: { patch },
|
|
9
|
+
} as any;
|
|
10
|
+
const payload = {
|
|
11
|
+
garmentAttributeCatalogs: [
|
|
12
|
+
{ type: "color", values: ["Rojo", "Azul"] },
|
|
13
|
+
{ type: "damage", values: ["Rasgado"] },
|
|
14
|
+
{ type: "stain", values: [] },
|
|
15
|
+
{ type: "brand", values: ["Nike"] },
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
await updateGarmentAttributeCatalogsById.call(client, "company-1", payload);
|
|
20
|
+
|
|
21
|
+
expect(patch).toHaveBeenCalledWith(
|
|
22
|
+
"api/company/company-1/garment-attribute-catalogs",
|
|
23
|
+
payload,
|
|
24
|
+
{
|
|
25
|
+
headers: { Authorization: "Bearer token-1" },
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
});
|