import { ErrorWithCause } from '@sap-cloud-sdk/util' ; import { Destination , DestinationFetchOptions , noDestinationErrorMessage , useOrFetchDestination } from '@sap-cloud-sdk/connectivity' ; import { ODataRequest , ODataRequestConfig } from '../request' ; typeparam internal export abstract class MethodRequestBuilder < RequestConfigT extends ODataRequestConfig = any > { param requestConfig constructor ( public requestConfig ) { } param destination returns async url ( destination ) { const request = await this . build ( destination ) ; return request . url ( ) ; } returns relativeUrl ( ) { return this . build ( ) . relativeUrl ( ) ; } param headers returns addCustomHeaders ( headers ) { this . requestConfig . addCustomHeaders ( headers ) ; return this ; } param queryParameters returns addCustomQueryParameters ( queryParameters ) { this . requestConfig . addCustomQueryParameters ( queryParameters ) ; return this ; } param servicePath returns setCustomServicePath ( servicePath ) { this . requestConfig . customServicePath = servicePath ; return this ; } param requestConfiguration returns addCustomRequestConfiguration ( requestConfiguration ) { this . requestConfig . addCustomRequestConfiguration ( requestConfiguration ) ; return this ; } param path returns appendPath ( ... path ) { this . requestConfig . appendPath ( ... path ) ; return this ; } returns skipCsrfTokenFetching ( ) { this . requestConfig . fetchCsrfToken = false ; return this ; } protected build ( ) ; protected build ( destination ) ; param destination returns protected build ( destination ? ) { if ( destination ) { return useOrFetchDestination ( destination ) . then ( dest => { if ( ! dest ) { throw Error ( noDestinationErrorMessage ( destination ) ) ; } return new ODataRequest ( this . requestConfig , dest ) ; } ) . catch ( error => { throw new ErrorWithCause ( noDestinationErrorMessage ( destination ) , error ) ; } ) ; } return new ODataRequest ( this . requestConfig ) ; } }