@sp-api-sdk/solicitations-api-v1
Advanced tools
Comparing version
@@ -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.SolicitationsApiClient = 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: 'get', | ||
// eslint-disable-next-line prefer-regex-literals | ||
urlRegex: new RegExp('^/solicitations/v1/orders/[^/]*$'), | ||
@@ -17,2 +16,3 @@ rate: 1, | ||
method: 'post', | ||
// eslint-disable-next-line prefer-regex-literals | ||
urlRegex: new RegExp('^/solicitations/v1/orders/[^/]*/solicitations/productReviewAndSellerFeedback$'), | ||
@@ -24,23 +24,7 @@ rate: 1, | ||
class SolicitationsApiClient extends api_model_1.SolicitationsApi { | ||
constructor(parameters) { | ||
const config = common_1.sellingPartnerRegions[parameters.region]; | ||
if (!config) { | ||
throw new error_1.SolicitationsApiError(`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.SolicitationsApiClient = SolicitationsApiClient; |
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, SolicitationsApi } from './api-model'; | ||
import { SolicitationsApiError } from './error'; | ||
export const clientRateLimits = [ | ||
{ | ||
method: 'get', | ||
// eslint-disable-next-line prefer-regex-literals | ||
urlRegex: new RegExp('^/solicitations/v1/orders/[^/]*$'), | ||
@@ -14,2 +13,3 @@ rate: 1, | ||
method: 'post', | ||
// eslint-disable-next-line prefer-regex-literals | ||
urlRegex: new RegExp('^/solicitations/v1/orders/[^/]*/solicitations/productReviewAndSellerFeedback$'), | ||
@@ -21,22 +21,6 @@ rate: 1, | ||
export class SolicitationsApiClient extends SolicitationsApi { | ||
constructor(parameters) { | ||
const config = sellingPartnerRegions[parameters.region]; | ||
if (!config) { | ||
throw new SolicitationsApiError(`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 { SolicitationsApi } 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 SolicitationsApiClient extends SolicitationsApi { | ||
constructor(parameters: ClientParameters); | ||
constructor(configuration: ClientConfiguration); | ||
} |
@@ -5,6 +5,7 @@ { | ||
"description": "With the Solicitations API you can build applications that send non-critical solicitations to buyers. You can get a list of solicitation types that are available for an order that you specify, then call an operation that sends a solicitation to the buyer for that order. Buyers cannot respond to solicitations sent by this API, and these solicitations do not appear in the Messaging section of Seller Central or in the recipient's Message Center. The Solicitations API returns responses that are formed according to the JSON Hypertext Application Language (HAL) standard.", | ||
"version": "1.8.3", | ||
"version": "1.9.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" | ||
} |
@@ -67,2 +67,25 @@ # `solicitations-api-v1` | ||
## 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 SolicitationsApiClient({ | ||
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 | ||
@@ -69,0 +92,0 @@ |
105
28.05%124993
-1.34%66
-4.35%2233
-2.66%Updated
Updated