@sp-api-sdk/tokens-api-2021-03-01
Advanced tools
Comparing version 1.9.3 to 1.10.0
@@ -5,3 +5,2 @@ "use strict"; | ||
tslib_1.__exportStar(require("./src/client"), exports); | ||
tslib_1.__exportStar(require("./src/error"), exports); | ||
tslib_1.__exportStar(require("./src/api-model/models"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TokensApiClient = exports.clientRateLimits = void 0; | ||
/* eslint-disable prefer-regex-literals */ | ||
const common_1 = require("@sp-api-sdk/common"); | ||
const api_model_1 = require("./api-model"); | ||
const error_1 = require("./error"); | ||
exports.clientRateLimits = [ | ||
{ | ||
method: 'post', | ||
// eslint-disable-next-line prefer-regex-literals | ||
urlRegex: new RegExp('^/tokens/2021-03-01/restrictedDataToken$'), | ||
@@ -17,23 +16,7 @@ rate: 1, | ||
class TokensApiClient extends api_model_1.TokensApi { | ||
constructor(parameters) { | ||
const config = common_1.sellingPartnerRegions[parameters.region]; | ||
if (!config) { | ||
throw new error_1.TokensApiError(`Unknown region: ${parameters.region}`); | ||
} | ||
const { rateLimiting, ...clientParameters } = parameters; | ||
const axiosParameters = { | ||
...clientParameters, | ||
region: config.awsRegion, | ||
}; | ||
if (rateLimiting?.retry) { | ||
axiosParameters.rateLimits = exports.clientRateLimits; | ||
axiosParameters.onRetry = rateLimiting.onRetry; | ||
} | ||
const axiosInstance = (0, common_1.createAxiosInstance)(axiosParameters); | ||
const configuration = new api_model_1.Configuration(); | ||
const environment = parameters.sandbox ? 'sandbox' : 'production'; | ||
const endpoint = config.endpoints[environment]; | ||
super(configuration, endpoint, axiosInstance); | ||
constructor(configuration) { | ||
const { axios, endpoint } = (0, common_1.createAxiosInstance)(configuration, exports.clientRateLimits); | ||
super(new api_model_1.Configuration(), endpoint, axios); | ||
} | ||
} | ||
exports.TokensApiClient = TokensApiClient; |
export * from './src/client'; | ||
export * from './src/error'; | ||
export * from './src/api-model/models'; |
@@ -1,8 +0,7 @@ | ||
/* eslint-disable prefer-regex-literals */ | ||
import { sellingPartnerRegions, createAxiosInstance } from '@sp-api-sdk/common'; | ||
import { createAxiosInstance } from '@sp-api-sdk/common'; | ||
import { Configuration, TokensApi } from './api-model'; | ||
import { TokensApiError } from './error'; | ||
export const clientRateLimits = [ | ||
{ | ||
method: 'post', | ||
// eslint-disable-next-line prefer-regex-literals | ||
urlRegex: new RegExp('^/tokens/2021-03-01/restrictedDataToken$'), | ||
@@ -14,22 +13,6 @@ rate: 1, | ||
export class TokensApiClient extends TokensApi { | ||
constructor(parameters) { | ||
const config = sellingPartnerRegions[parameters.region]; | ||
if (!config) { | ||
throw new TokensApiError(`Unknown region: ${parameters.region}`); | ||
} | ||
const { rateLimiting, ...clientParameters } = parameters; | ||
const axiosParameters = { | ||
...clientParameters, | ||
region: config.awsRegion, | ||
}; | ||
if (rateLimiting?.retry) { | ||
axiosParameters.rateLimits = clientRateLimits; | ||
axiosParameters.onRetry = rateLimiting.onRetry; | ||
} | ||
const axiosInstance = createAxiosInstance(axiosParameters); | ||
const configuration = new Configuration(); | ||
const environment = parameters.sandbox ? 'sandbox' : 'production'; | ||
const endpoint = config.endpoints[environment]; | ||
super(configuration, endpoint, axiosInstance); | ||
constructor(configuration) { | ||
const { axios, endpoint } = createAxiosInstance(configuration, clientRateLimits); | ||
super(new Configuration(), endpoint, axios); | ||
} | ||
} |
export * from './src/client'; | ||
export * from './src/error'; | ||
export * from './src/api-model/models'; |
@@ -1,13 +0,6 @@ | ||
import type { ClientConfiguration, SellingPartnerRegion, RateLimit, OnRetryHandler } from '@sp-api-sdk/common'; | ||
import { type ClientConfiguration, type RateLimit } from '@sp-api-sdk/common'; | ||
import { TokensApi } from './api-model'; | ||
export declare const clientRateLimits: RateLimit[]; | ||
export interface ClientParameters extends Omit<ClientConfiguration, 'rateLimits' | 'onRetry'> { | ||
region: SellingPartnerRegion; | ||
rateLimiting?: { | ||
retry: boolean; | ||
onRetry?: OnRetryHandler; | ||
}; | ||
} | ||
export declare class TokensApiClient extends TokensApi { | ||
constructor(parameters: ClientParameters); | ||
constructor(configuration: ClientConfiguration); | ||
} |
@@ -5,6 +5,7 @@ { | ||
"description": "The Selling Partner API for Tokens provides a secure way to access a customer's PII (Personally Identifiable Information). You can call the Tokens API to get a Restricted Data Token (RDT) for one or more restricted resources that you specify. The RDT authorizes subsequent calls to restricted operations that correspond to the restricted resources that you specified. For more information, see the Tokens API Use Case Guide.", | ||
"version": "1.9.3", | ||
"version": "1.10.0", | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/es/index.js", | ||
"types": "dist/types/index.d.ts", | ||
"typedocMain": "./index.ts", | ||
"license": "MIT", | ||
@@ -30,4 +31,4 @@ "publishConfig": { | ||
"dependencies": { | ||
"@sp-api-sdk/auth": "^1.9.12", | ||
"@sp-api-sdk/common": "^1.7.14", | ||
"@sp-api-sdk/auth": "^1.9.13", | ||
"@sp-api-sdk/common": "^1.8.0", | ||
"axios": "^0.27.2" | ||
@@ -54,3 +55,3 @@ }, | ||
], | ||
"gitHead": "e6a6c9da0de5a001da60b1d3f34a3796a3adab0d" | ||
"gitHead": "975705017de9384bf28b85e97d93f866d4d71611" | ||
} |
@@ -69,2 +69,25 @@ # `tokens-api-2021-03-01` | ||
## Logging | ||
You can enable logging for both SP-API requests and responses by configuring the `logging.request` and `logging.response` properties. | ||
```javascript | ||
const client = new TokensApiClient({ | ||
auth, | ||
region: 'eu', | ||
logging: { | ||
request: { | ||
logger: console.debug | ||
}, | ||
response: { | ||
logger: console.debug | ||
} | ||
}, | ||
}) | ||
``` | ||
Specifying `true` will use the default options, specifying an object will allow you to override the default options. | ||
This uses [axios-logger](https://github.com/hg-pyun/axios-logger) under the hood. | ||
## License | ||
@@ -71,0 +94,0 @@ |
107
81195
45
1548
Updated@sp-api-sdk/auth@^1.9.13
Updated@sp-api-sdk/common@^1.8.0