@hapl/api-queries 0.1.114 → 0.1.117

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/api-queries.cjs.development.js +213 -22
  3. package/dist/api-queries.cjs.development.js.map +1 -1
  4. package/dist/api-queries.cjs.production.min.js +1 -1
  5. package/dist/api-queries.cjs.production.min.js.map +1 -1
  6. package/dist/api-queries.esm.js +213 -22
  7. package/dist/api-queries.esm.js.map +1 -1
  8. package/dist/clients/v1/api/experts/findExperts/index.d.ts +22 -17
  9. package/dist/clients/v1/api/index.d.ts +3 -0
  10. package/dist/clients/v1/api/serviceRequest/findServiceRequestSellerReport/index.d.ts +42 -0
  11. package/dist/clients/v1/api/sold/findSoldStatistic/index.d.ts +25 -0
  12. package/dist/clients/v1/api/valuation/findValuationByServiceRequestId/index.d.ts +29 -0
  13. package/dist/clients/v1/dictionaries/Valuation.d.ts +10 -0
  14. package/dist/clients/v1/dictionaries/index.d.ts +1 -0
  15. package/dist/clients/v1/index.d.ts +3 -0
  16. package/dist/clients/v1/types/ServiceRequestSellerReport.d.ts +20 -0
  17. package/dist/clients/v1/types/SoldStatistic.d.ts +9 -0
  18. package/dist/clients/v1/types/User.d.ts +1 -0
  19. package/dist/clients/v1/types/Valuation.d.ts +69 -0
  20. package/dist/clients/v1/types/index.d.ts +3 -0
  21. package/dist/clients/v2/api/index.d.ts +1 -0
  22. package/dist/clients/v2/api/realty/findRealties/index.d.ts +74 -0
  23. package/dist/clients/v2/api/realty/findRealtyById/index.d.ts +1 -0
  24. package/dist/clients/v2/index.d.ts +1 -0
  25. package/package.json +1 -1
  26. package/src/clients/v1/api/experts/findExperts/index.ts +33 -29
  27. package/src/clients/v1/api/index.ts +5 -0
  28. package/src/clients/v1/api/serviceRequest/findServiceRequestSellerReport/index.ts +62 -0
  29. package/src/clients/v1/api/sold/findSoldStatistic/index.ts +35 -0
  30. package/src/clients/v1/api/valuation/findValuationByServiceRequestId/index.ts +42 -0
  31. package/src/clients/v1/dictionaries/Valuation.ts +11 -0
  32. package/src/clients/v1/dictionaries/index.ts +1 -0
  33. package/src/clients/v1/index.ts +23 -0
  34. package/src/clients/v1/types/ServiceRequestSellerReport.ts +20 -0
  35. package/src/clients/v1/types/SoldStatistic.ts +10 -0
  36. package/src/clients/v1/types/User.ts +1 -0
  37. package/src/clients/v1/types/Valuation.ts +57 -0
  38. package/src/clients/v1/types/index.ts +3 -0
  39. package/src/clients/v2/api/index.ts +1 -0
  40. package/src/clients/v2/api/realty/findRealties/index.ts +105 -0
  41. package/src/clients/v2/api/realty/findRealtyById/index.ts +1 -0
  42. package/src/clients/v2/index.ts +4 -0
@@ -1,34 +1,39 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
1
2
  import { User } from '../../../types';
3
+ declare type ErrorData = {
4
+ success: false;
5
+ data: {
6
+ error: string;
7
+ };
8
+ };
9
+ declare type ResultData = {
10
+ ids: number[];
11
+ byId: Record<string, Partial<User> & {
12
+ id: number;
13
+ }>;
14
+ meta: {
15
+ total: number;
16
+ };
17
+ };
18
+ declare type ResultError = ErrorData['data']['error'];
2
19
  export declare type FindExpertsParams = {
3
20
  filter?: {
4
21
  id?: number | number[];
5
22
  };
6
23
  limits?: {
7
- page: number;
8
- count: number;
24
+ page?: number;
25
+ count: number | 'all';
9
26
  };
10
27
  sorting?: {
11
28
  direction: 'asc' | 'desc';
12
29
  type: 'id' | 'createdAt';
13
30
  };
14
31
  };
