@sap-cloud-sdk/core
Version:
SAP Cloud SDK for JavaScript core
92 lines • 5.25 kB
TypeScript
import { Destination, DestinationNameAndJwt, DestinationOptions, DestinationRetrievalOptions } from '../../connectivity/scp-cf';
import { ODataRequest } from '../request/odata-request';
import { ODataRequestConfig } from '../request/odata-request-config';
/**
* Base class for all request builders.
* @typeparam EntityT - Type of the entity to create a request for.
*/
export declare abstract class MethodRequestBuilder<RequestConfigT extends ODataRequestConfig = any> {
requestConfig: RequestConfigT;
/**
* Creates an instance of MethodRequestBuilder.
* @param requestConfig - Request configuration to initialize with.
*/
constructor(requestConfig: RequestConfigT);
/**
* Create the URL based on configuration of the given builder.
* @param destination - Destination to execute the request against.
* @param options - Options to employ when fetching destinations.
* @returns Promise resolving to the URL for the request
*/
url(destination: Destination | DestinationNameAndJwt, options?: DestinationRetrievalOptions): Promise<string>;
/**
* Create the relative URL based on configuration of the given builder.
* @returns The relative URL for the request
*/
relativeUrl(): string;
/**
* @deprecated Since version 1.34.0 Use [[addCustomHeaders]] instead.
* Add custom headers to the request.
* @param headers - Key-value pairs denoting additional custom headers.
* @returns The request builder itself, to facilitate method chaining.
*/
withCustomHeaders(headers: Record<string, string>): this;
/**
* Add custom headers to the request. Existing headers will be 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;
/**
* @deprecated Since version 1.34.0 Use [[addCustomQueryParameters]] instead.
* Add custom query parameters to the request.
* @param queryParameters - Key-value pairs denoting additional custom query parameters to be set in the request.
* @returns The request builder itself, to facilitate method chaining.
*/
withCustomQueryParameters(queryParameters: Record<string, string>): this;
/**
* Add custom query parameters to the request. If a query parameter with the given name already exists it is overwritten.
* @param queryParameters - Key-value pairs denoting additional custom query parameters to be set in the request.
* @returns The request builder itself, to facilitate method chaining
*/
addCustomQueryParameters(queryParameters: Record<string, string>): this;
/**
* @deprecated Since version 1.34.0 Use [[setCustomServicePath]] instead.
* Replace the default service path with the given custom path.
* In case of the SAP S/4HANA APIs the servicePath defaults to `/sap/opu/odata/sap/<SERVICE_NAME>` and can be overwritten here.
* @param servicePath - Path to override the default with.
* @returns The request builder itself, to facilitate method chaining.
*/
withCustomServicePath(servicePath: string): this;
/**
* Replace the default service path with the given custom path.
* In case of the SAP S/4HANA APIs the servicePath defaults to `/sap/opu/odata/sap/<SERVICE_NAME>` and can be overwritten here.
* @param servicePath - Path to override the default with
* @returns The request builder itself, to facilitate method chaining
*/
setCustomServicePath(servicePath: string): this;
/**
* Add a custom request configuration to the request. Typically, this is used when specifying a response type for downloading files.
* If the custom request configuration contains [[defaultDisallowedKeys | disallowed keys]], those will be ignored.
* @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;
/**
* Append the given path to the URL.
* This can be used for querying navigation properties of an entity.
* To execute a request with an appended path use `executeRaw` to avoid errors during deserialization. When using this, the `execute` method is omitted from the return type.
* @param path - Path to be appended.
* @returns The request builder itself without "execute" function, to facilitate method chaining.
*/
appendPath(...path: string[]): Omit<this, 'execute'>;
/**
* 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;
build(): ODataRequest<RequestConfigT>;
build(destination: Destination | DestinationNameAndJwt, options?: DestinationOptions): Promise<ODataRequest<RequestConfigT>>;
}
export { MethodRequestBuilder as MethodRequestBuilderBase };
//# sourceMappingURL=request-builder-base.d.ts.map