@hapl/api-queries 0.1.131 → 0.1.133

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 (56) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/api-queries.cjs.development.js +66 -75
  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 +66 -75
  7. package/dist/api-queries.esm.js.map +1 -1
  8. package/dist/clients/v1/api/{experts → expert}/createExpertCase/index.d.ts +0 -0
  9. package/dist/clients/v1/api/{experts → expert}/findExpertById/index.d.ts +0 -0
  10. package/dist/clients/v1/api/{experts → expert}/findExpertCaseById/index.d.ts +0 -0
  11. package/dist/clients/v1/api/{experts → expert}/findExpertCases/index.d.ts +0 -0
  12. package/dist/clients/v1/api/{experts → expert}/findExperts/index.d.ts +0 -0
  13. package/dist/clients/v1/api/{experts → expert}/findPublishedExperts/index.d.ts +0 -0
  14. package/dist/clients/v1/api/{experts → expert}/updateExpertCase/index.d.ts +0 -0
  15. package/dist/clients/v1/api/index.d.ts +13 -13
  16. package/dist/clients/v1/api/serviceRequest/findServiceRequests/index.d.ts +5 -1
  17. package/dist/clients/v1/api/{users → user}/assignSubordinateUsers/index.d.ts +11 -7
  18. package/dist/clients/v1/api/user/createUser/index.d.ts +33 -0
  19. package/dist/clients/v1/api/{users → user}/findUserById/index.d.ts +11 -7
  20. package/dist/clients/v1/api/user/findUsers/index.d.ts +41 -0
  21. package/dist/clients/v1/api/{users → user}/fireUser/index.d.ts +4 -4
  22. package/dist/clients/v1/api/user/updateUser/index.d.ts +61 -0
  23. package/dist/clients/v1/dictionaries/{Contract.d.ts → Contact.d.ts} +1 -1
  24. package/dist/clients/v1/dictionaries/User.d.ts +4 -0
  25. package/dist/clients/v1/dictionaries/UserPhone.d.ts +19 -0
  26. package/dist/clients/v1/dictionaries/index.d.ts +2 -1
  27. package/dist/clients/v1/types/User.d.ts +32 -10
  28. package/package.json +1 -1
  29. package/src/clients/v1/api/{experts → expert}/createExpertCase/index.ts +0 -0
  30. package/src/clients/v1/api/{experts → expert}/findExpertById/index.ts +0 -0
  31. package/src/clients/v1/api/{experts → expert}/findExpertCaseById/index.ts +0 -0
  32. package/src/clients/v1/api/{experts → expert}/findExpertCases/index.ts +0 -0
  33. package/src/clients/v1/api/{experts → expert}/findExperts/index.ts +0 -0
  34. package/src/clients/v1/api/{experts → expert}/findPublishedExperts/index.ts +0 -0
  35. package/src/clients/v1/api/{experts → expert}/updateExpertCase/index.ts +0 -0
  36. package/src/clients/v1/api/index.ts +13 -13
  37. package/src/clients/v1/api/serviceRequest/findServiceRequests/index.ts +2 -1
  38. package/src/clients/v1/api/{users → user}/assignSubordinateUsers/index.ts +13 -16
  39. package/src/clients/v1/api/user/createUser/index.ts +42 -0
  40. package/src/clients/v1/api/user/findUserById/index.ts +34 -0
  41. package/src/clients/v1/api/user/findUsers/index.ts +61 -0
  42. package/src/clients/v1/api/{users → user}/fireUser/index.ts +5 -9
  43. package/src/clients/v1/api/user/updateUser/index.ts +71 -0
  44. package/src/clients/v1/dictionaries/{Contract.ts → Contact.ts} +1 -1
  45. package/src/clients/v1/dictionaries/User.ts +4 -0
  46. package/src/clients/v1/dictionaries/UserPhone.ts +20 -0
  47. package/src/clients/v1/dictionaries/index.ts +2 -1
  48. package/src/clients/v1/index.ts +1 -1
  49. package/src/clients/v1/types/User.ts +23 -9
  50. package/dist/clients/v1/api/users/createUser/index.d.ts +0 -27
  51. package/dist/clients/v1/api/users/findUsers/index.d.ts +0 -39
  52. package/dist/clients/v1/api/users/updateUser/index.d.ts +0 -29
  53. package/src/clients/v1/api/users/createUser/index.ts +0 -34
  54. package/src/clients/v1/api/users/findUserById/index.ts +0 -33
  55. package/src/clients/v1/api/users/findUsers/index.ts +0 -57
  56. package/src/clients/v1/api/users/updateUser/index.ts +0 -46
