@hapl/api-queries 0.1.70 → 0.1.74
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/CHANGELOG.md +50 -0
- package/dist/api-queries.cjs.development.js +80 -101
- package/dist/api-queries.cjs.development.js.map +1 -1
- package/dist/api-queries.cjs.production.min.js +1 -1
- package/dist/api-queries.cjs.production.min.js.map +1 -1
- package/dist/api-queries.esm.js +80 -101
- package/dist/api-queries.esm.js.map +1 -1
- package/dist/clients/v1/api/auth/checkPassword/index.d.ts +2 -6
- package/dist/clients/v1/api/auth/checkToken/index.d.ts +9 -7
- package/dist/clients/v1/api/auth/getPassword/index.d.ts +11 -7
- package/dist/clients/v1/api/availableFunds/createAvailableFunds/index.d.ts +16 -7
- package/dist/clients/v1/api/availableFunds/deleteAvailableFunds/index.d.ts +16 -7
- package/dist/clients/v1/api/availableFunds/findAvailableFunds/index.d.ts +12 -13
- package/dist/clients/v1/api/availableFunds/updateAvailableFunds/index.d.ts +16 -7
- package/dist/clients/v1/api/experts/findPublishedExperts/index.d.ts +14 -15
- package/package.json +1 -1
- package/src/clients/v1/api/auth/checkPassword/index.ts +4 -6
- package/src/clients/v1/api/auth/checkToken/index.ts +17 -15
- package/src/clients/v1/api/auth/getPassword/index.ts +22 -15
- package/src/clients/v1/api/availableFunds/createAvailableFunds/index.ts +17 -15
- package/src/clients/v1/api/availableFunds/deleteAvailableFunds/index.ts +21 -16
- package/src/clients/v1/api/availableFunds/findAvailableFunds/index.ts +27 -32
- package/src/clients/v1/api/availableFunds/updateAvailableFunds/index.ts +17 -16
- package/src/clients/v1/api/experts/findPublishedExperts/index.ts +27 -31
|
@@ -17,12 +17,8 @@ declare type ErrorData = {
|
|
|
17
17
|
error: string;
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
-
declare type ResultData =
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
declare type ResultError = {
|
|
24
|
-
result: ErrorData['data']['error'];
|
|
25
|
-
};
|
|
20
|
+
declare type ResultData = SuccessData['data'];
|
|
21
|
+
declare type ResultError = ErrorData['data']['error'];
|
|
26
22
|
export declare type CheckPasswordBody = {
|
|
27
23
|
phone: string;
|
|
28
24
|
password: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AxiosResponse, AxiosError } from 'axios';
|
|
1
2
|
import { User } from '../../../types';
|
|
2
3
|
declare type SuccessData = {
|
|
3
4
|
success: true;
|
|
@@ -10,16 +11,17 @@ declare type SuccessData = {
|
|
|
10
11
|
};
|
|
11
12
|
};
|
|
12
13
|
};
|
|
14
|
+
declare type ErrorData = {
|
|
15
|
+
success: false;
|
|
16
|
+
data: string;
|
|
17
|
+
};
|
|
18
|
+
declare type ResultData = SuccessData['data'];
|
|
19
|
+
declare type ResultError = ErrorData['data'];
|
|
13
20
|
export declare type CheckTokenHeaders = {
|
|
14
21
|
'x-auth-hc': string;
|
|
15
22
|
};
|
|
16
|
-
export declare type CheckTokenData =
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
export declare type CheckTokenError = {
|
|
20
|
-
status: number;
|
|
21
|
-
data: string;
|
|
22
|
-
};
|
|
23
|
+
export declare type CheckTokenData = AxiosResponse<ResultData>;
|
|
24
|
+
export declare type CheckTokenError = AxiosError<ResultError>;
|
|
23
25
|
export declare type CheckTokenConfig = {
|
|
24
26
|
baseURL?: string;
|
|
25
27
|
headers: CheckTokenHeaders;
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
+
import { AxiosResponse, AxiosError } from 'axios';
|
|
1
2
|
declare type SuccessData = {
|
|
2
3
|
success: true;
|
|
3
4
|
data: {
|
|
4
5
|
expiresAt: string;
|
|
5
6
|
};
|
|
6
7
|
};
|
|
8
|
+
declare type ErrorData = {
|
|
9
|
+
success: false;
|
|
10
|
+
data: {
|
|
11
|
+
error: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
declare type ResultData = SuccessData['data'];
|
|
15
|
+
declare type ResultError = ErrorData['data']['error'];
|
|
7
16
|
export declare type GetPasswordParams = {
|
|
8
17
|
phone: string;
|
|
9
18
|
};
|
|
10
|
-
export declare type GetPasswordData =
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
export declare type GetPasswordError = {
|
|
14
|
-
status: number;
|
|
15
|
-
data: string;
|
|
16
|
-
};
|
|
19
|
+
export declare type GetPasswordData = AxiosResponse<ResultData>;
|
|
20
|
+
export declare type GetPasswordError = AxiosError<ResultError>;
|
|
17
21
|
export declare type GetPasswordConfig = {
|
|
18
22
|
baseURL?: string;
|
|
19
23
|
params: GetPasswordParams;
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
+
import { AxiosResponse, AxiosError } from 'axios';
|
|
1
2
|
import { AvailableFunds, AvailableFundsIncomeType, AvailableFundsPaymentType, AvailableFundsCostType, AvailableFundsRealtyType } from '../../../types';
|
|
3
|
+
declare type SuccessData = {
|
|
4
|
+
success: true;
|
|
5
|
+
data: AvailableFunds;
|
|
6
|
+
};
|
|
7
|
+
declare type ErrorData = {
|
|
8
|
+
success: false;
|
|
9
|
+
data: {
|
|
10
|
+
error: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
declare type ResultData = SuccessData['data'];
|
|
14
|
+
declare type ResultError = ErrorData['data']['error'];
|
|
2
15
|
export declare type CreateAvailableFundsHeaders = {
|
|
3
16
|
'x-auth-hc': string;
|
|
4
17
|
};
|
|
@@ -11,16 +24,12 @@ export declare type CreateAvailableFundsBody = {
|
|
|
11
24
|
serviceRequestId: number;
|
|
12
25
|
comment?: string;
|
|
13
26
|
};
|
|
14
|
-
export declare type CreateAvailableFundsData =
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
export declare type CreateAvailableFundsError = {
|
|
18
|
-
status: number;
|
|
19
|
-
data: string;
|
|
20
|
-
};
|
|
27
|
+
export declare type CreateAvailableFundsData = AxiosResponse<ResultData>;
|
|
28
|
+
export declare type CreateAvailableFundsError = AxiosError<ResultError>;
|
|
21
29
|
export declare type CreateAvailableFundsConfig = {
|
|
22
30
|
baseURL?: string;
|
|
23
31
|
headers: CreateAvailableFundsHeaders;
|
|
24
32
|
body: CreateAvailableFundsBody;
|
|
25
33
|
};
|
|
26
34
|
export declare function createAvailableFundsRequest({ baseURL, body, headers, }: CreateAvailableFundsConfig): Promise<CreateAvailableFundsData>;
|
|
35
|
+
export {};
|
|
@@ -1,19 +1,28 @@
|
|
|
1
|
+
import { AxiosResponse, AxiosError } from 'axios';
|
|
2
|
+
declare type SuccessData = {
|
|
3
|
+
success: true;
|
|
4
|
+
data: string;
|
|
5
|
+
};
|
|
6
|
+
declare type ErrorData = {
|
|
7
|
+
success: false;
|
|
8
|
+
data: {
|
|
9
|
+
error: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
declare type ResultData = SuccessData['data'];
|
|
13
|
+
declare type ResultError = ErrorData['data']['error'];
|
|
1
14
|
export declare type DeleteAvailableFundsHeaders = {
|
|
2
15
|
'x-auth-hc': string;
|
|
3
16
|
};
|
|
4
17
|
export declare type DeleteAvailableFundsUrlParams = {
|
|
5
18
|
id: number;
|
|
6
19
|
};
|
|
7
|
-
export declare type DeleteAvailableFundsData =
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
export declare type DeleteAvailableFundsError = {
|
|
11
|
-
status: number;
|
|
12
|
-
data: string;
|
|
13
|
-
};
|
|
20
|
+
export declare type DeleteAvailableFundsData = AxiosResponse<ResultData>;
|
|
21
|
+
export declare type DeleteAvailableFundsError = AxiosError<ResultError>;
|
|
14
22
|
export declare type DeleteAvailableFundsConfig = {
|
|
15
23
|
baseURL?: string;
|
|
16
24
|
urlParams: DeleteAvailableFundsUrlParams;
|
|
17
25
|
headers: DeleteAvailableFundsHeaders;
|
|
18
26
|
};
|
|
19
27
|
export declare function deleteAvailableFundsRequest({ baseURL, urlParams, headers, }: DeleteAvailableFundsConfig): Promise<DeleteAvailableFundsData>;
|
|
28
|
+
export {};
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
import { AxiosResponse, AxiosError } from 'axios';
|
|
1
2
|
import { AvailableFunds } from '../../../types';
|
|
3
|
+
declare type ResultData = {
|
|
4
|
+
ids: number[];
|
|
5
|
+
byId: Record<string, AvailableFunds>;
|
|
6
|
+
meta: {
|
|
7
|
+
total: number;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
declare type ResultError = string;
|
|
2
11
|
export declare type FindAvailableFundsHeaders = {
|
|
3
12
|
'x-auth-hc': string;
|
|
4
13
|
};
|
|
@@ -17,22 +26,12 @@ export declare type FindAvailableFundsParams = {
|
|
|
17
26
|
type: 'createdAt' | 'id' | 'receivedAt' | 'serviceRequest';
|
|
18
27
|
};
|
|
19
28
|
};
|
|
20
|
-
export declare type FindAvailableFundsData =
|
|
21
|
-
|
|
22
|
-
ids: number[];
|
|
23
|
-
byId: Record<string, AvailableFunds>;
|
|
24
|
-
};
|
|
25
|
-
meta: {
|
|
26
|
-
total: number;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
export declare type FindAvailableFundsError = {
|
|
30
|
-
status: number;
|
|
31
|
-
data: string;
|
|
32
|
-
};
|
|
29
|
+
export declare type FindAvailableFundsData = AxiosResponse<ResultData>;
|
|
30
|
+
export declare type FindAvailableFundsError = AxiosError<ResultError>;
|
|
33
31
|
export declare type FindAvailableFundsConfig = {
|
|
34
32
|
baseURL?: string;
|
|
35
33
|
headers: FindAvailableFundsHeaders;
|
|
36
34
|
params: FindAvailableFundsParams;
|
|
37
35
|
};
|
|
38
36
|
export declare function findAvailableFundsRequest({ baseURL, headers, params, }: FindAvailableFundsConfig): Promise<FindAvailableFundsData>;
|
|
37
|
+
export {};
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
+
import { AxiosResponse, AxiosError } from 'axios';
|
|
1
2
|
import { AvailableFunds, AvailableFundsIncomeType, AvailableFundsPaymentType, AvailableFundsCostType, AvailableFundsRealtyType } from '../../../types';
|
|
3
|
+
declare type SuccessData = {
|
|
4
|
+
success: true;
|
|
5
|
+
data: AvailableFunds;
|
|
6
|
+
};
|
|
7
|
+
declare type ErrorData = {
|
|
8
|
+
success: false;
|
|
9
|
+
data: {
|
|
10
|
+
error: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
declare type ResultData = SuccessData['data'];
|
|
14
|
+
declare type ResultError = ErrorData['data']['error'];
|
|
2
15
|
export declare type UpdateAvailableFundsUrlParams = {
|
|
3
16
|
id: number;
|
|
4
17
|
};
|
|
@@ -12,13 +25,8 @@ export declare type UpdateAvailableFundsBody = {
|
|
|
12
25
|
realtyType?: AvailableFundsRealtyType;
|
|
13
26
|
comment?: string;
|
|
14
27
|
};
|
|
15
|
-
export declare type UpdateAvailableFundsData =
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
export declare type UpdateAvailableFundsError = {
|
|
19
|
-
status: number;
|
|
20
|
-
data: string;
|
|
21
|
-
};
|
|
28
|
+
export declare type UpdateAvailableFundsData = AxiosResponse<ResultData>;
|
|
29
|
+
export declare type UpdateAvailableFundsError = AxiosError<ResultError>;
|
|
22
30
|
export declare type UpdateAvailableFundsConfig = {
|
|
23
31
|
baseURL?: string;
|
|
24
32
|
urlParams: UpdateAvailableFundsUrlParams;
|
|
@@ -26,3 +34,4 @@ export declare type UpdateAvailableFundsConfig = {
|
|
|
26
34
|
body: UpdateAvailableFundsBody;
|
|
27
35
|
};
|
|
28
36
|
export declare function updateAvailableFundsRequest({ baseURL, urlParams, body, headers, }: UpdateAvailableFundsConfig): Promise<UpdateAvailableFundsData>;
|
|
37
|
+
export {};
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
+
import { AxiosResponse, AxiosError } from 'axios';
|
|
1
2
|
import { User, UserDirection, UserOffice } from '../../../types';
|
|
3
|
+
declare type ResultData = {
|
|
4
|
+
ids: number[];
|
|
5
|
+
byId: Record<string, Partial<User> & {
|
|
6
|
+
id: number;
|
|
7
|
+
}>;
|
|
8
|
+
meta: {
|
|
9
|
+
total: number;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
declare type ResultError = string;
|
|
2
13
|
export declare type FindPublishedExpertsParams = {
|
|
3
14
|
filter?: {
|
|
4
15
|
id?: number | number[];
|
|
@@ -15,23 +26,11 @@ export declare type FindPublishedExpertsParams = {
|
|
|
15
26
|
type: 'id' | 'expert.scoring';
|
|
16
27
|
};
|
|
17
28
|
};
|
|
18
|
-
export declare type FindPublishedExpertsData =
|
|
19
|
-
|
|
20
|
-
ids: number[];
|
|
21
|
-
byId: Record<string, Partial<User> & {
|
|
22
|
-
id: number;
|
|
23
|
-
}>;
|
|
24
|
-
};
|
|
25
|
-
meta: {
|
|
26
|
-
total: number;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
export declare type FindPublishedExpertsError = {
|
|
30
|
-
status: number;
|
|
31
|
-
data: string;
|
|
32
|
-
};
|
|
29
|
+
export declare type FindPublishedExpertsData = AxiosResponse<ResultData>;
|
|
30
|
+
export declare type FindPublishedExpertsError = AxiosError<ResultError>;
|
|
33
31
|
export declare type FindPublishedExpertsConfig = {
|
|
34
32
|
baseURL?: string;
|
|
35
33
|
params: FindPublishedExpertsParams;
|
|
36
34
|
};
|
|
37
35
|
export declare function findPublishedExpertsRequest({ baseURL, params, }: FindPublishedExpertsConfig): Promise<FindPublishedExpertsData>;
|
|
36
|
+
export {};
|
package/package.json
CHANGED
|
@@ -7,8 +7,8 @@ type SuccessData = {
|
|
|
7
7
|
};
|
|
8
8
|
type ErrorData = { success: false; data: { error: string } };
|
|
9
9
|
|
|
10
|
-
type ResultData =
|
|
11
|
-
type ResultError =
|
|
10
|
+
type ResultData = SuccessData['data'];
|
|
11
|
+
type ResultError = ErrorData['data']['error'];
|
|
12
12
|
|
|
13
13
|
export type CheckPasswordBody = { phone: string; password: string };
|
|
14
14
|
export type CheckPasswordData = AxiosResponse<ResultData>;
|
|
@@ -23,11 +23,9 @@ export function checkPasswordRequest({ baseURL = 'https://clients.homeapp.ru', b
|
|
|
23
23
|
transformResponse: [
|
|
24
24
|
...(axios.defaults.transformResponse as AxiosTransformer[]),
|
|
25
25
|
(data: SuccessData | ErrorData): ResultData | ResultError => {
|
|
26
|
-
if (data.success)
|
|
27
|
-
return { result: data.data };
|
|
28
|
-
}
|
|
26
|
+
if (data.success) return data.data;
|
|
29
27
|
|
|
30
|
-
return
|
|
28
|
+
return data.data.error;
|
|
31
29
|
},
|
|
32
30
|
],
|
|
33
31
|
})
|
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
import axios, { AxiosResponse, AxiosError } from 'axios';
|
|
1
|
+
import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
|
|
2
2
|
import { User } from '../../../types';
|
|
3
3
|
|
|
4
4
|
type SuccessData = {
|
|
5
5
|
success: true;
|
|
6
6
|
data: { createdAt: string; expiresAt: string; key: string; user: Partial<User> & { id: number } };
|
|
7
7
|
};
|
|
8
|
-
|
|
9
8
|
type ErrorData = { success: false; data: string };
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export type CheckTokenData = { data: SuccessData['data'] };
|
|
14
|
-
|
|
15
|
-
export type CheckTokenError = { status: number; data: string };
|
|
10
|
+
type ResultData = SuccessData['data'];
|
|
11
|
+
type ResultError = ErrorData['data'];
|
|
16
12
|
|
|
13
|
+
export type CheckTokenHeaders = { 'x-auth-hc': string };
|
|
14
|
+
export type CheckTokenData = AxiosResponse<ResultData>;
|
|
15
|
+
export type CheckTokenError = AxiosError<ResultError>;
|
|
17
16
|
export type CheckTokenConfig = { baseURL?: string; headers: CheckTokenHeaders };
|
|
18
17
|
|
|
19
18
|
export function checkTokenRequest({ baseURL = 'https://clients.homeapp.ru', headers }: CheckTokenConfig) {
|
|
20
19
|
return axios
|
|
21
|
-
.get('/api/user/auth/session', {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
.get('/api/user/auth/session', {
|
|
21
|
+
baseURL,
|
|
22
|
+
headers: { Accept: 'application/json', ...headers },
|
|
23
|
+
transformResponse: [
|
|
24
|
+
...(axios.defaults.transformResponse as AxiosTransformer[]),
|
|
25
|
+
(data: SuccessData | ErrorData): ResultData | ResultError => data.data,
|
|
26
|
+
],
|
|
27
|
+
})
|
|
28
|
+
.then((res: CheckTokenData): CheckTokenData => res)
|
|
29
|
+
.catch((err: CheckTokenError) => {
|
|
30
|
+
throw err;
|
|
29
31
|
});
|
|
30
32
|
}
|
|
@@ -1,26 +1,33 @@
|
|
|
1
|
-
import axios, { AxiosResponse, AxiosError } from 'axios';
|
|
1
|
+
import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
|
|
2
2
|
|
|
3
3
|
type SuccessData = { success: true; data: { expiresAt: string } };
|
|
4
|
-
|
|
5
4
|
type ErrorData = { success: false; data: { error: string } };
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export type GetPasswordData = { data: SuccessData['data'] };
|
|
10
|
-
|
|
11
|
-
export type GetPasswordError = { status: number; data: string };
|
|
6
|
+
type ResultData = SuccessData['data'];
|
|
7
|
+
type ResultError = ErrorData['data']['error'];
|
|
12
8
|
|
|
9
|
+
export type GetPasswordParams = { phone: string };
|
|
10
|
+
export type GetPasswordData = AxiosResponse<ResultData>;
|
|
11
|
+
export type GetPasswordError = AxiosError<ResultError>;
|
|
13
12
|
export type GetPasswordConfig = { baseURL?: string; params: GetPasswordParams };
|
|
14
13
|
|
|
15
14
|
export function getPasswordRequest({ baseURL = 'https://clients.homeapp.ru', params }: GetPasswordConfig) {
|
|
16
15
|
return axios
|
|
17
|
-
.get('/api/user/auth/get-pass', {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
.get('/api/user/auth/get-pass', {
|
|
17
|
+
baseURL,
|
|
18
|
+
params,
|
|
19
|
+
headers: { Accept: 'application/json' },
|
|
20
|
+
transformResponse: [
|
|
21
|
+
...(axios.defaults.transformResponse as AxiosTransformer[]),
|
|
22
|
+
(data: SuccessData | ErrorData): ResultData | ResultError => {
|
|
23
|
+
if (data.success) return data.data;
|
|
24
|
+
|
|
25
|
+
return data.data.error;
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
})
|
|
29
|
+
.then((res: GetPasswordData) => res)
|
|
30
|
+
.catch((err: GetPasswordError) => {
|
|
31
|
+
throw err;
|
|
25
32
|
});
|
|
26
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import axios, { AxiosResponse, AxiosError } from 'axios';
|
|
1
|
+
import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
|
|
2
2
|
import {
|
|
3
3
|
AvailableFunds,
|
|
4
4
|
AvailableFundsIncomeType,
|
|
@@ -8,11 +8,12 @@ import {
|
|
|
8
8
|
} from '../../../types';
|
|
9
9
|
|
|
10
10
|
type SuccessData = { success: true; data: AvailableFunds };
|
|
11
|
-
|
|
12
11
|
type ErrorData = { success: false; data: { error: string } };
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
type ResultData = SuccessData['data'];
|
|
14
|
+
type ResultError = ErrorData['data']['error'];
|
|
15
15
|
|
|
16
|
+
export type CreateAvailableFundsHeaders = { 'x-auth-hc': string };
|
|
16
17
|
export type CreateAvailableFundsBody = {
|
|
17
18
|
amount: number;
|
|
18
19
|
incomeType: AvailableFundsIncomeType;
|
|
@@ -22,11 +23,8 @@ export type CreateAvailableFundsBody = {
|
|
|
22
23
|
serviceRequestId: number;
|
|
23
24
|
comment?: string;
|
|
24
25
|
};
|
|
25
|
-
|
|
26
|
-
export type
|
|
27
|
-
|
|
28
|
-
export type CreateAvailableFundsError = { status: number; data: string };
|
|
29
|
-
|
|
26
|
+
export type CreateAvailableFundsData = AxiosResponse<ResultData>;
|
|
27
|
+
export type CreateAvailableFundsError = AxiosError<ResultError>;
|
|
30
28
|
export type CreateAvailableFundsConfig = {
|
|
31
29
|
baseURL?: string;
|
|
32
30
|
headers: CreateAvailableFundsHeaders;
|
|
@@ -42,13 +40,17 @@ export function createAvailableFundsRequest({
|
|
|
42
40
|
.post('/api/available-funds', body, {
|
|
43
41
|
baseURL,
|
|
44
42
|
headers: { Accept: 'application/json', 'Content-Type': 'application/json', ...headers },
|
|
43
|
+
transformResponse: [
|
|
44
|
+
...(axios.defaults.transformResponse as AxiosTransformer[]),
|
|
45
|
+
(data: SuccessData | ErrorData): ResultData | ResultError => {
|
|
46
|
+
if (data.success) return data.data;
|
|
47
|
+
|
|
48
|
+
return data.data.error;
|
|
49
|
+
},
|
|
50
|
+
],
|
|
45
51
|
})
|
|
46
|
-
.then((res:
|
|
47
|
-
.catch((err:
|
|
48
|
-
|
|
49
|
-
error.status = err.response?.status ?? 520;
|
|
50
|
-
error.data = err.response?.data.data.error ?? 'Unknown Error';
|
|
51
|
-
|
|
52
|
-
throw error;
|
|
52
|
+
.then((res: CreateAvailableFundsData) => res)
|
|
53
|
+
.catch((err: CreateAvailableFundsError) => {
|
|
54
|
+
throw err;
|
|
53
55
|
});
|
|
54
56
|
}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import axios, { AxiosResponse, AxiosError } from 'axios';
|
|
1
|
+
import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
|
|
2
2
|
|
|
3
3
|
type SuccessData = { success: true; data: string };
|
|
4
|
-
|
|
5
4
|
type ErrorData = { success: false; data: { error: string } };
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
type ResultData = SuccessData['data'];
|
|
7
|
+
type ResultError = ErrorData['data']['error'];
|
|
8
8
|
|
|
9
|
+
export type DeleteAvailableFundsHeaders = { 'x-auth-hc': string };
|
|
9
10
|
export type DeleteAvailableFundsUrlParams = { id: number };
|
|
10
|
-
|
|
11
|
-
export type
|
|
12
|
-
|
|
13
|
-
export type DeleteAvailableFundsError = { status: number; data: string };
|
|
14
|
-
|
|
11
|
+
export type DeleteAvailableFundsData = AxiosResponse<ResultData>;
|
|
12
|
+
export type DeleteAvailableFundsError = AxiosError<ResultError>;
|
|
15
13
|
export type DeleteAvailableFundsConfig = {
|
|
16
14
|
baseURL?: string;
|
|
17
15
|
urlParams: DeleteAvailableFundsUrlParams;
|
|
@@ -24,13 +22,20 @@ export function deleteAvailableFundsRequest({
|
|
|
24
22
|
headers,
|
|
25
23
|
}: DeleteAvailableFundsConfig) {
|
|
26
24
|
return axios
|
|
27
|
-
.delete('/api/available-funds/' + urlParams.id, {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
.delete('/api/available-funds/' + urlParams.id, {
|
|
26
|
+
baseURL,
|
|
27
|
+
headers: { Accept: 'application/json', ...headers },
|
|
28
|
+
transformResponse: [
|
|
29
|
+
...(axios.defaults.transformResponse as AxiosTransformer[]),
|
|
30
|
+
(data: SuccessData | ErrorData): ResultData | ResultError => {
|
|
31
|
+
if (data.success) return data.data;
|
|
32
|
+
|
|
33
|
+
return data.data.error;
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
})
|
|
37
|
+
.then((res: DeleteAvailableFundsData) => res)
|
|
38
|
+
.catch((err: DeleteAvailableFundsError) => {
|
|
39
|
+
throw err;
|
|
35
40
|
});
|
|
36
41
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import axios, { AxiosResponse, AxiosError } from 'axios';
|
|
1
|
+
import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
|
|
2
2
|
import qs from 'qs';
|
|
3
3
|
import { AvailableFunds } from '../../../types';
|
|
4
4
|
|
|
5
5
|
type SuccessData = { success: true; data: AvailableFunds[]; pageParams: { page: number; length: number } };
|
|
6
|
+
type ErrorData = { success: false; data: Record<'error' | 'message', string> };
|
|
6
7
|
|
|
7
|
-
type
|
|
8
|
+
type ResultData = { ids: number[]; byId: Record<string, AvailableFunds>; meta: { total: number } };
|
|
9
|
+
type ResultError = string;
|
|
8
10
|
|
|
9
11
|
export type FindAvailableFundsHeaders = { 'x-auth-hc': string };
|
|
10
|
-
|
|
11
12
|
export type FindAvailableFundsParams = {
|
|
12
13
|
filter?: {
|
|
13
14
|
'serviceRequest.contract.formalId'?: number | number[];
|
|
@@ -17,14 +18,8 @@ export type FindAvailableFundsParams = {
|
|
|
17
18
|
limits?: { page: number; count: number };
|
|
18
19
|
sorting?: { direction: 'asc' | 'desc'; type: 'createdAt' | 'id' | 'receivedAt' | 'serviceRequest' };
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
-
export type
|
|
22
|
-
data: { ids: number[]; byId: Record<string, AvailableFunds> };
|
|
23
|
-
meta: { total: number };
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type FindAvailableFundsError = { status: number; data: string };
|
|
27
|
-
|
|
21
|
+
export type FindAvailableFundsData = AxiosResponse<ResultData>;
|
|
22
|
+
export type FindAvailableFundsError = AxiosError<ResultError>;
|
|
28
23
|
export type FindAvailableFundsConfig = {
|
|
29
24
|
baseURL?: string;
|
|
30
25
|
headers: FindAvailableFundsHeaders;
|
|
@@ -42,27 +37,27 @@ export function findAvailableFundsRequest({
|
|
|
42
37
|
params,
|
|
43
38
|
paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
|
|
44
39
|
headers: { Accept: 'application/json', ...headers },
|
|
40
|
+
transformResponse: [
|
|
41
|
+
...(axios.defaults.transformResponse as AxiosTransformer[]),
|
|
42
|
+
(data: SuccessData | ErrorData): ResultData | ResultError => {
|
|
43
|
+
if (data.success) {
|
|
44
|
+
const ids: ResultData['ids'] = [];
|
|
45
|
+
const byId: ResultData['byId'] = {};
|
|
46
|
+
|
|
47
|
+
data.data.forEach(entity => {
|
|
48
|
+
byId[entity.id] = entity;
|
|
49
|
+
ids.push(entity.id);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return { ids, byId, meta: { total: data.pageParams.length } };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return data.data.error || data.data.message;
|
|
56
|
+
},
|
|
57
|
+
],
|
|
45
58
|
})
|
|
46
|
-
.then(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
data: { byId: {}, ids: [] },
|
|
50
|
-
meta: { total: res.data.pageParams.length },
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
res.data.data.forEach(entity => {
|
|
54
|
-
data.data.byId[entity.id] = entity;
|
|
55
|
-
data.data.ids.push(entity.id);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
return data;
|
|
59
|
-
}
|
|
60
|
-
)
|
|
61
|
-
.catch((err: AxiosError<ErrorData>) => {
|
|
62
|
-
const error: Error & Partial<FindAvailableFundsError> = new Error(err.message);
|
|
63
|
-
error.status = err.response?.status ?? 520;
|
|
64
|
-
error.data = err.response?.data.data.message ?? err.response?.data.data.error ?? 'Unknown Error';
|
|
65
|
-
|
|
66
|
-
throw error;
|
|
59
|
+
.then((res: FindAvailableFundsData) => res)
|
|
60
|
+
.catch((err: FindAvailableFundsError) => {
|
|
61
|
+
throw err;
|
|
67
62
|
});
|
|
68
63
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import axios, { AxiosResponse, AxiosError } from 'axios';
|
|
1
|
+
import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
AvailableFunds,
|
|
@@ -9,13 +9,13 @@ import {
|
|
|
9
9
|
} from '../../../types';
|
|
10
10
|
|
|
11
11
|
type SuccessData = { success: true; data: AvailableFunds };
|
|
12
|
-
|
|
13
12
|
type ErrorData = { success: false; data: { error: string } };
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
type ResultData = SuccessData['data'];
|
|
15
|
+
type ResultError = ErrorData['data']['error'];
|
|
16
16
|
|
|
17
|
+
export type UpdateAvailableFundsUrlParams = { id: number };
|
|
17
18
|
export type UpdateAvailableFundsHeaders = { 'x-auth-hc': string };
|
|
18
|
-
|
|
19
19
|
export type UpdateAvailableFundsBody = {
|
|
20
20
|
amount?: number;
|
|
21
21
|
incomeType?: AvailableFundsIncomeType;
|
|
@@ -23,11 +23,8 @@ export type UpdateAvailableFundsBody = {
|
|
|
23
23
|
realtyType?: AvailableFundsRealtyType;
|
|
24
24
|
comment?: string;
|
|
25
25
|
};
|
|
26
|
-
|
|
27
|
-
export type
|
|
28
|
-
|
|
29
|
-
export type UpdateAvailableFundsError = { status: number; data: string };
|
|
30
|
-
|
|
26
|
+
export type UpdateAvailableFundsData = AxiosResponse<ResultData>;
|
|
27
|
+
export type UpdateAvailableFundsError = AxiosError<ResultError>;
|
|
31
28
|
export type UpdateAvailableFundsConfig = {
|
|
32
29
|
baseURL?: string;
|
|
33
30
|
urlParams: UpdateAvailableFundsUrlParams;
|
|
@@ -45,13 +42,17 @@ export function updateAvailableFundsRequest({
|
|
|
45
42
|
.patch('/api/available-funds/' + urlParams.id, body, {
|
|
46
43
|
baseURL,
|
|
47
44
|
headers: { Accept: 'application/json', 'Content-Type': 'application/json', ...headers },
|
|
45
|
+
transformResponse: [
|
|
46
|
+
...(axios.defaults.transformResponse as AxiosTransformer[]),
|
|
47
|
+
(data: SuccessData | ErrorData): ResultData | ResultError => {
|
|
48
|
+
if (data.success) return data.data;
|
|
49
|
+
|
|
50
|
+
return data.data.error;
|
|
51
|
+
},
|
|
52
|
+
],
|
|
48
53
|
})
|
|
49
|
-
.then((res:
|
|
50
|
-
.catch((err:
|
|
51
|
-
|
|
52
|
-
error.status = err.response?.status ?? 520;
|
|
53
|
-
error.data = err.response?.data.data.error ?? 'Unknown Error';
|
|
54
|
-
|
|
55
|
-
throw error;
|
|
54
|
+
.then((res: UpdateAvailableFundsData) => res)
|
|
55
|
+
.catch((err: UpdateAvailableFundsError) => {
|
|
56
|
+
throw err;
|
|
56
57
|
});
|
|
57
58
|
}
|