@sp-api-sdk/product-type-definitions-api-2020-09-01 1.7.10 → 1.7.11

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
@@ -4,6 +4,9 @@ The Selling Partner API for Product Type Definitions provides programmatic acces
4
4
 
5
5
  For more information, see the [Product Type Definitions API Use Case Guide](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/use-case-guides/product-type-definitions-api-use-case-guide/definitions-product-types-api-use-case-guide_2020-09-01.md).
6
6
 
7
+ [![npm version](https://badgen.net/npm/v/@sp-api-sdk/product-type-definitions-api-2020-09-01)](https://www.npmjs.com/package/@sp-api-sdk/product-type-definitions-api-2020-09-01)
8
+ [![XO code style](https://badgen.net/badge/code%20style/XO/cyan)](https://github.com/xojs/xo)
9
+
7
10
  ## Documentation
8
11
 
9
12
  Learn more about this Selling Partner API by visiting the [official documentation](https://github.com/amzn/selling-partner-api-docs/tree/main/references/product-type-definitions-api/definitionsProductTypes_2020-09-01.md).
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProductTypeDefinitionsApiClient = exports.RATE_LIMITS = void 0;
3
+ exports.ProductTypeDefinitionsApiClient = 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: 'get',
11
11
  urlRegex: new RegExp('^/definitions/2020-09-01/productTypes$'),
@@ -21,20 +21,23 @@ exports.RATE_LIMITS = [
21
21
  ];
22
22
  class ProductTypeDefinitionsApiClient extends api_model_1.DefinitionsApi {
23
23
  constructor(parameters) {
24
- const region = common_1.awsRegionByCode[parameters.region] ?? parameters.region;
24
+ const config = common_1.sellingPartnerRegions[parameters.region];
25
+ if (!config) {
26
+ throw new error_1.ProductTypeDefinitionsApiError(`Unknown region: ${parameters.region}`);
27
+ }
25
28
  const { rateLimiting, ...clientParameters } = parameters;
26
- const axiosParameters = { ...clientParameters, region };
29
+ const axiosParameters = {
30
+ ...clientParameters,
31
+ region: config.awsRegion,
32
+ };
27
33
  if (rateLimiting?.retry) {
28
- axiosParameters.rateLimits = exports.RATE_LIMITS;
34
+ axiosParameters.rateLimits = exports.clientRateLimits;
29
35
  axiosParameters.onRetry = rateLimiting.onRetry;
30
36
  }
31
37
  const axiosInstance = (0, common_1.createAxiosInstance)(axiosParameters);
32
38
  const configuration = new api_model_1.Configuration();
33
39
  const environment = parameters.sandbox ? 'sandbox' : 'production';
34
- const endpoint = common_1.endpoints[environment][region];
35
- if (!endpoint) {
36
- throw new error_1.ProductTypeDefinitionsApiError(`Unknown region : ${region}`);
37
- }
40
+ const endpoint = config.endpoints[environment];
38
41
  super(configuration, endpoint, axiosInstance);
39
42
  }
40
43
  }
@@ -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, DefinitionsApi } from './api-model';
4
4
  import { ProductTypeDefinitionsApiError } from './error';
5
- export const RATE_LIMITS = [
5
+ export const clientRateLimits = [
6
6
  {
7
7
  method: 'get',
8
8
  urlRegex: new RegExp('^/definitions/2020-09-01/productTypes$'),
@@ -18,20 +18,23 @@ export const RATE_LIMITS = [
18
18
  ];
19
19
  export class ProductTypeDefinitionsApiClient extends DefinitionsApi {
20
20
  constructor(parameters) {
21
- const region = awsRegionByCode[parameters.region] ?? parameters.region;
21
+ const config = sellingPartnerRegions[parameters.region];
22
+ if (!config) {
23
+ throw new ProductTypeDefinitionsApiError(`Unknown region: ${parameters.region}`);
24
+ }
22
25
  const { rateLimiting, ...clientParameters } = parameters;
23
- const axiosParameters = { ...clientParameters, region };
26
+ const axiosParameters = {
27
+ ...clientParameters,
28
+ region: config.awsRegion,
29
+ };
24
30
  if (rateLimiting?.retry) {
25
- axiosParameters.rateLimits = RATE_LIMITS;
31
+ axiosParameters.rateLimits = clientRateLimits;
26
32
  axiosParameters.onRetry = rateLimiting.onRetry;
27
33
  }
28
34
  const axiosInstance = createAxiosInstance(axiosParameters);
29
35
  const configuration = new Configuration();
30
36
  const environment = parameters.sandbox ? 'sandbox' : 'production';
31
- const endpoint = endpoints[environment][region];
32
- if (!endpoint) {
33
- throw new ProductTypeDefinitionsApiError(`Unknown region : ${region}`);
34
- }
37
+ const endpoint = config.endpoints[environment];
35
38
  super(configuration, endpoint, axiosInstance);
36
39
  }
37
40
  }
@@ -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 { DefinitionsApi } 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/product-type-definitions-api-2020-09-01",
3
3
  "author": "Vincent Mesquita <vincent.mesquita@bizon.solutions>",
4
4
  "description": "The Selling Partner API for Product Type Definitions provides programmatic access to attribute and data requirements for product types in the Amazon catalog. Use this API to return the JSON Schema for a product type that you can then use with other Selling Partner APIs, such as the Selling Partner API for Listings Items, the Selling Partner API for Catalog Items, and the Selling Partner API for Feeds (for JSON-based listing feeds). For more information, see the Product Type Definitions API Use Case Guide.",
5
- "version": "1.7.10",
5
+ "version": "1.7.11",
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
  "product type definitions api"
50
50
  ],
51
- "gitHead": "e8c21d7d481263e8a6663ee11f6708d4dc6968b6"
51
+ "gitHead": "f21b5cb511abd110bf1f07843558719993f36187"
52
52
  }