aboutsummaryrefslogtreecommitdiff
path: root/node_modules/typed-rest-client/RestClient.d.ts
blob: 74b33cba2ee4fa6c5c32bf634bc7b8c3b8351720 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/// <reference types="node" />
import httpm = require('./HttpClient');
import ifm = require("./Interfaces");
export interface IRestResponse<T> {
    statusCode: number;
    result: T | null;
    headers: Object;
}
export interface IRequestOptions {
    acceptHeader?: string;
    additionalHeaders?: ifm.IHeaders;
    responseProcessor?: Function;
    deserializeDates?: boolean;
}
export declare class RestClient {
    client: httpm.HttpClient;
    versionParam: string;
    /**
     * Creates an instance of the RestClient
     * @constructor
     * @param {string} userAgent - userAgent for requests
     * @param {string} baseUrl - (Optional) If not specified, use full urls per request.  If supplied and a function passes a relative url, it will be appended to this
     * @param {ifm.IRequestHandler[]} handlers - handlers are typically auth handlers (basic, bearer, ntlm supplied)
     * @param {ifm.IRequestOptions} requestOptions - options for each http requests (http proxy setting, socket timeout)
     */
    constructor(userAgent: string, baseUrl?: string, handlers?: ifm.IRequestHandler[], requestOptions?: ifm.IRequestOptions);
    private _baseUrl;
    /**
     * Gets a resource from an endpoint
     * Be aware that not found returns a null.  Other error conditions reject the promise
     * @param {string} requestUrl - fully qualified or relative url
     * @param {IRequestOptions} requestOptions - (optional) requestOptions object
     */
    options<T>(requestUrl: string, options?: IRequestOptions): Promise<IRestResponse<T>>;
    /**
     * Gets a resource from an endpoint
     * Be aware that not found returns a null.  Other error conditions reject the promise
     * @param {string} resource - fully qualified url or relative path
     * @param {IRequestOptions} requestOptions - (optional) requestOptions object
     */
    get<T>(resource: string, options?: IRequestOptions): Promise<IRestResponse<T>>;
    /**
     * Deletes a resource from an endpoint
     * Be aware that not found returns a null.  Other error conditions reject the promise
     * @param {string} resource - fully qualified or relative url
     * @param {IRequestOptions} requestOptions - (optional) requestOptions object
     */
    del<T>(resource: string, options?: IRequestOptions): Promise<IRestResponse<T>>;
    /**
     * Creates resource(s) from an endpoint
     * T type of object returned.
     * Be aware that not found returns a null.  Other error conditions reject the promise
     * @param {string} resource - fully qualified or relative url
     * @param {IRequestOptions} requestOptions - (optional) requestOptions object
     */
    create<T>(resource: string, resources: any, options?: IRequestOptions): Promise<IRestResponse<T>>;
    /**
     * Updates resource(s) from an endpoint
     * T type of object returned.
     * Be aware that not found returns a null.  Other error conditions reject the promise
     * @param {string} resource - fully qualified or relative url
     * @param {IRequestOptions} requestOptions - (optional) requestOptions object
     */
    update<T>(resource: string, resources: any, options?: IRequestOptions): Promise<IRestResponse<T>>;
    /**
     * Replaces resource(s) from an endpoint
     * T type of object returned.
     * Be aware that not found returns a null.  Other error conditions reject the promise
     * @param {string} resource - fully qualified or relative url
     * @param {IRequestOptions} requestOptions - (optional) requestOptions object
     */
    replace<T>(resource: string, resources: any, options?: IRequestOptions): Promise<IRestResponse<T>>;
    uploadStream<T>(verb: string, requestUrl: string, stream: NodeJS.ReadableStream, options?: IRequestOptions): Promise<IRestResponse<T>>;
    private _headersFromOptions(options, contentType?);
    private static dateTimeDeserializer(key, value);
    private _processResponse<T>(res, options);
}