UNPKG

5.25 kBTypeScriptView Raw
1import { Destination, DestinationNameAndJwt, DestinationOptions, DestinationRetrievalOptions } from '../../connectivity/scp-cf';
2import { ODataRequest } from '../request/odata-request';
3import { ODataRequestConfig } from '../request/odata-request-config';
4/**
5 * Base class for all request builders.
6 * @typeparam EntityT - Type of the entity to create a request for.
7 */
8export declare abstract class MethodRequestBuilder<RequestConfigT extends ODataRequestConfig = any> {
9 requestConfig: RequestConfigT;
10 /**
11 * Creates an instance of MethodRequestBuilder.
12 * @param requestConfig - Request configuration to initialize with.
13 */
14 constructor(requestConfig: RequestConfigT);
15 /**
16 * Create the URL based on configuration of the given builder.
17 * @param destination - Destination to execute the request against.
18 * @param options - Options to employ when fetching destinations.
19 * @returns Promise resolving to the URL for the request
20 */
21 url(destination: Destination | DestinationNameAndJwt, options?: DestinationRetrievalOptions): Promise<string>;
22 /**
23 * Create the relative URL based on configuration of the given builder.
24 * @returns The relative URL for the request
25 */
26 relativeUrl(): string;
27 /**
28 * @deprecated Since version 1.34.0 Use [[addCustomHeaders]] instead.
29 * Add custom headers to the request.
30 * @param headers - Key-value pairs denoting additional custom headers.
31 * @returns The request builder itself, to facilitate method chaining.
32 */
33 withCustomHeaders(headers: Record<string, string>): this;
34 /**
35 * Add custom headers to the request. Existing headers will be overwritten.
36 * @param headers - Key-value pairs denoting additional custom headers.
37 * @returns The request builder itself, to facilitate method chaining.
38 */
39 addCustomHeaders(headers: Record<string, string>): this;
40 /**
41 * @deprecated Since version 1.34.0 Use [[addCustomQueryParameters]] instead.
42 * Add custom query parameters to the request.
43 * @param queryParameters - Key-value pairs denoting additional custom query parameters to be set in the request.
44 * @returns The request builder itself, to facilitate method chaining.
45 */
46 withCustomQueryParameters(queryParameters: Record<string, string>): this;
47 /**
48 * Add custom query parameters to the request. If a query parameter with the given name already exists it is overwritten.
49 * @param queryParameters - Key-value pairs denoting additional custom query parameters to be set in the request.
50 * @returns The request builder itself, to facilitate method chaining
51 */
52 addCustomQueryParameters(queryParameters: Record<string, string>): this;
53 /**
54 * @deprecated Since version 1.34.0 Use [[setCustomServicePath]] instead.
55 * Replace the default service path with the given custom path.
56 * In case of the SAP S/4HANA APIs the servicePath defaults to `/sap/opu/odata/sap/<SERVICE_NAME>` and can be overwritten here.
57 * @param servicePath - Path to override the default with.
58 * @returns The request builder itself, to facilitate method chaining.
59 */
60 withCustomServicePath(servicePath: string): this;
61 /**
62 * Replace the default service path with the given custom path.
63 * In case of the SAP S/4HANA APIs the servicePath defaults to `/sap/opu/odata/sap/<SERVICE_NAME>` and can be overwritten here.
64 * @param servicePath - Path to override the default with
65 * @returns The request builder itself, to facilitate method chaining
66 */
67 setCustomServicePath(servicePath: string): this;
68 /**
69 * Add a custom request configuration to the request. Typically, this is used when specifying a response type for downloading files.
70 * If the custom request configuration contains [[defaultDisallowedKeys | disallowed keys]], those will be ignored.
71 * @param requestConfiguration - Key-value pairs denoting additional custom request configuration options to be set in the request.
72 * @returns The request builder itself, to facilitate method chaining.
73 */
74 addCustomRequestConfiguration(requestConfiguration: Record<string, string>): this;
75 /**
76 * Append the given path to the URL.
77 * This can be used for querying navigation properties of an entity.
78 * 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.
79 * @param path - Path to be appended.
80 * @returns The request builder itself without "execute" function, to facilitate method chaining.
81 */
82 appendPath(...path: string[]): Omit<this, 'execute'>;
83 /**
84 * Skip fetching csrf token for this request, which is typically useful when the csrf token is not required.
85 * @returns The request builder itself, to facilitate method chaining.
86 */
87 skipCsrfTokenFetching(): this;
88 build(): ODataRequest<RequestConfigT>;
89 build(destination: Destination | DestinationNameAndJwt, options?: DestinationOptions): Promise<ODataRequest<RequestConfigT>>;
90}
91export { MethodRequestBuilder as MethodRequestBuilderBase };
92//# sourceMappingURL=request-builder-base.d.ts.map
\No newline at end of file