@sap-cloud-sdk/odata-common
Version:
SAP Cloud SDK for JavaScript common functions of OData client generator and OpenAPI clint generator.
67 lines (66 loc) • 3.1 kB
TypeScript
import type { ParameterEncoder, HttpMiddleware } from '@sap-cloud-sdk/http-client/internal';
import type { CustomRequestConfig } from '@sap-cloud-sdk/http-client';
/**
* Set of possible request methods.
*/
export type RequestMethodType = 'get' | 'post' | 'patch' | 'delete' | 'put';
/**
* Parent class for all OData request configs like `getAll`, `delete` or `count`.
*/
export declare abstract class ODataRequestConfig {
method: RequestMethodType;
readonly defaultBasePath: string;
payload: Record<string, any> | string;
basePath: string;
readonly defaultHeaders: Record<string, any>;
readonly parameterEncoder: ParameterEncoder;
private _customHeaders;
private _customQueryParameters;
private _customRequestConfiguration;
private _appendedPaths;
private _fetchCsrfToken;
private _middlewares;
/**
* Creates an instance of ODataRequest.
* @param method - HTTP method of the request.
* @param defaultBasePath - Default path of the according service.
* @param defaultHeaders - The default headers of the given request as an object.
*/
constructor(method: RequestMethodType, defaultBasePath: string, defaultHeaders?: Record<string, any>);
set middlewares(middlewares: HttpMiddleware[]);
get middlewares(): HttpMiddleware[];
set customHeaders(headers: Record<string, string>);
get customHeaders(): Record<string, string>;
set customQueryParameters(queryParameters: Record<string, string>);
get customQueryParameters(): Record<string, string>;
set customRequestConfiguration(requestConfiguration: CustomRequestConfig);
get customRequestConfiguration(): Record<string, string>;
get appendedPaths(): string[];
set fetchCsrfToken(fetchCsrfToken: boolean);
get fetchCsrfToken(): boolean;
/**
* Add custom headers to the request. This is useful in case you want to provide your own authorization headers for example.
* @param headers - Key-value pairs where the key is the name of a header property and the value is the respective value.
*/
addCustomHeaders(headers: Record<string, string>): void;
/**
* Add custom query parameters to the request. This is useful in case your OData service allows non-standard query parameters.
* @param queryParameters - Key-value pairs where the key is the name of a query parameter and the value is the respective value.
*/
addCustomQueryParameters(queryParameters: Record<string, string>): void;
/**
* Add custom request configuration to the request.
* @param requestConfiguration - Key-value pairs where the key is the name of a request configuration and the value is the respective value.
*/
addCustomRequestConfiguration(requestConfiguration: Record<string, any>): void;
appendPath(...path: string[]): void;
protected prependDollarToQueryParameters(params: Record<string, any>): Record<string, any>;
/**
* @internal
*/
abstract resourcePath(): string;
/**
* @internal
*/
abstract queryParameters(): Record<string, any>;
}