@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.
- package/CHANGELOG.md +24 -0
- package/dist/api-queries.cjs.development.js +66 -75
- package/dist/api-queries.cjs.development.js.map +1 -1
- package/dist/api-queries.cjs.production.min.js +1 -1
- package/dist/api-queries.cjs.production.min.js.map +1 -1
- package/dist/api-queries.esm.js +66 -75
- package/dist/api-queries.esm.js.map +1 -1
- package/dist/clients/v1/api/{experts → expert}/createExpertCase/index.d.ts +0 -0
- package/dist/clients/v1/api/{experts → expert}/findExpertById/index.d.ts +0 -0
- package/dist/clients/v1/api/{experts → expert}/findExpertCaseById/index.d.ts +0 -0
- package/dist/clients/v1/api/{experts → expert}/findExpertCases/index.d.ts +0 -0
- package/dist/clients/v1/api/{experts → expert}/findExperts/index.d.ts +0 -0
- package/dist/clients/v1/api/{experts → expert}/findPublishedExperts/index.d.ts +0 -0
- package/dist/clients/v1/api/{experts → expert}/updateExpertCase/index.d.ts +0 -0
- package/dist/clients/v1/api/index.d.ts +13 -13
- package/dist/clients/v1/api/serviceRequest/findServiceRequests/index.d.ts +5 -1
- package/dist/clients/v1/api/{users → user}/assignSubordinateUsers/index.d.ts +11 -7
- package/dist/clients/v1/api/user/createUser/index.d.ts +33 -0
- package/dist/clients/v1/api/{users → user}/findUserById/index.d.ts +11 -7
- package/dist/clients/v1/api/user/findUsers/index.d.ts +41 -0
- package/dist/clients/v1/api/{users → user}/fireUser/index.d.ts +4 -4
- package/dist/clients/v1/api/user/updateUser/index.d.ts +61 -0
- package/dist/clients/v1/dictionaries/{Contract.d.ts → Contact.d.ts} +1 -1
- package/dist/clients/v1/dictionaries/User.d.ts +4 -0
- package/dist/clients/v1/dictionaries/UserPhone.d.ts +19 -0
- package/dist/clients/v1/dictionaries/index.d.ts +2 -1
- package/dist/clients/v1/types/User.d.ts +32 -10
- package/package.json +1 -1
- package/src/clients/v1/api/{experts → expert}/createExpertCase/index.ts +0 -0
- package/src/clients/v1/api/{experts → expert}/findExpertById/index.ts +0 -0
- package/src/clients/v1/api/{experts → expert}/findExpertCaseById/index.ts +0 -0
- package/src/clients/v1/api/{experts → expert}/findExpertCases/index.ts +0 -0
- package/src/clients/v1/api/{experts → expert}/findExperts/index.ts +0 -0
- package/src/clients/v1/api/{experts → expert}/findPublishedExperts/index.ts +0 -0
- package/src/clients/v1/api/{experts → expert}/updateExpertCase/index.ts +0 -0
- package/src/clients/v1/api/index.ts +13 -13
- package/src/clients/v1/api/serviceRequest/findServiceRequests/index.ts +2 -1
- package/src/clients/v1/api/{users → user}/assignSubordinateUsers/index.ts +13 -16
- package/src/clients/v1/api/user/createUser/index.ts +42 -0
- package/src/clients/v1/api/user/findUserById/index.ts +34 -0
- package/src/clients/v1/api/user/findUsers/index.ts +61 -0
- package/src/clients/v1/api/{users → user}/fireUser/index.ts +5 -9
- package/src/clients/v1/api/user/updateUser/index.ts +71 -0
- package/src/clients/v1/dictionaries/{Contract.ts → Contact.ts} +1 -1
- package/src/clients/v1/dictionaries/User.ts +4 -0
- package/src/clients/v1/dictionaries/UserPhone.ts +20 -0
- package/src/clients/v1/dictionaries/index.ts +2 -1
- package/src/clients/v1/index.ts +1 -1
- package/src/clients/v1/types/User.ts +23 -9
- package/dist/clients/v1/api/users/createUser/index.d.ts +0 -27
- package/dist/clients/v1/api/users/findUsers/index.d.ts +0 -39
- package/dist/clients/v1/api/users/updateUser/index.d.ts +0 -29
- package/src/clients/v1/api/users/createUser/index.ts +0 -34
- package/src/clients/v1/api/users/findUserById/index.ts +0 -33
- package/src/clients/v1/api/users/findUsers/index.ts +0 -57
- package/src/clients/v1/api/users/updateUser/index.ts +0 -46
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
|
|
2
|
+
import qs from 'qs';
|
|
3
|
+
import { User, UserRole } from '../../../types';
|
|
4
|
+
|
|
5
|
+
type SuccessData = {
|
|
6
|
+
success: true;
|
|
7
|
+
data: User[];
|
|
8
|
+
pageParams: { page: number; length: number };
|
|
9
|
+
};
|
|
10
|
+
type ErrorData = { success: false; data: { error: string } };
|
|
11
|
+
|
|
12
|
+
type ResultData = { ids: number[]; byId: Record<string, User>; meta: { total: number } };
|
|
13
|
+
type ResultError = string;
|
|
14
|
+
|
|
15
|
+
export type FindUsersHeaders = { 'x-auth-hc': string };
|
|
16
|
+
export type FindUsersParams = {
|
|
17
|
+
filter?: {
|
|
18
|
+
banned?: boolean;
|
|
19
|
+
enabled?: boolean;
|
|
20
|
+
fullName?: string;
|
|
21
|
+
id?: number | number[];
|
|
22
|
+
login?: string;
|
|
23
|
+
phone?: number;
|
|
24
|
+
'roles.role'?: UserRole[];
|
|
25
|
+
};
|
|
26
|
+
limits?: { page?: number; count: number | 'all' };
|
|
27
|
+
sorting?: { direction: 'asc' | 'desc'; type: 'createdAt' | 'id' | 'login' };
|
|
28
|
+
};
|
|
29
|
+
export type FindUsersData = AxiosResponse<ResultData>;
|
|
30
|
+
export type FindUsersError = AxiosError<ResultError>;
|
|
31
|
+
export type FindUsersConfig = { baseURL?: string; headers: FindUsersHeaders; params: FindUsersParams };
|
|
32
|
+
|
|
33
|
+
export function findUsersRequest({ baseURL = 'https://clients.homeapp.ru', headers, params }: FindUsersConfig) {
|
|
34
|
+
return axios
|
|
35
|
+
.get('/api/user', {
|
|
36
|
+
baseURL,
|
|
37
|
+
headers: { Accept: 'application/json', ...headers },
|
|
38
|
+
params,
|
|
39
|
+
paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
|
|
40
|
+
transformResponse: [
|
|
41
|
+
...(axios.defaults.transformResponse as AxiosTransformer[]),
|
|
42
|
+
(data: SuccessData | ErrorData): ResultData | ResultError => {
|
|
43
|
+
if (!data.success) return data.data.error;
|
|
44
|
+
|
|
45
|
+
const ids: ResultData['ids'] = [];
|
|
46
|
+
const byId: ResultData['byId'] = {};
|
|
47
|
+
|
|
48
|
+
data.data.forEach(entity => {
|
|
49
|
+
byId[entity.id] = entity;
|
|
50
|
+
ids.push(entity.id);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return { ids, byId, meta: { total: data.pageParams.length } };
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
})
|
|
57
|
+
.then((res: FindUsersData) => res)
|
|
58
|
+
.catch((err: FindUsersError) => {
|
|
59
|
+
throw err;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
@@ -10,10 +10,10 @@ type ResultError = ErrorData['data']['error'];
|
|
|
10
10
|
export type FireUserUrlParams = { id: number };
|
|
11
11
|
export type FireUserHeaders = { 'x-auth-hc': string };
|
|
12
12
|
export type FireUserBody = {
|
|
13
|
-
firedAt: User['firedAt']
|
|
14
|
-
firedType?: User['firedType'];
|
|
15
|
-
firedReason?: User['firedReason'];
|
|
16
|
-
firedComment?: User['firedComment'];
|
|
13
|
+
firedAt: NonNullable<NonNullable<User['employeeInfo']>['firedAt']>;
|
|
14
|
+
firedType?: NonNullable<User['employeeInfo']>['firedType'];
|
|
15
|
+
firedReason?: NonNullable<User['employeeInfo']>['firedReason'];
|
|
16
|
+
firedComment?: NonNullable<User['employeeInfo']>['firedComment'];
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export type FireUserData = AxiosResponse<ResultData>;
|
|
@@ -32,11 +32,7 @@ export function fireUserRequest({ baseURL = 'https://clients.homeapp.ru', urlPar
|
|
|
32
32
|
headers: { Accept: 'application/json', 'Content-Type': 'application/json', ...headers },
|
|
33
33
|
transformResponse: [
|
|
34
34
|
...(axios.defaults.transformResponse as AxiosTransformer[]),
|
|
35
|
-
(data: SuccessData | ErrorData): ResultData | ResultError =>
|
|
36
|
-
if (data.success) return null;
|
|
37
|
-
|
|
38
|
-
return data.data.error;
|
|
39
|
-
},
|
|
35
|
+
(data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? null : data.data.error),
|
|
40
36
|
],
|
|
41
37
|
})
|
|
42
38
|
.then((res: FireUserData) => res)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
|
|
2
|
+
import { User, UserPhone, Contact } 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 UpdateUserUrlParams = { id: number };
|
|
11
|
+
export type UpdateUserHeaders = { 'x-auth-hc': string };
|
|
12
|
+
export type UpdateUserBody = {
|
|
13
|
+
banned?: Required<User>['banned'];
|
|
14
|
+
bornAt?: Required<User>['bornAt'];
|
|
15
|
+
cases?: Required<User>['cases'];
|
|
16
|
+
comment?: Required<User>['comment'];
|
|
17
|
+
contactInfo?: Array<Omit<Contact, 'id'>>;
|
|
18
|
+
courses?: Required<User>['courses'];
|
|
19
|
+
defaultTelephony?: Required<User>['defaultTelephony'] | null;
|
|
20
|
+
description?: Required<User>['description'];
|
|
21
|
+
direction?: Required<User>['direction'];
|
|
22
|
+
districts?: Required<User>['districts'];
|
|
23
|
+
educations?: Required<User>['educations'];
|
|
24
|
+
employeeInfo?: Required<User>['employeeInfo'];
|
|
25
|
+
enabled?: Required<User>['enabled'];
|
|
26
|
+
firstName?: Required<User>['firstName'] | null;
|
|
27
|
+
gallery?: Required<User>['gallery'];
|
|
28
|
+
gender?: Required<User>['gender'];
|
|
29
|
+
hiredAt?: Required<User>['hiredAt'];
|
|
30
|
+
isPublished?: Required<User>['isPublished'];
|
|
31
|
+
lastName?: Required<User>['lastName'] | null;
|
|
32
|
+
level?: Required<User>['level'];
|
|
33
|
+
login?: Required<User>['login'];
|
|
34
|
+
mentor?: Required<User>['mentor'];
|
|
35
|
+
office?: Required<User>['office'];
|
|
36
|
+
patronymic?: Required<User>['patronymic'] | null;
|
|
37
|
+
phones?: Array<Omit<UserPhone, 'id'>>;
|
|
38
|
+
roles?: Required<User>['roles'];
|
|
39
|
+
supervisor?: Required<User>['supervisor'];
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type UpdateUserData = AxiosResponse<ResultData>;
|
|
43
|
+
export type UpdateUserError = AxiosError<ResultError>;
|
|
44
|
+
|
|
45
|
+
export type UpdateUserConfig = {
|
|
46
|
+
baseURL?: string;
|
|
47
|
+
urlParams: UpdateUserUrlParams;
|
|
48
|
+
headers: UpdateUserHeaders;
|
|
49
|
+
body: UpdateUserBody;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export function updateUserRequest({
|
|
53
|
+
baseURL = 'https://clients.homeapp.ru',
|
|
54
|
+
urlParams,
|
|
55
|
+
headers,
|
|
56
|
+
body,
|
|
57
|
+
}: UpdateUserConfig) {
|
|
58
|
+
return axios
|
|
59
|
+
.patch('/api/user/' + urlParams.id, body, {
|
|
60
|
+
baseURL,
|
|
61
|
+
headers: { Accept: 'application/json', 'Content-Type': 'application/json', ...headers },
|
|
62
|
+
transformResponse: [
|
|
63
|
+
...(axios.defaults.transformResponse as AxiosTransformer[]),
|
|
64
|
+
(data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? data.data : data.data.error),
|
|
65
|
+
],
|
|
66
|
+
})
|
|
67
|
+
.then((res: UpdateUserData) => res)
|
|
68
|
+
.catch((err: UpdateUserError) => {
|
|
69
|
+
throw err;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
@@ -20,6 +20,7 @@ export const UserDictionary = {
|
|
|
20
20
|
[UserDirection.NewBuildings]: 'Новостройки',
|
|
21
21
|
[UserDirection.Elite]: 'Элитное жилье',
|
|
22
22
|
[UserDirection.Private]: 'Частные дома',
|
|
23
|
+
[UserDirection.Commercial]: 'Коммерческая недвижимость',
|
|
23
24
|
},
|
|
24
25
|
Gender: {
|
|
25
26
|
[UserGender.Female]: 'Женщина',
|
|
@@ -31,6 +32,7 @@ export const UserDictionary = {
|
|
|
31
32
|
[UserLevel.Expert]: 'Эксперт',
|
|
32
33
|
},
|
|
33
34
|
Office: {
|
|
35
|
+
[UserOffice.Lyubertsy]: 'Люберцы',
|
|
34
36
|
[UserOffice.Moscow]: 'Москва',
|
|
35
37
|
[UserOffice.Zelenograd]: 'Зеленоград',
|
|
36
38
|
[UserOffice.Zhukovsky]: 'Жуковский',
|
|
@@ -53,10 +55,12 @@ export const UserDictionary = {
|
|
|
53
55
|
[UserRole.FinanceHead]: 'Директор финансового отдела',
|
|
54
56
|
[UserRole.ExternalPartner]: 'Внешний партнёр',
|
|
55
57
|
[UserRole.QualityAssessor]: 'Контролёр',
|
|
58
|
+
[UserRole.ChatQualityAssessor]: 'Контролёр чатов',
|
|
56
59
|
[UserRole.SalesHead]: 'Директор по продажам',
|
|
57
60
|
[UserRole.TechSupport]: 'Техподдержка',
|
|
58
61
|
[UserRole.LiquidityReportReader]: 'Чтение отчета по портфелю',
|
|
59
62
|
[UserRole.CashManager]: 'Управление наличными',
|
|
63
|
+
[UserRole.DataScience]: 'Data science',
|
|
60
64
|
[UserRole.Reader]: 'Чтение всего',
|
|
61
65
|
},
|
|
62
66
|
FiredType: {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { UserPhoneType } from '../types';
|
|
2
|
+
|
|
3
|
+
export const UserPhoneDictionary = {
|
|
4
|
+
Type: {
|
|
5
|
+
[UserPhoneType.Sip]: 'Внутренний',
|
|
6
|
+
[UserPhoneType.Main]: 'Основной',
|
|
7
|
+
[UserPhoneType.Work]: 'Рабочий',
|
|
8
|
+
[UserPhoneType.Home]: 'Домашний',
|
|
9
|
+
[UserPhoneType.VirtualZadarma]: 'Общий виртуальный (ZADARMA)',
|
|
10
|
+
[UserPhoneType.VirtualVox]: 'Общий виртуальный (VOX)',
|
|
11
|
+
[UserPhoneType.CianZadarma]: 'Трекинг ЦИАН (ZADARMA)',
|
|
12
|
+
[UserPhoneType.CianVox]: 'Трекинг ЦИАН (VOX)',
|
|
13
|
+
[UserPhoneType.YandexZadarma]: 'Трекинг Яндекс (ZADARMA)',
|
|
14
|
+
[UserPhoneType.YandexVox]: 'Трекинг Яндекс (VOX)',
|
|
15
|
+
[UserPhoneType.AvitoZadarma]: 'Трекинг Avito (ZADARMA)',
|
|
16
|
+
[UserPhoneType.AvitoVox]: 'Трекинг Avito (VOX)',
|
|
17
|
+
[UserPhoneType.YaBlack]: 'Яндекс black (VOX)',
|
|
18
|
+
[UserPhoneType.CiBlack]: 'ЦИАН black (VOX)',
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -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 './
|
|
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';
|
package/src/clients/v1/index.ts
CHANGED
|
@@ -175,7 +175,7 @@ export class Api {
|
|
|
175
175
|
return api.updateDealRequest({ urlParams, body, headers, baseURL: this.baseURL });
|
|
176
176
|
};
|
|
177
177
|
|
|
178
|
-
//
|
|
178
|
+
// expert
|
|
179
179
|
|
|
180
180
|
findExperts = (params: api.FindExpertsParams) => {
|
|
181
181
|
return api.findExpertsRequest({ params, baseURL: this.baseURL });
|
|
@@ -14,6 +14,7 @@ export enum UserDirection {
|
|
|
14
14
|
NewBuildings = 'new-buildings',
|
|
15
15
|
Elite = 'elite',
|
|
16
16
|
Private = 'private',
|
|
17
|
+
Commercial = 'commercial',
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export enum UserGender {
|
|
@@ -28,6 +29,7 @@ export enum UserLevel {
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
export enum UserOffice {
|
|
32
|
+
Lyubertsy = 'lyubertsy',
|
|
31
33
|
Moscow = 'moscow',
|
|
32
34
|
Zelenograd = 'zelenograd',
|
|
33
35
|
Zhukovsky = 'zhukovsky',
|
|
@@ -51,10 +53,12 @@ export enum UserRole {
|
|
|
51
53
|
FinanceHead = 'finance_head',
|
|
52
54
|
ExternalPartner = 'external_partner',
|
|
53
55
|
QualityAssessor = 'quality_assessor',
|
|
56
|
+
ChatQualityAssessor = 'chat_quality_assessor',
|
|
54
57
|
SalesHead = 'sales_head',
|
|
55
58
|
TechSupport = 'tech_support',
|
|
56
59
|
LiquidityReportReader = 'liquidity_report_reader',
|
|
57
60
|
CashManager = 'cash_manager',
|
|
61
|
+
DataScience = 'data_science',
|
|
58
62
|
Reader = 'reader',
|
|
59
63
|
}
|
|
60
64
|
|
|
@@ -122,22 +126,13 @@ export type User = {
|
|
|
122
126
|
phones: Array<Partial<UserPhone> & { id: number }>;
|
|
123
127
|
realtyIds: number[];
|
|
124
128
|
roles: UserRole[];
|
|
125
|
-
attractionChannel: UserAttractionChannel;
|
|
126
129
|
|
|
127
|
-
/**
|
|
128
|
-
* заполняется, если `attractionChannel` равен `other` или `recommendations`
|
|
129
|
-
*/
|
|
130
|
-
attractionChannelExplain?: string;
|
|
131
130
|
transliteratedFullName?: string;
|
|
132
131
|
bornAt?: string;
|
|
133
132
|
comment?: string;
|
|
134
133
|
defaultVirtualPhone?: string;
|
|
135
134
|
description?: string;
|
|
136
135
|
direction?: UserDirection;
|
|
137
|
-
firedAt?: string;
|
|
138
|
-
firedType?: UserFiredType;
|
|
139
|
-
firedReason?: UserFiredReason;
|
|
140
|
-
firedComment?: string;
|
|
141
136
|
firstName?: string;
|
|
142
137
|
gender?: UserGender;
|
|
143
138
|
hiredAt?: string;
|
|
@@ -149,4 +144,23 @@ export type User = {
|
|
|
149
144
|
supervisor?: User;
|
|
150
145
|
updatedAt?: string;
|
|
151
146
|
fullNameTranslit?: string;
|
|
147
|
+
employeeInfo?: {
|
|
148
|
+
attractionChannel: UserAttractionChannel;
|
|
149
|
+
/**
|
|
150
|
+
* заполняется, если `attractionChannel` равен `other` или `recommendations`
|
|
151
|
+
*/
|
|
152
|
+
attractionChannelExplain?: string;
|
|
153
|
+
firedAt?: string;
|
|
154
|
+
firedType?: UserFiredType;
|
|
155
|
+
firedReason?: UserFiredReason;
|
|
156
|
+
firedComment?: string;
|
|
157
|
+
callProxy?: {
|
|
158
|
+
id: number;
|
|
159
|
+
expert: { id: number };
|
|
160
|
+
expertPhone: { id: number; number: number };
|
|
161
|
+
purposePhone: { id: number; number: number };
|
|
162
|
+
createdAt: string;
|
|
163
|
+
expiresAt: string;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
152
166
|
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { User } from '../../../types';
|
|
2
|
-
declare type SuccessData = {
|
|
3
|
-
success: true;
|
|
4
|
-
data: Partial<User> & {
|
|
5
|
-
id: number;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export declare type CreateUserHeaders = {
|
|
9
|
-
'x-auth-hc': string;
|
|
10
|
-
};
|
|
11
|
-
export declare type CreateUserBody = Partial<Omit<User, 'id' | 'createdAt' | 'defaultVirtualPhone' | 'realtyIds' | 'transliteratedFullName' | 'updatedAt'>> & {
|
|
12
|
-
login: string;
|
|
13
|
-
};
|
|
14
|
-
export declare type CreateUserData = {
|
|
15
|
-
data: SuccessData['data'];
|
|
16
|
-
};
|
|
17
|
-
export declare type CreateUserError = {
|
|
18
|
-
status: number;
|
|
19
|
-
data: string;
|
|
20
|
-
};
|
|
21
|
-
export declare type CreateUserConfig = {
|
|
22
|
-
baseURL?: string;
|
|
23
|
-
headers: CreateUserHeaders;
|
|
24
|
-
body: CreateUserBody;
|
|
25
|
-
};
|
|
26
|
-
export declare function createUserRequest({ baseURL, headers, body }: CreateUserConfig): Promise<CreateUserData>;
|
|
27
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { User } from '../../../types';
|
|
2
|
-
export declare type FindUsersHeaders = {
|
|
3
|
-
'x-auth-hc': string;
|
|
4
|
-
};
|
|
5
|
-
export declare type FindUsersParams = {
|
|
6
|
-
filter?: {
|
|
7
|
-
id?: number | number[];
|
|
8
|
-
login?: string;
|
|
9
|
-
};
|
|
10
|
-
limits?: {
|
|
11
|
-
page: number;
|
|
12
|
-
count: number;
|
|
13
|
-
};
|
|
14
|
-
sorting?: {
|
|
15
|
-
direction: 'asc' | 'desc';
|
|
16
|
-
type: 'id' | 'createdAt';
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export declare type FindUsersData = {
|
|
20
|
-
data: {
|
|
21
|
-
ids: number[];
|
|
22
|
-
byId: Record<string, Partial<User> & {
|
|
23
|
-
id: number;
|
|
24
|
-
}>;
|
|
25
|
-
};
|
|
26
|
-
meta: {
|
|
27
|
-
total: number;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
export declare type FindUsersError = {
|
|
31
|
-
status: number;
|
|
32
|
-
data: string;
|
|
33
|
-
};
|
|
34
|
-
export declare type FindUsersConfig = {
|
|
35
|
-
baseURL?: string;
|
|
36
|
-
headers: FindUsersHeaders;
|
|
37
|
-
params: FindUsersParams;
|
|
38
|
-
};
|
|
39
|
-
export declare function findUsersRequest({ baseURL, headers, params }: FindUsersConfig): Promise<FindUsersData>;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { User } from '../../../types';
|
|
2
|
-
declare type SuccessData = {
|
|
3
|
-
success: true;
|
|
4
|
-
data: Partial<User> & {
|
|
5
|
-
id: number;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export declare type UpdateUserUrlParams = {
|
|
9
|
-
id: number;
|
|
10
|
-
};
|
|
11
|
-
export declare type UpdateUserHeaders = {
|
|
12
|
-
'x-auth-hc': string;
|
|
13
|
-
};
|
|
14
|
-
export declare type UpdateUserBody = Partial<Omit<User, 'id' | 'createdAt' | 'defaultVirtualPhone' | 'realtyIds' | 'transliteratedFullName' | 'updatedAt'>>;
|
|
15
|
-
export declare type UpdateUserData = {
|
|
16
|
-
data: SuccessData['data'];
|
|
17
|
-
};
|
|
18
|
-
export declare type UpdateUserError = {
|
|
19
|
-
status: number;
|
|
20
|
-
data: string;
|
|
21
|
-
};
|
|
22
|
-
export declare type UpdateUserConfig = {
|
|
23
|
-
baseURL?: string;
|
|
24
|
-
urlParams: UpdateUserUrlParams;
|
|
25
|
-
headers: UpdateUserHeaders;
|
|
26
|
-
body: UpdateUserBody;
|
|
27
|
-
};
|
|
28
|
-
export declare function updateUserRequest({ baseURL, urlParams, headers, body, }: UpdateUserConfig): Promise<UpdateUserData>;
|
|
29
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import axios, { AxiosResponse, AxiosError } from 'axios';
|
|
2
|
-
import { User } from '../../../types';
|
|
3
|
-
|
|
4
|
-
type SuccessData = { success: true; data: Partial<User> & { id: number } };
|
|
5
|
-
|
|
6
|
-
type ErrorData = { success: false; data: { error: string } };
|
|
7
|
-
|
|
8
|
-
export type CreateUserHeaders = { 'x-auth-hc': string };
|
|
9
|
-
|
|
10
|
-
export type CreateUserBody = Partial<
|
|
11
|
-
Omit<User, 'id' | 'createdAt' | 'defaultVirtualPhone' | 'realtyIds' | 'transliteratedFullName' | 'updatedAt'>
|
|
12
|
-
> & { login: string };
|
|
13
|
-
|
|
14
|
-
export type CreateUserData = { data: SuccessData['data'] };
|
|
15
|
-
|
|
16
|
-
export type CreateUserError = { status: number; data: string };
|
|
17
|
-
|
|
18
|
-
export type CreateUserConfig = { baseURL?: string; headers: CreateUserHeaders; body: CreateUserBody };
|
|
19
|
-
|
|
20
|
-
export function createUserRequest({ baseURL = 'https://clients.homeapp.ru', headers, body }: CreateUserConfig) {
|
|
21
|
-
return axios
|
|
22
|
-
.post('/api/user', body, {
|
|
23
|
-
baseURL,
|
|
24
|
-
headers: { Accept: 'application/json', 'Content-Type': 'application/json', ...headers },
|
|
25
|
-
})
|
|
26
|
-
.then((res: AxiosResponse<SuccessData>): CreateUserData => ({ data: res.data.data }))
|
|
27
|
-
.catch((err: AxiosError<ErrorData>) => {
|
|
28
|
-
const error: Error & Partial<CreateUserError> = new Error(err.message);
|
|
29
|
-
error.status = err.response?.status ?? 520;
|
|
30
|
-
error.data = err.response?.data.data.error ?? 'Unknown Error';
|
|
31
|
-
|
|
32
|
-
throw error;
|
|
33
|
-
});
|
|
34
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import axios, { AxiosResponse, AxiosError } from 'axios';
|
|
2
|
-
import { User } from '../../../types';
|
|
3
|
-
|
|
4
|
-
type SuccessData = { success: true; data: Partial<User> & { id: number } };
|
|
5
|
-
|
|
6
|
-
type ErrorData = { success: false; data: { error: string } };
|
|
7
|
-
|
|
8
|
-
export type FindUserByIdUrlParams = { id: number };
|
|
9
|
-
|
|
10
|
-
export type FindUserByIdHeaders = { 'x-auth-hc': string };
|
|
11
|
-
|
|
12
|
-
export type FindUserByIdData = { data: SuccessData['data'] };
|
|
13
|
-
|
|
14
|
-
export type FindUserByIdError = { status: number; data: string };
|
|
15
|
-
|
|
16
|
-
export type FindUserByIdConfig = { baseURL?: string; urlParams: FindUserByIdUrlParams; headers: FindUserByIdHeaders };
|
|
17
|
-
|
|
18
|
-
export function findUserByIdRequest({
|
|
19
|
-
baseURL = 'https://clients.homeapp.ru',
|
|
20
|
-
urlParams,
|
|
21
|
-
headers,
|
|
22
|
-
}: FindUserByIdConfig) {
|
|
23
|
-
return axios
|
|
24
|
-
.get('/api/user/' + urlParams.id, { baseURL, headers: { Accept: 'application/json', ...headers } })
|
|
25
|
-
.then((res: AxiosResponse<SuccessData>): FindUserByIdData => ({ data: res.data.data }))
|
|
26
|
-
.catch((err: AxiosError<ErrorData>) => {
|
|
27
|
-
const error: Error & Partial<FindUserByIdError> = new Error(err.message);
|
|
28
|
-
error.status = err.response?.status ?? 520;
|
|
29
|
-
error.data = err.response?.data.data.error ?? 'Unknown Error';
|
|
30
|
-
|
|
31
|
-
throw error;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import axios, { AxiosResponse, AxiosError } from 'axios';
|
|
2
|
-
import qs from 'qs';
|
|
3
|
-
import { User } from '../../../types';
|
|
4
|
-
|
|
5
|
-
type SuccessData = {
|
|
6
|
-
success: true;
|
|
7
|
-
data: Partial<User> & { id: number }[];
|
|
8
|
-
pageParams: { page: number; length: number };
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
type ErrorData = { success: false; data: { error: string } };
|
|
12
|
-
|
|
13
|
-
export type FindUsersHeaders = { 'x-auth-hc': string };
|
|
14
|
-
|
|
15
|
-
export type FindUsersParams = {
|
|
16
|
-
filter?: { id?: number | number[]; login?: string };
|
|
17
|
-
limits?: { page: number; count: number };
|
|
18
|
-
sorting?: { direction: 'asc' | 'desc'; type: 'id' | 'createdAt' };
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type FindUsersData = {
|
|
22
|
-
data: { ids: number[]; byId: Record<string, Partial<User> & { id: number }> };
|
|
23
|
-
meta: { total: number };
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type FindUsersError = { status: number; data: string };
|
|
27
|
-
|
|
28
|
-
export type FindUsersConfig = { baseURL?: string; headers: FindUsersHeaders; params: FindUsersParams };
|
|
29
|
-
|
|
30
|
-
export function findUsersRequest({ baseURL = 'https://clients.homeapp.ru', headers, params }: FindUsersConfig) {
|
|
31
|
-
return axios
|
|
32
|
-
.get('/api/user', {
|
|
33
|
-
baseURL,
|
|
34
|
-
headers: { Accept: 'application/json', ...headers },
|
|
35
|
-
params,
|
|
36
|
-
paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
|
|
37
|
-
})
|
|
38
|
-
.then(
|
|
39
|
-
(res: AxiosResponse<SuccessData>): FindUsersData => {
|
|
40
|
-
const data: FindUsersData = { data: { byId: {}, ids: [] }, meta: { total: res.data.pageParams.length } };
|
|
41
|
-
|
|
42
|
-
res.data.data.forEach(entity => {
|
|
43
|
-
data.data.byId[entity.id] = entity;
|
|
44
|
-
data.data.ids.push(entity.id);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
return data;
|
|
48
|
-
}
|
|
49
|
-
)
|
|
50
|
-
.catch((err: AxiosError<ErrorData>) => {
|
|
51
|
-
const error: Error & Partial<FindUsersError> = new Error(err.message);
|
|
52
|
-
error.status = err.response?.status ?? 520;
|
|
53
|
-
error.data = err.response?.data.data.error ?? 'Unknown Error';
|
|
54
|
-
|
|
55
|
-
throw error;
|
|
56
|
-
});
|
|
57
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import axios, { AxiosResponse, AxiosError } from 'axios';
|
|
2
|
-
import { User } from '../../../types';
|
|
3
|
-
|
|
4
|
-
type SuccessData = { success: true; data: Partial<User> & { id: number } };
|
|
5
|
-
|
|
6
|
-
type ErrorData = { success: false; data: { error: string } };
|
|
7
|
-
|
|
8
|
-
export type UpdateUserUrlParams = { id: number };
|
|
9
|
-
|
|
10
|
-
export type UpdateUserHeaders = { 'x-auth-hc': string };
|
|
11
|
-
|
|
12
|
-
export type UpdateUserBody = Partial<
|
|
13
|
-
Omit<User, 'id' | 'createdAt' | 'defaultVirtualPhone' | 'realtyIds' | 'transliteratedFullName' | 'updatedAt'>
|
|
14
|
-
>;
|
|
15
|
-
|
|
16
|
-
export type UpdateUserData = { data: SuccessData['data'] };
|
|
17
|
-
|
|
18
|
-
export type UpdateUserError = { status: number; data: string };
|
|
19
|
-
|
|
20
|
-
export type UpdateUserConfig = {
|
|
21
|
-
baseURL?: string;
|
|
22
|
-
urlParams: UpdateUserUrlParams;
|
|
23
|
-
headers: UpdateUserHeaders;
|
|
24
|
-
body: UpdateUserBody;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export function updateUserRequest({
|
|
28
|
-
baseURL = 'https://clients.homeapp.ru',
|
|
29
|
-
urlParams,
|
|
30
|
-
headers,
|
|
31
|
-
body,
|
|
32
|
-
}: UpdateUserConfig) {
|
|
33
|
-
return axios
|
|
34
|
-
.patch('/api/user/' + urlParams.id, body, {
|
|
35
|
-
baseURL,
|
|
36
|
-
headers: { Accept: 'application/json', 'Content-Type': 'application/json', ...headers },
|
|
37
|
-
})
|
|
38
|
-
.then((res: AxiosResponse<SuccessData>): UpdateUserData => ({ data: res.data.data }))
|
|
39
|
-
.catch((err: AxiosError<ErrorData>) => {
|
|
40
|
-
const error: Error & Partial<UpdateUserError> = new Error(err.message);
|
|
41
|
-
error.status = err.response?.status ?? 520;
|
|
42
|
-
error.data = err.response?.data.data.error ?? 'Unknown Error';
|
|
43
|
-
|
|
44
|
-
throw error;
|
|
45
|
-
});
|
|
46
|
-
}
|