@@ -54,6 +54,12 @@ export interface ItemsList {
5454 }
5555}
5656
57+ export interface EndpointClientRequestOptions < T > {
58+ headerOverrides ?: HttpClientHeaders
59+ dryRun ?: boolean
60+ dryRunReturnValue ?: T
61+ }
62+
5763export class EndpointClient {
5864 private logger : Logger
5965
@@ -90,7 +96,7 @@ export class EndpointClient {
9096
9197 /* eslint-disable @typescript-eslint/no-explicit-any */
9298 public async request < T = any , R = AxiosResponse < T > > ( method : HttpClientMethod , path ?: string ,
93- data ?: any , params ?: HttpClientParams ) : Promise < T > {
99+ data ?: any , params ?: HttpClientParams , options ?: EndpointClientRequestOptions < T > ) : Promise < T > {
94100 const headers : HttpClientHeaders = this . config . headers ? { ...this . config . headers } : { }
95101
96102 if ( this . config . loggingId ) {
@@ -111,7 +117,7 @@ export class EndpointClient {
111117 let axiosConfig : AxiosRequestConfig = {
112118 url : this . url ( path ) ,
113119 method,
114- headers,
120+ headers : options ?. headerOverrides ? { ... headers , ... options . headerOverrides } : headers ,
115121 params,
116122 data,
117123 paramsSerializer : params => qs . stringify ( params , { indices : false } ) ,
@@ -122,6 +128,12 @@ export class EndpointClient {
122128 if ( this . logger . isDebugEnabled ( ) ) {
123129 this . logger . debug ( `making axios request: ${ JSON . stringify ( axiosConfig ) } ` )
124130 }
131+ if ( options ?. dryRun ) {
132+ if ( options . dryRunReturnValue ) {
133+ return options . dryRunReturnValue
134+ }
135+ throw new Error ( 'skipping request; dry run mode' )
136+ }
125137 let response
126138 try {
127139 response = await axios . request ( axiosConfig )
0 commit comments