Skip to content

Commit

Permalink
refactor: remove username and password, add axios instance into APICo…
Browse files Browse the repository at this point in the history
…nfigurationParameters
  • Loading branch information
nguyentoanit committed Mar 9, 2021
1 parent a67acba commit 51d4a46
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/clients/uploads-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { isJsonMime } from '../helpers/is-json-mime'
import { APIConfigurationParameters } from '../types/api-configuration-parameters'

export class UploadsApiClient extends UploadsApi {
constructor(parameters?: APIConfigurationParameters, axios?: AxiosInstance) {
constructor(parameters?: APIConfigurationParameters) {
const { sellingPartner } = amazonMarketplaces.US
const basePath: string = sellingPartner ? sellingPartner.region.endpoint : ''
let axiosInstance: AxiosInstance

if (axios) {
axiosInstance = axios
if (parameters && parameters.axios) {
axiosInstance = parameters.axios
} else {
axiosInstance = globalAxios.create()
axiosInstance.interceptors.response.use(
Expand Down
17 changes: 6 additions & 11 deletions src/types/api-configuration-parameters.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AxiosRequestConfig } from 'axios'
import { AxiosInstance, AxiosRequestConfig } from 'axios'

export interface APIConfigurationParameters {
/**
Expand All @@ -11,20 +11,15 @@ export interface APIConfigurationParameters {
| Promise<string>
| ((name: string) => string)
| ((name: string) => Promise<string>)

/**
* parameter for basic security
*
* @type {string}
* @memberof APIConfigurationParameters
*/
username?: string
/**
* parameter for basic security
* Axios Instance
*
* @type {string}
* @type {AxiosInstance}
* @memberof APIConfigurationParameters
*/
password?: string
axios?: AxiosInstance

/**
* parameter for oauth2 security
* @param name security name
Expand Down

0 comments on commit 51d4a46

Please sign in to comment.