@hapl/api-queries 0.1.101 → 0.1.102

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.
@@ -22,6 +22,7 @@ export * from './experts/createExpertCase';
22
22
  export * from './experts/findExpertCases';
23
23
  export * from './experts/findExpertCaseById';
24
24
  export * from './experts/updateExpertCase';
25
+ export * from './serviceRequest/closeServiceRequest';
25
26
  export * from './serviceRequest/completeServiceRequestModeration';
26
27
  export * from './serviceRequest/createServiceRequest';
27
28
  export * from './serviceRequest/createServiceRequestCategorizedFile';
@@ -0,0 +1,31 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { ServiceRequest } from '../../../types';
3
+ declare type SuccessData = {
4
+ success: true;
5
+ data: Partial<ServiceRequest> & {
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 CloseServiceRequestHeaders = {
18
+ 'x-auth-hc': string;
19
+ };
20
+ export declare type CloseServiceRequestUrlParams = {
21
+ id: number;
22
+ };
23
+ export declare type CloseServiceRequestData = AxiosResponse<ResultData>;
24
+ export declare type CloseServiceRequestError = AxiosError<ResultError>;
25
+ export declare type CloseServiceRequestConfig = {
26
+ baseURL?: string;
27
+ urlParams: CloseServiceRequestUrlParams;
28
+ headers: CloseServiceRequestHeaders;
29
+ };
30
+ export declare function closeServiceRequest({ baseURL, urlParams, headers, }: CloseServiceRequestConfig): Promise<CloseServiceRequestData>;
31
+ export {};
@@ -26,6 +26,7 @@ export declare class Api {
26
26
  findExpertCases: (headers?: api.FindExpertCasesHeaders | undefined) => Promise<api.FindExpertCasesData>;
27
27
  findExpertCaseById: (urlParams: api.FindExpertCaseByIdUrlParams, headers?: api.FindExpertCaseByIdHeaders | undefined) => Promise<api.FindExpertCaseByIdData>;
28
28
  updateExpertCase: (urlParams: api.UpdateExpertCaseUrlParams, body: api.UpdateExpertCaseBody, headers: api.UpdateExpertCaseHeaders) => Promise<api.UpdateExpertCaseData>;
29
+ closeServiceRequest: (urlParams: api.CloseServiceRequestUrlParams, headers: api.CloseServiceRequestHeaders) => Promise<api.CloseServiceRequestData>;
29
30
  completeServiceRequestModeration: (urlParams: api.CompleteServiceRequestModerationUrlParams, headers: api.CompleteServiceRequestModerationHeaders) => Promise<api.CompleteServiceRequestModerationData>;
30
31
  createServiceRequest: (body: api.CreateServiceRequestBody, headers: api.CreateServiceRequestHeaders) => Promise<api.CreateServiceRequestData>;
31
32
  createServiceRequestCategorizedFile: (urlParams: api.CreateServiceRequestCategorizedFileUrlParams, body: api.CreateServiceRequestCategorizedFileBody, headers: api.CreateServiceRequestCategorizedFileHeaders) => Promise<api.CreateServiceRequestCategorizedFileData>;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.101",
2
+ "version": "0.1.102",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -29,6 +29,7 @@ export * from './experts/findExpertCases';
29
29
  export * from './experts/findExpertCaseById';
30
30
  export * from './experts/updateExpertCase';
31
31
 
32
+ export * from './serviceRequest/closeServiceRequest';
32
33
  export * from './serviceRequest/completeServiceRequestModeration';
33
34
  export * from './serviceRequest/createServiceRequest';
34
35
  export * from './serviceRequest/createServiceRequestCategorizedFile';
@@ -0,0 +1,42 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+ import { ServiceRequest } from '../../../types';
3
+
4
+ type SuccessData = { success: true; data: Partial<ServiceRequest> & { 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 CloseServiceRequestHeaders = { 'x-auth-hc': string };
11
+ export type CloseServiceRequestUrlParams = { id: number };
12
+ export type CloseServiceRequestData = AxiosResponse<ResultData>;
13
+ export type CloseServiceRequestError = AxiosError<ResultError>;
14
+ export type CloseServiceRequestConfig = {
15
+ baseURL?: string;
16
+ urlParams: CloseServiceRequestUrlParams;
17
+ headers: CloseServiceRequestHeaders;
18
+ };
19
+
20
+ export function closeServiceRequest({
21
+ baseURL = 'https://clients.homeapp.ru',
22
+ urlParams,
23
+ headers,
24
+ }: CloseServiceRequestConfig) {
25
+ return axios
26
+ .patch(
27
+ `/api/service-request/close/${urlParams.id}`,
28
+ {},
29
+ {
30
+ baseURL,
31
+ headers: { Accept: '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
+ )
38
+ .then((res: CloseServiceRequestData) => res)
39
+ .catch((err: CloseServiceRequestError) => {
40
+ throw err;
41
+ });
42
+ }
@@ -145,6 +145,10 @@ export class Api {
145
145
 
146
146
  // serviceRequest
147
147
 
148
+ closeServiceRequest = (urlParams: api.CloseServiceRequestUrlParams, headers: api.CloseServiceRequestHeaders) => {
149
+ return api.closeServiceRequest({ urlParams, headers, baseURL: this.baseURL });
150
+ };
151
+
148
152
  completeServiceRequestModeration = (
149
153
  urlParams: api.CompleteServiceRequestModerationUrlParams,
150
154
  headers: api.CompleteServiceRequestModerationHeaders