@hapl/api-queries 0.2.34 → 0.2.35

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 (43) hide show
  1. package/dist/api-queries.cjs.development.js +1947 -1387
  2. package/dist/api-queries.cjs.development.js.map +1 -1
  3. package/dist/api-queries.cjs.production.min.js +1 -1
  4. package/dist/api-queries.cjs.production.min.js.map +1 -1
  5. package/dist/api-queries.esm.js +1947 -1387
  6. package/dist/api-queries.esm.js.map +1 -1
  7. package/dist/clients/v1/api/callTask/bookCallTask.d.ts +29 -0
  8. package/dist/clients/v1/api/callTask/findCallTasks.d.ts +8 -1
  9. package/dist/clients/v1/api/callTask/findCallTasksCount.d.ts +48 -0
  10. package/dist/clients/v1/api/deal/createDeal/index.d.ts +56 -0
  11. package/dist/clients/v1/api/deal/findDealById/index.d.ts +29 -0
  12. package/dist/clients/v1/api/deal/setDealPrepaidDate/index.d.ts +35 -0
  13. package/dist/clients/v1/api/deal/updateDeal/index.d.ts +4 -3
  14. package/dist/clients/v1/api/index.d.ts +8 -0
  15. package/dist/clients/v1/api/realty/findRealtyDuplicate/index.d.ts +37 -0
  16. package/dist/clients/v1/api/stats/findMarkupBySourceCalls/index.d.ts +42 -0
  17. package/dist/clients/v1/api/stats/findMarkupCalls/index.d.ts +42 -0
  18. package/dist/clients/v1/dictionaries/Deal.d.ts +28 -1
  19. package/dist/clients/v1/index.d.ts +8 -0
  20. package/dist/clients/v1/types/CallStats.d.ts +15 -0
  21. package/dist/clients/v1/types/Deal.d.ts +29 -0
  22. package/dist/clients/v1/types/DealParticipant.d.ts +4 -1
  23. package/dist/clients/v1/types/File.d.ts +1 -0
  24. package/dist/clients/v1/types/index.d.ts +3 -2
  25. package/package.json +1 -1
  26. package/src/clients/v1/api/callTask/bookCallTask.ts +42 -0
  27. package/src/clients/v1/api/callTask/findCallTasks.ts +5 -1
  28. package/src/clients/v1/api/callTask/findCallTasksCount.ts +58 -0
  29. package/src/clients/v1/api/deal/createDeal/index.ts +52 -0
  30. package/src/clients/v1/api/deal/findDealById/index.ts +39 -0
  31. package/src/clients/v1/api/deal/setDealPrepaidDate/index.ts +44 -0
  32. package/src/clients/v1/api/deal/updateDeal/index.ts +10 -3
  33. package/src/clients/v1/api/index.ts +9 -0
  34. package/src/clients/v1/api/realty/findRealtyDuplicate/index.ts +48 -0
  35. package/src/clients/v1/api/stats/findMarkupBySourceCalls/index.ts +59 -0
  36. package/src/clients/v1/api/stats/findMarkupCalls/index.ts +59 -0
  37. package/src/clients/v1/dictionaries/Deal.ts +28 -1
  38. package/src/clients/v1/index.ts +41 -0
  39. package/src/clients/v1/types/CallStats.ts +16 -0
  40. package/src/clients/v1/types/Deal.ts +31 -0
  41. package/src/clients/v1/types/DealParticipant.ts +1 -1
  42. package/src/clients/v1/types/File.ts +1 -0
  43. package/src/clients/v1/types/index.ts +3 -2
