washday-sdk 1.6.45 → 1.6.47

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.
@@ -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
+ };
@@ -0,0 +1,28 @@
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_CONFIG = "api/config";
11
+ export const getTaxPresets = function (params) {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ try {
14
+ const config = Object.assign({ headers: { Authorization: `Bearer ${this.apiToken}` } }, ((params === null || params === void 0 ? void 0 : params.country)
15
+ ? {
16
+ params: {
17
+ country: params.country,
18
+ },
19
+ }
20
+ : {}));
21
+ return yield this.axiosInstance.get(`${GET_SET_CONFIG}/tax-presets`, config);
22
+ }
23
+ catch (error) {
24
+ console.error("Error fetching getTaxPresets:", error);
25
+ throw error;
26
+ }
27
+ });
28
+ };
@@ -0,0 +1 @@
1
+ export * as getModule from "./get";
package/dist/api/index.js CHANGED
@@ -2,10 +2,11 @@ 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
+ import * as configEndpoints from "./config";
9
10
  import { getAutomaticDiscountById, getAutomaticDiscounts, getAvailableAutomaticDiscounts, getDiscountCodeById, getDiscountCodes, verifyDiscountCode, verifyDiscountCodeCustomersApp } from './discounts/get';
10
11
  import { createAutomaticDiscount, createDiscountCode } from "./discounts/post";
11
12
  import { deleteAutomaticDiscountById, deleteDiscountCodeById, updateAutomaticDiscountById, updateDiscountCodeById } from "./discounts/put";
@@ -216,6 +217,9 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD', clientId, c
216
217
  this.countries = bindMethods(this, {
217
218
  getCountries: getCountries,
218
219
  });
