@sap-cloud-sdk/core
Version:
SAP Cloud SDK for JavaScript core
64 lines • 3.42 kB
TypeScript
import { Destination, DestinationNameAndJwt, DestinationOptions } from '../connectivity';
import { HttpResponse, Method } from '../http-client';
/**
* Request builder for OpenAPI requests.
* @typeParam ResponseT - Type of the response for the request.
*/
export declare class OpenApiRequestBuilder<ResponseT = any> {
method: Method;
private pathPattern;
private parameters?;
private static isPlaceholder;
private customHeaders;
private customRequestConfiguration;
private _fetchCsrfToken;
/**
* Create an instance of `OpenApiRequestBuilder`.
* @param method - HTTP method of the request to be built.
* @param pathPattern - Path for the request containing path parameter references as in the OpenAPI specification.
* @param parameters - Query parameters and or body to pass to the request.
*/
constructor(method: Method, pathPattern: string, parameters?: OpenApiRequestParameters | undefined);
/**
* Add custom headers to the request. If a header field with the given name already exists it is overwritten.
* @param headers - Key-value pairs denoting additional custom headers.
* @returns The request builder itself, to facilitate method chaining.
*/
addCustomHeaders(headers: Record<string, string>): this;
/**
* Add custom request configuration to the request. Typically, this is used when specifying response type for downloading files.
* If the custom request configuration contains keys in this list [[defaultDisallowedKeys]], they will be removed.
*
* @param requestConfiguration - Key-value pairs denoting additional custom request configuration options to be set in the request.
* @returns The request builder itself, to facilitate method chaining.
*/
addCustomRequestConfiguration(requestConfiguration: Record<string, string>): this;
/**
* Skip fetching csrf token for this request, which is typically useful when the csrf token is not required.
* @returns The request builder itself, to facilitate method chaining.
*/
skipCsrfTokenFetching(): this;
/**
* Execute request and get a raw HttpResponse, including all information about the HTTP response.
* This especially comes in handy, when you need to access the headers or status code of the response.
* @param destination - Destination to execute the request against.
* @param destinationOptions - Options to employ when fetching destinations.
* @returns A promise resolving to an HttpResponse.
*/
executeRaw(destination: Destination | DestinationNameAndJwt, destinationOptions?: DestinationOptions): Promise<HttpResponse>;
/**
* Execute request and get the response data. Use this to conveniently access the data of a service without technical information about the response.
* @param destination - Destination to execute the request against.
* @param destinationOptions - Options to employ when fetching destinations.
* @returns A promise resolving to the requested return type.
*/
execute(destination: Destination | DestinationNameAndJwt, destinationOptions?: DestinationOptions): Promise<ResponseT>;
private getPath;
}
interface OpenApiRequestParameters {
pathParameters?: Record<string, any>;
queryParameters?: Record<string, any>;
body?: any;
}
export {};
//# sourceMappingURL=openapi-request-builder.d.ts.map