@hapl/api-queries 0.1.188 → 0.1.189

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.
@@ -0,0 +1,29 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { Event } from '../../../types';
3
+ declare type SuccessData = {
4
+ success: true;
5
+ data: Event;
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 FindEventByIdUrlParams = {
16
+ id: number;
17
+ };
18
+ export declare type FindEventByIdHeaders = {
19
+ 'x-auth-hc'?: string;
20
+ };
21
+ export declare type FindEventByIdData = AxiosResponse<ResultData>;
22
+ export declare type FindEventByIdError = AxiosError<ResultError>;
23
+ export declare type FindEventByIdConfig = {
24
+ baseURL?: string;
25
+ urlParams: FindEventByIdUrlParams;
26
+ headers?: FindEventByIdHeaders;
27
+ };
28
+ export declare function findEventByIdRequest({ baseURL, urlParams, headers, }: FindEventByIdConfig): Promise<FindEventByIdData>;
29
+ export {};
@@ -12,7 +12,7 @@ export declare type CreateExpertCaseError = {
12
12
  };
13
13
  export declare type CreateExpertCaseConfig = {
14
14
  baseURL?: string;
15
- headers: CreateExpertCaseHeaders;
15
+ headers?: CreateExpertCaseHeaders;
16
16
  body: CreateExpertCaseBody;
17
17
  };
18
18
  export declare function createExpertCaseRequest({ baseURL, headers, body, }: CreateExpertCaseConfig): Promise<CreateExpertCaseData>;
@@ -50,6 +50,7 @@ export * from './deal/setDealSignPlannedState';
50
50
  export * from './deal/setDealSignedState';
51
51
  export * from './deal/terminateDeal';
52
52
  export * from './deal/updateDeal';
53
+ export * from './event/findEventById';
53
54
  export * from './expert/createExpertCase';
54
55
  export * from './expert/createExpertReview';
55
56
  export * from './expert/findExpertById';
@@ -54,7 +54,8 @@ export declare class Api {
54
54
  setDealSignPlannedState: (urlParams: api.SetDealSignPlannedStateUrlParams, body: api.SetDealSignPlannedStateBody, headers: api.SetDealSignPlannedStateHeaders) => Promise<api.SetDealSignPlannedStateData>;
55
55
  terminateDeal: (urlParams: api.TerminateDealUrlParams, body: api.TerminateDealBody, headers: api.TerminateDealHeaders) => Promise<api.TerminateDealData>;
56
56
  updateDeal: (urlParams: api.UpdateDealUrlParams, body: api.UpdateDealBody, headers: api.UpdateDealHeaders) => Promise<api.UpdateDealData>;
57
- createExpertCase: (body: api.CreateExpertCaseBody, headers: api.CreateExpertCaseHeaders) => Promise<api.CreateExpertCaseData>;
57
+ findEventById: (urlParams: api.FindEventByIdUrlParams, headers?: api.FindEventByIdHeaders | undefined) => Promise<api.FindEventByIdData>;
58
+ createExpertCase: (body: api.CreateExpertCaseBody, headers?: api.CreateExpertCaseHeaders | undefined) => Promise<api.CreateExpertCaseData>;
58
59
  createExpertReview: (urlParams: api.CreateExpertReviewUrlParams, body: api.CreateExpertReviewBody, headers: api.CreateExpertReviewHeaders) => Promise<api.CreateExpertReviewData>;
59
60
  findExpertById: (urlParams: api.FindExpertByIdUrlParams, headers: api.FindExpertByIdHeaders) => Promise<api.FindExpertByIdData>;
60
61
  findExpertCaseById: (urlParams: api.FindExpertCaseByIdUrlParams, headers?: api.FindExpertCaseByIdHeaders | undefined) => Promise<api.FindExpertCaseByIdData>;
@@ -0,0 +1,12 @@
1
+ import { File } from './File';
2
+ export declare type Event = {
3
+ description: string;
4
+ files: Array<Partial<File> & {
5
+ id: number;
6
+ }>;
7
+ id: number;
8
+ name: string;
9
+ promoImage: Partial<File>;
10
+ scheduledAt: string;
11
+ videoUrl?: string;
12
+ };
@@ -16,6 +16,7 @@ export * from './CrossSale';
16
16
  export * from './Deal';
17
17
  export * from './DealCategorizedFile';
18
18
  export * from './DealParticipant';
19
+ export * from './Event';
19
20
  export * from './ExpertReview';
20
21
  export * from './File';
21
22
  export * from './GalleryImage';
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.188",
2
+ "version": "0.1.189",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -0,0 +1,39 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+ import { Event } from '../../../types';
3
+
4
+ type SuccessData = { success: true; data: Event };
5
+ type ErrorData = { success: false; data: { error: string } };
6
+
7
+ type ResultData = SuccessData['data'];
8
+ type ResultError = ErrorData['data']['error'];
9
+
10
+ export type FindEventByIdUrlParams = { id: number };
11
+ export type FindEventByIdHeaders = { 'x-auth-hc'?: string };
12
+ export type FindEventByIdData = AxiosResponse<ResultData>;
13
+ export type FindEventByIdError = AxiosError<ResultError>;
14
+
15
+ export type FindEventByIdConfig = {
16
+ baseURL?: string;
17
+ urlParams: FindEventByIdUrlParams;
18
+ headers?: FindEventByIdHeaders;
19
+ };
20
+
21
+ export function findEventByIdRequest({
22
+ baseURL = 'https://clients.homeapp.ru',
23
+ urlParams,
24
+ headers,
25
+ }: FindEventByIdConfig) {
26
+ return axios
27
+ .get(`/api/site/event/${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: FindEventByIdData) => res)
36
+ .catch((err: FindEventByIdError) => {
37
+ throw err;
38
+ });
39
+ }
@@ -11,7 +11,7 @@ export type CreateExpertCaseData = { data: UserCase };
11
11
  export type CreateExpertCaseError = { status: number; data: string };
12
12
  export type CreateExpertCaseConfig = {
13
13
  baseURL?: string;
14
- headers: CreateExpertCaseHeaders;
14
+ headers?: CreateExpertCaseHeaders;
15
15
  body: CreateExpertCaseBody;
16
16
  };
17
17
 
@@ -60,6 +60,8 @@ export * from './deal/setDealSignedState';
60
60
  export * from './deal/terminateDeal';
61
61
  export * from './deal/updateDeal';
62
62
 
63
+ export * from './event/findEventById';
64
+
63
65
  export * from './expert/createExpertCase';
64
66
  export * from './expert/createExpertReview';
65
67
  export * from './expert/findExpertById';
@@ -314,9 +314,14 @@ export class Api {
314
314
  return api.updateDealRequest({ urlParams, body, headers, baseURL: this.baseURL });
315
315
  };
316
316
 
317
+ // event
318
+ findEventById = (urlParams: api.FindEventByIdUrlParams, headers?: api.FindEventByIdHeaders) => {
319
+ return api.findEventByIdRequest({ urlParams, headers, baseURL: this.baseURL });
320
+ };
321
+
317
322
  // expert
318
323
 
319
- createExpertCase = (body: api.CreateExpertCaseBody, headers: api.CreateExpertCaseHeaders) => {
324
+ createExpertCase = (body: api.CreateExpertCaseBody, headers?: api.CreateExpertCaseHeaders) => {
320
325
  return api.createExpertCaseRequest({ body, headers, baseURL: this.baseURL });
321
326
  };
322
327
 
@@ -0,0 +1,11 @@
1
+ import { File } from './File';
2
+
3
+ export type Event = {
4
+ description: string;
5
+ files: Array<Partial<File> & { id: number }>;
6
+ id: number;
7
+ name: string;
8
+ promoImage: Partial<File>;
9
+ scheduledAt: string;
10
+ videoUrl?: string;
11
+ };
@@ -16,6 +16,7 @@ export * from './CrossSale';
16
16
  export * from './Deal';
17
17
  export * from './DealCategorizedFile';
18
18
  export * from './DealParticipant';
19
+ export * from './Event';
19
20
  export * from './ExpertReview';
20
21
  export * from './File';
21
22
  export * from './GalleryImage';