@@ -0,0 +1,42 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosResponseTransformer } from 'axios';
2
+ import { CallTask } from '../../types';
3
+
4
+ type SuccessData = { success: true; data: CallTask };
5
+ type ErrorData = { success: false; data: { error: string } };
6
+
7
+ type ResultData = SuccessData['data'];
8
+ type ResultError = ErrorData['data']['error'];
9
+
10
+ export type BookCallTaskHeaders = { 'x-auth-hc'?: string };
11
+ export type BookCallTaskUrlParams = { id: number };
12
+ export type BookCallTaskData = AxiosResponse<ResultData>;
13
+ export type BookCallTaskError = AxiosError<ResultError>;
14
+ export type BookCallTaskConfig = {
15
+ baseURL?: string;
16
+ headers?: BookCallTaskHeaders;
17
+ urlParams: BookCallTaskUrlParams;
18
+ };
19
+
20
+ export function bookCallTaskRequest({
21
+ baseURL = 'https://clients.homeapp.ru',
22
+ urlParams,
23
+ headers,
24
+ }: BookCallTaskConfig) {
25
+ return axios
26
+ .put(`/api/calls/task/book/${urlParams.id}`, undefined, {
27
+ baseURL,
28
+ headers: { Accept: 'application/json', 'Content-Type': 'application/json', ...headers },
29
+ transformResponse: [
30
+ ...(axios.defaults.transformResponse as AxiosResponseTransformer[]),
31
+ (data: SuccessData | ErrorData): ResultData | ResultError => {
32
+ if (data.success) return data.data;
33
+
34
+ return data.data.error;
35
+ },
36
+ ],
37
+ })
38
+ .then((res: BookCallTaskData) => res)
39
+ .catch((err: BookCallTaskError) => {
40
+ throw err;
41
+ });
42
+ }
@@ -14,16 +14,20 @@ export type FindCallTasksHeaders = { 'x-auth-hc': string };
14
14
  export type FindCallTasksParams = {
15
15
  filter?: {
16
16
  'serviceRequest.id'?: string;
17
+ 'curator.id'?: string;
18
+ actualAt?: string | { from: string; to: string };
17
19
  createdAt?: string | { from: string; to: string };
18
20
  hasAccessTags?: string[];
19
21
  hasNoAccessTags?: string[];
20
22
  id?: number | number[];
23
+ isObjectRequest?: boolean;
21
24
  qualityAssurance?: boolean;
25
+ query?: string;
22
26
  status?: CallTaskStatus | CallTaskStatus[];
23
27
  triggeredByEvent?: CallTaskTriggeredByEvent;
24
28
  };
25
29
  limits?: { page?: number; count: number | 'all' };
26
- sorting?: { direction: 'asc' | 'desc'; type: 'createdAt' | 'id' };
30
+ sorting?: { direction: 'asc' | 'desc'; type: 'createdAt' | 'id' | 'source' };
27
31
  };
28
32
  export type FindCallTasksData = AxiosResponse<ResultData>;
29
33
  export type FindCallTasksError = AxiosError<ResultError>;
