@sap-cloud-sdk/odata-common
Version:
SAP Cloud SDK for JavaScript common functions of OData client generator and OpenAPI clint generator.
97 lines (96 loc) • 4.08 kB
TypeScript
import type { Destination } from '@sap-cloud-sdk/connectivity';
import type { HttpResponse } from '@sap-cloud-sdk/http-client';
import type { OriginOptions } from '@sap-cloud-sdk/http-client/internal';
import type { HttpDestination } from '@sap-cloud-sdk/connectivity/internal';
import type { ODataRequestConfig } from './odata-request-config';
/**
* OData request configuration for an entity type.
* @typeParam EntityT - Type of the entity to setup a request for.
*/
export declare class ODataRequest<RequestConfigT extends ODataRequestConfig> {
config: RequestConfigT;
private _destination?;
/**
* Creates an instance of ODataRequest.
* @param config - Configuration of the request.
* @param _destination - Destination to setup the request against.
*/
constructor(config: RequestConfigT, _destination?: HttpDestination | undefined);
set destination(dest: Destination | undefined);
get destination(): HttpDestination | undefined;
/**
* Constructs an absolute URL for the given request.
* @returns The absolute URL for the request.
*/
url(): string;
/**
* Constructs a URL relative to the destination.
* @param includeBasePath - Whether or not to include the base path in the URL.
* @param includeQueryParameters - Whether or not to include the query parameters in the URL.
* @returns The relative URL for the request.
*/
relativeUrl(includeBasePath?: boolean, includeQueryParameters?: boolean): string;
/**
* Specifies whether the destination needs a specific authentication or not.
* @returns A boolean value that specifies whether the destination needs authentication or not.
*/
needsAuthentication(): boolean;
/**
* Returns the service URL for a given OData request.
* @returns The URL of the service the given entity belongs to.
*/
serviceUrl(): string;
/**
* Returns the service URL relative to the url of the destination for a given OData request.
* @returns The relative URL of the service the given entity belongs to.
*/
relativeServiceUrl(): string;
/**
* Returns the URL to a specific OData .resource, i.e. the entity collection.
* @returns The URL of the resource.
*/
resourceUrl(): string;
/**
* Returns the relative URL to a specific OData resource.
* @param includeBasePath - Whether or not to include the base path in the URL.
* @returns The relative URL of the resource.
*/
relativeResourceUrl(includeBasePath?: boolean): string;
/**
* Get query parameters as string. Leads with `?` if there are parameters to return.
* @returns Query parameter string.
*/
query(): string;
/**
* Create object containing all headers, including custom headers for the given request.
* @returns Key-value pairs where the key is the name of a header property and the value is the respective value.
*/
headers(): Promise<OriginOptions>;
/**
* Get all custom headers.
* @returns Key-value pairs where the key is the name of a header property and the value is the respective value.
*/
customHeaders(): Record<string, any>;
/**
* Get all default headers. If custom headers are set, those take precedence.
* @returns Key-value pairs where the key is the name of a header property and the value is the respective value.
*/
defaultHeaders(): Record<string, any>;
/**
* Get the eTag related headers, e.g. `if-match`.
* @returns Key-value pairs where the key is the name of a header property and the value is the respective value.
*/
eTagHeaders(): Record<string, any>;
/**
* Execute the given request and return the according promise.
* @returns Promise resolving to the requested data.
*/
execute(): Promise<HttpResponse>;
/**
* Get http request config.
* @returns Promise of http request config with origin.
*/
private requestConfig;
private getAdditionalHeadersForKeys;
private queryParameters;
}