@hapl/api-queries 0.1.135 → 0.1.136--canary.de6ca88.0

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.
@@ -72,5 +72,7 @@ export * from './user/findUserById';
72
72
  export * from './user/updateUser';
73
73
  export * from './user/fireUser';
74
74
  export * from './user/assignSubordinateUsers';
75
+ export * from './task/createTask';
75
76
  export * from './task/findTasks';
77
+ export * from './task/updateTask';
76
78
  export * from './valuation/findValuationByServiceRequestId';
@@ -0,0 +1,35 @@
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 CreateTaskHeaders = {
16
+ 'x-auth-hc': string;
17
+ };
18
+ export declare type CreateTaskBody = {
19
+ expiresAt: string;
20
+ importance: string;
21
+ notificationType: string;
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,39 @@
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 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: string;
24
+ notificationType: string;
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 {};
@@ -71,6 +71,8 @@ export declare class Api {
71
71
  findServiceRequestSellerReports: (urlParams: api.FindServiceRequestSellerReportsUrlParams, params: api.FindServiceRequestSellerReportsParams, headers: api.FindServiceRequestSellerReportsHeaders) => Promise<api.FindServiceRequestSellerReportsData>;
72
72
  findSoldStatistic: (headers?: api.FindSoldStatisticHeaders | undefined) => Promise<api.FindSoldStatisticData>;
73
73
  findTasks: (params: api.FindTasksParams, headers: api.FindTasksHeaders) => Promise<api.FindTasksData>;
74
+ createTask: (body: api.CreateTaskBody, headers: api.CreateTaskHeaders) => Promise<api.CreateTaskData>;
75
+ updateTask: (urlParams: api.UpdateTaskUrlParams, body: api.UpdateTaskBody, headers: api.UpdateTaskHeaders) => Promise<api.UpdateTaskData>;
74
76
  createUser: (body: api.CreateUserBody, headers: api.CreateUserHeaders) => Promise<api.CreateUserData>;
75
77
  findUsers: (params: api.FindUsersParams, headers: api.FindUsersHeaders) => Promise<api.FindUsersData>;
76
78
  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.135",
2
+ "version": "0.1.136--canary.de6ca88.0",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -85,6 +85,8 @@ export * from './user/updateUser';
85
85
  export * from './user/fireUser';
86
86
  export * from './user/assignSubordinateUsers';
87
87
 
88
+ export * from './task/createTask';
88
89
  export * from './task/findTasks';
90
+ export * from './task/updateTask';
89
91
 
90
92
  export * from './valuation/findValuationByServiceRequestId';
@@ -0,0 +1,41 @@
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 CreateTaskHeaders = { 'x-auth-hc': string };
11
+ export type CreateTaskBody = {
12
+ expiresAt: string;
13
+ importance: string;
14
+ notificationType: string;
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,48 @@
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 UpdateTaskUrlParams = { id: number };
11
+ export type UpdateTaskHeaders = { 'x-auth-hc': string };
12
+ export type UpdateTaskBody = {
13
+ expiresAt: string;
14
+ importance: string;
15
+ notificationType: string;
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
+ }
@@ -446,6 +446,14 @@ export class Api {
446
446
  return api.findTasksRequest({ params, headers, baseURL: this.baseURL });
447
447
  };
448
448
 
449
+ createTask = (body: api.CreateTaskBody, headers: api.CreateTaskHeaders) => {
450
+ return api.createTaskRequest({ body, headers, baseURL: this.baseURL });
451
+ };
452
+
453
+ updateTask = (urlParams: api.UpdateTaskUrlParams, body: api.UpdateTaskBody, headers: api.UpdateTaskHeaders) => {
454
+ return api.updateTaskRequest({ urlParams, body, headers, baseURL: this.baseURL });
455
+ };
456
+
449
457
  // user
450
458
 
451
459
  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;