@@ -0,0 +1,58 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosResponseTransformer } from 'axios';
2
+ import qs from 'qs';
3
+ import { CallTaskStatus, CallTaskTriggeredByEvent } from '../../types';
4
+
5
+ type SuccessData = { success: true; data: { count: number } };
6
+ type ErrorData = { success: false; data: Record<'error' | 'message', string> };
7
+
8
+ type ResultData = SuccessData['data'];
9
+ type ResultError = string;
10
+
11
+ export type FindCallTasksCountHeaders = { 'x-auth-hc': string };
12
+ export type FindCallTasksCountParams = {
13
+ filter?: {
14
+ 'serviceRequest.id'?: string;
15
+ actualAt?: string | { from: string; to: string };
16
+ createdAt?: string | { from: string; to: string };
17
+ hasAccessTags?: string[];
18
+ hasNoAccessTags?: string[];
19
+ id?: number | number[];
20
+ isObjectRequest?: boolean;
21
+ qualityAssurance?: boolean;
22
+ query?: string;
23
+ status?: CallTaskStatus | CallTaskStatus[];
24
+ triggeredByEvent?: CallTaskTriggeredByEvent;
25
+ lastRequestDate?: string;
26
+ };
27
+ limits?: { page?: number; count: number | 'all' };
28
+ };
29
+ export type FindCallTasksCountData = AxiosResponse<ResultData>;
30
+ export type FindCallTasksCountError = AxiosError<ResultError>;
31
+ export type FindCallTasksCountConfig = {
32
+ baseURL?: string;
33
+ headers: FindCallTasksCountHeaders;
34
+ params: FindCallTasksCountParams;
35
+ };
36
+
37
+ export function findCallTasksCountRequest({
38
+ baseURL = 'https://clients.homeapp.ru',
39
+ headers,
40
+ params,
41
+ }: FindCallTasksCountConfig) {
42
+ return axios
43
+ .get('/api/calls/task/last', {
44
+ baseURL,
45
+ params,
46
+ paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
47
+ headers: { Accept: 'application/json', 'Content-Type': 'application/json', ...headers },
48
+ transformResponse: [
49
+ ...(axios.defaults.transformResponse as AxiosResponseTransformer[]),
50
+ (data: SuccessData | ErrorData): ResultData | ResultError =>
51
+ data.success ? { count: data?.data?.count } : data.data.error || data.data.message,
52
+ ],
53
+ })
54
+ .then((res: FindCallTasksCountData) => res)
55
+ .catch((err: FindCallTasksCountError) => {
56
+ throw err;
57
+ });
58
+ }
@@ -0,0 +1,52 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosResponseTransformer } from 'axios';
2
+ import { Deal, DealPartnerDealType, DealParticipant } from '../../../types';
3
+
4
+ type SuccessData = { success: true; data: Deal };
5
+ type ErrorData = { success: false; data: { error: string } };
6
+
7
+ type ResultData = SuccessData['data'];
8
+ type ResultError = ErrorData['data']['error'];
9
+
10
+ export type CreateDealHeaders = { 'x-auth-hc': string };
11
+ export type CreateDealBody = {
12
+ prepaymentPlannedPlace?: string;
13
+ prepaymentPlannedAt?: string;
14
+ plannedCommission: number;
15
+ partnerDealType?: DealPartnerDealType;
16
+ partnerCommission?: number;
17
+ hasPrepayment?: boolean;
18
+ finalPrice?: number;
19
+ developerCommission?: number;
20
+ comment?: string;
21
+ contract?: { id: number };
22
+ buyParams?: { address?: string; flatNumber?: number; cadastralNumber?: string };
23
+ buyer?: { id?: number; name: string; phone: string };
24
+ invest: { isInvestBuyout: boolean } | null;
25
+ dealSignPlannedAt?: string;
26
+ participants: Partial<DealParticipant>[];
27
+ companyDedicatedCommission?: number;
28
+ };
29
+
30
+ export type CreateDealData = AxiosResponse<ResultData>;
31
+ export type CreateDealError = AxiosError<ResultError>;
32
+ export type CreateDealConfig = {
33
+ baseURL?: string;
34
+ headers: CreateDealHeaders;
35
+ body: CreateDealBody;
36
+ };
37
+
38
+ export function createDealRequest({ baseURL = 'https://clients.homeapp.ru', body, headers }: CreateDealConfig) {
39
+ return axios
40
+ .post(`/api/deal`, body, {
41
+ baseURL,
42
+ headers: { Accept: 'application/json', 'Content-Type': 'application/json', ...headers },
43
+ transformResponse: [
44
+ ...(axios.defaults.transformResponse as AxiosResponseTransformer[]),
45
+ (data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? data.data : data.data.error),
46
+ ],
47
+ })
48
+ .then((res: CreateDealData) => res)
49
+ .catch((err: CreateDealError) => {
50
+ throw err;
51
+ });
52
+ }
@@ -0,0 +1,39 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosResponseTransformer } from 'axios';
2
+ import { Deal } from '../../../types';
3
+
4
+ type SuccessData = { success: true; data: Deal };
5
+ type ErrorData = { success: false; data: { error: string } };
6
+
7
+ type ResultData = SuccessData['data'];
8
+ type ResultError = ErrorData['data']['error'];
9
+
10
+ export type FindDealByIdUrlParams = { id: number };
11
+ export type FindDealByIdHeaders = { 'x-auth-hc': string };
12
+ export type FindDealByIdData = AxiosResponse<ResultData>;
13
+ export type FindDealByIdError = AxiosError<ResultError>;
14
+
15
+ export type FindDealByIdConfig = {
16
+ baseURL?: string;
17
+ urlParams: FindDealByIdUrlParams;
18
+ headers: FindDealByIdHeaders;
19
+ };
20
+
21
+ export function findDealByIdRequest({
22
+ baseURL = 'https://clients.homeapp.ru',
23
+ urlParams,
24
+ headers,
25
+ }: FindDealByIdConfig) {
26
+ return axios
27
+ .get(`/api/deal/${urlParams.id}`, {
28
+ baseURL,
29
+ headers: { Accept: 'application/json', ...headers },
30
+ transformResponse: [
31
+ ...(axios.defaults.transformResponse as AxiosResponseTransformer[]),
32
+ (data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? data.data : data.data.error),
33
+ ],
34
+ })
35
+ .then((res: FindDealByIdData) => res)
36
+ .catch((err: FindDealByIdError) => {
37
+ throw err;
38
+ });
39
+ }
@@ -0,0 +1,44 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosResponseTransformer } from 'axios';
2
+ import { Deal } from '../../../types';
3
+
4
+ type SuccessData = { success: true; data: Partial<Deal> & { id: number } };
5
+ type ErrorData = { success: false; data: { error: string } };
6
+
7
+ type ResultData = SuccessData['data'];
8
+ type ResultError = ErrorData['data']['error'];
9
+
10
+ export type SetDealPrepaidDateUrlParams = { id: number };
11
+ export type SetDealPrepaidDateHeaders = { 'x-auth-hc': string };
12
+ export type SetDealPrepaidDateBody = {
13
+ prepaidAt: string;
14
+ };
15
+
16
+ export type SetDealPrepaidDateData = AxiosResponse<ResultData>;
17
+ export type SetDealPrepaidDateError = AxiosError<ResultError>;
18
+ export type SetDealPrepaidDateConfig = {
19
+ baseURL?: string;
20
+ urlParams: SetDealPrepaidDateUrlParams;
21
+ headers: SetDealPrepaidDateHeaders;
22
+ body: SetDealPrepaidDateBody;
23
+ };
24
+
25
+ export function setDealPrepaidDateRequest({
26
+ baseURL = 'https://clients.homeapp.ru',
27
+ urlParams,
28
+ body,
29
+ headers,
30
+ }: SetDealPrepaidDateConfig) {
31
+ return axios
32
+ .patch(`/api/deal/set-prepaid-at/${urlParams.id}`, body, {
33
+ baseURL,
34
+ headers: { Accept: 'application/json', 'Content-Type': 'application/json', ...headers },
35
+ transformResponse: [
36
+ ...(axios.defaults.transformResponse as AxiosResponseTransformer[]),
37
+ (data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? data.data : data.data.error),
38
+ ],
39
+ })
40
+ .then((res: SetDealPrepaidDateData) => res)
41
+ .catch((err: SetDealPrepaidDateError) => {
42
+ throw err;
43
+ });
44
+ }
@@ -1,5 +1,11 @@
1
1
  import axios, { AxiosResponse, AxiosError, AxiosResponseTransformer } from 'axios';
