@sp-api-sdk/fba-inventory-api-v1
Advanced tools
Comparing version 1.9.2 to 1.9.3
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FbaInventoryApiClient = exports.RATE_LIMITS = void 0; | ||
exports.FbaInventoryApiClient = exports.clientRateLimits = void 0; | ||
/* eslint-disable prefer-regex-literals */ | ||
@@ -8,3 +8,3 @@ const common_1 = require("@sp-api-sdk/common"); | ||
const error_1 = require("./error"); | ||
exports.RATE_LIMITS = [ | ||
exports.clientRateLimits = [ | ||
{ | ||
@@ -19,7 +19,13 @@ method: 'get', | ||
constructor(parameters) { | ||
const region = common_1.awsRegionByCode[parameters.region] ?? parameters.region; | ||
const config = common_1.sellingPartnerRegions[parameters.region]; | ||
if (!config) { | ||
throw new error_1.FbaInventoryApiError(`Unknown region: ${parameters.region}`); | ||
} | ||
const { rateLimiting, ...clientParameters } = parameters; | ||
const axiosParameters = { ...clientParameters, region }; | ||
const axiosParameters = { | ||
...clientParameters, | ||
region: config.awsRegion, | ||
}; | ||
if (rateLimiting?.retry) { | ||
axiosParameters.rateLimits = exports.RATE_LIMITS; | ||
axiosParameters.rateLimits = exports.clientRateLimits; | ||
axiosParameters.onRetry = rateLimiting.onRetry; | ||
@@ -30,6 +36,3 @@ } | ||
const environment = parameters.sandbox ? 'sandbox' : 'production'; | ||
const endpoint = common_1.endpoints[environment][region]; | ||
if (!endpoint) { | ||
throw new error_1.FbaInventoryApiError(`Unknown region : ${region}`); | ||
} | ||
const endpoint = config.endpoints[environment]; | ||
super(configuration, endpoint, axiosInstance); | ||
@@ -36,0 +39,0 @@ } |
/* eslint-disable prefer-regex-literals */ | ||
import { endpoints, awsRegionByCode, createAxiosInstance } from '@sp-api-sdk/common'; | ||
import { sellingPartnerRegions, createAxiosInstance } from '@sp-api-sdk/common'; | ||
import { Configuration, FbaInventoryApi } from './api-model'; | ||
import { FbaInventoryApiError } from './error'; | ||
export const RATE_LIMITS = [ | ||
export const clientRateLimits = [ | ||
{ | ||
@@ -15,7 +15,13 @@ method: 'get', | ||
constructor(parameters) { | ||
const region = awsRegionByCode[parameters.region] ?? parameters.region; | ||
const config = sellingPartnerRegions[parameters.region]; | ||
if (!config) { | ||
throw new FbaInventoryApiError(`Unknown region: ${parameters.region}`); | ||
} | ||
const { rateLimiting, ...clientParameters } = parameters; | ||
const axiosParameters = { ...clientParameters, region }; | ||
const axiosParameters = { | ||
...clientParameters, | ||
region: config.awsRegion, | ||
}; | ||
if (rateLimiting?.retry) { | ||
axiosParameters.rateLimits = RATE_LIMITS; | ||
axiosParameters.rateLimits = clientRateLimits; | ||
axiosParameters.onRetry = rateLimiting.onRetry; | ||
@@ -26,8 +32,5 @@ } | ||
const environment = parameters.sandbox ? 'sandbox' : 'production'; | ||
const endpoint = endpoints[environment][region]; | ||
if (!endpoint) { | ||
throw new FbaInventoryApiError(`Unknown region : ${region}`); | ||
} | ||
const endpoint = config.endpoints[environment]; | ||
super(configuration, endpoint, axiosInstance); | ||
} | ||
} |
@@ -1,5 +0,6 @@ | ||
import type { ClientConfiguration, RateLimit, OnRetryHandler } from '@sp-api-sdk/common'; | ||
import type { ClientConfiguration, SellingPartnerRegion, RateLimit, OnRetryHandler } from '@sp-api-sdk/common'; | ||
import { FbaInventoryApi } from './api-model'; | ||
export declare const RATE_LIMITS: RateLimit[]; | ||
export declare const clientRateLimits: RateLimit[]; | ||
export interface ClientParameters extends Omit<ClientConfiguration, 'rateLimits' | 'onRetry'> { | ||
region: SellingPartnerRegion; | ||
rateLimiting?: { | ||
@@ -6,0 +7,0 @@ retry: boolean; |
@@ -5,3 +5,3 @@ { | ||
"description": "The Selling Partner API for FBA Inventory lets you programmatically retrieve information about inventory in Amazon's fulfillment network. Today this API is available only in the North America region. In 2021 we plan to release this API in the Europe and Far East regions.", | ||
"version": "1.9.2", | ||
"version": "1.9.3", | ||
"main": "dist/cjs/index.js", | ||
@@ -29,4 +29,4 @@ "module": "dist/es/index.js", | ||
"dependencies": { | ||
"@sp-api-sdk/auth": "^1.9.5", | ||
"@sp-api-sdk/common": "^1.7.7", | ||
"@sp-api-sdk/auth": "^1.9.6", | ||
"@sp-api-sdk/common": "^1.7.8", | ||
"axios": "^0.24.0" | ||
@@ -53,3 +53,3 @@ }, | ||
], | ||
"gitHead": "e8c21d7d481263e8a6663ee11f6708d4dc6968b6" | ||
"gitHead": "f21b5cb511abd110bf1f07843558719993f36187" | ||
} |
@@ -5,2 +5,5 @@ # `fba-inventory-api-v1` | ||
[![npm version](https://badgen.net/npm/v/@sp-api-sdk/fba-inventory-api-v1)](https://www.npmjs.com/package/@sp-api-sdk/fba-inventory-api-v1) | ||
[![XO code style](https://badgen.net/badge/code%20style/XO/cyan)](https://github.com/xojs/xo) | ||
## Documentation | ||
@@ -7,0 +10,0 @@ |
105836
2201
82
Updated@sp-api-sdk/auth@^1.9.6
Updated@sp-api-sdk/common@^1.7.8