UNPKG

2.07 kBTypeScriptView Raw
1export interface IODataParser<T> {
2 hydrate?: (d: any) => T;
3 parse(r: Response): Promise<T>;
4}
5export declare class ODataParser<T = any> implements IODataParser<T> {
6 parse(r: Response): Promise<T>;
7 protected parseImpl(r: Response, resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: Error) => void): void;
8 /**
9 * Handles a response with ok === false by parsing the body and creating a ProcessHttpClientResponseException
10 * which is passed to the reject delegate. This method returns true if there is no error, otherwise false
11 *
12 * @param r Current response object
13 * @param reject reject delegate for the surrounding promise
14 */
15 protected handleError(r: Response, reject: (err?: Error) => void): boolean;
16 /**
17 * Normalizes the json response by removing the various nested levels
18 *
19 * @param json json object to parse
20 */
21 protected parseODataJSON<U>(json: any): U;
22}
23export declare class TextParser extends ODataParser<string> {
24 protected parseImpl(r: Response, resolve: (value: any) => void): void;
25}
26export declare class BlobParser extends ODataParser<Blob> {
27 protected parseImpl(r: Response, resolve: (value: any) => void): void;
28}
29export declare class JSONParser extends ODataParser<any> {
30 protected parseImpl(r: Response, resolve: (value: any) => void): void;
31}
32export declare class BufferParser extends ODataParser<ArrayBuffer> {
33 protected parseImpl(r: Response, resolve: (value: any) => void): void;
34}
35export declare class LambdaParser<T = any> extends ODataParser<T> {
36 private parser;
37 constructor(parser: (r: Response) => Promise<T>);
38 protected parseImpl(r: Response, resolve: (value: any) => void): void;
39}
40export declare class HttpRequestError extends Error {
41 response: Response;
42 status: number;
43 statusText: string;
44 isHttpRequestError: boolean;
45 constructor(message: string, response: Response, status?: number, statusText?: string);
46 static init(r: Response): Promise<HttpRequestError>;
47}
48//# sourceMappingURL=parsers.d.ts.map
\No newline at end of file