@ima/plugin-rest-client
Version:
Generic REST API client plugin for the IMA application framework.
135 lines • 3.77 kB
TypeScript
/**
* Typed representation of a REST API request.
*/
export default class Request {
/**
* Initializes the request representation using the provided data.
*
* @param {{
* parentEntity: *,
* resource: *,
* parameters: ?Object<string, (number|string)>,
* method: string,
* url: string,
* data: *,
* headers: Object<string, string>,
* options: {
* timeout: number=,
* ttl: number=,
* repeatRequest: number=,
* cache: boolean=,
* withCredentials: boolean=
* },
* serverConfiguration: ?Object<string, *>
* }} requestData The data representing this request. See the fields
* of this class for more information.
*/
constructor(requestData: {
parentEntity: any;
resource: any;
parameters: {
[x: string]: (number | string);
} | null;
method: string;
url: string;
data: any;
headers: {
[x: string]: string;
};
options: {
timeout: number;
ttl: number;
repeatRequest: number;
cache: boolean;
withCredentials: boolean;
};
serverConfiguration: {
[x: string]: any;
} | null;
});
/**
* The parent entity within which the specified resource to manipulate.
* Set to {@code null} if the request's target resource is a top-level
* resource within the REST API.
*
* @type {*}
*/
parentEntity: any;
/**
* The identifier of the REST API resource to access using this
* request.
*
* @type {*}
*/
resource: any;
/**
* The request parameters that were used to generate the URL to which
* the request will be made.
*
* The parameters do not contain the resource entity id, even if one
* was provided.
*
* @type {?Object<string, (number|string|Array<(number|string)>)>}
*/
parameters: {
[x: string]: (number | string | Array<(number | string)>);
} | null;
/**
* The HTTP method to use to make the request. The method is specified
* in upper-case letters.
*
* @type {string}
*/
method: string;
/**
* The URL to which the request should be made.
*
* @type {string}
*/
url: string;
/**
* The data to send to the server as the request's body. The field is
* {@code null} if the request should not carry any data in its body.
*
* @type {*}
*/
data: any;
/**
* The headers to send with the HTTP request to the server. These are
* extracted from the request options into this separate field for
* conveniency.
*
* @type {Object<string, string>}
*/
headers: {
[x: string]: string;
};
/**
* HTTP request options, without the request headers.
*
* @type {{
* timeout: number=,
* ttl: number=,
* repeatRequest: number=,
* cache: boolean=,
* withCredentials: boolean=
* }}
*/
options: {
timeout: number;
ttl: number;
repeatRequest: number;
cache: boolean;
withCredentials: boolean;
};
/**
* The REST API client configuration provided by the server. The field
* is set to {@code null} if no server-provided configuration is used.
*
* @type {?Object<string, *>}
*/
serverConfiguration: {
[x: string]: any;
} | null;
}
//# sourceMappingURL=Request.d.ts.map