@hapl/api-queries 0.1.136 → 0.1.137

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.
@@ -74,5 +74,8 @@ export * from './user/findUserById';
74
74
  export * from './user/updateUser';
75
75
  export * from './user/fireUser';
76
76
  export * from './user/assignSubordinateUsers';
77
+ export * from './task/createTask';
77
78
  export * from './task/findTasks';
79
+ export * from './task/findTaskById';
80
+ export * from './task/updateTask';
78
81
  export * from './valuation/findValuationByServiceRequestId';
@@ -0,0 +1,35 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { Task, TaskImportance, TaskNotificationType } from '../../../types';
3
+ declare type SuccessData = {
4
+ success: true;
5
+ data: Task;
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 CreateTaskHeaders = {
16
+ 'x-auth-hc': string;
17
+ };
18
+ export declare type CreateTaskBody = {
19
+ expiresAt: string;
20
+ importance: TaskImportance;
21
+ notificationType: TaskNotificationType;
22
+ serviceRequest: {
23
+ id: number;
24
+ };
25
+ text: string;
26
+ };
27
+ export declare type CreateTaskData = AxiosResponse<ResultData>;
28
+ export declare type CreateTaskError = AxiosError<ResultError>;
29
+ export declare type CreateTaskConfig = {
30
+ baseURL?: string;
31
+ headers: CreateTaskHeaders;
32
+ body: CreateTaskBody;
33
+ };
34
+ export declare function createTaskRequest({ baseURL, body, headers }: CreateTaskConfig): Promise<CreateTaskData>;
35
+ export {};
@@ -0,0 +1,29 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { Task } from '../../../types';
3
+ declare type SuccessData = {
4
+ success: true;
5
+ data: Task;
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 FindTaskByIdUrlParams = {
16
+ id: number;
17
+ };
18
+ export declare type FindTaskByIdHeaders = {
19
+ 'x-auth-hc': string;
20
+ };
21
+ export declare type FindTaskByIdData = AxiosResponse<ResultData>;
22
+ export declare type FindTaskByIdError = AxiosError<ResultError>;
23
+ export declare type FindTaskByIdConfig = {
24
+ baseURL?: string;
25
+ urlParams: FindTaskByIdUrlParams;
26
+ headers: FindTaskByIdHeaders;
27
+ };
28
+ export declare function findTaskByIdRequest({ baseURL, urlParams, headers, }: FindTaskByIdConfig): Promise<FindTaskByIdData>;
29
+ export {};
@@ -0,0 +1,39 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { Task, TaskImportance, TaskNotificationType } from '../../../types';
3
+ declare type SuccessData = {
4
+ success: true;
5
+ data: Task;
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 UpdateTaskUrlParams = {
16
+ id: number;
17
+ };
18
+ export declare type UpdateTaskHeaders = {
19
+ 'x-auth-hc': string;
20
+ };
21
+ export declare type UpdateTaskBody = {
22
+ expiresAt: string;
23
+ importance: TaskImportance;
24
+ notificationType: TaskNotificationType;
25
+ serviceRequest: {
26
+ id: number;
27
+ };
28
+ text: string;
29
+ };
30
+ export declare type UpdateTaskData = AxiosResponse<ResultData>;
31
+ export declare type UpdateTaskError = AxiosError<ResultError>;
32
+ export declare type UpdateTaskConfig = {
33
+ baseURL?: string;
34
+ urlParams: UpdateTaskUrlParams;
35
+ headers: UpdateTaskHeaders;
36
+ body: UpdateTaskBody;
37
+ };
38
+ export declare function updateTaskRequest({ baseURL, urlParams, body, headers, }: UpdateTaskConfig): Promise<UpdateTaskData>;
39
+ export {};
@@ -73,6 +73,9 @@ export declare class Api {
73
73
  findServiceRequestSellerReports: (urlParams: api.FindServiceRequestSellerReportsUrlParams, params: api.FindServiceRequestSellerReportsParams, headers: api.FindServiceRequestSellerReportsHeaders) => Promise<api.FindServiceRequestSellerReportsData>;
74
74
  findSoldStatistic: (headers?: api.FindSoldStatisticHeaders | undefined) => Promise<api.FindSoldStatisticData>;
75
75
  findTasks: (params: api.FindTasksParams, headers: api.FindTasksHeaders) => Promise<api.FindTasksData>;
76
+ findTaskById: (urlParams: api.FindTaskByIdUrlParams, headers: api.FindTaskByIdHeaders) => Promise<api.FindTaskByIdData>;
77
+ createTask: (body: api.CreateTaskBody, headers: api.CreateTaskHeaders) => Promise<api.CreateTaskData>;
78
+ updateTask: (urlParams: api.UpdateTaskUrlParams, body: api.UpdateTaskBody, headers: api.UpdateTaskHeaders) => Promise<api.UpdateTaskData>;
76
79
  createUser: (body: api.CreateUserBody, headers: api.CreateUserHeaders) => Promise<api.CreateUserData>;
77
80
  findUsers: (params: api.FindUsersParams, headers: api.FindUsersHeaders) => Promise<api.FindUsersData>;
78
81
  findUserById: (urlParams: api.FindUserByIdUrlParams, headers: api.FindUserByIdHeaders) => Promise<api.FindUserByIdData>;
@@ -27,12 +27,12 @@ export declare type Task = {
27
27
  createdAt: string;
28
28
  expiresAt: string;
29
29
  id: number;
30
+ importance: TaskImportance;
31
+ notificationType: TaskNotificationType;
30
32
  serviceRequest: Partial<ServiceRequest> & {
31
33
  id: number;
32
34
  };
33
35
  status: TaskStatus;
34
- importance: TaskImportance;
35
- notificationType: TaskNotificationType;
36
36
  text: string;
37
37
  closedAt?: string;
38
38
  resolvedAt?: string;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.136",
2
+ "version": "0.1.137",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -87,6 +87,9 @@ export * from './user/updateUser';
87
87
  export * from './user/fireUser';
88
88
  export * from './user/assignSubordinateUsers';
89
89
 
90
+ export * from './task/createTask';
90
91
  export * from './task/findTasks';
92
+ export * from './task/findTaskById';
93
+ export * from './task/updateTask';
91
94
 
92
95
  export * from './valuation/findValuationByServiceRequestId';
@@ -0,0 +1,41 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+ import { Task, TaskImportance, TaskNotificationType } from '../../../types';
3
+
4
+ type SuccessData = { success: true; data: Task };
5
+ type ErrorData = { success: false; data: { error: string } };
6
+
7
+ type ResultData = SuccessData['data'];
8
+ type ResultError = ErrorData['data']['error'];
9
+
10
+ export type CreateTaskHeaders = { 'x-auth-hc': string };
11
+ export type CreateTaskBody = {
12
+ expiresAt: string;
13
+ importance: TaskImportance;
14
+ notificationType: TaskNotificationType;
15
+ serviceRequest: { id: number };
16
+ text: string;
17
+ };
18
+
19
+ export type CreateTaskData = AxiosResponse<ResultData>;
20
+ export type CreateTaskError = AxiosError<ResultError>;
21
+ export type CreateTaskConfig = {
22
+ baseURL?: string;
23
+ headers: CreateTaskHeaders;
24
+ body: CreateTaskBody;
25
+ };
26
+
27
+ export function createTaskRequest({ baseURL = 'https://clients.homeapp.ru', body, headers }: CreateTaskConfig) {
28
+ return axios
29
+ .post('/api/task', body, {
30
+ baseURL,
31
+ headers: { Accept: 'application/json', 'Content-Type': 'application/json', ...headers },
32
+ transformResponse: [
33
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
34
+ (data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? data.data : data.data.error),
35
+ ],
36
+ })
37
+ .then((res: CreateTaskData) => res)
38
+ .catch((err: CreateTaskError) => {
39
+ throw err;
40
+ });
41
+ }
@@ -0,0 +1,39 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+ import { Task } from '../../../types';
3
+
4
+ type SuccessData = { success: true; data: Task };
5
+ type ErrorData = { success: false; data: { error: string } };
6
+
7
+ type ResultData = SuccessData['data'];
8
+ type ResultError = ErrorData['data']['error'];
9
+
10
+ export type FindTaskByIdUrlParams = { id: number };
11
+ export type FindTaskByIdHeaders = { 'x-auth-hc': string };
12
+ export type FindTaskByIdData = AxiosResponse<ResultData>;
13
+ export type FindTaskByIdError = AxiosError<ResultError>;
14
+
15
+ export type FindTaskByIdConfig = {
16
+ baseURL?: string;
17
+ urlParams: FindTaskByIdUrlParams;
18
+ headers: FindTaskByIdHeaders;
19
+ };
20
+
21
+ export function findTaskByIdRequest({
22
+ baseURL = 'https://clients.homeapp.ru',
23
+ urlParams,
24
+ headers,
25
+ }: FindTaskByIdConfig) {
26
+ return axios
27
+ .get(`/api/task/${urlParams.id}`, {
28
+ baseURL,
29
+ headers: { Accept: 'application/json', ...headers },
30
+ transformResponse: [
31
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
32
+ (data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? data.data : data.data.error),
33
+ ],
34
+ })
35
+ .then((res: FindTaskByIdData) => res)
36
+ .catch((err: FindTaskByIdError) => {
37
+ throw err;
38
+ });
39
+ }
@@ -0,0 +1,48 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+ import { Task, TaskImportance, TaskNotificationType } from '../../../types';
3
+
4
+ type SuccessData = { success: true; data: Task };
5
+ type ErrorData = { success: false; data: { error: string } };
6
+
7
+ type ResultData = SuccessData['data'];
8
+ type ResultError = ErrorData['data']['error'];
9
+
10
+ export type UpdateTaskUrlParams = { id: number };
11
+ export type UpdateTaskHeaders = { 'x-auth-hc': string };
12
+ export type UpdateTaskBody = {
13
+ expiresAt: string;
14
+ importance: TaskImportance;
15
+ notificationType: TaskNotificationType;
16
+ serviceRequest: { id: number };
17
+ text: string;
18
+ };
19
+
20
+ export type UpdateTaskData = AxiosResponse<ResultData>;
21
+ export type UpdateTaskError = AxiosError<ResultError>;
22
+ export type UpdateTaskConfig = {
23
+ baseURL?: string;
24
+ urlParams: UpdateTaskUrlParams;
25
+ headers: UpdateTaskHeaders;
26
+ body: UpdateTaskBody;
27
+ };
28
+
29
+ export function updateTaskRequest({
30
+ baseURL = 'https://clients.homeapp.ru',
31
+ urlParams,
32
+ body,
33
+ headers,
34
+ }: UpdateTaskConfig) {
35
+ return axios
36
+ .put(`/api/task/${urlParams.id}`, body, {
37
+ baseURL,
38
+ headers: { Accept: 'application/json', 'Content-Type': 'application/json', ...headers },
39
+ transformResponse: [
40
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
41
+ (data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? data.data : data.data.error),
42
+ ],
43
+ })
44
+ .then((res: UpdateTaskData) => res)
45
+ .catch((err: UpdateTaskError) => {
46
+ throw err;
47
+ });
48
+ }
@@ -454,6 +454,18 @@ export class Api {
454
454
  return api.findTasksRequest({ params, headers, baseURL: this.baseURL });
455
455
  };
456
456
 
457
+ findTaskById = (urlParams: api.FindTaskByIdUrlParams, headers: api.FindTaskByIdHeaders) => {
458
+ return api.findTaskByIdRequest({ urlParams, headers, baseURL: this.baseURL });
459
+ };
460
+
461
+ createTask = (body: api.CreateTaskBody, headers: api.CreateTaskHeaders) => {
462
+ return api.createTaskRequest({ body, headers, baseURL: this.baseURL });
463
+ };
464
+
465
+ updateTask = (urlParams: api.UpdateTaskUrlParams, body: api.UpdateTaskBody, headers: api.UpdateTaskHeaders) => {
466
+ return api.updateTaskRequest({ urlParams, body, headers, baseURL: this.baseURL });
467
+ };
468
+
457
469
  // user
458
470
 
459
471
  createUser = (body: api.CreateUserBody, headers: api.CreateUserHeaders) => {
@@ -27,10 +27,10 @@ export type Task = {
27
27
  createdAt: string;
28
28
  expiresAt: string;
29
29
  id: number;
30
- serviceRequest: Partial<ServiceRequest> & { id: number };
31
- status: TaskStatus;
32
30
  importance: TaskImportance;
33
31
  notificationType: TaskNotificationType;
32
+ serviceRequest: Partial<ServiceRequest> & { id: number };
33
+ status: TaskStatus;
34
34
  text: string;
35
35
 
36
36
  closedAt?: string;