/// declare namespace Leaf { interface APICallback { (error: Error, result: TResult): void; } interface APIFunction { (option: TOption, callback: APICallback): void; API?: APIDeclare; } interface APIOption { method: string | "GET" | "POST" | "PUT" | "DELETE"; path: string; timeout?: number; headers?: any; data?: any; withCredentials?: boolean; } class APIFactory { option: { root?: string; prefix?: string; suffix?: string; dataField?: string; errorField?: string; defaultTimeout?: number; withCredentials?: boolean; }; constructor(option: { root?: string; prefix?: string; suffix?: string; dataField?: string; errorField?: string; defaultTimeout?: number; withCredentials?: boolean; }); createAPI(option: APIOption): APIDeclare; createAPIFunction(option: APIOption): APIFunction; private solveResponse(err, response, callback); request(option: { method?: string; url: string; query?: any; withCredentials?: boolean; headers?: any; timeout?: number; }, callback: { (err, result: TResult): void; }): XMLHttpRequest; buildQueryString(query: any): string; } class APIDeclare { private factory; private option; constructor(factory: APIFactory, option: APIOption); getFunction(): APIFunction; invoke(data: TOption, callback: APICallback): void; } }