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.
- package/dist/api/auth/get.js +22 -0
- package/dist/api/auth/index.js +1 -0
- package/dist/api/index.js +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/Auth.js +1 -0
- package/package.json +1 -1
- package/src/api/auth/get.ts +18 -0
- package/src/api/auth/index.ts +1 -0
- package/src/api/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/interfaces/Api.ts +1 -0
- package/src/interfaces/Auth.ts +9 -0
- package/test/auth.signupCountrySuggestionBinding.test.ts +44 -0
|
@@ -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
|
+
};
|
package/dist/api/auth/index.js
CHANGED
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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -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
|
+
};
|
package/src/api/auth/index.ts
CHANGED
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
package/src/interfaces/Api.ts
CHANGED
|
@@ -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
|
+
});
|