UNPKG

2.4 kBTypeScriptView Raw
1export declare type RequestType = "post" | "get" | "jsonp";
2export declare type ResponseType = "json" | "text";
3export declare type IOptionsSend = (options: IOptions, action: string, request: any, responseType: ResponseType, defaultSend: SendFunc, header?: any) => Promise<any>;
4export interface IOptions {
5 baseUrl: string;
6 type?: RequestType;
7 userID?: string;
8 password?: string;
9 rejectUnauthorized?: boolean;
10 timeoutSecs?: number;
11 hookSend?: IOptionsSend;
12 encodeRequest?: boolean;
13}
14export declare function instanceOfIOptions(object: any): object is IOptions;
15export interface IConnection {
16 opts(_: Partial<IOptions>): this;
17 opts(): IOptions;
18 baseUrl: string;
19 send(action: string, request: any, responseType?: ResponseType): Promise<any>;
20 clone(): IConnection;
21}
22export declare function instanceOfIConnection(object: any): object is IConnection;
23export declare function serializeRequest(obj: any, encodeRequest?: boolean, prefix?: string): string;
24export declare function deserializeResponse(body: string): any;
25export declare function jsonp(opts: IOptions, action: string, request?: any, responseType?: ResponseType, header?: any): Promise<any>;
26export declare function post(opts: IOptions, action: string, request: any, responseType?: ResponseType, header?: any): Promise<any>;
27export declare function get(opts: IOptions, action: string, request: any, responseType?: ResponseType, header?: any): Promise<any>;
28export declare type SendFunc = (opts: IOptions, action: string, request: any, responseType: ResponseType, header?: any) => Promise<any>;
29export declare function send(opts: IOptions, action: string, request: any, responseType?: ResponseType, header?: any): Promise<any>;
30export declare function hookSend(newSend?: SendFunc): SendFunc;
31export declare class Connection implements IConnection {
32 protected _opts: IOptions;
33 readonly baseUrl: string;
34 constructor(opts: IOptions);
35 opts(_: Partial<IOptions>): this;
36 opts(): IOptions;
37 send(action: string, request: any, responseType?: ResponseType, header?: any): Promise<any>;
38 clone(): Connection;
39}
40export declare type IConnectionFactory = (opts: IOptions) => IConnection;
41export declare let createConnection: IConnectionFactory;
42export declare function setTransportFactory(newFunc: IConnectionFactory): IConnectionFactory;
43//# sourceMappingURL=connection.d.ts.map
\No newline at end of file