@hapl/api-queries 0.2.7 → 0.2.8

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 (39) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/api-queries.cjs.development.js +652 -546
  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 +652 -546
  7. package/dist/api-queries.esm.js.map +1 -1
  8. package/dist/clients/v1/api/buyer/createBuyer/index.d.ts +10 -2
  9. package/dist/clients/v1/api/expert/findExperts/index.d.ts +1 -0
  10. package/dist/clients/v1/api/index.d.ts +1 -0
  11. package/dist/clients/v1/api/realty/subscribeToRealtyUpdates/index.d.ts +22 -0
  12. package/dist/clients/v1/index.d.ts +2 -1
  13. package/dist/clients/v2/api/realty/findRealties/index.d.ts +10 -6
  14. package/dist/clients/v2/api/realty/findRealtyById/index.d.ts +2 -2
  15. package/dist/clients/v2/types/Address.d.ts +3 -3
  16. package/dist/clients/v2/types/Realty.d.ts +2 -2
  17. package/dist/publisher/v1/api/findHomeappStatisticRowByRealtyId/index.d.ts +25 -0
  18. package/dist/publisher/v1/api/findStatisticRow/index.d.ts +1 -21
  19. package/dist/publisher/v1/api/index.d.ts +2 -1
  20. package/dist/publisher/v1/index.d.ts +1 -0
  21. package/dist/publisher/v1/types/StatisticRow.d.ts +21 -0
  22. package/dist/publisher/v1/types/index.d.ts +1 -0
  23. package/package.json +1 -1
  24. package/src/clients/v1/api/buyer/createBuyer/index.ts +6 -3
  25. package/src/clients/v1/api/expert/findExperts/index.ts +4 -1
  26. package/src/clients/v1/api/index.ts +1 -0
  27. package/src/clients/v1/api/realty/findSimilarRealtyIdsById/{index.tsx → index.ts} +0 -0
  28. package/src/clients/v1/api/realty/subscribeToRealtyUpdates/index.ts +38 -0
  29. package/src/clients/v1/index.ts +5 -1
  30. package/src/clients/v2/api/realty/findRealties/index.ts +6 -4
  31. package/src/clients/v2/api/realty/findRealtyById/index.ts +4 -0
  32. package/src/clients/v2/types/Address.ts +5 -8
  33. package/src/clients/v2/types/Realty.ts +3 -2
  34. package/src/publisher/v1/api/findHomeappStatisticRowByRealtyId/index.ts +36 -0
  35. package/src/publisher/v1/api/findStatisticRow/index.ts +2 -10
  36. package/src/publisher/v1/api/index.ts +2 -1
  37. package/src/publisher/v1/index.ts +4 -0
  38. package/src/publisher/v1/types/StatisticRow.ts +9 -0
  39. package/src/publisher/v1/types/index.ts +1 -0
@@ -19,16 +19,24 @@ export declare type CreateBuyerBody = {
19
19
  phone: string;
20
20
  serviceRequest: {
21
21
  id: number;
22
+ } | {
23
+ realtyExtId: number;
22
24
  };
25
+ comment?: string;
26
+ contacts?: Array<{
27
+ type: string;
28
+ value: string;
29
+ }>;
23
30
  name?: string;
31
+ offer?: number;
32
+ source?: string;
24
33
  status?: BuyerStatus;
25
- comment?: string;
26
34
  };
27
35
  export declare type CreateBuyerData = AxiosResponse<ResultData>;
28
36
  export declare type CreateBuyerError = AxiosError<ResultError>;
29
37
  export declare type CreateBuyerConfig = {
30
38
  baseURL?: string;
31
- headers: CreateBuyerHeaders;
39
+ headers?: CreateBuyerHeaders;
32
40
  body: CreateBuyerBody;
33
41
  };
34
42
  export declare function createBuyerRequest({ baseURL, body, headers }: CreateBuyerConfig): Promise<CreateBuyerData>;
