UNPKG

@topsoft4u/openapi-wrapper

Version:

Wrapper for easier usage of client files generated with openapi-generator-cli

20 lines (19 loc) 833 B
export declare type CallAPIOptions<FuncArgs> = { params: FuncArgs; setInProgress?: (state: boolean) => void; onException?: (exception: any) => void; onResponseFail?: (error: any, code: number) => void; }; export declare type CallAPIRawFunction<T> = { raw: Response; value(): Promise<T>; }; export declare type CallAPIReturn<T> = { result?: T; error?: any; isSuccess: boolean; statusCode: number; }; export declare type CallAPIReturnType<TResult> = Promise<CallAPIReturn<TResult>>; export declare type CallAPIFuncType<TFuncArgs, TResult> = (params: TFuncArgs) => Promise<CallAPIRawFunction<TResult>>; export declare const callAPI: <TClient, TFuncArgs, TResult>(client: TClient, func: CallAPIFuncType<TFuncArgs, TResult>, options?: CallAPIOptions<TFuncArgs>) => Promise<CallAPIReturn<TResult>>;