15
- export declare type FindExpertsData = {
16
- data: {
17
- ids: number[];
18
- byId: Record<string, Partial<User> & {
19
- id: number;
20
- }>;
21
- };
22
- meta: {
23
- total: number;
24
- };
25
- };
26
- export declare type FindExpertsError = {
27
- status: number;
28
- data: string;
29
- };
32
+ export declare type FindExpertsData = AxiosResponse<ResultData>;
33
+ export declare type FindExpertsError = AxiosError<ResultError>;
30
34
  export declare type FindExpertsConfig = {
31
35
  baseURL?: string;
32
36
  params: FindExpertsParams;
33
37
  };
34
38
  export declare function findExpertsRequest({ baseURL, params }: FindExpertsConfig): Promise<FindExpertsData>;
39
+ export {};
@@ -43,6 +43,7 @@ export * from './serviceRequest/findServiceRequestActivities';
43
43
  export * from './serviceRequest/findServiceRequestById';
44
44
  export * from './serviceRequest/findServiceRequestDuplicates';
45
45
  export * from './serviceRequest/findServiceRequests';
46
+ export * from './serviceRequest/findServiceRequestSellerReport';
46
47
  export * from './serviceRequest/findServiceRequestShortInfo';
47
48
  export * from './serviceRequest/findServiceRequestShortInfoById';
48
49
  export * from './serviceRequest/findServiceRequestShortInfoByDealId';
@@ -52,6 +53,7 @@ export * from './serviceRequest/returnDeferredServiceRequest';
52
53
  export * from './serviceRequest/sendServiceRequestToModeration';
53
54
  export * from './serviceRequest/startServiceRequestModeration';
54
55
  export * from './serviceRequest/startServiceRequestModerationForOldRealty';
56
+ export * from './sold/findSoldStatistic';
55
57
  export * from './users/createUser';
56
58
  export * from './users/findUsers';
57
59
  export * from './users/findUserById';
@@ -59,3 +61,4 @@ export * from './users/updateUser';
59
61
  export * from './users/fireUser';
60
62
  export * from './users/assignSubordinateUsers';
61
63
  export * from './task/findTasks';