2
- import { Deal, DealNoLawyerReason, DealPartnerDealType, DealCategorizedFileCategory } from '../../../types';
2
+ import {
3
+ Deal,
4
+ DealNoLawyerReason,
5
+ DealPartnerDealType,
6
+ DealCategorizedFileCategory,
7
+ DealParticipant,
8
+ } from '../../../types';
3
9
 
4
10
  type SuccessData = { success: true; data: Deal };
5
11
  type ErrorData = { success: false; data: { error: string } };
@@ -21,7 +27,7 @@ export type UpdateDealBody = {
21
27
  developerCommission?: number;
22
28
  files?: Array<{
23
29
  category: DealCategorizedFileCategory;
24
- id: number;
30
+ id?: number;
25
31
  name: string;
26
32
  type: string;
27
33
  url: string;
@@ -31,10 +37,11 @@ export type UpdateDealBody = {
31
37
  isLawyerRequired?: boolean;
32
38
  lawyer?: { id: number } | null;
33
39
  lawyerNotRequiredReason?: DealNoLawyerReason | null;
34
- partnerCommission?: number;
40
+ partnerCommission?: number | null;
35
41
  partnerDealType?: DealPartnerDealType;
36
42
  plannedCommission?: number;
37
43
  prepaidAt?: string;
44
+ participants?: Partial<DealParticipant>[];
38
45
  prepaymentPlannedAt?: string;
39
46
  registeredAt?: string;
40
47
  registerPlannedAt?: string;
@@ -38,6 +38,7 @@ export * from './callCenter/finishOperatorWork';
38
38
  export * from './callCenter/getOperatorStatus';
39
39
  export * from './callCenter/startOperatorWork';
40
40
 
41
+ export * from './callTask/bookCallTask';
41
42
  export * from './callTask/callCallTask';
42
43
  export * from './callTask/callCallTaskExpert';
43
44
  export * from './callTask/closeCallTask';
@@ -45,6 +46,7 @@ export * from './callTask/createCallTask';
45
46
  export * from './callTask/findCallTaskById';
46
47
  export * from './callTask/findCallTaskSourceInfo';
47
48
  export * from './callTask/findCallTasks';
49
+ export * from './callTask/findCallTasksCount';
48
50
  export * from './callTask/joinCallTaskCall';
49
51
  export * from './callTask/returnCallTaskCall';
50
52
  export * from './callTask/shiftCallTask';
@@ -72,15 +74,18 @@ export * from './crossSale/deleteCrossSale';
72
74
  export * from './crossSale/findCrossSales';
73
75
  export * from './crossSale/updateCrossSale';
74
76
 
77
+ export * from './deal/createDeal';
75
78
  export * from './deal/createDealCategorizedFile';
76
79
  export * from './deal/createDealInvestPrepayment';
77
80
  export * from './deal/deleteDealCategorizedFile';
81
+ export * from './deal/findDealById';
78
82
  export * from './deal/findDealCategorizedFiles';
79
83
  export * from './deal/findDealExpertStatistics';
80
84
  export * from './deal/findDeals';
81
85
  export * from './deal/setDealClassificationScore';
82
86
  export * from './deal/setDealDoneState';
83
87
  export * from './deal/setDealGuaranteedPayment';
88
+ export * from './deal/setDealPrepaidDate';
84
89
  export * from './deal/setDealPrepaymentState';
85
90
  export * from './deal/setDealRegisteredState';
86
91
  export * from './deal/setDealSignPlannedState';
@@ -138,6 +143,7 @@ export * from './photoOrder/findPhotoOrders';
138
143
  export * from './photoOrder/sendPhotoOrderFeedback';
139
144
  export * from './photoOrder/terminatePhotoOrder';
140
145
 
146
+ export * from './realty/findRealtyDuplicate';
141
147
  export * from './realty/findRealtyPriceHistory';
142
148
  export * from './realty/findSimilarRealtyIdsById';
143
149
  export * from './realty/subscribeToRealtyUpdates';
@@ -190,6 +196,9 @@ export * from './slack/createCianRating';
190
196
 
191
197
  export * from './soldStatistic/findSoldStatistic';
192
198
 
199
+ export * from './stats/findMarkupCalls';
200
+ export * from './stats/findMarkupBySourceCalls';
201
+
193
202
  export * from './user/assignSubordinateUsers';
194
203
  export * from './user/createUser';
195
204
  export * from './user/findUserById';
@@ -0,0 +1,48 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosResponseTransformer } from 'axios';
2
+ import { RealtyType } from '../../../types';
3
+ import qs from 'qs';
4
+
5
+ type SuccessData = { success: true; data: { realtyId: number; serviceRequestId: number; formalId: string } };
6
+ type ErrorData = { success: false; data: { error: string } };
7
+
8
+ type ResultData = SuccessData['data'];
9
+ type ResultError = ErrorData['data']['error'];
10
+
11
+ export type FindRealtyDuplicateParams = Partial<{
12
+ fullAddress: string;
13
+ roomCount: number;
14
+ serviceRequestId: number;
15
+ realtyType: RealtyType;
16
+ floor: number;
17
+ }>;
18
+
19
+ export type FindRealtyDuplicateHeaders = { 'x-auth-hc': string };
20
+ export type FindRealtyDuplicateData = AxiosResponse<ResultData>;
21
+ export type FindRealtyDuplicateError = AxiosError<ResultError>;
22
+ export type FindRealtyDuplicateConfig = {
23
+ baseURL?: string;
24
+ params: FindRealtyDuplicateParams;
25
+ headers: FindRealtyDuplicateHeaders;
26
+ };
27
+
28
+ export function findRealtyDuplicateRequest({
29
+ baseURL = 'https://clients.homeapp.ru',
30
+ headers,
31
+ params,
32
+ }: FindRealtyDuplicateConfig) {
33
+ return axios
34
+ .get('/api/realty/duplicate', {
35
+ baseURL,
36
+ headers: { Accept: 'application/json', ...headers },
37
+ params,
38
+ paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
39
+ transformResponse: [
40
+ ...(axios.defaults.transformResponse as AxiosResponseTransformer[]),
41
+ (data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? data.data : data.data.error),
42
+ ],
43
+ })
44
+ .then((res: FindRealtyDuplicateData) => res)
45
+ .catch((err: FindRealtyDuplicateError) => {
46
+ throw err;
47
+ });
48
+ }
@@ -0,0 +1,59 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosResponseTransformer } from 'axios';
2
+ import qs from 'qs';
3
+ import { MarkupBySource } from '../../../types';
4
+ import { nanoid } from 'nanoid';
5
+
6
+ type SuccessData = { success: true; data: MarkupBySource[]; pageParams: { page: number; length: number } };
7
+ type ErrorData = { success: false; data: { error: string } };
8
+
9
+ type ResultData = { ids: string[]; byId: Record<string, MarkupBySource & { _id: string }>; meta: { total: number } };
10
+ type ResultError = ErrorData['data']['error'];
11
+
12
+ export type FindMarkupBySourceCallsParams = {
13
+ filter?: { date?: string | { from?: string; to?: string } };
14
+ limits?: { page?: number; count: number | 'all' };
15
+ };
16
+
17
+ export type FindMarkupBySourceCallsHeaders = { 'x-auth-hc': string };
18
+ export type FindMarkupBySourceCallsData = AxiosResponse<ResultData>;
19
+ export type FindMarkupBySourceCallsError = AxiosError<ResultError>;
20
+ export type FindMarkupBySourceCallsConfig = {
21
+ baseURL?: string;
22
+ params: FindMarkupBySourceCallsParams;
23
+ headers: FindMarkupBySourceCallsHeaders;
24
+ };
25
+
26
+ export function findMarkupBySourceCallsRequest({
27
+ baseURL = 'https://clients.homeapp.ru',
28
+ headers,
29
+ params,
30
+ }: FindMarkupBySourceCallsConfig) {
31
+ return axios
32
+ .get('/api/stats/markup-by-source', {
33
+ baseURL,
34
+ params,
35
+ paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
36
+ headers: { Accept: 'application/json', ...headers },
37
+ transformResponse: [
38
+ ...(axios.defaults.transformResponse as AxiosResponseTransformer[]),
39
+ (data: SuccessData | ErrorData): ResultData | ResultError => {
40
+ if (!data.success) return data.data.error;
41
+
42
+ const ids: ResultData['ids'] = [];
43
+ const byId: ResultData['byId'] = {};
44
+
45
+ (data.data ?? []).forEach(entity => {
46
+ const _id = nanoid();
47
+ byId[_id] = { ...entity, _id };
48
+ ids.push(_id);
49
+ });
50
+
51
+ return { ids, byId, meta: { total: (data.data ?? []).length } };
52
+ },
53
+ ],
54
+ })
55
+ .then((res: FindMarkupBySourceCallsData) => res)
56
+ .catch((err: FindMarkupBySourceCallsError) => {
57
+ throw err;
58
+ });
59
+ }
@@ -0,0 +1,59 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosResponseTransformer } from 'axios';
2
+ import qs from 'qs';
3
+ import { Markup } from '../../../types';
4
+ import { nanoid } from 'nanoid';
5
+
6
+ type SuccessData = { success: true; data: Markup[]; pageParams: { page: number; length: number } };
7
+ type ErrorData = { success: false; data: { error: string } };
8
+
9
+ type ResultData = { ids: string[]; byId: Record<string, Markup & { _id: string }>; meta: { total: number } };
10
+ type ResultError = ErrorData['data']['error'];
11
+
12
+ export type FindMarkupCallsParams = {
13
+ filter?: { date?: string | { from?: string; to?: string } };
14
+ limits?: { page?: number; count: number | 'all' };
15
+ };
16
+
17
+ export type FindMarkupCallsHeaders = { 'x-auth-hc': string };
18
+ export type FindMarkupCallsData = AxiosResponse<ResultData>;
19
+ export type FindMarkupCallsError = AxiosError<ResultError>;
20
+ export type FindMarkupCallsConfig = {
21
+ baseURL?: string;
22
+ params: FindMarkupCallsParams;
23
+ headers: FindMarkupCallsHeaders;
24
+ };
25
+
26
+ export function findMarkupCallsRequest({
27
+ baseURL = 'https://clients.homeapp.ru',
28
+ headers,
29
+ params,
30
+ }: FindMarkupCallsConfig) {
31
+ return axios
32
+ .get('/api/stats/markup', {
33
+ baseURL,
34
+ params,
35
+ paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
36
+ headers: { Accept: 'application/json', ...headers },
37
+ transformResponse: [
38
+ ...(axios.defaults.transformResponse as AxiosResponseTransformer[]),
39
+ (data: SuccessData | ErrorData): ResultData | ResultError => {
40
+ if (!data.success) return data.data.error;
41
+
42
+ const ids: ResultData['ids'] = [];
43
+ const byId: ResultData['byId'] = {};
44
+
45
+ (data.data ?? []).forEach(entity => {
46
+ const _id = nanoid();
47
+ byId[_id] = { ...entity, _id };
48
+ ids.push(_id);
49
+ });
50
+
51
+ return { ids, byId, meta: { total: (data.data ?? []).length } };
52
+ },
53
+ ],
54
+ })
55
+ .then((res: FindMarkupCallsData) => res)
56
+ .catch((err: FindMarkupCallsError) => {
57
+ throw err;
58
+ });
59
+ }
@@ -1,4 +1,4 @@
1
- import { DealNoLawyerReason, DealPartnerDealType, DealStatus } from '../types';
1
+ import { DealBillServiceType, DealFileCategory, DealNoLawyerReason, DealPartnerDealType, DealStatus } from '../types';
2
2
 
