@sp-api-sdk/product-pricing-api-v0 1.9.3 → 1.10.2
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 +25 -0
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/src/client.js +7 -21
- package/dist/es/index.js +0 -1
- package/dist/es/src/client.js +8 -22
- package/dist/types/index.d.ts +0 -1
- package/dist/types/src/client.d.ts +2 -9
- package/package.json +5 -4
- package/dist/cjs/src/error.js +0 -10
- package/dist/es/src/error.js +0 -6
- package/dist/types/src/error.d.ts +0 -3
package/README.md
CHANGED
|
@@ -64,6 +64,31 @@ const client = new ProductPricingApiClient({
|
|
|
64
64
|
|
|
65
65
|
The rate limits used for each route are specified in the [API documentation](https://developer-docs.amazon.com/sp-api/docs).
|
|
66
66
|
|
|
67
|
+
## Logging
|
|
68
|
+
|
|
69
|
+
You can enable logging for both SP-API requests and responses by configuring the `logging.request` and `logging.response` properties.
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
const client = new ProductPricingApiClient({
|
|
73
|
+
auth,
|
|
74
|
+
region: 'eu',
|
|
75
|
+
logging: {
|
|
76
|
+
request: {
|
|
77
|
+
logger: console.debug
|
|
78
|
+
},
|
|
79
|
+
response: {
|
|
80
|
+
logger: console.debug
|
|
81
|
+
},
|
|
82
|
+
error: true,
|
|
83
|
+
},
|
|
84
|
+
})
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Specifying `true` will use the default options, specifying an object will allow you to override the default options.
|
|
88
|
+
This uses [axios-logger](https://github.com/hg-pyun/axios-logger) under the hood.
|
|
89
|
+
By default, if enabled, the `request` and `response` loggers will use `console.info` and the `error` logger will use `console.error`.
|
|
90
|
+
|
|
91
|
+
|
|
67
92
|
## License
|
|
68
93
|
|
|
69
94
|
MIT
|
package/dist/cjs/index.js
CHANGED
|
@@ -2,5 +2,4 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./src/client"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./src/error"), exports);
|
|
6
5
|
tslib_1.__exportStar(require("./src/api-model/models"), exports);
|
package/dist/cjs/src/client.js
CHANGED
|
@@ -1,56 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProductPricingApiClient = exports.clientRateLimits = void 0;
|
|
4
|
-
/* eslint-disable prefer-regex-literals */
|
|
5
4
|
const common_1 = require("@sp-api-sdk/common");
|
|
6
5
|
const api_model_1 = require("./api-model");
|
|
7
|
-
const error_1 = require("./error");
|
|
8
6
|
exports.clientRateLimits = [
|
|
9
7
|
{
|
|
10
8
|
method: 'get',
|
|
9
|
+
// eslint-disable-next-line prefer-regex-literals
|
|
11
10
|
urlRegex: new RegExp('^/products/pricing/v0/price$'),
|
|
12
11
|
rate: 10,
|
|
13
12
|
burst: 20,
|
|
14
13
|
},
|
|
15
14
|
{
|
|
16
15
|
method: 'get',
|
|
16
|
+
// eslint-disable-next-line prefer-regex-literals
|
|
17
17
|
urlRegex: new RegExp('^/products/pricing/v0/competitivePrice$'),
|
|
18
18
|
rate: 10,
|
|
19
19
|
burst: 20,
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
method: 'get',
|
|
23
|
+
// eslint-disable-next-line prefer-regex-literals
|
|
23
24
|
urlRegex: new RegExp('^/products/pricing/v0/listings/[^/]*/offers$'),
|
|
24
25
|
rate: 5,
|
|
25
26
|
burst: 10,
|
|
26
27
|
},
|
|
27
28
|
{
|
|
28
29
|
method: 'get',
|
|
30
|
+
// eslint-disable-next-line prefer-regex-literals
|
|
29
31
|
urlRegex: new RegExp('^/products/pricing/v0/items/[^/]*/offers$'),
|
|
30
32
|
rate: 5,
|
|
31
33
|
burst: 10,
|
|
32
34
|
},
|
|
33
35
|
];
|
|
34
36
|
class ProductPricingApiClient extends api_model_1.ProductPricingApi {
|
|
35
|
-
constructor(
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
throw new error_1.ProductPricingApiError(`Unknown region: ${parameters.region}`);
|
|
39
|
-
}
|
|
40
|
-
const { rateLimiting, ...clientParameters } = parameters;
|
|
41
|
-
const axiosParameters = {
|
|
42
|
-
...clientParameters,
|
|
43
|
-
region: config.awsRegion,
|
|
44
|
-
};
|
|
45
|
-
if (rateLimiting?.retry) {
|
|
46
|
-
axiosParameters.rateLimits = exports.clientRateLimits;
|
|
47
|
-
axiosParameters.onRetry = rateLimiting.onRetry;
|
|
48
|
-
}
|
|
49
|
-
const axiosInstance = (0, common_1.createAxiosInstance)(axiosParameters);
|
|
50
|
-
const configuration = new api_model_1.Configuration();
|
|
51
|
-
const environment = parameters.sandbox ? 'sandbox' : 'production';
|
|
52
|
-
const endpoint = config.endpoints[environment];
|
|
53
|
-
super(configuration, endpoint, axiosInstance);
|
|
37
|
+
constructor(configuration) {
|
|
38
|
+
const { axios, endpoint } = (0, common_1.createAxiosInstance)(configuration, exports.clientRateLimits);
|
|
39
|
+
super(new api_model_1.Configuration(), endpoint, axios);
|
|
54
40
|
}
|
|
55
41
|
}
|
|
56
42
|
exports.ProductPricingApiClient = ProductPricingApiClient;
|
package/dist/es/index.js
CHANGED
package/dist/es/src/client.js
CHANGED
|
@@ -1,52 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
import { sellingPartnerRegions, createAxiosInstance } from '@sp-api-sdk/common';
|
|
1
|
+
import { createAxiosInstance } from '@sp-api-sdk/common';
|
|
3
2
|
import { Configuration, ProductPricingApi } from './api-model';
|
|
4
|
-
import { ProductPricingApiError } from './error';
|
|
5
3
|
export const clientRateLimits = [
|
|
6
4
|
{
|
|
7
5
|
method: 'get',
|
|
6
|
+
// eslint-disable-next-line prefer-regex-literals
|
|
8
7
|
urlRegex: new RegExp('^/products/pricing/v0/price$'),
|
|
9
8
|
rate: 10,
|
|
10
9
|
burst: 20,
|
|
11
10
|
},
|
|
12
11
|
{
|
|
13
12
|
method: 'get',
|
|
13
|
+
// eslint-disable-next-line prefer-regex-literals
|
|
14
14
|
urlRegex: new RegExp('^/products/pricing/v0/competitivePrice$'),
|
|
15
15
|
rate: 10,
|
|
16
16
|
burst: 20,
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
method: 'get',
|
|
20
|
+
// eslint-disable-next-line prefer-regex-literals
|
|
20
21
|
urlRegex: new RegExp('^/products/pricing/v0/listings/[^/]*/offers$'),
|
|
21
22
|
rate: 5,
|
|
22
23
|
burst: 10,
|
|
23
24
|
},
|
|
24
25
|
{
|
|
25
26
|
method: 'get',
|
|
27
|
+
// eslint-disable-next-line prefer-regex-literals
|
|
26
28
|
urlRegex: new RegExp('^/products/pricing/v0/items/[^/]*/offers$'),
|
|
27
29
|
rate: 5,
|
|
28
30
|
burst: 10,
|
|
29
31
|
},
|
|
30
32
|
];
|
|
31
33
|
export class ProductPricingApiClient extends ProductPricingApi {
|
|
32
|
-
constructor(
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
throw new ProductPricingApiError(`Unknown region: ${parameters.region}`);
|
|
36
|
-
}
|
|
37
|
-
const { rateLimiting, ...clientParameters } = parameters;
|
|
38
|
-
const axiosParameters = {
|
|
39
|
-
...clientParameters,
|
|
40
|
-
region: config.awsRegion,
|
|
41
|
-
};
|
|
42
|
-
if (rateLimiting?.retry) {
|
|
43
|
-
axiosParameters.rateLimits = clientRateLimits;
|
|
44
|
-
axiosParameters.onRetry = rateLimiting.onRetry;
|
|
45
|
-
}
|
|
46
|
-
const axiosInstance = createAxiosInstance(axiosParameters);
|
|
47
|
-
const configuration = new Configuration();
|
|
48
|
-
const environment = parameters.sandbox ? 'sandbox' : 'production';
|
|
49
|
-
const endpoint = config.endpoints[environment];
|
|
50
|
-
super(configuration, endpoint, axiosInstance);
|
|
34
|
+
constructor(configuration) {
|
|
35
|
+
const { axios, endpoint } = createAxiosInstance(configuration, clientRateLimits);
|
|
36
|
+
super(new Configuration(), endpoint, axios);
|
|
51
37
|
}
|
|
52
38
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ClientConfiguration, type RateLimit } from '@sp-api-sdk/common';
|
|
2
2
|
import { ProductPricingApi } from './api-model';
|
|
3
3
|
export declare const clientRateLimits: RateLimit[];
|
|
4
|
-
export interface ClientParameters extends Omit<ClientConfiguration, 'rateLimits' | 'onRetry'> {
|
|
5
|
-
region: SellingPartnerRegion;
|
|
6
|
-
rateLimiting?: {
|
|
7
|
-
retry: boolean;
|
|
8
|
-
onRetry?: OnRetryHandler;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
4
|
export declare class ProductPricingApiClient extends ProductPricingApi {
|
|
12
|
-
constructor(
|
|
5
|
+
constructor(configuration: ClientConfiguration);
|
|
13
6
|
}
|
package/package.json
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
"name": "@sp-api-sdk/product-pricing-api-v0",
|
|
3
3
|
"author": "Vincent Mesquita <vincent.mesquita@bizon.solutions>",
|
|
4
4
|
"description": "The Selling Partner API for Pricing helps you programmatically retrieve product pricing and offer information for Amazon Marketplace products.",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.10.2",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
7
7
|
"module": "dist/es/index.js",
|
|
8
8
|
"types": "dist/types/index.d.ts",
|
|
9
|
+
"typedocMain": "./index.ts",
|
|
9
10
|
"license": "MIT",
|
|
10
11
|
"publishConfig": {
|
|
11
12
|
"access": "public"
|
|
@@ -26,8 +27,8 @@
|
|
|
26
27
|
"test": "NODE_ENV='test' yarn jest"
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"@sp-api-sdk/auth": "^1.9.
|
|
30
|
-
"@sp-api-sdk/common": "^1.
|
|
30
|
+
"@sp-api-sdk/auth": "^1.9.15",
|
|
31
|
+
"@sp-api-sdk/common": "^1.9.1",
|
|
31
32
|
"axios": "^0.27.2"
|
|
32
33
|
},
|
|
33
34
|
"repository": {
|
|
@@ -49,5 +50,5 @@
|
|
|
49
50
|
"sp sdk",
|
|
50
51
|
"product pricing api"
|
|
51
52
|
],
|
|
52
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "e49e4267a61beba2869d509719731bea6cc2c6d8"
|
|
53
54
|
}
|
package/dist/cjs/src/error.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProductPricingApiError = void 0;
|
|
4
|
-
class ProductPricingApiError extends Error {
|
|
5
|
-
constructor(message) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = 'ProductPricingApiError';
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.ProductPricingApiError = ProductPricingApiError;
|
package/dist/es/src/error.js
DELETED