@sp-api-sdk/notifications-api-v1 1.9.2 → 1.9.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 +3 -0
- package/dist/cjs/src/client.js +12 -9
- package/dist/es/src/client.js +12 -9
- package/dist/types/src/client.d.ts +3 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -4,6 +4,9 @@ The Selling Partner API for Notifications lets you subscribe to notifications th
|
|
|
4
4
|
|
|
5
5
|
For more information, see the [Notifications Use Case Guide](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/use-case-guides/notifications-api-use-case-guide/notifications-use-case-guide-v1.md)
|
|
6
6
|
|
|
7
|
+
[](https://www.npmjs.com/package/@sp-api-sdk/notifications-api-v1)
|
|
8
|
+
[](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/notifications-api/notifications.md).
|
package/dist/cjs/src/client.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotificationsApiClient = exports.
|
|
3
|
+
exports.NotificationsApiClient = 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.
|
|
8
|
+
exports.clientRateLimits = [
|
|
9
9
|
{
|
|
10
10
|
method: 'get',
|
|
11
11
|
urlRegex: new RegExp('^/notifications/v1/subscriptions/[^/]*$'),
|
|
@@ -57,20 +57,23 @@ exports.RATE_LIMITS = [
|
|
|
57
57
|
];
|
|
58
58
|
class NotificationsApiClient extends api_model_1.NotificationsApi {
|
|
59
59
|
constructor(parameters) {
|
|
60
|
-
const
|
|
60
|
+
const config = common_1.sellingPartnerRegions[parameters.region];
|
|
61
|
+
if (!config) {
|
|
62
|
+
throw new error_1.NotificationsApiError(`Unknown region: ${parameters.region}`);
|
|
63
|
+
}
|
|
61
64
|
const { rateLimiting, ...clientParameters } = parameters;
|
|
62
|
-
const axiosParameters = {
|
|
65
|
+
const axiosParameters = {
|
|
66
|
+
...clientParameters,
|
|
67
|
+
region: config.awsRegion,
|
|
68
|
+
};
|
|
63
69
|
if (rateLimiting?.retry) {
|
|
64
|
-
axiosParameters.rateLimits = exports.
|
|
70
|
+
axiosParameters.rateLimits = exports.clientRateLimits;
|
|
65
71
|
axiosParameters.onRetry = rateLimiting.onRetry;
|
|
66
72
|
}
|
|
67
73
|
const axiosInstance = (0, common_1.createAxiosInstance)(axiosParameters);
|
|
68
74
|
const configuration = new api_model_1.Configuration();
|
|
69
75
|
const environment = parameters.sandbox ? 'sandbox' : 'production';
|
|
70
|
-
const endpoint =
|
|
71
|
-
if (!endpoint) {
|
|
72
|
-
throw new error_1.NotificationsApiError(`Unknown region : ${region}`);
|
|
73
|
-
}
|
|
76
|
+
const endpoint = config.endpoints[environment];
|
|
74
77
|
super(configuration, endpoint, axiosInstance);
|
|
75
78
|
}
|
|
76
79
|
}
|
package/dist/es/src/client.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable prefer-regex-literals */
|
|
2
|
-
import {
|
|
2
|
+
import { sellingPartnerRegions, createAxiosInstance } from '@sp-api-sdk/common';
|
|
3
3
|
import { Configuration, NotificationsApi } from './api-model';
|
|
4
4
|
import { NotificationsApiError } from './error';
|
|
5
|
-
export const
|
|
5
|
+
export const clientRateLimits = [
|
|
6
6
|
{
|
|
7
7
|
method: 'get',
|
|
8
8
|
urlRegex: new RegExp('^/notifications/v1/subscriptions/[^/]*$'),
|
|
@@ -54,20 +54,23 @@ export const RATE_LIMITS = [
|
|
|
54
54
|
];
|
|
55
55
|
export class NotificationsApiClient extends NotificationsApi {
|
|
56
56
|
constructor(parameters) {
|
|
57
|
-
const
|
|
57
|
+
const config = sellingPartnerRegions[parameters.region];
|
|
58
|
+
if (!config) {
|
|
59
|
+
throw new NotificationsApiError(`Unknown region: ${parameters.region}`);
|
|
60
|
+
}
|
|
58
61
|
const { rateLimiting, ...clientParameters } = parameters;
|
|
59
|
-
const axiosParameters = {
|
|
62
|
+
const axiosParameters = {
|
|
63
|
+
...clientParameters,
|
|
64
|
+
region: config.awsRegion,
|
|
65
|
+
};
|
|
60
66
|
if (rateLimiting?.retry) {
|
|
61
|
-
axiosParameters.rateLimits =
|
|
67
|
+
axiosParameters.rateLimits = clientRateLimits;
|
|
62
68
|
axiosParameters.onRetry = rateLimiting.onRetry;
|
|
63
69
|
}
|
|
64
70
|
const axiosInstance = createAxiosInstance(axiosParameters);
|
|
65
71
|
const configuration = new Configuration();
|
|
66
72
|
const environment = parameters.sandbox ? 'sandbox' : 'production';
|
|
67
|
-
const endpoint = endpoints[environment]
|
|
68
|
-
if (!endpoint) {
|
|
69
|
-
throw new NotificationsApiError(`Unknown region : ${region}`);
|
|
70
|
-
}
|
|
73
|
+
const endpoint = config.endpoints[environment];
|
|
71
74
|
super(configuration, endpoint, axiosInstance);
|
|
72
75
|
}
|
|
73
76
|
}
|
|
@@ -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 { NotificationsApi } from './api-model';
|
|
3
|
-
export declare const
|
|
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/notifications-api-v1",
|
|
3
3
|
"author": "Vincent Mesquita <vincent.mesquita@bizon.solutions>",
|
|
4
4
|
"description": "The Selling Partner API for Notifications lets you subscribe to notifications that are relevant to a selling partner's business. Using this API you can create a destination to receive notifications, subscribe to notifications, delete notification subscriptions, and more. For more information, see the Notifications Use Case Guide",
|
|
5
|
-
"version": "1.9.
|
|
5
|
+
"version": "1.9.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.
|
|
29
|
-
"@sp-api-sdk/common": "^1.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
|
"notifications api"
|
|
50
50
|
],
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "f21b5cb511abd110bf1f07843558719993f36187"
|
|
52
52
|
}
|