3
3
  export const DealDictionary = {
4
4
  DealNoLawyerReason: {
@@ -9,6 +9,33 @@ export const DealDictionary = {
9
9
  [DealPartnerDealType.PartnerCommission]: 'Партнерская сделка (комиссия партнера)',
10
10
  [DealPartnerDealType.HomeappCommission]: 'Партнерская сделка (комиссия Homeapp)',
11
11
  },
12
+ DealFileCategory: {
13
+ [DealFileCategory.DeleteReason]: 'Является обоснованием закрытия сделки',
14
+ [DealFileCategory.Egrn]: 'ЕГРН',
15
+ [DealFileCategory.OwnershipTransfers]: 'Переходы собственности',
16
+ [DealFileCategory.Risk]: 'Проверка на риски',
17
+ [DealFileCategory.Act]: 'Акт с клиентом',
18
+ [DealFileCategory.ActDeveloper]: 'Инвестор',
19
+ [DealFileCategory.OwnershipCertificate]: 'Свид-во права собственности (при покупке)',
20
+ [DealFileCategory.FloorPlan]: 'Поэтажный план',
21
+ [DealFileCategory.Explication]: 'Экспликация',
22
+ [DealFileCategory.Egd]: 'Выписка из домовой книги/ЕЖД',
23
+ [DealFileCategory.ReferenceNoDebtGku]: 'Справка об отсутствии задолж-ти ЖКУ',
24
+ [DealFileCategory.ReferenceNoDebtRepair]: 'Справка об отсутствии задолж-ти по кап. ремонту',
25
+ [DealFileCategory.ReferencePnd]: 'Справки ПНД',
26
+ [DealFileCategory.ReferenceNd]: 'Справки НД',
27
+ [DealFileCategory.PassportContractor]: 'Паспорта контрагента (свид-ва о рождении)',
28
+ [DealFileCategory.MarriageCertificateContractor]: 'Свидетельство о регистрации/расторжении брака',
29
+ [DealFileCategory.SpouseAgreementContractor]: 'Нотариальное согласие супруга',
30
+ [DealFileCategory.Invest]: 'Документы инвестпроекта',
31
+ [DealFileCategory.Other]: 'Разное (сделка)',
32
+ },
33
+ DealBillServiceType: {
34
+ [DealBillServiceType.PartPayment]: 'Частичная оплата обеспечительного платежа по договору',
35
+ [DealBillServiceType.FullPayment]: 'Окончательный расчет по договору',
36
+ [DealBillServiceType.BuyServicePayment]: 'Оплата по договору оказания услуг',
37
+ [DealBillServiceType.SecurityDepositPayment]: 'Оплата по соглашению о принятии ОП',
38
+ },
12
39
  DealStatus: {
13
40
  [DealStatus.PrepaymentPlanned]: 'Запланирован аванс',
14
41
  [DealStatus.NoPrepayment]: 'Запланирована сделка без аванса',
@@ -198,6 +198,10 @@ export class Api {
198
198
 
199
199
  // call task
200
200
 
201
+ bookCallTask = async (urlParams: api.BookCallTaskUrlParams, headers?: api.BookCallTaskHeaders) => {
202
+ return api.bookCallTaskRequest({ urlParams, headers, baseURL: await this.baseURL });
203
+ };
204
+
201
205
  callCallTask = async (urlParams: api.CallCallTaskUrlParams, headers?: api.CreateCallTaskHeaders) => {
202
206
  return api.callCallTaskRequest({ urlParams, headers, baseURL: await this.baseURL });
203
207
  };
@@ -233,6 +237,10 @@ export class Api {
233
237
  return api.findCallTasksRequest({ params, headers, baseURL: await this.baseURL });
234
238
  };
235
239
 
240
+ findCallTasksCount = async (params: api.FindCallTasksCountParams, headers: api.FindCallTasksCountHeaders) => {
241
+ return api.findCallTasksCountRequest({ params, headers, baseURL: await this.baseURL });
242
+ };
243
+
236
244
  joinCallTaskCall = async (urlParams: api.JoinCallTaskCallUrlParams, headers?: api.JoinCallTaskCallHeaders) => {
237
245
  return api.joinCallTaskCallRequest({ urlParams, headers, baseURL: await this.baseURL });
238
246
  };
@@ -380,6 +388,10 @@ export class Api {
380
388
 
381
389
  // deal
382
390
 
391
+ createDeal = async (body: api.CreateDealBody, headers: api.CreateDealHeaders) => {
392
+ return api.createDealRequest({ body, headers, baseURL: await this.baseURL });
393
+ };
394
+
383
395
  createDealCategorizedFile = async (
384
396
  urlParams: api.CreateDealCategorizedFileUrlParams,
385
397
  body: api.CreateDealCategorizedFileBody,
@@ -403,6 +415,10 @@ export class Api {
403
415
  return api.deleteDealCategorizedFileRequest({ urlParams, headers, baseURL: await this.baseURL });
404
416
  };
405
417
 
418
+ findDealById = async (urlParams: api.FindDealByIdUrlParams, headers: api.FindDealByIdHeaders) => {
419
+ return api.findDealByIdRequest({ urlParams, headers, baseURL: await this.baseURL });
420
+ };
421
+
406
422
  findDealCategorizedFiles = async (
407
423
  urlParams: api.FindDealCategorizedFilesUrlParams,
408
424
  params: api.FindDealCategorizedFilesParams,
@@ -443,6 +459,14 @@ export class Api {
443
459
  return api.setDealGuaranteedPaymentRequest({ urlParams, body, headers, baseURL: await this.baseURL });
444
460
  };
445
461
 
462
+ setDealPrepaidDate = async (
463
+ urlParams: api.SetDealPrepaidDateUrlParams,
464
+ body: api.SetDealPrepaidDateBody,
465
+ headers: api.SetDealPrepaidDateHeaders
466
+ ) => {
467
+ return api.setDealPrepaidDateRequest({ urlParams, body, headers, baseURL: await this.baseURL });
468
+ };
469
+
446
470
  setDealPrepaymentState = async (
447
471
  urlParams: api.SetDealPrepaymentStateUrlParams,
448
472
  body: api.SetDealPrepaymentStateBody,
@@ -732,6 +756,10 @@ export class Api {
732
756
 
733
757
  // realty
734
758
 
759
+ findRealtyDuplicate = async (params: api.FindRealtyDuplicateParams, headers: api.FindRealtyDuplicateHeaders) => {
760
+ return api.findRealtyDuplicateRequest({ params, headers, baseURL: await this.baseURL });
761
+ };
762
+
735
763
  findRealtyPriceHistory = async (
736
764
  params: api.FindRealtyPriceHistoryParams,
737
765
  headers: api.FindRealtyPriceHistoryHeaders
@@ -1101,6 +1129,19 @@ export class Api {
1101
1129
  return api.findSoldStatisticRequest({ headers, baseURL: await this.baseURL });
1102
1130
  };
1103
1131
 
1132
+ // stats markup
1133
+
1134
+ findMarkupCalls = async (params: api.FindMarkupCallsParams, headers: api.FindMarkupCallsHeaders) => {
1135
+ return api.findMarkupCallsRequest({ params, headers, baseURL: await this.baseURL });
1136
+ };
1137
+
1138
+ findMarkupBySourceCalls = async (
1139
+ params: api.FindMarkupBySourceCallsParams,
1140
+ headers: api.FindMarkupBySourceCallsHeaders
1141
+ ) => {
1142
+ return api.findMarkupBySourceCallsRequest({ params, headers, baseURL: await this.baseURL });
1143
+ };
1144
+
1104
1145
  // task
1105
1146
 
1106
1147
  findTasks = async (params: api.FindTasksParams, headers: api.FindTasksHeaders) => {
@@ -0,0 +1,16 @@
1
+ export type Markup = {
2
+ count: number;
3
+ createdAt: string;
4
+ markup: number;
5
+ nonMarkup: number;
6
+ };
7
+
8
+ export type MarkupBySource = {
9
+ avito: number;
10
+ cian: number;
11
+ count: number;
12
+ createdAt: string;
13
+ other: number;
14
+ targeting: number;
15
+ yandex: number;
16
+ };