220
+ this.config = bindMethods(this, {
221
+ getTaxPresets: configEndpoints.getModule.getTaxPresets,
222
+ });
219
223
  this.supplies = bindMethods(this, {
220
224
  getSupplies: getSupplies,
221
225
  getSupplyById: getSupplyById,
@@ -256,10 +260,12 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD', clientId, c
256
260
  this.companies = bindMethods(this, {
257
261
  getCompanyById: getCompanyById,
258
262
  getCompanyOrdersMetrics: getCompanyOrdersMetrics,
263
+ getGarmentAttributeCatalogs: getGarmentAttributeCatalogs,
259
264
  updateCompanyById: updateCompanyById,
260
265
  updateCompanyLogoById: updateCompanyLogoById,
261
266
  updateCompanySubscriptionBillingInfoById: updateCompanySubscriptionBillingInfoById,
262
267
  updateCompanyTaxInfoById: updateCompanyTaxInfoById,
268
+ updateGarmentAttributeCatalogsById: updateGarmentAttributeCatalogsById,
263
269
  updateCompanyTaxInfoCertificates: updateCompanyTaxInfoCertificates,
264
270
  updateCFDIOrgLogo: updateCFDIOrgLogo,
265
271
  enableBillingOverage: enableBillingOverage,
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as utils from './utils';
2
2
  import WashdayClient from './api';
3
3
  export * from './interfaces/Company';
4
+ export * from './interfaces/Config';
4
5
  export * from './interfaces/Cfdi';
5
6
  export { WashdayClient, utils };
@@ -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 {};
@@ -0,0 +1 @@
1
+ export {};
package/jest.config.cjs CHANGED
@@ -1,5 +1,6 @@
1
1
  module.exports = {
2
2
  testEnvironment: "node",
3
+ testMatch: ["<rootDir>/test/**/*.test.ts"],
3
4
  transform: {
4
5
  "^.+\\.(ts|tsx)$": [
5
6
  "babel-jest",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "1.6.45",
3
+ "version": "1.6.47",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -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
+ };
@@ -1,6 +1,8 @@
1
1
  import { WashdayClientInstance } from "../../interfaces/Api";
2
- import { UpdateCompanySubscriptionBillingInfoPayload } from "../../interfaces/Company";
3
- import axiosInstance from "../axiosInstance";
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
+ };
@@ -0,0 +1,26 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+
3
+ const GET_SET_CONFIG = "api/config";
4
+
5
+ export const getTaxPresets = async function (
6
+ this: WashdayClientInstance,
7
+ params?: { country?: string }
8
+ ): Promise<any> {
9
+ try {
10
+ const config = {
11
+ headers: { Authorization: `Bearer ${this.apiToken}` },
12
+ ...(params?.country
13
+ ? {
14
+ params: {
15
+ country: params.country,
16
+ },
17
+ }
18
+ : {}),
19
+ };
20
+
21
+ return await this.axiosInstance.get(`${GET_SET_CONFIG}/tax-presets`, config);
22
+ } catch (error) {
23
+ console.error("Error fetching getTaxPresets:", error);
24
+ throw error;
25
+ }
26
+ };
@@ -0,0 +1 @@
1
+ export * as getModule from "./get";
package/src/api/index.ts CHANGED
@@ -3,10 +3,11 @@ 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
+ import * as configEndpoints from "./config";
10
11
  import { getAutomaticDiscountById, getAutomaticDiscounts, getAvailableAutomaticDiscounts, getDiscountCodeById, getDiscountCodes, verifyDiscountCode, verifyDiscountCodeCustomersApp } from './discounts/get';
11
12
  import { createAutomaticDiscount, createDiscountCode } from "./discounts/post";
12
13
  import { deleteAutomaticDiscountById, deleteDiscountCodeById, updateAutomaticDiscountById, updateDiscountCodeById } from "./discounts/put";
@@ -223,6 +224,9 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
223
224
  this.countries = bindMethods(this, {
224
225
  getCountries: getCountries,
225
226
  });
227
+ this.config = bindMethods(this, {
228
+ getTaxPresets: configEndpoints.getModule.getTaxPresets,
229
+ });
226
230
  this.supplies = bindMethods(this, {
227
231
  getSupplies: getSupplies,
228
232
  getSupplyById: getSupplyById,
@@ -263,10 +267,12 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
263
267
  this.companies = bindMethods(this, {
264
268
  getCompanyById: getCompanyById,
265
269
  getCompanyOrdersMetrics: getCompanyOrdersMetrics,
270
+ getGarmentAttributeCatalogs: getGarmentAttributeCatalogs,
266
271
  updateCompanyById: updateCompanyById,
267
272
  updateCompanyLogoById: updateCompanyLogoById,
268
273
  updateCompanySubscriptionBillingInfoById: updateCompanySubscriptionBillingInfoById,
269
274
  updateCompanyTaxInfoById: updateCompanyTaxInfoById,
275
+ updateGarmentAttributeCatalogsById: updateGarmentAttributeCatalogsById,
270
276
  updateCompanyTaxInfoCertificates: updateCompanyTaxInfoCertificates,
271
277
  updateCFDIOrgLogo: updateCFDIOrgLogo,
272
278
  enableBillingOverage: enableBillingOverage,
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as utils from './utils';
2
2
  import WashdayClient from './api';
3
3
  export * from './interfaces/Company';
4
+ export * from './interfaces/Config';
4
5
  export * from './interfaces/Cfdi';
5
6
 
6
7
  export { WashdayClient, utils };
@@ -2,10 +2,11 @@ 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
+ import * as configEndpoints from "../api/config";
9
10
  import { getAutomaticDiscountById, getAutomaticDiscounts, getAvailableAutomaticDiscounts, getDiscountCodeById, getDiscountCodes, verifyDiscountCode, verifyDiscountCodeCustomersApp } from '../api/discounts/get';
10
11
  import { createAutomaticDiscount, createDiscountCode } from "../api/discounts/post";
11
12
  import { deleteAutomaticDiscountById, deleteDiscountCodeById, updateAutomaticDiscountById, updateDiscountCodeById } from "../api/discounts/put";
@@ -208,6 +209,9 @@ export interface WashdayClientInstance {
208
209
  countries: {
209
210
  getCountries: typeof getCountries;
210
211
  };
212
+ config: {
213
+ getTaxPresets: typeof configEndpoints.getModule.getTaxPresets;
214
+ };
211
215
  supplies: {
212
216
  getSupplies: typeof getSupplies;
213
217
  getSupplyById: typeof getSupplyById;
@@ -248,10 +252,12 @@ export interface WashdayClientInstance {
248
252
  companies: {
249
253
  getCompanyById: typeof getCompanyById;
250
254
  getCompanyOrdersMetrics: typeof getCompanyOrdersMetrics;
255
+ getGarmentAttributeCatalogs: typeof getGarmentAttributeCatalogs;
251
256
  updateCompanyById: typeof updateCompanyById;
252
257
  updateCompanyLogoById: typeof updateCompanyLogoById;
253
258
  updateCompanySubscriptionBillingInfoById: typeof updateCompanySubscriptionBillingInfoById;
254
259
  updateCompanyTaxInfoById: typeof updateCompanyTaxInfoById;
260
+ updateGarmentAttributeCatalogsById: typeof updateGarmentAttributeCatalogsById;
255
261
  updateCompanyTaxInfoCertificates: typeof updateCompanyTaxInfoCertificates;
256
262
  updateCFDIOrgLogo: typeof updateCFDIOrgLogo;
257
263
  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,14 @@
1
+ export type TaxPreset = {
2
+ country: string;
3
+ code: string;
4
+ label: string;
5
+ defaultRate: number;
6
+ description?: string;
7
+ isDefault?: boolean;
8
+ advanced?: boolean;
9
+ };
10
+
11
+ export type GetTaxPresetsResponse = {
12
+ country: string;
13
+ items: TaxPreset[];
14
+ };
@@ -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
+ });
@@ -0,0 +1,91 @@
1
+ import WashdayClient from "../src/api";
2
+ import { getTaxPresets } from "../src/api/config/get";
3
+
4
+ describe("getTaxPresets", () => {
5
+ it("calls the tax preset endpoint with MX", async () => {
6
+ const get = jest.fn().mockResolvedValue({
7
+ data: {
8
+ data: {
9
+ country: "MX",
10
+ items: [{ code: "IVA" }],
11
+ },
12
+ },
13
+ });
14
+ const client = {
15
+ apiToken: "token-1",
16
+ axiosInstance: { get },
17
+ } as any;
18
+
19
+ const result = await getTaxPresets.call(client, { country: "MX" });
20
+
21
+ expect(get).toHaveBeenCalledWith("api/config/tax-presets", {
22
+ headers: { Authorization: "Bearer token-1" },
23
+ params: { country: "MX" },
24
+ });
25
+ expect(result.data.data.country).toBe("MX");
26
+ });
27
+
28
+ it("calls the tax preset endpoint with PE", async () => {
29
+ const get = jest.fn().mockResolvedValue({
30
+ data: {
31
+ data: {
32
+ country: "PE",
33
+ items: [{ code: "IGV", defaultRate: 18 }],
34
+ },
35
+ },
36
+ });
37
+ const client = {
38
+ apiToken: "token-2",
39
+ axiosInstance: { get },
40
+ } as any;
41
+
42
+ const result = await getTaxPresets.call(client, { country: "PE" });
43
+
44
+ expect(get).toHaveBeenCalledWith("api/config/tax-presets", {
45
+ headers: { Authorization: "Bearer token-2" },
46
+ params: { country: "PE" },
47
+ });
48
+ expect(result.data.data.items[0].code).toBe("IGV");
49
+ });
50
+
51
+ it("calls the tax preset endpoint without params when country is missing", async () => {
52
+ const get = jest.fn().mockResolvedValue({
53
+ data: {
54
+ data: {
55
+ country: "MX",
56
+ items: [],
57
+ },
58
+ },
59
+ });
60
+ const client = {
61
+ apiToken: "token-3",
62
+ axiosInstance: { get },
63
+ } as any;
64
+
65
+ const result = await getTaxPresets.call(client);
66
+
67
+ expect(get).toHaveBeenCalledWith("api/config/tax-presets", {
68
+ headers: { Authorization: "Bearer token-3" },
69
+ });
70
+ expect(result.data.data.items).toEqual([]);
71
+ });
72
+
73
+ it("binds the config namespace on WashdayClient", async () => {
74
+ const client = new (WashdayClient as any)("token-4", "DEV");
75
+ client.axiosInstance.get = jest.fn().mockResolvedValue({
76
+ data: {
77
+ data: {
78
+ country: "MX",
79
+ items: [{ code: "IVA" }],
80
+ },
81
+ },
82
+ });
83
+
84
+ await client.config.getTaxPresets({ country: "MX" });
85
+
86
+ expect(client.axiosInstance.get).toHaveBeenCalledWith("api/config/tax-presets", {
87
+ headers: { Authorization: "Bearer token-4" },
88
+ params: { country: "MX" },
89
+ });
90
+ });
91
+ });