washday-sdk 1.6.47 → 1.6.48

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.
@@ -0,0 +1,22 @@
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 REGULAR_USER_AUTH = "api/auth";
11
+ export const getSignupCountrySuggestion = function () {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ try {
14
+ const config = {};
15
+ return yield this.axiosInstance.get(`${REGULAR_USER_AUTH}/signup-country-suggestion`, config);
16
+ }
17
+ catch (error) {
18
+ console.error("Error fetching getSignupCountrySuggestion:", error);
19
+ throw error;
20
+ }
21
+ });
22
+ };
@@ -1,3 +1,4 @@
1
+ export * as getModule from './get';
1
2
  // export * as deleteModule from './delete';
2
3
  export * as postModule from './post';
3
4
  // export * as putModule from './put';
package/dist/api/index.js CHANGED
@@ -124,6 +124,7 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD', clientId, c
124
124
  customersAppForgotPassword: authEndpoints.postModule.customersAppForgotPassword,
125
125
  customersAppChangePassword: authEndpoints.postModule.customersAppChangePassword,
126
126
  companySignUp: authEndpoints.postModule.companySignUp,
127
+ getSignupCountrySuggestion: authEndpoints.getModule.getSignupCountrySuggestion,
127
128
  });
128
129
  this.orders = bindMethods(this, {
129
130
  getList: ordersEndpoints.getModule.getList,
package/dist/index.js CHANGED
@@ -3,4 +3,5 @@ import WashdayClient from './api';
3
3
  export * from './interfaces/Company';
4
4
  export * from './interfaces/Config';
5
5
  export * from './interfaces/Cfdi';
6
+ export * from './interfaces/Auth';
6
7
  export { WashdayClient, utils };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "1.6.47",
3
+ "version": "1.6.48",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -0,0 +1,18 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+
3
+ const REGULAR_USER_AUTH = "api/auth";
4
+
5
+ export const getSignupCountrySuggestion = async function (
6
+ this: WashdayClientInstance,
7
+ ): Promise<any> {
8
+ try {
9
+ const config = {};
10
+ return await this.axiosInstance.get(
11
+ `${REGULAR_USER_AUTH}/signup-country-suggestion`,
12
+ config,
13
+ );
14
+ } catch (error) {
15
+ console.error("Error fetching getSignupCountrySuggestion:", error);
16
+ throw error;
17
+ }
18
+ };
@@ -1,3 +1,4 @@
1
+ export * as getModule from './get';
1
2
  // export * as deleteModule from './delete';
2
3
  export * as postModule from './post';
3
4
  // export * as putModule from './put';
package/src/api/index.ts CHANGED
@@ -131,6 +131,7 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
131
131
  customersAppForgotPassword: authEndpoints.postModule.customersAppForgotPassword,
132
132
  customersAppChangePassword: authEndpoints.postModule.customersAppChangePassword,
133
133
  companySignUp: authEndpoints.postModule.companySignUp,
134
+ getSignupCountrySuggestion: authEndpoints.getModule.getSignupCountrySuggestion,
134
135
  });
135
136
  this.orders = bindMethods(this, {
136
137
  getList: ordersEndpoints.getModule.getList,
package/src/index.ts CHANGED
@@ -3,5 +3,6 @@ import WashdayClient from './api';
3
3
  export * from './interfaces/Company';
4
4
  export * from './interfaces/Config';
5
5
  export * from './interfaces/Cfdi';
6
+ export * from './interfaces/Auth';
6
7
 
7
8
  export { WashdayClient, utils };
@@ -89,6 +89,7 @@ export interface WashdayClientInstance {
89
89
  customersAppForgotPassword: typeof authEndpoints.postModule.customersAppForgotPassword;
90
90
  customersAppChangePassword: typeof authEndpoints.postModule.customersAppChangePassword;
91
91
  companySignUp: typeof authEndpoints.postModule.companySignUp;
92
+ getSignupCountrySuggestion: typeof authEndpoints.getModule.getSignupCountrySuggestion;
92
93
  }
93
94
  review: {
94
95
  getList: typeof reviewsEndpoints.getModule.getList;
@@ -0,0 +1,9 @@
1
+ export type SignupCountryIso = "MX" | "PE";
2
+ export type SignupCountrySuggestionSource = "ip" | "fallback" | "unknown";
3
+ export type SignupCountrySuggestionConfidence = "medium" | "low";
4
+
5
+ export interface SignupCountrySuggestion {
6
+ countryIso: SignupCountryIso;
7
+ source: SignupCountrySuggestionSource;
8
+ confidence: SignupCountrySuggestionConfidence;
9
+ }
@@ -0,0 +1,44 @@
1
+ const mockGet = jest.fn().mockResolvedValue({
2
+ data: {
3
+ data: {
4
+ countryIso: "PE",
5
+ source: "ip",
6
+ confidence: "medium",
7
+ },
8
+ errors: null,
9
+ },
10
+ });
11
+
12
+ jest.mock("../src/api/axiosInstance", () => ({
13
+ __esModule: true,
14
+ getAxiosInstance: jest.fn(() => ({
15
+ get: mockGet,
16
+ interceptors: {
17
+ request: {
18
+ use: jest.fn(),
19
+ },
20
+ },
21
+ })),
22
+ }));
23
+
24
+ import WashdayClient from "../src/api";
25
+
26
+ describe("WashdayClient signup country suggestion binding", () => {
27
+ beforeEach(() => {
28
+ jest.clearAllMocks();
29
+ mockGet.mockClear();
30
+ });
31
+
32
+ it("binds auth.getSignupCountrySuggestion to the public GET endpoint", async () => {
33
+ const client = new (WashdayClient as any)("token-that-should-not-be-used");
34
+
35
+ const result = await client.auth.getSignupCountrySuggestion();
36
+
37
+ expect(mockGet).toHaveBeenCalledWith(
38
+ "api/auth/signup-country-suggestion",
39
+ {}
40
+ );
41
+ expect(result.data.data.countryIso).toBe("PE");
42
+ expect(result.data.errors).toBeNull();
43
+ });
44
+ });