@@ -19,6 +19,7 @@ declare type ResultError = ErrorData['data']['error'];
19
19
  export declare type FindExpertsParams = {
20
20
  filter?: {
21
21
  id?: number | number[];
22
+ realtyId?: number;
22
23
  };
23
24
  limits?: {
24
25
  page?: number;
@@ -79,6 +79,7 @@ export * from './photoOrder/findPhotoOrders';
79
79
  export * from './photoOrder/sendPhotoOrderFeedback';
80
80
  export * from './photoOrder/terminatePhotoOrder';
81
81
  export * from './realty/findSimilarRealtyIdsById';
82
+ export * from './realty/subscribeToRealtyUpdates';
82
83
  export * from './serviceRequest/approveCloseServiceRequest';
83
84
  export * from './serviceRequest/callbackServiceRequest';
84
85
  export * from './serviceRequest/closeServiceRequest';
@@ -0,0 +1,22 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ declare type ErrorData = {
3
+ success: false;
4
+ data: {
5
+ error: string;
6
+ };
7
+ };
8
+ declare type ResultData = null;
9
+ declare type ResultError = ErrorData['data']['error'];
10
+ export declare type SubscribeToRealtyUpdatesBody = {
11
+ email: string;
12
+ realtyExtId: number;
13
+ events: Array<'price_changed' | 'published' | 'depublished'>;
14
+ };
15
+ export declare type SubscribeToRealtyUpdatesData = AxiosResponse<ResultData>;
16
+ export declare type SubscribeToRealtyUpdatesError = AxiosError<ResultError>;
17
+ export declare type SubscribeToRealtyUpdatesConfig = {
18
+ baseURL?: string;
19
+ body: SubscribeToRealtyUpdatesBody;
20
+ };
21
+ export declare function subscribeToRealtyUpdatesRequest({ baseURL, body, }: SubscribeToRealtyUpdatesConfig): Promise<SubscribeToRealtyUpdatesData>;
22
+ export {};
@@ -13,7 +13,7 @@ export declare class Api {
13
13
  findBills: (params: api.FindBillsParams, headers: api.FindBillsHeaders) => Promise<api.FindBillsData>;
14
14
  callbackBuyer: (urlParams: api.CallbackBuyerUrlParams, headers: api.CallbackBuyerHeaders) => Promise<api.CallbackBuyerData>;
15
15
  countBuyers: (params: api.CountBuyersParams, headers: api.CountBuyersHeaders) => Promise<api.CountBuyersData>;
16
- createBuyer: (body: api.CreateBuyerBody, headers: api.CallbackBuyerHeaders) => Promise<api.CreateBuyerData>;
16
+ createBuyer: (body: api.CreateBuyerBody, headers?: api.CallbackBuyerHeaders | undefined) => Promise<api.CreateBuyerData>;
17
17
  findBuyerClosingReason: (headers: api.FindBuyerClosingReasonHeaders) => Promise<api.FindBuyerClosingReasonData>;
18
18
  findBuyers: (params: api.FindBuyersParams, headers: api.FindBuyersHeaders) => Promise<api.FindBuyersData>;
19
19
  findCalls: (params: api.FindCallsParams, headers: api.FindCallsHeaders) => Promise<api.FindCallsData>;
@@ -83,6 +83,7 @@ export declare class Api {
83
83
  sendPhotoOrderFeedback: (urlParams: api.SendPhotoOrderFeedbackUrlParams, headers: api.SendPhotoOrderFeedbackHeaders) => Promise<api.SendPhotoOrderFeedbackData>;
84
84
  terminatePhotoOrder: (urlParams: api.TerminatePhotoOrderUrlParams, headers: api.TerminatePhotoOrderHeaders) => Promise<api.TerminatePhotoOrderData>;
85
85
  findSimilarRealtyIdsById: (urlParams: api.FindSimilarRealtyIdsByIdUrlParams) => Promise<api.FindSimilarRealtyIdsByIdData>;
86
+ subscribeToRealtyUpdates: (body: api.SubscribeToRealtyUpdatesBody) => Promise<api.SubscribeToRealtyUpdatesData>;
86
87
  approveCloseServiceRequest: (urlParams: api.ApproveCloseServiceRequestUrlParams, body: api.ApproveCloseServiceRequestBody, headers: api.ApproveCloseServiceRequestHeaders) => Promise<api.ApproveCloseServiceRequestData>;
87
88
  callbackServiceRequest: (urlParams: api.CallbackServiceRequestUrlParams, headers: api.CallbackServiceRequestHeaders) => Promise<api.CallbackServiceRequestData>;
88
89
  closeServiceRequest: (urlParams: api.CloseServiceRequestUrlParams, body: api.CloseServiceRequestBody, headers: api.CloseServiceRequestHeaders) => Promise<api.CloseServiceRequestData>;
@@ -1,5 +1,5 @@
1
1
  import { AxiosResponse, AxiosError } from 'axios';
2
- import { Realty, Address, AddressBTIParams, Complex, ComplexHousing, RealtyImage, Image, RealtyHouseHighwayDistance, RealtyMetroDistance, RealtyType, ExternalLink, PriceHistory } from '../../../types';
2
+ import { Realty, Address, AddressBTIParams, Complex, ComplexHousing, RealtyImage, Image, RealtyHouseHighwayDistance, RealtyMetroDistance, RealtyType, ExternalLink, PriceHistory, Highway, MetroStation } from '../../../types';
3
3
  declare type RealtyMeta = {
4
4
  createdAt: string;
5
5
  isPresentationReady: boolean;
@@ -8,7 +8,7 @@ declare type SuccessData = {
8
8
  data: Array<Realty & {
9
9
  meta: RealtyMeta;
10
10
  }>;
11
- included?: Array<Address | AddressBTIParams | Complex | ComplexHousing | ExternalLink | Image | RealtyHouseHighwayDistance | RealtyImage | RealtyMetroDistance | PriceHistory>;
11
+ included?: Array<Address | AddressBTIParams | Complex | ComplexHousing | ExternalLink | Image | RealtyHouseHighwayDistance | RealtyImage | RealtyMetroDistance | PriceHistory | Highway | MetroStation>;
12
12
  meta: {
13
13
  page: {
14
14
  offset: number;
@@ -62,10 +62,14 @@ export declare type FindRealtiesParams = {
62
62
  price?: NumberRange;
63
63
  area?: NumberRange;
64
64
  coordinates?: {
65
- 'topLeft.lat'?: number;
66
- 'topLeft.lng'?: number;
67
- 'bottomRight.lat'?: number;
68
- 'bottomRight.lng'?: number;
65
+ topLeft: {
66
+ lat: number;
67
+ lng: number;
68
+ };
69
+ bottomRight: {
70
+ lat: number;
71
+ lng: number;
72
+ };
69
73
  };
70
74
  updatedAt?: string;
71
75
  createdAt?: string;
@@ -1,5 +1,5 @@
1
1
  import { AxiosResponse, AxiosError } from 'axios';
2
- import { Realty, Address, AddressBTIParams, Complex, ComplexHousing, RealtyImage, Image, RealtyHouseHighwayDistance, RealtyMetroDistance, ExternalLink, PriceHistory } from '../../../types';
2
+ import { Realty, Address, AddressBTIParams, Complex, ComplexHousing, RealtyImage, Image, RealtyHouseHighwayDistance, RealtyMetroDistance, ExternalLink, PriceHistory, Highway, MetroStation } from '../../../types';
3
3
  export declare enum FindRealtyByIdDataMetaRealtyAccess {
4
4
  Curator = "curator",
5
5
  CuratorMentor = "curator_mentor",
@@ -25,7 +25,7 @@ declare type SuccessData = {
25
25
  serviceRequestId?: number;
26
26
  };
27
27
  };
28
- included?: Array<Address | AddressBTIParams | Complex | ComplexHousing | ExternalLink | Image | RealtyHouseHighwayDistance | RealtyImage | RealtyMetroDistance | PriceHistory>;
28
+ included?: Array<Address | AddressBTIParams | Complex | ComplexHousing | ExternalLink | Image | RealtyHouseHighwayDistance | RealtyImage | RealtyMetroDistance | PriceHistory | Highway | MetroStation>;
29
29
  errors: never;
30
30
  };
31
31
  declare type ErrorData = {
@@ -3,8 +3,8 @@ export declare type Address = {
3
3
  type: 'address';
4
4
  attributes: {
5
5
  fullAddress: string;
6
- lat: string;
7
- lng: string;
6
+ lat: number;
7
+ lng: number;
8
8
  city?: string;
9
9
  house?: string;
10
10
  region?: string;
@@ -12,7 +12,7 @@ export declare type Address = {
12
12
  };
13
13
  relationships: {
14
14
  addressBti: {
15
- data: {
15
+ data?: {
16
16
  id: string;
17
17
  type: 'addressBti';
18
18
  };
@@ -207,13 +207,13 @@ export declare type RealtyRelationshipsFlatSecondary = {
207
207
  };
208
208
  };
209
209
  complex?: {
210
- data: {
210
+ data?: {
211
211
  id: string;
212
212
  type: 'complex';
213
213
  };
214
214
  };
215
215
  complexHousing?: {
216
- data: {
216
+ data?: {
217
217
  id: string;
218
218
  type: 'complexHousing';
219
219
  };
@@ -0,0 +1,25 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { StatisticRow } from '../../types';
3
+ declare type SuccessData = {
4
+ success: true;
5
+ data: StatisticRow;
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 FindHomeappStatisticRowByRealtyIdUrlParams = {
16
+ realtyId: number;
17
+ };
18
+ export declare type FindHomeappStatisticRowByRealtyIdData = AxiosResponse<ResultData>;
19
+ export declare type FindHomeappStatisticRowByRealtyIdError = AxiosError<ResultError>;
20
+ export declare type FindHomeappStatisticRowByRealtyIdConfig = {
21
+ baseURL?: string;
22
+ urlParams: FindHomeappStatisticRowByRealtyIdUrlParams;
23
+ };
24
+ export declare function findHomeappStatisticRowByRealtyId({ baseURL, urlParams, }: FindHomeappStatisticRowByRealtyIdConfig): Promise<FindHomeappStatisticRowByRealtyIdData>;
25
+ export {};
@@ -1,25 +1,5 @@
1
1
  import { AxiosResponse, AxiosError } from 'axios';
2
- export declare type StatisticRow = {
3
- createdAt: string;
4
- apartmentId?: number;
5
- likes?: {
6
- value: number;
7
- delta: number;
8
- };
9
- listingViews?: {
10
- value: number;
11
- delta: number;
12
- };
13
- phoneViews?: {
14
- value: number;
15
- delta: number;
16
- };
17
- source: string;
18
- views: {
19
- value: number;
20
- delta: number;
21
- };
22
- };
2
+ import { StatisticRow } from '../../types';
23
3
  declare type ErrorData = {
24
4
  success?: false;
25
5
  data: {
@@ -1,8 +1,9 @@
1
1
  export * from './findActualEventsRow';
2
+ export * from './findExternalLinks';
3
+ export * from './findHomeappStatisticRowByRealtyId';
2
4
  export * from './findNewBuildings';
3
5
  export * from './findPlannedEventsRow';
4
6
  export * from './findScoring';
5
- export * from './findExternalLinks';
6
7
  export * from './findStatisticRow';
7
8
  export * from './getFirstPublishedAt';
8
9
  export * from './getPublishedDays';
@@ -6,6 +6,7 @@ export declare class Api {
6
6
  getPublishedDays: (urlParams: api.GetPublishedDaysUrlParams, headers: api.GetPublishedDaysHeaders) => Promise<api.GetPublishedDaysData>;
7
7
  findNewBuildings: (params: api.FindNewBuildingsParams, headers: api.FindNewBuildingsHeaders) => Promise<api.FindNewBuildingsData>;
8
8
  findExternalLinks: (params: api.FindExternalLinksParams, headers?: api.FindExternalLinksHeaders | undefined) => Promise<api.FindExternalLinksData>;
9
+ findHomeappStatisticRowByRealtyId: (urlParams: api.FindHomeappStatisticRowByRealtyIdUrlParams) => Promise<api.FindHomeappStatisticRowByRealtyIdData>;
9
10
  findStatisticRow: (params: api.FindStatisticRowParams, headers?: api.FindStatisticRowHeaders | undefined) => Promise<api.FindStatisticRowData>;
10
11
  findActualEventsRow: (params: api.FindActualEventsRowParams, headers: api.FindActualEventsRowHeaders) => Promise<api.FindActualEventsRowData>;
11
12
  findPlannedEventsRow: (params: api.FindPlannedEventsRowParams, headers: api.FindPlannedEventsRowHeaders) => Promise<api.FindPlannedEventsRowData>;
@@ -0,0 +1,21 @@
1
+ export declare type StatisticRow = {
2
+ createdAt: string;
3
+ apartmentId?: number;
4
+ likes?: {
5
+ value: number;
6
+ delta: number;
7
+ };
8
+ listingViews?: {
9
+ value: number;
10
+ delta: number;
11
+ };
12
+ phoneViews?: {
13
+ value: number;
14
+ delta: number;
15
+ };
16
+ source: string;
17
+ views: {
18
+ value: number;
19
+ delta: number;
20
+ };
21
+ };
@@ -2,3 +2,4 @@ export * from './ActualEventsRow';
2
2
  export * from './NewBuilding';
3
3
  export * from './PlannedEventsRow';
4
4
  export * from './Scoring';
5
+ export * from './StatisticRow';
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.7",
2
+ "version": "0.2.8",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -10,17 +10,20 @@ type ResultError = ErrorData['data']['error'];
10
10
  export type CreateBuyerHeaders = { 'x-auth-hc': string };
11
11
  export type CreateBuyerBody = {
12
12
  phone: string;
13
- serviceRequest: { id: number };
13
+ serviceRequest: { id: number } | { realtyExtId: number };
14
+ comment?: string;
15
+ contacts?: Array<{ type: string; value: string }>;
14
16
  name?: string;
17
+ offer?: number;
18
+ source?: string;
15
19
  status?: BuyerStatus;
16
- comment?: string;
17
20
  };
18
21
 
19
22
  export type CreateBuyerData = AxiosResponse<ResultData>;
20
23
  export type CreateBuyerError = AxiosError<ResultError>;
21
24
  export type CreateBuyerConfig = {
22
25
  baseURL?: string;
23
- headers: CreateBuyerHeaders;
26
+ headers?: CreateBuyerHeaders;
24
27
  body: CreateBuyerBody;
25
28
  };
26
29
 
@@ -13,7 +13,10 @@ type ResultData = { ids: number[]; byId: Record<string, Partial<User> & { id: nu
13
13
  type ResultError = ErrorData['data']['error'];
14
14
 
15
15
  export type FindExpertsParams = {
16
- filter?: { id?: number | number[] };
16
+ filter?: {
17
+ id?: number | number[];
18
+ realtyId?: number;
19
+ };
17
20
  limits?: { page?: number; count: number | 'all' };
18
21
  sorting?: { direction: 'asc' | 'desc'; type: 'id' | 'createdAt' };
19
22
  };
@@ -96,6 +96,7 @@ export * from './photoOrder/sendPhotoOrderFeedback';
96
96
  export * from './photoOrder/terminatePhotoOrder';
97
97
 
98
98
  export * from './realty/findSimilarRealtyIdsById';
99
+ export * from './realty/subscribeToRealtyUpdates';
99
100
 
100
101
  export * from './serviceRequest/approveCloseServiceRequest';
101
102
  export * from './serviceRequest/callbackServiceRequest';
@@ -0,0 +1,38 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+
3
+ type SuccessData = { success: true };
4
+ type ErrorData = { success: false; data: { error: string } };
5
+
6
+ type ResultData = null;
7
+ type ResultError = ErrorData['data']['error'];
8
+
9
+ export type SubscribeToRealtyUpdatesBody = {
10
+ email: string;
11
+ realtyExtId: number;
12
+ events: Array<'price_changed' | 'published' | 'depublished'>;
13
+ };
14
+ export type SubscribeToRealtyUpdatesData = AxiosResponse<ResultData>;
15
+ export type SubscribeToRealtyUpdatesError = AxiosError<ResultError>;
16
+ export type SubscribeToRealtyUpdatesConfig = {
17
+ baseURL?: string;
18
+ body: SubscribeToRealtyUpdatesBody;
19
+ };
20
+
21
+ export function subscribeToRealtyUpdatesRequest({
22
+ baseURL = 'https://clients.homeapp.ru',
23
+ body,
24
+ }: SubscribeToRealtyUpdatesConfig) {
25
+ return axios
26
+ .post('/api/realty-subscription', body, {
27
+ baseURL,
28
+ headers: { Accept: 'application/json' },
29
+ transformResponse: [
30
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
31
+ (data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? null : data.data.error),
32
+ ],
33
+ })
34
+ .then((res: SubscribeToRealtyUpdatesData) => res)
35
+ .catch((err: SubscribeToRealtyUpdatesError) => {
36
+ throw err;
37
+ });
38
+ }
@@ -62,7 +62,7 @@ export class Api {
62
62
  return api.countBuyersRequest({ params, headers, baseURL: await this.baseURL });
63
63
  };
64
64
 
65
- createBuyer = async (body: api.CreateBuyerBody, headers: api.CallbackBuyerHeaders) => {
65
+ createBuyer = async (body: api.CreateBuyerBody, headers?: api.CallbackBuyerHeaders) => {
66
66
  return api.createBuyerRequest({ body, headers, baseURL: await this.baseURL });
67
67
  };
68
68
 
@@ -485,6 +485,10 @@ export class Api {
485
485
  return api.findSimilarRealtyIdsById({ urlParams, baseURL: await this.baseURL });
486
486
  };
487
487
 
488
+ subscribeToRealtyUpdates = async (body: api.SubscribeToRealtyUpdatesBody) => {
489
+ return api.subscribeToRealtyUpdatesRequest({ body, baseURL: await this.baseURL });
490
+ };
491
+
488
492
  // serviceRequest
489
493
 
490
494
  approveCloseServiceRequest = async (
@@ -13,6 +13,8 @@ import {
13
13
  RealtyType,
14
14
  ExternalLink,
15
15
  PriceHistory,
16
+ Highway,
17
+ MetroStation,
16
18
  } from '../../../types';
17
19
 
18
20
  type RealtyMeta = {
@@ -33,6 +35,8 @@ type SuccessData = {
33
35
  | RealtyImage
34
36
  | RealtyMetroDistance
35
37
  | PriceHistory
38
+ | Highway
39
+ | MetroStation
36
40
  >;
37
41
  meta: { page: { offset: number; count: number; total: number } };
38
42
  errors: never;
@@ -84,10 +88,8 @@ export type FindRealtiesParams = {
84
88
  price?: NumberRange;
85
89
  area?: NumberRange;
86
90
  coordinates?: {
87
- 'topLeft.lat'?: number;
88
- 'topLeft.lng'?: number;
89
- 'bottomRight.lat'?: number;
90
- 'bottomRight.lng'?: number;
91
+ topLeft: { lat: number; lng: number };
92
+ bottomRight: { lat: number; lng: number };
91
93
  };
92
94
  updatedAt?: string;
93
95
  createdAt?: string;
@@ -12,6 +12,8 @@ import {
12
12
  RealtyMetroDistance,
13
13
  ExternalLink,
14
14
  PriceHistory,
15
+ Highway,
16
+ MetroStation,
15
17
  } from '../../../types';
16
18
 
17
19
  export enum FindRealtyByIdDataMetaRealtyAccess {
@@ -45,6 +47,8 @@ type SuccessData = {
45
47
  | RealtyImage
46
48
  | RealtyMetroDistance
47
49
  | PriceHistory
50
+ | Highway
51
+ | MetroStation
48
52
  >;
49
53
  errors: never;
50
54
  };
@@ -3,19 +3,16 @@ export type Address = {
3
3
  type: 'address';
4
4
  attributes: {
5
5
  fullAddress: string;
6
- lat: string;
7
- lng: string;
6
+ lat: number;
7
+ lng: number;
8
8
  city?: string;
9
9
  house?: string;
10
10
  region?: string;
11
11
  street?: string;
12
12
  };
13
13
  relationships: {
14
- addressBti: {
15
- data: { id: string; type: 'addressBti' };
16
- };
17
- metroDistance: {
18
- data: Array<{ id: string; type: 'addressMetroDistance' }>;
19
- };
14
+ // для addressBti data? тк он может приходить как пустой объект
15
+ addressBti: { data?: { id: string; type: 'addressBti' } };
16
+ metroDistance: { data: Array<{ id: string; type: 'addressMetroDistance' }> };
20
17
  };
21
18
  };
@@ -223,10 +223,11 @@ export type RealtyAttributesFlatSecondary = {
223
223
  windowView?: RealtyWindowView;
224
224
  };
225
225
 
226
+ // для complex и complexHousing data? тк они могут приходить как пустой объект
226
227
  export type RealtyRelationshipsFlatSecondary = {
227
228
  address: { data: { id: string; type: 'address' } };
228
- complex?: { data: { id: string; type: 'complex' } };
229
- complexHousing?: { data: { id: string; type: 'complexHousing' } };
229
+ complex?: { data?: { id: string; type: 'complex' } };
230
+ complexHousing?: { data?: { id: string; type: 'complexHousing' } };
230
231
  externalLink?: { data: { id: string; type: 'externalLink' } };
231
232
  metroDistance?: { data: Array<{ id: string; type: 'realtyMetroDistance' }> };
232
233
  realtyImage?: { data: Array<{ id: string; type: 'realtyImage' }> };
@@ -0,0 +1,36 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+ import { StatisticRow } from '../../types';
3
+
4
+ type SuccessData = { success: true; data: StatisticRow };
5
+ type ErrorData = { success: false; data: { error: string } };
6
+
7
+ type ResultData = SuccessData['data'];
8
+ type ResultError = ErrorData['data']['error'];
9
+
10
+ export type FindHomeappStatisticRowByRealtyIdUrlParams = { realtyId: number };
11
+ export type FindHomeappStatisticRowByRealtyIdData = AxiosResponse<ResultData>;
12
+ export type FindHomeappStatisticRowByRealtyIdError = AxiosError<ResultError>;
13
+
14
+ export type FindHomeappStatisticRowByRealtyIdConfig = {
15
+ baseURL?: string;
16
+ urlParams: FindHomeappStatisticRowByRealtyIdUrlParams;
17
+ };
18
+
19
+ export function findHomeappStatisticRowByRealtyId({
20
+ baseURL = 'https://registry.homeapp.ru',
21
+ urlParams,
22
+ }: FindHomeappStatisticRowByRealtyIdConfig) {
23
+ return axios
24
+ .get(`/api/crud/statistic-row/homeapp/last/${urlParams.realtyId}`, {
25
+ baseURL,
26
+ headers: { Accept: 'application/json' },
27
+ transformResponse: [
28
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
29
+ (data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? data.data : data.data.error),
30
+ ],
31
+ })
32
+ .then((res: FindHomeappStatisticRowByRealtyIdData) => res)
33
+ .catch((err: FindHomeappStatisticRowByRealtyIdError) => {
34
+ throw err;
35
+ });
36
+ }
@@ -1,16 +1,8 @@
1
1
  import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
2
  import qs from 'qs';
3
+ import { StatisticRow } from '../../types';
3
4
 
4
- export type StatisticRow = {
5
- createdAt: string;
6
- apartmentId?: number;
7
- likes?: { value: number; delta: number };
8
- listingViews?: { value: number; delta: number };
9
- phoneViews?: { value: number; delta: number };
10
- source: string;
11
- views: { value: number; delta: number };
12
- };
13
- type SuccessData = { success: true; data: Array<StatisticRow>; pageParams: { page?: number; length: number } };
5
+ type SuccessData = { success: true; data: StatisticRow[]; pageParams: { page?: number; length: number } };
14
6
  type ErrorData = { success?: false; data: { error: string } };
15
7
 
16
8
  type ResultData = { ids: string[]; byId: Record<string, StatisticRow>; meta: { total: number } };
@@ -1,8 +1,9 @@
1
1
  export * from './findActualEventsRow';
2
+ export * from './findExternalLinks';
3
+ export * from './findHomeappStatisticRowByRealtyId';
2
4
  export * from './findNewBuildings';
3
5
  export * from './findPlannedEventsRow';
4
6
  export * from './findScoring';
5
- export * from './findExternalLinks';
6
7
  export * from './findStatisticRow';
7
8
  export * from './getFirstPublishedAt';
8
9
  export * from './getPublishedDays';
@@ -22,6 +22,10 @@ export class Api {
22
22
  return api.findExternalLinksRequest({ params, headers, baseURL: await this.baseURL });
23
23
  };
24
24
 
25
+ findHomeappStatisticRowByRealtyId = async (urlParams: api.FindHomeappStatisticRowByRealtyIdUrlParams) => {
26
+ return api.findHomeappStatisticRowByRealtyId({ urlParams, baseURL: await this.baseURL });
27
+ };
28
+
25
29
  findStatisticRow = async (params: api.FindStatisticRowParams, headers?: api.FindStatisticRowHeaders) => {
26
30
  return api.findStatisticRowRequest({ params, headers, baseURL: await this.baseURL });
27
31
  };
@@ -0,0 +1,9 @@
1
+ export type StatisticRow = {
2
+ createdAt: string;
3
+ apartmentId?: number;
4
+ likes?: { value: number; delta: number };
5
+ listingViews?: { value: number; delta: number };
6
+ phoneViews?: { value: number; delta: number };
7
+ source: string;
8
+ views: { value: number; delta: number };
9
+ };
@@ -2,3 +2,4 @@ export * from './ActualEventsRow';
2
2
  export * from './NewBuilding';
3
3
  export * from './PlannedEventsRow';
4
4
  export * from './Scoring';
5
+ export * from './StatisticRow';