@sp-api-sdk/fulfillment-outbound-api-2020-07-01 1.7.2 → 1.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  The Selling Partner API for Fulfillment Outbound lets you create applications that help a seller fulfill Multi-Channel Fulfillment orders using their inventory in Amazon's fulfillment network. You can get information on both potential and existing fulfillment orders.
4
4
 
5
+ [![npm version](https://badgen.net/npm/v/@sp-api-sdk/fulfillment-outbound-api-2020-07-01)](https://www.npmjs.com/package/@sp-api-sdk/fulfillment-outbound-api-2020-07-01)
6
+ [![XO code style](https://badgen.net/badge/code%20style/XO/cyan)](https://github.com/xojs/xo)
7
+
5
8
  ## Documentation
6
9
 
7
10
  Learn more about this Selling Partner API by visiting the [official documentation](https://github.com/amzn/selling-partner-api-docs/tree/main/references/fulfillment-outbound-api/fulfillmentOutbound_2020-07-01.md).
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FulfillmentOutboundApiClient = exports.RATE_LIMITS = void 0;
3
+ exports.FulfillmentOutboundApiClient = exports.clientRateLimits = void 0;
4
4
  /* eslint-disable prefer-regex-literals */
5
5
  const common_1 = require("@sp-api-sdk/common");
6
6
  const api_model_1 = require("./api-model");
7
7
  const error_1 = require("./error");
8
- exports.RATE_LIMITS = [
8
+ exports.clientRateLimits = [
9
9
  {
10
10
  method: 'post',
11
11
  urlRegex: new RegExp('^/fba/outbound/2020-07-01/fulfillmentOrders/preview$'),
@@ -81,20 +81,23 @@ exports.RATE_LIMITS = [
81
81
  ];
82
82
  class FulfillmentOutboundApiClient extends api_model_1.FbaOutboundApi {
83
83
  constructor(parameters) {
84
- const region = common_1.awsRegionByCode[parameters.region] ?? parameters.region;
84
+ const config = common_1.sellingPartnerRegions[parameters.region];
85
+ if (!config) {
86
+ throw new error_1.FulfillmentOutboundApiError(`Unknown region: ${parameters.region}`);
87
+ }
85
88
  const { rateLimiting, ...clientParameters } = parameters;
86
- const axiosParameters = { ...clientParameters, region };
89
+ const axiosParameters = {
90
+ ...clientParameters,
91
+ region: config.awsRegion,
92
+ };
87
93
  if (rateLimiting?.retry) {
88
- axiosParameters.rateLimits = exports.RATE_LIMITS;
94
+ axiosParameters.rateLimits = exports.clientRateLimits;
89
95
  axiosParameters.onRetry = rateLimiting.onRetry;
90
96
  }
91
97
  const axiosInstance = (0, common_1.createAxiosInstance)(axiosParameters);
92
98
  const configuration = new api_model_1.Configuration();
93
99
  const environment = parameters.sandbox ? 'sandbox' : 'production';
94
- const endpoint = common_1.endpoints[environment][region];
95
- if (!endpoint) {
96
- throw new error_1.FulfillmentOutboundApiError(`Unknown region : ${region}`);
97
- }
100
+ const endpoint = config.endpoints[environment];
98
101
  super(configuration, endpoint, axiosInstance);
99
102
  }
100
103
  }
@@ -1,8 +1,8 @@
1
1
  /* eslint-disable prefer-regex-literals */
2
- import { endpoints, awsRegionByCode, createAxiosInstance } from '@sp-api-sdk/common';
2
+ import { sellingPartnerRegions, createAxiosInstance } from '@sp-api-sdk/common';
3
3
  import { Configuration, FbaOutboundApi } from './api-model';
4
4
  import { FulfillmentOutboundApiError } from './error';
5
- export const RATE_LIMITS = [
5
+ export const clientRateLimits = [
6
6
  {
7
7
  method: 'post',
8
8
  urlRegex: new RegExp('^/fba/outbound/2020-07-01/fulfillmentOrders/preview$'),
@@ -78,20 +78,23 @@ export const RATE_LIMITS = [
78
78
  ];
79
79
  export class FulfillmentOutboundApiClient extends FbaOutboundApi {
80
80
  constructor(parameters) {
81
- const region = awsRegionByCode[parameters.region] ?? parameters.region;
81
+ const config = sellingPartnerRegions[parameters.region];
82
+ if (!config) {
83
+ throw new FulfillmentOutboundApiError(`Unknown region: ${parameters.region}`);
84
+ }
82
85
  const { rateLimiting, ...clientParameters } = parameters;
83
- const axiosParameters = { ...clientParameters, region };
86
+ const axiosParameters = {
87
+ ...clientParameters,
88
+ region: config.awsRegion,
89
+ };
84
90
  if (rateLimiting?.retry) {
85
- axiosParameters.rateLimits = RATE_LIMITS;
91
+ axiosParameters.rateLimits = clientRateLimits;
86
92
  axiosParameters.onRetry = rateLimiting.onRetry;
87
93
  }
88
94
  const axiosInstance = createAxiosInstance(axiosParameters);
89
95
  const configuration = new Configuration();
90
96
  const environment = parameters.sandbox ? 'sandbox' : 'production';
91
- const endpoint = endpoints[environment][region];
92
- if (!endpoint) {
93
- throw new FulfillmentOutboundApiError(`Unknown region : ${region}`);
94
- }
97
+ const endpoint = config.endpoints[environment];
95
98
  super(configuration, endpoint, axiosInstance);
96
99
  }
97
100
  }
@@ -1,7 +1,8 @@
1
- import type { ClientConfiguration, RateLimit, OnRetryHandler } from '@sp-api-sdk/common';
1
+ import type { ClientConfiguration, SellingPartnerRegion, RateLimit, OnRetryHandler } from '@sp-api-sdk/common';
2
2
  import { FbaOutboundApi } from './api-model';
3
- export declare const RATE_LIMITS: RateLimit[];
3
+ export declare const clientRateLimits: RateLimit[];
4
4
  export interface ClientParameters extends Omit<ClientConfiguration, 'rateLimits' | 'onRetry'> {
5
+ region: SellingPartnerRegion;
5
6
  rateLimiting?: {
6
7
  retry: boolean;
7
8
  onRetry?: OnRetryHandler;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@sp-api-sdk/fulfillment-outbound-api-2020-07-01",
3
3
  "author": "Vincent Mesquita <vincent.mesquita@bizon.solutions>",
4
4
  "description": "The Selling Partner API for Fulfillment Outbound lets you create applications that help a seller fulfill Multi-Channel Fulfillment orders using their inventory in Amazon's fulfillment network. You can get information on both potential and existing fulfillment orders.",
5
- "version": "1.7.2",
5
+ "version": "1.7.3",
6
6
  "main": "dist/cjs/index.js",
7
7
  "module": "dist/es/index.js",
8
8
  "types": "dist/types/index.d.ts",
@@ -25,8 +25,8 @@
25
25
  "test": "NODE_ENV='test' yarn jest"
26
26
  },
27
27
  "dependencies": {
28
- "@sp-api-sdk/auth": "^1.9.5",
29
- "@sp-api-sdk/common": "^1.7.7",
28
+ "@sp-api-sdk/auth": "^1.9.6",
29
+ "@sp-api-sdk/common": "^1.7.8",
30
30
  "axios": "^0.24.0"
31
31
  },
32
32
  "repository": {
@@ -48,5 +48,5 @@
48
48
  "sp sdk",
49
49
  "fulfillment outbound api"
50
50
  ],
51
- "gitHead": "e8c21d7d481263e8a6663ee11f6708d4dc6968b6"
51
+ "gitHead": "f21b5cb511abd110bf1f07843558719993f36187"
52
52
  }