Skip to content

Commit

Permalink
refactor: naming for api client helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyentoanit committed Mar 9, 2021
1 parent 2cd529f commit 9b6244c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
5 changes: 2 additions & 3 deletions src/clients/uploads-api-client.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { UploadsApi } from '../api-models/uploads-api-model'
import { ApiClientHelpers } from '../helpers'
import { isJsonMime } from '../helpers/is-json-mime'
import { APIConfigurationParameters } from '../types/api-configuration-parameters'

export class UploadsApiClient extends UploadsApi {
constructor(parameters?: APIConfigurationParameters) {
const axios = ApiClientHelpers.assertAxiosInstance(parameters)
const basePath = ApiClientHelpers.assertBasePath()
const basePath = ApiClientHelpers.getDefaultBasePath()

super(
{
isJsonMime,
isJsonMime: ApiClientHelpers.isJsonMime,
...parameters,
},
basePath,
Expand Down
10 changes: 9 additions & 1 deletion src/helpers/api-client-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,16 @@ export class ApiClientHelpers {
return axiosInstance
}

static assertBasePath(): string {
static getDefaultBasePath(): string {
const { sellingPartner } = amazonMarketplaces.US
return sellingPartner ? sellingPartner.region.endpoint : ''
}

static isJsonMime(mime: string): boolean {
/* eslint-disable-next-line no-control-regex */
const jsonMime = new RegExp('^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i')
return (
mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json')
)
}
}
1 change: 0 additions & 1 deletion src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './api-client-helpers'
export * from './api-error-factory'
export * from './decoder'
export * from './is-json-mime'
7 changes: 0 additions & 7 deletions src/helpers/is-json-mime.ts

This file was deleted.

0 comments on commit 9b6244c

Please sign in to comment.