64
+ export * from './valuation/findValuationByServiceRequestId';
@@ -0,0 +1,42 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { ServiceRequestSellerReport } from '../../../types';
3
+ declare type ErrorData = {
4
+ success: false;
5
+ data: {
6
+ error: string;
7
+ };
8
+ };
9
+ declare type ResultData = {
10
+ ids: string[];
11
+ byId: Record<string, ServiceRequestSellerReport>;
12
+ meta: {
13
+ total: number;
14
+ };
15
+ };
16
+ declare type ResultError = ErrorData['data']['error'];
17
+ export declare type FindServiceRequestSellerReportParams = {
18
+ sorting?: {
19
+ type: 'createdAt';
20
+ direction: 'asc' | 'desc';
21
+ };
22
+ limits?: {
23
+ page?: number;
24
+ count?: number | 'all';
25
+ };
26
+ };
27
+ export declare type FindServiceRequestSellerReportUrlParams = {
28
+ id: number;
29
+ };
30
+ export declare type FindServiceRequestSellerReportHeaders = {
31
+ 'x-auth-hc': string;
32
+ };
33
+ export declare type FindServiceRequestSellerReportData = AxiosResponse<ResultData>;
34
+ export declare type FindServiceRequestSellerReportError = AxiosError<ResultError>;
35
+ export declare type FindServiceRequestSellerReportConfig = {
36
+ baseURL?: string;
37
+ urlParams: FindServiceRequestSellerReportUrlParams;
38
+ params: FindServiceRequestSellerReportParams;
39
+ headers?: FindServiceRequestSellerReportHeaders;
40
+ };
41
+ export declare function findServiceRequestSellerReportRequest({ baseURL, urlParams, headers, params, }: FindServiceRequestSellerReportConfig): Promise<FindServiceRequestSellerReportData>;
42
+ export {};
@@ -0,0 +1,25 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { SoldStatistic } from '../../../types';
3
+ declare type SuccessData = {
4
+ success: true;
5
+ data: SoldStatistic[];
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'];
15
+ export declare type FindSoldStatisticHeaders = {
16
+ 'x-auth-hc'?: string;
17
+ };
18
+ export declare type FindSoldStatisticData = AxiosResponse<ResultData>;
19
+ export declare type FindSoldStatisticError = AxiosError<ResultError>;
20
+ export declare type FindSoldStatisticConfig = {
21
+ baseURL?: string;
22
+ headers?: FindSoldStatisticHeaders;
23
+ };
24
+ export declare function findSoldStatisticRequest({ baseURL, headers }: FindSoldStatisticConfig): Promise<FindSoldStatisticData>;
25
+ export {};
@@ -0,0 +1,29 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { Valuation } from '../../../types';
3
+ declare type SuccessData = {
4
+ success: true;
5
+ data: Valuation;
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'];
15
+ export declare type FindValuationByServiceRequestIdUrlParams = {
16
+ id: number;
17
+ };
18
+ export declare type FindValuationByServiceRequestIdParams = {
19
+ withDrafts?: boolean;
20
+ };
21
+ export declare type FindValuationByServiceRequestIdData = AxiosResponse<ResultData>;
22
+ export declare type FindValuationByServiceRequestIdError = AxiosError<ResultError>;
23
+ export declare type FindValuationByServiceRequestIdConfig = {
24
+ baseURL?: string;
25
+ urlParams: FindValuationByServiceRequestIdUrlParams;
26
+ params?: FindValuationByServiceRequestIdParams;
27
+ };
28
+ export declare function findValuationByServiceRequestIdRequest({ baseURL, urlParams, params, }: FindValuationByServiceRequestIdConfig): Promise<FindValuationByServiceRequestIdData>;
29
+ export {};
@@ -0,0 +1,10 @@
1
+ import { ValuationConcurrency } from '../types';
2
+ export declare const ValuationDictionary: {
3
+ Concurrency: {
4
+ low: string;
5
+ medium: string;
6
+ "medium-high": string;
7
+ high: string;
8
+ "very-high": string;
9
+ };
10
+ };
@@ -16,3 +16,4 @@ export * from './ServiceRequestCategorizedFile';
16
16
  export * from './Shape';
17
17
  export * from './Task';
18
18
  export * from './User';
19
+ export * from './Valuation';
@@ -56,6 +56,8 @@ export declare class Api {
56
56
  returnDeferredServiceRequest: (body: api.ReturnDeferredServiceRequestBody, headers: api.ReturnDeferredServiceRequestHeaders) => Promise<api.ReturnDeferredServiceRequestData>;
57
57
  startServiceRequestModeration: (urlParams: api.StartServiceRequestModerationUrlParams, headers: api.StartServiceRequestModerationHeaders) => Promise<api.StartServiceRequestModerationData>;
58
58
  startServiceRequestModerationForOldRealty: (urlParams: api.StartServiceRequestModerationForOldRealtyUrlParams, headers: api.StartServiceRequestModerationForOldRealtyHeaders) => Promise<api.StartServiceRequestModerationForOldRealtyData>;
59
+ findServiceRequestSellerReport: (urlParams: api.FindServiceRequestSellerReportUrlParams, params: api.FindServiceRequestSellerReportParams, headers: api.FindServiceRequestSellerReportHeaders) => Promise<api.FindServiceRequestSellerReportData>;
60
+ findSoldStatistic: (headers?: api.FindSoldStatisticHeaders | undefined) => Promise<api.FindSoldStatisticData>;
59
61
  findTasks: (params: api.FindTasksParams, headers: api.FindTasksHeaders) => Promise<api.FindTasksData>;
60
62
  createUser: (body: api.CreateUserBody, headers: api.CreateUserHeaders) => Promise<api.CreateUserData>;
61
63
  findUsers: (params: api.FindUsersParams, headers: api.FindUsersHeaders) => Promise<api.FindUsersData>;
@@ -63,6 +65,7 @@ export declare class Api {
63
65
  updateUser: (urlParams: api.UpdateUserUrlParams, body: api.UpdateUserBody, headers: api.UpdateUserHeaders) => Promise<api.UpdateUserData>;
64
66
  fireUser: (urlParams: api.FireUserUrlParams, body: api.FireUserBody, headers: api.FireUserHeaders) => Promise<api.FireUserData>;
65
67
  assignSubordinateUsers: (urlParams: api.AssignSubordinateUsersUrlParams, body: api.AssignSubordinateUsersBody, headers: api.AssignSubordinateUsersHeaders) => Promise<api.AssignSubordinateUsersData>;
68
+ findValuationByServiceRequestId: (urlParams: api.FindValuationByServiceRequestIdUrlParams, params?: api.FindValuationByServiceRequestIdParams | undefined) => Promise<api.FindValuationByServiceRequestIdData>;
66
69
  }
67
70
  export * from './api';
68
71
  export * from './dictionaries';
@@ -0,0 +1,20 @@
1
+ export declare type ServiceRequestSellerReport = {
2
+ id: string;
3
+ closingReasons: Array<{
4
+ label: string;
5
+ value: number;
6
+ }>;
7
+ comment: string;
8
+ createdAt: string;
9
+ curatorId: number;
10
+ from: string;
11
+ serviceRequestId: number;
12
+ stats: {
13
+ calls: number;
14
+ rejections: number;
15
+ shows: number;
16
+ views: number;
17
+ priceStatus?: string;
18
+ };
19
+ to: string;
20
+ };
@@ -0,0 +1,9 @@
1
+ export declare enum SoldStatisticTypes {
2
+ House = "house",
3
+ FlatNew = "flat_new",
4
+ FlatSecondary = "flat_secondary"
5
+ }
6
+ export declare type SoldStatistic = {
7
+ type: SoldStatisticTypes;
8
+ price: number;
9
+ };
@@ -143,4 +143,5 @@ export declare type User = {
143
143
  patronymic?: string;
144
144
  supervisor?: User;
145
145
  updatedAt?: string;
146
+ fullNameTranslit?: string;
146
147
  };
@@ -0,0 +1,69 @@
1
+ import { ServiceRequest } from './ServiceRequest';
2
+ export declare enum ValuationConcurrency {
3
+ Low = "low",
4
+ Medium = "medium",
5
+ MediumHigh = "medium-high",
6
+ High = "high",
7
+ VeryHigh = "very-high"
8
+ }
9
+ declare type ValueRange = {
10
+ max: number;
11
+ min: number;
12
+ p10: number;
13
+ p50: number;
14
+ p90: number;
15
+ };
16
+ declare type Stats = {
17
+ count: number;
18
+ outOfRange: number;
19
+ area?: ValueRange;
20
+ price?: ValueRange;
21
+ realtyIds?: number[];
22
+ };
23
+ export declare type Valuation = {
24
+ addresses: number[];
25
+ comments: Array<{
26
+ comment: string;
27
+ realtyId: number;
28
+ }>;
29
+ createdAt: string;
30
+ id: number;
31
+ isDraft: boolean;
32
+ isOnlyInMarketRangeShown: boolean;
33
+ realties: number[];
34
+ realtyParams: any[] | {
35
+ address?: string;
36
+ area?: number;
37
+ floor?: number;
38
+ lat?: number;
39
+ lng?: number;
40
+ price?: number;
41
+ roomsNumber?: number;
42
+ };
43
+ serviceRequest: Partial<ServiceRequest> & Required<Pick<ServiceRequest, 'id'>>;
44
+ calculationData?: {
45
+ active: Stats;
46
+ concurrencyLevel: ValuationConcurrency;
47
+ inventoryPerBuyer: number;
48
+ sold: Stats;
49
+ };
50
+ comment?: string;
51
+ filter?: {
52
+ address?: string;
53
+ area?: {
54
+ from?: number;
55
+ to?: number;
56
+ };
57
+ floor?: {
58
+ from?: number;
59
+ to?: number;
60
+ };
61
+ floorsNumber?: {
62
+ from: number;
63
+ to: number;
64
+ };
65
+ isShortDateRange?: boolean;
66
+ roomsNumber?: number[];
67
+ };
68
+ };
69
+ export {};
@@ -18,10 +18,13 @@ export * from './Realty';
18
18
  export * from './RealtyOffer';
19
19
  export * from './ServiceRequest';
20
20
  export * from './ServiceRequestActivity';
21
+ export * from './ServiceRequestSellerReport';
21
22
  export * from './ServiceRequestShortInfo';
22
23
  export * from './ServiceRequestCategorizedFile';
23
24
  export * from './Shape';
25
+ export * from './SoldStatistic';
24
26
  export * from './Task';
25
27
  export * from './User';
26
28
  export * from './UserCase';
27
29
  export * from './UserPhone';
30
+ export * from './Valuation';
@@ -9,6 +9,7 @@ export * from './realty/createRealtyHouseHighwayDistance';
9
9
  export * from './realty/createRealtyImage';
10
10
  export * from './realty/createRealtyMetroDistance';
11
11
  export * from './realty/deleteRealtyImage';
12
+ export * from './realty/findRealties';
12
13
  export * from './realty/findRealtyById';
13
14
  export * from './realty/updateRealty';
14
15
  export * from './realty/updateRealtyHouseHighwayDistance';
@@ -0,0 +1,74 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { Realty, Address, AddressBTIParams, Complex, RealtyImage, Image, RealtyHouseHighwayDistance, RealtyMetroDistance, RealtyType } from '../../../types';
3
+ declare type SuccessData = {
4
+ data: Realty[];
5
+ included?: Array<Address | AddressBTIParams | Complex | RealtyImage | Image | RealtyHouseHighwayDistance | RealtyMetroDistance>;
6
+ meta: {
7
+ page: {
8
+ offset: number;
9
+ count: number;
10
+ total: number;
11
+ };
12
+ };
13
+ errors: never;
14
+ };
15
+ declare type ErrorData = {
16
+ data: never;
17
+ included: never;
18
+ meta: never;
19
+ errors: Array<{
20
+ source?: {
21
+ parameter: string;
22
+ };
23
+ detail: string;
24
+ description?: string;
25
+ }>;
26
+ };
27
+ declare type ResultData = {
28
+ ids: string[];
29
+ byId: Record<string, Realty>;
30
+ meta: SuccessData['meta'];
31
+ included?: SuccessData['included'];
32
+ };
33
+ declare type ResultError = ErrorData['errors'];
34
+ export declare type FindRealtiesInclude = 'address.bti' | 'complex' | 'metroDistance.metroStation' | 'address.metroDistance.metroStation' | 'highwayDistance.highway' | 'realtyImage.image';
35
+ export declare type FindRealtiesParams = {
36
+ include?: Array<FindRealtiesInclude>;
37
+ filter?: {
38
+ id?: number | number[] | string | string[];
39
+ realtyType?: RealtyType;
40
+ district?: string;
41
+ cityArea?: string;
42
+ isHomeapp?: boolean;
43
+ isSold?: boolean;
44
+ 'address.fullAddress'?: string;
45
+ roomCount?: number;
46
+ floor?: number;
47
+ price?: {
48
+ from?: number;
49
+ to?: number;
50
+ };
51
+ coordinates?: {
52
+ 'topLeft.lat'?: number;
53
+ 'topLeft.lng'?: number;
54
+ 'bottomRight.lat'?: number;
55
+ 'bottomRight.lng'?: number;
56
+ };
57
+ };
58
+ page?: {
59
+ offset?: number;
60
+ limit?: number;
61
+ };
62
+ };
63
+ export declare type FindRealtiesHeaders = {
64
+ 'x-auth-hc'?: string;
65
+ };
66
+ export declare type FindRealtiesData = AxiosResponse<ResultData>;
67
+ export declare type FindRealtiesError = AxiosError<ResultError>;
68
+ export declare type FindRealtiesConfig = {
69
+ baseURL?: string;
70
+ params?: FindRealtiesParams;
71
+ headers?: FindRealtiesHeaders;
72
+ };
73
+ export declare function findRealtiesRequest({ baseURL, params, headers }: FindRealtiesConfig): Promise<FindRealtiesData>;
74
+ export {};
@@ -16,6 +16,7 @@ declare type SuccessData = {
16
16
  }>;
17
17
  realtyAccess?: Array<FindRealtyByIdDataMetaRealtyAccess>;
18
18
  updatedAt?: string;
19
+ serviceRequestId?: number;
19
20
  };
20
21
  };
21
22
  included?: Array<Address | AddressBTIParams | Complex | RealtyImage | Image | RealtyHouseHighwayDistance | RealtyMetroDistance>;
@@ -13,6 +13,7 @@ export declare class Api {
13
13
  createRealtyImage: (body: api.CreateRealtyImageBody, headers: api.CreateRealtyImageHeaders) => Promise<api.CreateRealtyImageData>;
14
14
  createRealtyMetroDistance: (body: api.CreateRealtyMetroDistanceBody, headers: api.CreateRealtyMetroDistanceHeaders) => Promise<api.CreateRealtyMetroDistanceData>;
15
15
  deleteRealtyImage: (urlParams: api.DeleteRealtyImageUrlParams, headers: api.DeleteRealtyImageHeaders) => Promise<api.DeleteRealtyImageData>;
16
+ findRealties: (params: api.FindRealtiesParams, headers?: api.FindRealtiesHeaders | undefined) => Promise<api.FindRealtiesData>;
16
17
  findRealtyById: (urlParams: api.FindRealtyByIdUrlParams, params: api.FindRealtyByIdParams, headers?: api.FindRealtyByIdHeaders | undefined) => Promise<api.FindRealtyByIdData>;
17
18
  updateRealty: (urlParams: api.UpdateRealtyUrlParams, body: api.UpdateRealtyBody, headers: api.UpdateRealtyHeaders) => Promise<api.UpdateRealtyData>;
18
19
  updateRealtyHouseHighwayDistance: (urlParams: api.UpdateRealtyHouseHighwayDistanceUrlParams, body: api.UpdateRealtyHouseHighwayDistanceBody, headers: api.UpdateRealtyHouseHighwayDistanceHeaders) => Promise<api.UpdateRealtyHouseHighwayDistanceData>;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.114",
2
+ "version": "0.1.117",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -1,49 +1,53 @@
1
- import axios, { AxiosResponse, AxiosError } from 'axios';
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
2
  import { User } from '../../../types';
3
+ import qs from 'qs';
3
4
 
4
5
  type SuccessData = {
5
6
  success: true;
6
7
  data: Partial<User> & { id: number }[];
7
8
  pageParams: { page: number; length: number };
8
9
  };
9
-
10
10
  type ErrorData = { success: false; data: { error: string } };
11
11
 
12
+ type ResultData = { ids: number[]; byId: Record<string, Partial<User> & { id: number }>; meta: { total: number } };
13
+ type ResultError = ErrorData['data']['error'];
14
+
12
15
  export type FindExpertsParams = {
13
16
  filter?: { id?: number | number[] };
14
- limits?: { page: number; count: number };
17
+ limits?: { page?: number; count: number | 'all' };
15
18
  sorting?: { direction: 'asc' | 'desc'; type: 'id' | 'createdAt' };
16
19
  };
17
20
 
18
- export type FindExpertsData = {
19
- data: { ids: number[]; byId: Record<string, Partial<User> & { id: number }> };
20
- meta: { total: number };
21
- };
22
-
23
- export type FindExpertsError = { status: number; data: string };
24
-
21
+ export type FindExpertsData = AxiosResponse<ResultData>;
22
+ export type FindExpertsError = AxiosError<ResultError>;
25
23
  export type FindExpertsConfig = { baseURL?: string; params: FindExpertsParams };
26
24
 
27
25
  export function findExpertsRequest({ baseURL = 'https://clients.homeapp.ru', params }: FindExpertsConfig) {
28
26
  return axios
29
- .get('/api/experts', { baseURL, params, headers: { Accept: 'application/json' } })
30
- .then(
31
- (res: AxiosResponse<SuccessData>): FindExpertsData => {
32
- const data: FindExpertsData = { data: { byId: {}, ids: [] }, meta: { total: res.data.pageParams.length } };
33
-
34
- res.data.data.forEach(entity => {
35
- data.data.byId[entity.id] = entity;
36
- data.data.ids.push(entity.id);
37
- });
38
-
39
- return data;
40
- }
41
- )
42
- .catch((err: AxiosError<ErrorData>) => {
43
- const error: Error & Partial<FindExpertsError> = new Error(err.message);
44
- error.status = err.response?.status ?? 520;
45
- error.data = err.response?.data.data.error ?? 'Unknown Error';
46
-
47
- throw error;
27
+ .get('/api/experts', {
28
+ baseURL,
29
+ params,
30
+ paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
31
+ headers: { Accept: 'application/json' },
32
+ transformResponse: [
33
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
34
+ (data: SuccessData | ErrorData): ResultData | ResultError => {
35
+ if (!data.success) return data.data.error;
36
+
37
+ const ids: ResultData['ids'] = [];
38
+ const byId: ResultData['byId'] = {};
39
+
40
+ data.data.forEach(entity => {
41
+ byId[entity.id] = entity;
42
+ ids.push(entity.id);
43
+ });
44
+
45
+ return { ids, byId, meta: { total: data.pageParams.length } };
46
+ },
47
+ ],
48
+ })
49
+ .then((res: FindExpertsData) => res)
50
+ .catch((err: FindExpertsError) => {
51
+ throw err;
48
52
  });
49
53
  }
@@ -51,6 +51,7 @@ export * from './serviceRequest/findServiceRequestActivities';
51
51
  export * from './serviceRequest/findServiceRequestById';
52
52
  export * from './serviceRequest/findServiceRequestDuplicates';
53
53
  export * from './serviceRequest/findServiceRequests';
54
+ export * from './serviceRequest/findServiceRequestSellerReport';
54
55
  export * from './serviceRequest/findServiceRequestShortInfo';
55
56
  export * from './serviceRequest/findServiceRequestShortInfoById';
56
57
  export * from './serviceRequest/findServiceRequestShortInfoByDealId';
@@ -61,6 +62,8 @@ export * from './serviceRequest/sendServiceRequestToModeration';
61
62
  export * from './serviceRequest/startServiceRequestModeration';
62
63
  export * from './serviceRequest/startServiceRequestModerationForOldRealty';
63
64
 
65
+ export * from './sold/findSoldStatistic';
66
+
64
67
  export * from './users/createUser';
65
68
  export * from './users/findUsers';
66
69
  export * from './users/findUserById';
@@ -69,3 +72,5 @@ export * from './users/fireUser';
69
72
  export * from './users/assignSubordinateUsers';
70
73
 
71
74
  export * from './task/findTasks';
75
+
76
+ export * from './valuation/findValuationByServiceRequestId';
@@ -0,0 +1,62 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+ import { ServiceRequestSellerReport } from '../../../types';
3
+ import qs from 'qs';
4
+
5
+ type SuccessData = { success: true; data: ServiceRequestSellerReport[]; pageParams: { page: number; length: number } };
6
+ type ErrorData = { success: false; data: { error: string } };
7
+
8
+ type ResultData = { ids: string[]; byId: Record<string, ServiceRequestSellerReport>; meta: { total: number } };
9
+ type ResultError = ErrorData['data']['error'];
10
+
11
+ export type FindServiceRequestSellerReportParams = {
12
+ sorting?: {
13
+ type: 'createdAt';
14
+ direction: 'asc' | 'desc';
15
+ };
16
+ limits?: { page?: number; count?: number | 'all' };
17
+ };
18
+ export type FindServiceRequestSellerReportUrlParams = { id: number };
19
+ export type FindServiceRequestSellerReportHeaders = { 'x-auth-hc': string };
20
+ export type FindServiceRequestSellerReportData = AxiosResponse<ResultData>;
21
+ export type FindServiceRequestSellerReportError = AxiosError<ResultError>;
22
+ export type FindServiceRequestSellerReportConfig = {
23
+ baseURL?: string;
24
+ urlParams: FindServiceRequestSellerReportUrlParams;
25
+ params: FindServiceRequestSellerReportParams;
26
+ headers?: FindServiceRequestSellerReportHeaders;
27
+ };
28
+
29
+ export function findServiceRequestSellerReportRequest({
30
+ baseURL = 'https://clients.homeapp.ru',
31
+ urlParams,
32
+ headers,
33
+ params,
34
+ }: FindServiceRequestSellerReportConfig) {
35
+ return axios
36
+ .get(`/api/service-request/${urlParams.id}/report-for-seller`, {
37
+ baseURL,
38
+ params,
39
+ paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
40
+ headers: { Accept: 'application/json', ...headers },
41
+ transformResponse: [
42
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
43
+ (data: SuccessData | ErrorData): ResultData | ResultError => {
44
+ if (!data.success) return data.data.error;
45
+
46
+ const ids: ResultData['ids'] = [];
47
+ const byId: ResultData['byId'] = {};
48
+
49
+ data.data.forEach(entity => {
50
+ byId[entity.id] = entity;
51
+ ids.push(entity.id);
52
+ });
53
+
54
+ return { ids, byId, meta: { total: data.pageParams.length } };
55
+ },
56
+ ],
57
+ })
58
+ .then((res: FindServiceRequestSellerReportData) => res)
59
+ .catch((err: FindServiceRequestSellerReportError) => {
60
+ throw err;
61
+ });
62
+ }
@@ -0,0 +1,35 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+ import { SoldStatistic } from '../../../types';
3
+
4
+ type SuccessData = {
5
+ success: true;
6
+ data: SoldStatistic[];
7
+ };
8
+ type ErrorData = { success: false; data: { error: string } };
9
+
10
+ type ResultData = SuccessData['data'];
11
+ type ResultError = ErrorData['data']['error'];
12
+
13
+ export type FindSoldStatisticHeaders = { 'x-auth-hc'?: string };
14
+ export type FindSoldStatisticData = AxiosResponse<ResultData>;
15
+ export type FindSoldStatisticError = AxiosError<ResultError>;
16
+ export type FindSoldStatisticConfig = {
17
+ baseURL?: string;
18
+ headers?: FindSoldStatisticHeaders;
19
+ };
20
+
21
+ export function findSoldStatisticRequest({ baseURL = 'https://clients.homeapp.ru', headers }: FindSoldStatisticConfig) {
22
+ return axios
23
+ .get('/api/sold/statistic', {
24
+ baseURL,
25
+ headers: { Accept: 'application/json', ...headers },
26
+ transformResponse: [
27
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
28
+ (data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? data.data : data.data.error),
29
+ ],
30
+ })
31
+ .then((res: FindSoldStatisticData) => res)
32
+ .catch((err: FindSoldStatisticError) => {
33
+ throw err;
34
+ });
35
+ }