@@ -27,13 +27,13 @@ export * from './deal/deleteDealCategorizedFile';
27
27
  export * from './deal/findDealCategorizedFiles';
28
28
  export * from './deal/terminateDeal';
29
29
  export * from './deal/updateDeal';
30
- export * from './experts/findExperts';
31
- export * from './experts/findPublishedExperts';
32
- export * from './experts/findExpertById';
33
- export * from './experts/createExpertCase';
34
- export * from './experts/findExpertCases';
35
- export * from './experts/findExpertCaseById';
36
- export * from './experts/updateExpertCase';
30
+ export * from './expert/findExperts';
31
+ export * from './expert/findPublishedExperts';
32
+ export * from './expert/findExpertById';
33
+ export * from './expert/createExpertCase';
34
+ export * from './expert/findExpertCases';
35
+ export * from './expert/findExpertCaseById';
36
+ export * from './expert/updateExpertCase';
37
37
  export * from './serviceRequest/approveCloseServiceRequest';
38
38
  export * from './serviceRequest/closeServiceRequest';
39
39
  export * from './serviceRequest/completeServiceRequestModeration';
@@ -62,11 +62,11 @@ export * from './serviceRequest/startServiceRequestModerationForOldRealty';
62
62
  export * from './serviceRequest/publishServiceRequest';
63
63
  export * from './serviceRequest/depublishServiceRequest';
64
64
  export * from './sold/findSoldStatistic';
65
- export * from './users/createUser';
66
- export * from './users/findUsers';
67
- export * from './users/findUserById';
68
- export * from './users/updateUser';
69
- export * from './users/fireUser';
70
- export * from './users/assignSubordinateUsers';
65
+ export * from './user/createUser';
66
+ export * from './user/findUsers';
67
+ export * from './user/findUserById';
68
+ export * from './user/updateUser';
69
+ export * from './user/fireUser';
70
+ export * from './user/assignSubordinateUsers';
71
71
  export * from './task/findTasks';
72
72
  export * from './valuation/findValuationByServiceRequestId';
@@ -49,7 +49,11 @@ export declare type FindServiceRequestsParams = {
49
49
  };
50
50
  limits?: {
51
51
  page: number;
52
- count: number;
52
+ count: number | 'all';
53
+ };
54
+ sorting?: {
55
+ direction: 'asc' | 'desc';
56
+ type: 'createdAt' | 'id';
53
57
  };
54
58
  };
