@hapl/api-queries 0.1.95 → 0.1.96

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.
@@ -29,6 +29,7 @@ export * from './serviceRequest/extendServiceRequestByRealty';
29
29
  export * from './serviceRequest/findServiceRequestById';
30
30
  export * from './serviceRequest/findServiceRequestDuplicates';
31
31
  export * from './serviceRequest/findServiceRequests';
32
+ export * from './serviceRequest/findServiceRequestShortInfoById';
32
33
  export * from './serviceRequest/findServiceRequestCategorizedFiles';
33
34
  export * from './serviceRequest/sendServiceRequestToModeration';
34
35
  export * from './serviceRequest/startServiceRequestModeration';
@@ -1,12 +1,16 @@
1
1
  import { AxiosResponse, AxiosError } from 'axios';
2
2
  import { ServiceRequest } from '../../../types';
3
+ declare type SuccessData = {
4
+ success: true;
5
+ data: ServiceRequest;
6
+ };
3
7
  declare type ErrorData = {
4
8
  success: false;
5
9
  data: {
6
10
  error: string;
7
11
  };
8
12
  };
9
- declare type ResultData = ServiceRequest;
13
+ declare type ResultData = SuccessData['data'];
10
14
  declare type ResultError = ErrorData['data']['error'];
11
15
  export declare type FindServiceRequestByIdUrlParams = {
12
16
  id: number;
@@ -0,0 +1,34 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { ServiceRequest, Realty, User } from '../../../types';
3
+ declare type SuccessData = {
4
+ success: true;
5
+ data: Pick<ServiceRequest, 'curator' | 'publicationTestPeriodDays' | 'realtyExtId'> & {
6
+ realty?: Pick<Realty, 'price' | 'roomsNumber' | 'floorsNumber' | 'area' | 'realtyType'>;
7
+ user?: Pick<User, 'firstName'> & {
8
+ phonePostfix: string;
9
+ };
10
+ };
11
+ };
12
+ declare type ErrorData = {
13
+ success: false;
14
+ data: {
15
+ error: string;
16
+ };
17
+ };
18
+ declare type ResultData = SuccessData['data'];
19
+ declare type ResultError = ErrorData['data']['error'];
20
+ export declare type FindServiceRequestShortInfoByIdUrlParams = {
21
+ id: number;
22
+ };
23
+ export declare type FindServiceRequestShortInfoByIdHeaders = {
24
+ 'x-auth-hc': string;
25
+ };
26
+ export declare type FindServiceRequestShortInfoByIdData = AxiosResponse<ResultData>;
27
+ export declare type FindServiceRequestShortInfoByIdError = AxiosError<ResultError>;
28
+ export declare type FindServiceRequestShortInfoByIdConfig = {
29
+ baseURL?: string;
30
+ urlParams: FindServiceRequestShortInfoByIdUrlParams;
31
+ headers: FindServiceRequestShortInfoByIdHeaders;
32
+ };
33
+ export declare function findServiceRequestShortInfoByIdRequest({ baseURL, urlParams, headers, }: FindServiceRequestShortInfoByIdConfig): Promise<FindServiceRequestShortInfoByIdData>;
34
+ export {};
@@ -33,6 +33,7 @@ export declare class Api {
33
33
  findServiceRequestById: (urlParams: api.FindServiceRequestByIdUrlParams, headers: api.FindServiceRequestByIdHeaders) => Promise<api.FindServiceRequestByIdData>;
34
34
  findServiceRequestDuplicates: (body: api.FindServiceRequestDuplicatesBody, headers: api.FindServiceRequestDuplicatesHeaders) => Promise<api.FindServiceRequestDuplicatesData>;
35
35
  findServiceRequests: (params: api.FindServiceRequestsParams, headers: api.FindServiceRequestsHeaders) => Promise<api.FindServiceRequestsData>;
36
+ findServiceRequestShortInfoById: (urlParams: api.FindServiceRequestShortInfoByIdUrlParams, headers: api.FindServiceRequestShortInfoByIdHeaders) => Promise<api.FindServiceRequestShortInfoByIdData>;
36
37
  findServiceRequestCategorizedFiles: (urlParams: api.FindServiceRequestCategorizedFilesUrlParams, params: api.FindServiceRequestCategorizedFilesParams, headers: api.FindServiceRequestCategorizedFilesHeaders) => Promise<api.FindServiceRequestCategorizedFilesData>;
37
38
  sendServiceRequestToModeration: (urlParams: api.SendServiceRequestToModerationUrlParams, headers: api.SendServiceRequestToModerationHeaders) => Promise<api.SendServiceRequestToModerationData>;
38
39
  startServiceRequestModeration: (urlParams: api.StartServiceRequestModerationUrlParams, headers: api.StartServiceRequestModerationHeaders) => Promise<api.StartServiceRequestModerationData>;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.95",
2
+ "version": "0.1.96",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -35,6 +35,7 @@ export * from './serviceRequest/extendServiceRequestByRealty';
35
35
  export * from './serviceRequest/findServiceRequestById';
36
36
  export * from './serviceRequest/findServiceRequestDuplicates';
37
37
  export * from './serviceRequest/findServiceRequests';
38
+ export * from './serviceRequest/findServiceRequestShortInfoById';
38
39
  export * from './serviceRequest/findServiceRequestCategorizedFiles';
39
40
  export * from './serviceRequest/sendServiceRequestToModeration';
40
41
  export * from './serviceRequest/startServiceRequestModeration';
@@ -4,7 +4,7 @@ import { ServiceRequest } from '../../../types';
4
4
  type SuccessData = { success: true; data: ServiceRequest };
5
5
  type ErrorData = { success: false; data: { error: string } };
6
6
 
7
- type ResultData = ServiceRequest;
7
+ type ResultData = SuccessData['data'];
8
8
  type ResultError = ErrorData['data']['error'];
9
9
 
10
10
  export type FindServiceRequestByIdUrlParams = { id: number };
@@ -26,7 +26,7 @@ export function findServiceRequestByIdRequest({
26
26
  return axios
27
27
  .get(`/api/service-request/${urlParams.id}`, {
28
28
  baseURL,
29
- headers: { Accept: 'application/json', 'Content-Type': 'application/json', ...headers },
29
+ headers: { Accept: 'application/json', ...headers },
30
30
  transformResponse: [
31
31
  ...(axios.defaults.transformResponse as AxiosTransformer[]),
32
32
  (data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? data.data : data.data.error),
@@ -0,0 +1,45 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+ import { ServiceRequest, Realty, User } from '../../../types';
3
+
4
+ type SuccessData = {
5
+ success: true;
6
+ data: Pick<ServiceRequest, 'curator' | 'publicationTestPeriodDays' | 'realtyExtId'> & {
7
+ realty?: Pick<Realty, 'price' | 'roomsNumber' | 'floorsNumber' | 'area' | 'realtyType'>;
8
+ user?: Pick<User, 'firstName'> & { phonePostfix: string };
9
+ };
10
+ };
11
+ type ErrorData = { success: false; data: { error: string } };
12
+
13
+ type ResultData = SuccessData['data'];
14
+ type ResultError = ErrorData['data']['error'];
15
+
16
+ export type FindServiceRequestShortInfoByIdUrlParams = { id: number };
17
+ export type FindServiceRequestShortInfoByIdHeaders = { 'x-auth-hc': string };
18
+ export type FindServiceRequestShortInfoByIdData = AxiosResponse<ResultData>;
19
+ export type FindServiceRequestShortInfoByIdError = AxiosError<ResultError>;
20
+
21
+ export type FindServiceRequestShortInfoByIdConfig = {
22
+ baseURL?: string;
23
+ urlParams: FindServiceRequestShortInfoByIdUrlParams;
24
+ headers: FindServiceRequestShortInfoByIdHeaders;
25
+ };
26
+
27
+ export function findServiceRequestShortInfoByIdRequest({
28
+ baseURL = 'https://clients.homeapp.ru',
29
+ urlParams,
30
+ headers,
31
+ }: FindServiceRequestShortInfoByIdConfig) {
32
+ return axios
33
+ .get(`/api/service-request/short/${urlParams.id}`, {
34
+ baseURL,
35
+ headers: { Accept: 'application/json', ...headers },
36
+ transformResponse: [
37
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
38
+ (data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? data.data : data.data.error),
39
+ ],
40
+ })
41
+ .then((res: FindServiceRequestShortInfoByIdData) => res)
42
+ .catch((err: FindServiceRequestShortInfoByIdError) => {
43
+ throw err;
44
+ });
45
+ }
@@ -185,6 +185,13 @@ export class Api {
185
185
  return api.findServiceRequestsRequest({ params, headers, baseURL: this.baseURL });
186
186
  };
187
187
 
188
+ findServiceRequestShortInfoById = (
189
+ urlParams: api.FindServiceRequestShortInfoByIdUrlParams,
190
+ headers: api.FindServiceRequestShortInfoByIdHeaders
191
+ ) => {
192
+ return api.findServiceRequestShortInfoByIdRequest({ urlParams, headers, baseURL: this.baseURL });
193
+ };
194
+
188
195
  findServiceRequestCategorizedFiles = (
189
196
  urlParams: api.FindServiceRequestCategorizedFilesUrlParams,
190
197
  params: api.FindServiceRequestCategorizedFilesParams,