Skip to content

Commit

Permalink
Merge pull request #2 from amper-fb/https_agent
Browse files Browse the repository at this point in the history
add interceptor
  • Loading branch information
amper-fb authored Jan 9, 2024
2 parents fe41e8a + b0f64ab commit abebe33
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export class ApiClient {
},
});

if (options?.customAxiosOptions?.interceptors?.request) {
this.axiosInstance.interceptors.request.use(options.customAxiosOptions.interceptors.request.onFulfilled, options.customAxiosOptions.interceptors.request.onRejected);
}
if (options?.customAxiosOptions?.interceptors?.response) {
this.axiosInstance.interceptors.response.use(options.customAxiosOptions.interceptors.response.onFulfilled, options.customAxiosOptions.interceptors.response.onRejected);
}
Expand Down
8 changes: 6 additions & 2 deletions src/fireblocks-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ import {
ScreeningConfigurationsResponse,
ScreeningPolicyRuleResponse, ScreeningProviderConfigurationResponse, AuditLogsResponse,
} from "./types";
import { AxiosProxyConfig, AxiosResponse } from "axios";
import { AxiosProxyConfig, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from "axios";
import { PIIEncryption } from "./pii-client";
import { NcwApiClient } from "./ncw-api-client";
import { NcwSdk } from "./ncw-sdk";
Expand Down Expand Up @@ -156,13 +156,17 @@ export interface SDKOptions {
userAgent?: string;

/** Replace default https agent */
httpsAgent?: any
httpsAgent?: any;

/**
* Providing custom axios options including a response interceptor (https://axios-http.com/docs/interceptors)
*/
customAxiosOptions?: {
interceptors?: {
request?: {
onFulfilled: (value: InternalAxiosRequestConfig<any>) => InternalAxiosRequestConfig<any> | Promise<InternalAxiosRequestConfig<any>>;
onRejected: (error: any) => any;
};
response?: {
onFulfilled: (value: AxiosResponse<any, any>) => AxiosResponse<any, any> | Promise<AxiosResponse<any, any>>;
onRejected: (error: any) => any;
Expand Down

0 comments on commit abebe33

Please sign in to comment.