55
59
  export declare type FindServiceRequestsHeaders = {
@@ -1,7 +1,16 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
1
2
  declare type SuccessData = {
2
3
  success: true;
3
4
  data: number[];
4
5
  };
6
+ declare type ErrorData = {
7
+ success: false;
8
+ data: {
9
+ error: string;
10
+ };
11
+ };
12
+ declare type ResultData = SuccessData['data'];
13
+ declare type ResultError = ErrorData['data']['error'];
5
14
  export declare type AssignSubordinateUsersUrlParams = {
6
15
  id: number;
7
16
  };
@@ -11,13 +20,8 @@ export declare type AssignSubordinateUsersHeaders = {
11
20
  export declare type AssignSubordinateUsersBody = {
12
21
  userIds: number[];
13
22
  };
14
- export declare type AssignSubordinateUsersData = {
15
- data: SuccessData['data'];
16
- };
17
- export declare type AssignSubordinateUsersError = {
18
- status: number;
19
- data: string;
20
- };
23
+ export declare type AssignSubordinateUsersData = AxiosResponse<ResultData>;
24
+ export declare type AssignSubordinateUsersError = AxiosError<ResultError>;
21
25
  export declare type AssignSubordinateUsersConfig = {
22
26
  baseURL?: string;
23
27
  urlParams: AssignSubordinateUsersUrlParams;
@@ -0,0 +1,33 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { User, Contact, UserPhone } from '../../../types';
3
+ declare type SuccessData = {
4
+ success: true;
5
+ data: Partial<User> & {
6
+ id: number;
7
+ };
8
+ };
9
+ declare type ErrorData = {
10
+ success: false;
11
+ data: {
12
+ error: string;
13
+ };
14
+ };
15
+ declare type ResultData = SuccessData['data'];
16
+ declare type ResultError = ErrorData['data']['error'];
17
+ export declare type CreateUserHeaders = {
18
+ 'x-auth-hc': string;
19
+ };
20
+ export declare type CreateUserBody = Partial<Omit<User, 'id' | 'contactInfo' | 'createdAt' | 'defaultVirtualPhone' | 'phones' | 'realtyIds' | 'transliteratedFullName' | 'updatedAt'>> & {
21
+ login: string;
22
+ contactInfo?: Array<Omit<Contact, 'id'>>;
23
+ phones?: Array<Omit<UserPhone, 'id'>>;
24
+ };
25
+ export declare type CreateUserData = AxiosResponse<ResultData>;
26
+ export declare type CreateUserError = AxiosError<ResultError>;
27
+ export declare type CreateUserConfig = {
28
+ baseURL?: string;
29
+ headers: CreateUserHeaders;
30
+ body: CreateUserBody;
31
+ };
32
+ export declare function createUserRequest({ baseURL, headers, body }: CreateUserConfig): Promise<CreateUserData>;
33
+ export {};
@@ -1,3 +1,4 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
1
2
  import { User } from '../../../types';
2
3
  declare type SuccessData = {
3
4
  success: true;
@@ -5,19 +6,22 @@ declare type SuccessData = {
5
6
  id: number;
6
7
  };
7
8
  };
9
+ declare type ErrorData = {
10
+ success: false;
11
+ data: {
12
+ error: string;
13
+ };
14
+ };
15
+ declare type ResultData = SuccessData['data'];
16
+ declare type ResultError = ErrorData['data']['error'];
8
17
  export declare type FindUserByIdUrlParams = {
9
18
  id: number;
10
19
  };
11
20
  export declare type FindUserByIdHeaders = {
12
21
  'x-auth-hc': string;
13
22
  };
14
- export declare type FindUserByIdData = {
15
- data: SuccessData['data'];
16
- };
17
- export declare type FindUserByIdError = {
18
- status: number;
19
- data: string;
20
- };
23
+ export declare type FindUserByIdData = AxiosResponse<ResultData>;
24
+ export declare type FindUserByIdError = AxiosError<ResultError>;
21
25
  export declare type FindUserByIdConfig = {
22
26
  baseURL?: string;
23
27
  urlParams: FindUserByIdUrlParams;
@@ -0,0 +1,41 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { User, UserRole } from '../../../types';
3
+ declare type ResultData = {
4
+ ids: number[];
5
+ byId: Record<string, User>;
6
+ meta: {
7
+ total: number;
8
+ };
9
+ };
10
+ declare type ResultError = string;
11
+ export declare type FindUsersHeaders = {
12
+ 'x-auth-hc': string;
13
+ };
14
+ export declare type FindUsersParams = {
15
+ filter?: {
16
+ banned?: boolean;
17
+ enabled?: boolean;
18
+ fullName?: string;
19
+ id?: number | number[];
20
+ login?: string;
21
+ phone?: number;
22
+ 'roles.role'?: UserRole[];
23
+ };
24
+ limits?: {
25
+ page?: number;
26
+ count: number | 'all';
27
+ };
28
+ sorting?: {
29
+ direction: 'asc' | 'desc';
30
+ type: 'createdAt' | 'id' | 'login';
31
+ };
32
+ };
33
+ export declare type FindUsersData = AxiosResponse<ResultData>;
34
+ export declare type FindUsersError = AxiosError<ResultError>;
35
+ export declare type FindUsersConfig = {
36
+ baseURL?: string;
37
+ headers: FindUsersHeaders;
38
+ params: FindUsersParams;
39
+ };
40
+ export declare function findUsersRequest({ baseURL, headers, params }: FindUsersConfig): Promise<FindUsersData>;
41
+ export {};
@@ -15,10 +15,10 @@ export declare type FireUserHeaders = {
15
15
  'x-auth-hc': string;
16
16
  };
17
17
  export declare type FireUserBody = {
18
- firedAt: User['firedAt'];
19
- firedType?: User['firedType'];
20
- firedReason?: User['firedReason'];
21
- firedComment?: User['firedComment'];
18
+ firedAt: NonNullable<NonNullable<User['employeeInfo']>['firedAt']>;
19
+ firedType?: NonNullable<User['employeeInfo']>['firedType'];
20
+ firedReason?: NonNullable<User['employeeInfo']>['firedReason'];
21
+ firedComment?: NonNullable<User['employeeInfo']>['firedComment'];
22
22
  };
23
23
  export declare type FireUserData = AxiosResponse<ResultData>;
24
24
  export declare type FireUserError = AxiosError<ResultError>;
@@ -0,0 +1,61 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { User, UserPhone, Contact } from '../../../types';
3
+ declare type SuccessData = {
4
+ success: true;
5
+ data: Partial<User> & {
6
+ id: number;
7
+ };
8
+ };
9
+ declare type ErrorData = {
10
+ success: false;
11
+ data: {
12
+ error: string;
13
+ };
14
+ };
15
+ declare type ResultData = SuccessData['data'];
16
+ declare type ResultError = ErrorData['data']['error'];
17
+ export declare type UpdateUserUrlParams = {
18
+ id: number;
19
+ };
20
+ export declare type UpdateUserHeaders = {
21
+ 'x-auth-hc': string;
22
+ };
23
+ export declare type UpdateUserBody = {
24
+ banned?: Required<User>['banned'];
25
+ bornAt?: Required<User>['bornAt'];
26
+ cases?: Required<User>['cases'];
27
+ comment?: Required<User>['comment'];
28
+ contactInfo?: Array<Omit<Contact, 'id'>>;
29
+ courses?: Required<User>['courses'];
30
+ defaultTelephony?: Required<User>['defaultTelephony'] | null;
31
+ description?: Required<User>['description'];
32
+ direction?: Required<User>['direction'];
33
+ districts?: Required<User>['districts'];
34
+ educations?: Required<User>['educations'];
35
+ employeeInfo?: Required<User>['employeeInfo'];
36
+ enabled?: Required<User>['enabled'];
37
+ firstName?: Required<User>['firstName'] | null;
38
+ gallery?: Required<User>['gallery'];
39
+ gender?: Required<User>['gender'];
40
+ hiredAt?: Required<User>['hiredAt'];
41
+ isPublished?: Required<User>['isPublished'];
42
+ lastName?: Required<User>['lastName'] | null;
43
+ level?: Required<User>['level'];
44
+ login?: Required<User>['login'];
45
+ mentor?: Required<User>['mentor'];
46
+ office?: Required<User>['office'];
47
+ patronymic?: Required<User>['patronymic'] | null;
48
+ phones?: Array<Omit<UserPhone, 'id'>>;
49
+ roles?: Required<User>['roles'];
50
+ supervisor?: Required<User>['supervisor'];
51
+ };
52
+ export declare type UpdateUserData = AxiosResponse<ResultData>;
53
+ export declare type UpdateUserError = AxiosError<ResultError>;
54
+ export declare type UpdateUserConfig = {
55
+ baseURL?: string;
56
+ urlParams: UpdateUserUrlParams;
57
+ headers: UpdateUserHeaders;
58
+ body: UpdateUserBody;
59
+ };
60
+ export declare function updateUserRequest({ baseURL, urlParams, headers, body, }: UpdateUserConfig): Promise<UpdateUserData>;
61
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { ContactType, ContractStatus, ContractKind } from '../types';
2
- export declare const ContractDictionary: {
2
+ export declare const ContactDictionary: {
3
3
  Type: {
4
4
  "slack-id": string;
5
5
  "slack-group-id": string;
@@ -9,6 +9,7 @@ export declare const UserDictionary: {
9
9
  "new-buildings": string;
10
10
  elite: string;
11
11
  private: string;
12
+ commercial: string;
12
13
  };
13
14
  Gender: {
14
15
  female: string;
@@ -20,6 +21,7 @@ export declare const UserDictionary: {
20
21
  expert: string;
21
22
  };
22
23
  Office: {
24
+ lyubertsy: string;
23
25
  moscow: string;
24
26
  zelenograd: string;
25
27
  zhukovsky: string;
@@ -42,10 +44,12 @@ export declare const UserDictionary: {
42
44
  finance_head: string;
43
45
  external_partner: string;
44
46
  quality_assessor: string;
47
+ chat_quality_assessor: string;
45
48
  sales_head: string;
46
49
  tech_support: string;
47
50
  liquidity_report_reader: string;
48
51
  cash_manager: string;
52
+ data_science: string;
49
53
  reader: string;
50
54
  };
51
55
  FiredType: {
@@ -0,0 +1,19 @@
1
+ import { UserPhoneType } from '../types';
2
+ export declare const UserPhoneDictionary: {
3
+ Type: {
4
+ sip: string;
5
+ main: string;
6
+ work: string;
7
+ home: string;
8
+ virtual_zadarma: string;
9
+ virtual_vox: string;
10
+ cian_zadarma: string;
11
+ cian_vox: string;
12
+ yandex_zadarma: string;
13
+ yandex_vox: string;
14
+ avito_zadarma: string;
15
+ avito_vox: string;
16
+ ya_black: string;
17
+ ci_black: string;
18
+ };
19
+ };
@@ -4,7 +4,7 @@ export * from './Bill';
4
4
  export * from './Buyer';
5
5
  export * from './Call';
6
6
  export * from './CallTask';
7
- export * from './Contract';
7
+ export * from './Contact';
8
8
  export * from './Deal';
9
9
  export * from './DealCategorizedFile';
10
10
  export * from './DealParticipant';
@@ -17,4 +17,5 @@ export * from './ServiceRequestCategorizedFile';
17
17
  export * from './Shape';
18
18
  export * from './Task';
19
19
  export * from './User';
20
+ export * from './UserPhone';
20
21
  export * from './Valuation';
@@ -11,7 +11,8 @@ export declare enum UserDirection {
11
11
  Resale = "resale",
12
12
  NewBuildings = "new-buildings",
13
13
  Elite = "elite",
14
- Private = "private"
14
+ Private = "private",
15
+ Commercial = "commercial"
15
16
  }
16
17
  export declare enum UserGender {
17
18
  Female = "female",
@@ -23,6 +24,7 @@ export declare enum UserLevel {
23
24
  Expert = "expert"
24
25
  }
25
26
  export declare enum UserOffice {
27
+ Lyubertsy = "lyubertsy",
26
28
  Moscow = "moscow",
27
29
  Zelenograd = "zelenograd",
28
30
  Zhukovsky = "zhukovsky"
@@ -45,10 +47,12 @@ export declare enum UserRole {
45
47
  FinanceHead = "finance_head",
46
48
  ExternalPartner = "external_partner",
47
49
  QualityAssessor = "quality_assessor",
50
+ ChatQualityAssessor = "chat_quality_assessor",
48
51
  SalesHead = "sales_head",
49
52
  TechSupport = "tech_support",
50
53
  LiquidityReportReader = "liquidity_report_reader",
51
54
  CashManager = "cash_manager",
55
+ DataScience = "data_science",
52
56
  Reader = "reader"
53
57
  }
54
58
  export declare enum UserFiredType {
@@ -118,21 +122,12 @@ export declare type User = {
118
122
  }>;
119
123
  realtyIds: number[];
120
124
  roles: UserRole[];
121
- attractionChannel: UserAttractionChannel;
122
- /**
123
- * заполняется, если `attractionChannel` равен `other` или `recommendations`
124
- */
125
- attractionChannelExplain?: string;
126
125
  transliteratedFullName?: string;
127
126
  bornAt?: string;
128
127
  comment?: string;
129
128
  defaultVirtualPhone?: string;
130
129
  description?: string;
131
130
  direction?: UserDirection;
132
- firedAt?: string;
133
- firedType?: UserFiredType;
134
- firedReason?: UserFiredReason;
135
- firedComment?: string;
136
131
  firstName?: string;
137
132
  gender?: UserGender;
138
133
  hiredAt?: string;
@@ -144,4 +139,31 @@ export declare type User = {
144
139
  supervisor?: User;
145
140
  updatedAt?: string;
146
141
  fullNameTranslit?: string;
142
+ employeeInfo?: {
143
+ attractionChannel: UserAttractionChannel;
144
+ /**
145
+ * заполняется, если `attractionChannel` равен `other` или `recommendations`
146
+ */
147
+ attractionChannelExplain?: string;
148
+ firedAt?: string;
149
+ firedType?: UserFiredType;
150
+ firedReason?: UserFiredReason;
151
+ firedComment?: string;
152
+ callProxy?: {
153
+ id: number;
154
+ expert: {
155
+ id: number;
156
+ };
157
+ expertPhone: {
158
+ id: number;
159
+ number: number;
160
+ };
161
+ purposePhone: {
162
+ id: number;
163
+ number: number;
164
+ };
165
+ createdAt: string;
166
+ expiresAt: string;
167
+ };
168
+ };
147
169
  };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.131",
2
+ "version": "0.1.133",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -36,13 +36,13 @@ export * from './deal/findDealCategorizedFiles';
36
36
  export * from './deal/terminateDeal';
37
37
  export * from './deal/updateDeal';
38
38
 
39
- export * from './experts/findExperts';
40
- export * from './experts/findPublishedExperts';
41
- export * from './experts/findExpertById';
42
- export * from './experts/createExpertCase';
43
- export * from './experts/findExpertCases';
44
- export * from './experts/findExpertCaseById';
45
- export * from './experts/updateExpertCase';
39
+ export * from './expert/findExperts';
40
+ export * from './expert/findPublishedExperts';
41
+ export * from './expert/findExpertById';
42
+ export * from './expert/createExpertCase';
43
+ export * from './expert/findExpertCases';
44
+ export * from './expert/findExpertCaseById';
45
+ export * from './expert/updateExpertCase';
46
46
 
47
47
  export * from './serviceRequest/approveCloseServiceRequest';
48
48
  export * from './serviceRequest/closeServiceRequest';
@@ -74,12 +74,12 @@ export * from './serviceRequest/depublishServiceRequest';
74
74
 
75
75
  export * from './sold/findSoldStatistic';
76
76
 
77
- export * from './users/createUser';
78
- export * from './users/findUsers';
79
- export * from './users/findUserById';
80
- export * from './users/updateUser';
81
- export * from './users/fireUser';
82
- export * from './users/assignSubordinateUsers';
77
+ export * from './user/createUser';
78
+ export * from './user/findUsers';
79
+ export * from './user/findUserById';
80
+ export * from './user/updateUser';
81
+ export * from './user/fireUser';
82
+ export * from './user/assignSubordinateUsers';
83
83
 
84
84
  export * from './task/findTasks';
85
85
 
@@ -35,7 +35,8 @@ export type FindServiceRequestsParams = {
35
35
  type?: ServiceRequestType | ServiceRequestType[];
36
36
  withRealty?: boolean;
37
37
  };
38
- limits?: { page: number; count: number };
38
+ limits?: { page: number; count: number | 'all' };
39
+ sorting?: { direction: 'asc' | 'desc'; type: 'createdAt' | 'id' };
39
40
  };
40
41
 
41
42
  export type FindServiceRequestsHeaders = { 'x-auth-hc': string };
@@ -1,19 +1,16 @@
1
- import axios, { AxiosResponse, AxiosError } from 'axios';
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
2
 
3
3
  type SuccessData = { success: true; data: number[] };
4
-
5
4
  type ErrorData = { success: false; data: { error: string } };
6
5
 
7
- export type AssignSubordinateUsersUrlParams = { id: number };
6
+ type ResultData = SuccessData['data'];
7
+ type ResultError = ErrorData['data']['error'];
8
8
 
9
+ export type AssignSubordinateUsersUrlParams = { id: number };
9
10
  export type AssignSubordinateUsersHeaders = { 'x-auth-hc': string };
10
-
11
11
  export type AssignSubordinateUsersBody = { userIds: number[] };
12
-
13
- export type AssignSubordinateUsersData = { data: SuccessData['data'] };
14
-
15
- export type AssignSubordinateUsersError = { status: number; data: string };
16
-
12
+ export type AssignSubordinateUsersData = AxiosResponse<ResultData>;
13
+ export type AssignSubordinateUsersError = AxiosError<ResultError>;
17
14
  export type AssignSubordinateUsersConfig = {
18
15
  baseURL?: string;
19
16
  urlParams: AssignSubordinateUsersUrlParams;
@@ -31,13 +28,13 @@ export function assignSubordinateUsersRequest({
31
28
  .put('/api/user/supervise/' + urlParams.id, body, {
32
29
  baseURL,
33
30
  headers: { Accept: 'application/json', 'Content-Type': 'application/json', ...headers },
31
+ transformResponse: [
32
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
33
+ (data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? data.data : data.data.error),
34
+ ],
34
35
  })
35
- .then((res: AxiosResponse<SuccessData>): AssignSubordinateUsersData => ({ data: res.data.data }))
36
- .catch((err: AxiosError<ErrorData>) => {
37
- const error: Error & Partial<AssignSubordinateUsersError> = new Error(err.message);
38
- error.status = err.response?.status ?? 520;
39
- error.data = err.response?.data.data.error ?? 'Unknown Error';
40
-
41
- throw error;
36
+ .then((res: AssignSubordinateUsersData) => res)
37
+ .catch((err: AssignSubordinateUsersError) => {
38
+ throw err;
42
39
  });
43
40
  }
@@ -0,0 +1,42 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+ import { User, Contact, UserPhone } from '../../../types';
3
+
4
+ type SuccessData = { success: true; data: Partial<User> & { 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 CreateUserHeaders = { 'x-auth-hc': string };
11
+ export type CreateUserBody = Partial<
12
+ Omit<
13
+ User,
14
+ | 'id'
15
+ | 'contactInfo'
16
+ | 'createdAt'
17
+ | 'defaultVirtualPhone'
18
+ | 'phones'
19
+ | 'realtyIds'
20
+ | 'transliteratedFullName'
21
+ | 'updatedAt'
22
+ >
23
+ > & { login: string; contactInfo?: Array<Omit<Contact, 'id'>>; phones?: Array<Omit<UserPhone, 'id'>> };
24
+ export type CreateUserData = AxiosResponse<ResultData>;
25
+ export type CreateUserError = AxiosError<ResultError>;
26
+ export type CreateUserConfig = { baseURL?: string; headers: CreateUserHeaders; body: CreateUserBody };
27
+
28
+ export function createUserRequest({ baseURL = 'https://clients.homeapp.ru', headers, body }: CreateUserConfig) {
29
+ return axios
30
+ .post('/api/user', body, {
31
+ baseURL,
32
+ headers: { Accept: 'application/json', 'Content-Type': 'application/json', ...headers },
33
+ transformResponse: [
34
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
35
+ (data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? data.data : data.data.error),
36
+ ],
37
+ })
38
+ .then((res: CreateUserData) => res)
39
+ .catch((err: CreateUserError) => {
40
+ throw err;
41
+ });
42
+ }
@@ -0,0 +1,34 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+ import { User } from '../../../types';
3
+
4
+ type SuccessData = { success: true; data: Partial<User> & { 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 FindUserByIdUrlParams = { id: number };
11
+ export type FindUserByIdHeaders = { 'x-auth-hc': string };
12
+ export type FindUserByIdData = AxiosResponse<ResultData>;
13
+ export type FindUserByIdError = AxiosError<ResultError>;
14
+ export type FindUserByIdConfig = { baseURL?: string; urlParams: FindUserByIdUrlParams; headers: FindUserByIdHeaders };
15
+
16
+ export function findUserByIdRequest({
17
+ baseURL = 'https://clients.homeapp.ru',
18
+ urlParams,
19
+ headers,
20
+ }: FindUserByIdConfig) {
21
+ return axios
22
+ .get('/api/user/' + urlParams.id, {
23
+ baseURL,
24
+ headers: { Accept: 'application/json', ...headers },
25
+ transformResponse: [
26
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
27
+ (data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? data.data : data.data.error),
28
+ ],
29
+ })
30
+ .then((res: FindUserByIdData) => res)
31
+ .catch((err: FindUserByIdError) => {
32
+ throw err;
33
+ });
34
+ }