@hapl/api-queries 0.1.121 → 0.1.124
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 +37 -0
- package/dist/api-queries.cjs.development.js +77 -23
- 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 +76 -22
- package/dist/api-queries.esm.js.map +1 -1
- package/dist/clients/v1/api/buyer/findBuyers/index.d.ts +35 -0
- package/dist/clients/v1/api/index.d.ts +1 -0
- package/dist/clients/v1/index.d.ts +1 -0
- package/dist/publisher/v1/api/findPlannedEventsRow/index.d.ts +17 -13
- package/package.json +1 -1
- package/src/clients/v1/api/buyer/findBuyers/index.ts +63 -0
- package/src/clients/v1/api/index.ts +1 -0
- package/src/clients/v1/index.ts +4 -0
- package/src/publisher/v1/api/findActualEventsRow/index.ts +1 -1
- package/src/publisher/v1/api/findPlannedEventsRow/index.ts +28 -32
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AxiosResponse, AxiosError } from 'axios';
|
|
2
|
+
import { Buyer } from '../../../types';
|
|
3
|
+
declare type ResultData = {
|
|
4
|
+
ids: number[];
|
|
5
|
+
byId: Record<string, Buyer>;
|
|
6
|
+
meta: {
|
|
7
|
+
total: number;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
declare type ResultError = string;
|
|
11
|
+
export declare type FindBuyersHeaders = {
|
|
12
|
+
'x-auth-hc': string;
|
|
13
|
+
};
|
|
14
|
+
export declare type FindBuyersParams = {
|
|
15
|
+
filter?: {
|
|
16
|
+
'serviceRequest.id'?: number;
|
|
17
|
+
};
|
|
18
|
+
limits?: {
|
|
19
|
+
page: number;
|
|
20
|
+
count: number | 'all';
|
|
21
|
+
};
|
|
22
|
+
sort?: {
|
|
23
|
+
type: 'createdAt';
|
|
24
|
+
direction: 'asc' | 'desc';
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare type FindBuyersData = AxiosResponse<ResultData>;
|
|
28
|
+
export declare type FindBuyersError = AxiosError<ResultError>;
|
|
29
|
+
export declare type FindBuyersConfig = {
|
|
30
|
+
baseURL?: string;
|
|
31
|
+
headers: FindBuyersHeaders;
|
|
32
|
+
params: FindBuyersParams;
|
|
33
|
+
};
|
|
34
|
+
export declare function findBuyersRequest({ baseURL, headers, params }: FindBuyersConfig): Promise<FindBuyersData>;
|
|
35
|
+
export {};
|
|
@@ -6,6 +6,7 @@ export * from './availableFunds/findAvailableFunds';
|
|
|
6
6
|
export * from './availableFunds/updateAvailableFunds';
|
|
7
7
|
export * from './availableFunds/deleteAvailableFunds';
|
|
8
8
|
export * from './buyer/countBuyers';
|
|
9
|
+
export * from './buyer/findBuyers';
|
|
9
10
|
export * from './call/findCalls';
|
|
10
11
|
export * from './call/findFirstSuccessOutgoingCalls';
|
|
11
12
|
export * from './call/markupCall';
|
|
@@ -10,6 +10,7 @@ export declare class Api {
|
|
|
10
10
|
updateAvailableFunds: (urlParams: api.UpdateAvailableFundsUrlParams, body: api.UpdateAvailableFundsBody, headers: api.UpdateAvailableFundsHeaders) => Promise<api.UpdateAvailableFundsData>;
|
|
11
11
|
deleteAvailableFunds: (urlParams: api.DeleteAvailableFundsUrlParams, headers: api.DeleteAvailableFundsHeaders) => Promise<api.DeleteAvailableFundsData>;
|
|
12
12
|
countBuyers: (params: api.CountBuyersParams, headers: api.CountBuyersHeaders) => Promise<api.CountBuyersData>;
|
|
13
|
+
findBuyers: (params: api.FindBuyersParams, headers: api.FindBuyersHeaders) => Promise<api.FindBuyersData>;
|
|
13
14
|
findCalls: (params: api.FindCallsParams, headers: api.FindCallsHeaders) => Promise<api.FindCallsData>;
|
|
14
15
|
findFirstSuccessOutgoingCalls: (params: api.FindFirstSuccessOutgoingCallsParams, headers: api.FindFirstSuccessOutgoingCallsHeaders) => Promise<api.FindFirstSuccessOutgoingCallsData>;
|
|
15
16
|
markupCall: (body: api.MarkupCallBody, headers: api.MarkupCallHeaders) => Promise<api.MarkupCallData>;
|
|
@@ -1,32 +1,36 @@
|
|
|
1
|
+
import { AxiosResponse, AxiosError } from 'axios';
|
|
1
2
|
import { PlannedEventsRow } from '../../types';
|
|
3
|
+
declare type ResultData = {
|
|
4
|
+
ids: number[];
|
|
5
|
+
byId: Record<string, PlannedEventsRow>;
|
|
6
|
+
meta: {
|
|
7
|
+
total: number;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
declare type ResultError = string;
|
|
2
11
|
export declare type FindPlannedEventsRowHeaders = {
|
|
3
12
|
'x-auth-hc': string;
|
|
4
13
|
};
|
|
5
14
|
export declare type FindPlannedEventsRowParams = {
|
|
6
15
|
filter?: {
|
|
7
16
|
id?: number;
|
|
17
|
+
'realty.id'?: number;
|
|
18
|
+
createdAt?: {
|
|
19
|
+
from?: string;
|
|
20
|
+
to?: string;
|
|
21
|
+
};
|
|
8
22
|
};
|
|
9
23
|
limits?: {
|
|
10
24
|
page: number;
|
|
11
25
|
count: number;
|
|
12
26
|
};
|
|
13
27
|
};
|
|
14
|
-
export declare type FindPlannedEventsRowData =
|
|
15
|
-
|
|
16
|
-
ids: number[];
|
|
17
|
-
byId: Record<string, PlannedEventsRow>;
|
|
18
|
-
};
|
|
19
|
-
meta: {
|
|
20
|
-
total: number;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
export declare type FindPlannedEventsRowError = {
|
|
24
|
-
status: number;
|
|
25
|
-
data: string;
|
|
26
|
-
};
|
|
28
|
+
export declare type FindPlannedEventsRowData = AxiosResponse<ResultData>;
|
|
29
|
+
export declare type FindPlannedEventsRowError = AxiosError<ResultError>;
|
|
27
30
|
export declare type FindPlannedEventsRowConfig = {
|
|
28
31
|
baseURL?: string;
|
|
29
32
|
headers: FindPlannedEventsRowHeaders;
|
|
30
33
|
params: FindPlannedEventsRowParams;
|
|
31
34
|
};
|
|
32
35
|
export declare function findPlannedEventsRowRequest({ baseURL, headers, params, }: FindPlannedEventsRowConfig): Promise<FindPlannedEventsRowData>;
|
|
36
|
+
export {};
|
package/package.json
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
|
|
2
|
+
import qs from 'qs';
|
|
3
|
+
import { Buyer } from '../../../types';
|
|
4
|
+
|
|
5
|
+
type SuccessData = { success: true; data: Buyer[]; pageParams: { length: number; page: number } };
|
|
6
|
+
type ErrorData = { success: false; data: { error: string } };
|
|
7
|
+
|
|
8
|
+
type ResultData = { ids: number[]; byId: Record<string, Buyer>; meta: { total: number } };
|
|
9
|
+
type ResultError = string;
|
|
10
|
+
|
|
11
|
+
export type FindBuyersHeaders = { 'x-auth-hc': string };
|
|
12
|
+
export type FindBuyersParams = {
|
|
13
|
+
filter?: {
|
|
14
|
+
'serviceRequest.id'?: number;
|
|
15
|
+
};
|
|
16
|
+
limits?: {
|
|
17
|
+
page: number;
|
|
18
|
+
count: number | 'all';
|
|
19
|
+
};
|
|
20
|
+
sort?: {
|
|
21
|
+
type: 'createdAt';
|
|
22
|
+
direction: 'asc' | 'desc';
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export type FindBuyersData = AxiosResponse<ResultData>;
|
|
26
|
+
export type FindBuyersError = AxiosError<ResultError>;
|
|
27
|
+
export type FindBuyersConfig = {
|
|
28
|
+
baseURL?: string;
|
|
29
|
+
headers: FindBuyersHeaders;
|
|
30
|
+
params: FindBuyersParams;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export function findBuyersRequest({ baseURL = 'https://clients.homeapp.ru', headers, params }: FindBuyersConfig) {
|
|
34
|
+
return axios
|
|
35
|
+
.get('/api/buyer', {
|
|
36
|
+
baseURL,
|
|
37
|
+
params,
|
|
38
|
+
paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
|
|
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;
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
})
|
|
59
|
+
.then((res: FindBuyersData) => res)
|
|
60
|
+
.catch((err: FindBuyersError) => {
|
|
61
|
+
throw err;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
@@ -8,6 +8,7 @@ export * from './availableFunds/updateAvailableFunds';
|
|
|
8
8
|
export * from './availableFunds/deleteAvailableFunds';
|
|
9
9
|
|
|
10
10
|
export * from './buyer/countBuyers';
|
|
11
|
+
export * from './buyer/findBuyers';
|
|
11
12
|
|
|
12
13
|
export * from './call/findCalls';
|
|
13
14
|
export * from './call/findFirstSuccessOutgoingCalls';
|
package/src/clients/v1/index.ts
CHANGED
|
@@ -45,6 +45,10 @@ export class Api {
|
|
|
45
45
|
return api.countBuyersRequest({ params, headers, baseURL: this.baseURL });
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
+
findBuyers = (params: api.FindBuyersParams, headers: api.FindBuyersHeaders) => {
|
|
49
|
+
return api.findBuyersRequest({ params, headers, baseURL: this.baseURL });
|
|
50
|
+
};
|
|
51
|
+
|
|
48
52
|
// call
|
|
49
53
|
|
|
50
54
|
findCalls = (params: api.FindCallsParams, headers: api.FindCallsHeaders) => {
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import axios, { AxiosResponse, AxiosError } from 'axios';
|
|
1
|
+
import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
|
|
2
2
|
import qs from 'qs';
|
|
3
3
|
import { PlannedEventsRow } from '../../types';
|
|
4
4
|
|
|
5
5
|
type SuccessData = { success: true; data: PlannedEventsRow[]; pageParams: { page: number; length: number } };
|
|
6
|
-
|
|
7
6
|
type ErrorData = { success?: false; data?: { error: string }; message?: string };
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
type ResultData = { ids: number[]; byId: Record<string, PlannedEventsRow>; meta: { total: number } };
|
|
9
|
+
type ResultError = string;
|
|
10
10
|
|
|
11
|
+
export type FindPlannedEventsRowHeaders = { 'x-auth-hc': string };
|
|
11
12
|
export type FindPlannedEventsRowParams = {
|
|
12
|
-
filter?: { id?: number };
|
|
13
|
+
filter?: { id?: number; 'realty.id'?: number; createdAt?: { from?: string; to?: string } };
|
|
13
14
|
limits?: { page: number; count: number };
|
|
14
15
|
};
|
|
15
|
-
|
|
16
|
-
export type
|
|
17
|
-
data: { ids: number[]; byId: Record<string, PlannedEventsRow> };
|
|
18
|
-
meta: { total: number };
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type FindPlannedEventsRowError = { status: number; data: string };
|
|
16
|
+
export type FindPlannedEventsRowData = AxiosResponse<ResultData>;
|
|
17
|
+
export type FindPlannedEventsRowError = AxiosError<ResultError>;
|
|
22
18
|
|
|
23
19
|
export type FindPlannedEventsRowConfig = {
|
|
24
20
|
baseURL?: string;
|
|
@@ -37,27 +33,27 @@ export function findPlannedEventsRowRequest({
|
|
|
37
33
|
params,
|
|
38
34
|
paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
|
|
39
35
|
headers: { Accept: 'application/json', ...headers },
|
|
36
|
+
transformResponse: [
|
|
37
|
+
...(axios.defaults.transformResponse as AxiosTransformer[]),
|
|
38
|
+
(data: SuccessData | ErrorData): ResultData | ResultError => {
|
|
39
|
+
if (data.success) {
|
|
40
|
+
const ids: ResultData['ids'] = [];
|
|
41
|
+
const byId: ResultData['byId'] = {};
|
|
42
|
+
|
|
43
|
+
data.data.forEach(entity => {
|
|
44
|
+
byId[entity.id] = entity;
|
|
45
|
+
ids.push(entity.id);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return { ids, byId, meta: { total: data.pageParams.length } };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return data.data?.error ?? data.message ?? 'Unknown Error';
|
|
52
|
+
},
|
|
53
|
+
],
|
|
40
54
|
})
|
|
41
|
-
.then(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
data: { byId: {}, ids: [] },
|
|
45
|
-
meta: { total: res.data.pageParams.length },
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
res.data.data.forEach(entity => {
|
|
49
|
-
data.data.byId[entity.id] = entity;
|
|
50
|
-
data.data.ids.push(entity.id);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
return data;
|
|
54
|
-
}
|
|
55
|
-
)
|
|
56
|
-
.catch((err: AxiosError<ErrorData>) => {
|
|
57
|
-
const error: Error & Partial<FindPlannedEventsRowError> = new Error(err.message);
|
|
58
|
-
error.status = err.response?.status ?? 520;
|
|
59
|
-
error.data = err.response?.data.message ?? err.response?.data.data?.error ?? 'Unknown Error';
|
|
60
|
-
|
|
61
|
-
throw error;
|
|
55
|
+
.then((res: FindPlannedEventsRowData) => res)
|
|
56
|
+
.catch((err: FindPlannedEventsRowError) => {
|
|
57
|
+
throw err;
|
|
62
58
|
});
|
|
63
59
|
}
|