@sp-api-sdk/notifications-api-v1 1.9.0 → 1.9.4
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,15 @@ 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
|
+
|
|
10
|
+
## Documentation
|
|
11
|
+
|
|
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).
|
|
13
|
+
|
|
14
|
+
Also, see the [generated documentation](https://bizon.github.io/selling-partner-api-sdk/modules/_sp_api_sdk_notifications_api_v1.html) for this API client.
|
|
15
|
+
|
|
7
16
|
## Installing
|
|
8
17
|
|
|
9
18
|
```sh
|
|
@@ -23,21 +32,20 @@ import {SellingPartnerApiAuth, AuthorizationScope} from '@sp-api-sdk/auth'
|
|
|
23
32
|
import {NotificationsApiClient} from '@sp-api-sdk/notifications-api-v1'
|
|
24
33
|
|
|
25
34
|
const auth = new SellingPartnerApiAuth({
|
|
26
|
-
clientId:
|
|
27
|
-
clientSecret:
|
|
35
|
+
clientId: process.env.LWA_CLIENT_ID,
|
|
36
|
+
clientSecret: process.env.LWA_CLIENT_SECRET,
|
|
28
37
|
scopes: [AuthorizationScope.NOTIFICATIONS],
|
|
29
|
-
secretAccessKey: '',
|
|
30
38
|
accessKeyId: '',
|
|
31
|
-
|
|
39
|
+
secretAccessKey: '',
|
|
32
40
|
role: {
|
|
33
|
-
arn: '',
|
|
41
|
+
arn: 'arn:aws:iam::…',
|
|
34
42
|
}
|
|
35
43
|
})
|
|
36
44
|
|
|
37
45
|
|
|
38
46
|
const client = new NotificationsApiClient({
|
|
39
47
|
auth,
|
|
40
|
-
region: 'eu'
|
|
48
|
+
region: 'eu'
|
|
41
49
|
})
|
|
42
50
|
```
|
|
43
51
|
|
|
@@ -48,26 +56,25 @@ import {SellingPartnerApiAuth} from '@sp-api-sdk/auth'
|
|
|
48
56
|
import {NotificationsApiClient} from '@sp-api-sdk/notifications-api-v1'
|
|
49
57
|
|
|
50
58
|
const auth = new SellingPartnerApiAuth({
|
|
51
|
-
clientId:
|
|
52
|
-
clientSecret:
|
|
53
|
-
refreshToken: '',
|
|
54
|
-
secretAccessKey: '',
|
|
59
|
+
clientId: process.env.LWA_CLIENT_ID,
|
|
60
|
+
clientSecret: process.env.LWA_CLIENT_SECRET,
|
|
61
|
+
refreshToken: 'Atzr|…',
|
|
55
62
|
accessKeyId: '',
|
|
56
|
-
|
|
63
|
+
secretAccessKey: '',
|
|
57
64
|
role: {
|
|
58
|
-
arn: '',
|
|
59
|
-
}
|
|
65
|
+
arn: 'arn:aws:iam::…',
|
|
66
|
+
},
|
|
60
67
|
})
|
|
61
68
|
|
|
62
69
|
const client = new NotificationsApiClient({
|
|
63
70
|
auth,
|
|
64
|
-
region: 'eu'
|
|
71
|
+
region: 'eu',
|
|
65
72
|
})
|
|
66
73
|
```
|
|
67
74
|
|
|
68
|
-
##
|
|
75
|
+
## Rate Limiting
|
|
69
76
|
|
|
70
|
-
|
|
77
|
+
In order to retry rate limited requests (HTTP 429), you can configure the API client as such:
|
|
71
78
|
|
|
72
79
|
```javascript
|
|
73
80
|
const client = new NotificationsApiClient({
|
|
@@ -75,13 +82,28 @@ const client = new NotificationsApiClient({
|
|
|
75
82
|
region: 'eu',
|
|
76
83
|
rateLimiting: {
|
|
77
84
|
retry: true,
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
// Optionally specify a callback that will be called on every retry.
|
|
86
|
+
onRetry: (retryInfo) => {
|
|
87
|
+
console.log(retryInfo)
|
|
88
|
+
},
|
|
89
|
+
},
|
|
80
90
|
})
|
|
81
91
|
```
|
|
82
92
|
|
|
83
|
-
The
|
|
93
|
+
The rate limits used for each route are specified in the [API documentation]((https://github.com/amzn/selling-partner-api-docs/tree/main/references/notifications-api/notifications.md)).
|
|
94
|
+
|
|
95
|
+
## License
|
|
84
96
|
|
|
85
|
-
|
|
97
|
+
MIT
|
|
86
98
|
|
|
87
|
-
|
|
99
|
+
## Miscellaneous
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
╚⊙ ⊙╝
|
|
103
|
+
╚═(███)═╝
|
|
104
|
+
╚═(███)═╝
|
|
105
|
+
╚═(███)═╝
|
|
106
|
+
╚═(███)═╝
|
|
107
|
+
╚═(███)═╝
|
|
108
|
+
╚═(███)═╝
|
|
109
|
+
```
|
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
|
}
|
|
@@ -337,7 +337,7 @@ export declare class NotificationsApi extends BaseAPI {
|
|
|
337
337
|
* @throws {RequiredError}
|
|
338
338
|
* @memberof NotificationsApi
|
|
339
339
|
*/
|
|
340
|
-
createDestination(requestParameters: NotificationsApiCreateDestinationRequest, options?: any): Promise<import("axios").AxiosResponse<CreateDestinationResponse>>;
|
|
340
|
+
createDestination(requestParameters: NotificationsApiCreateDestinationRequest, options?: any): Promise<import("axios").AxiosResponse<CreateDestinationResponse, any>>;
|
|
341
341
|
/**
|
|
342
342
|
* Creates a subscription for the specified notification type to be delivered to the specified destination. Before you can subscribe, you must first create the destination by calling the createDestination operation. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
|
|
343
343
|
* @param {NotificationsApiCreateSubscriptionRequest} requestParameters Request parameters.
|
|
@@ -345,7 +345,7 @@ export declare class NotificationsApi extends BaseAPI {
|
|
|
345
345
|
* @throws {RequiredError}
|
|
346
346
|
* @memberof NotificationsApi
|
|
347
347
|
*/
|
|
348
|
-
createSubscription(requestParameters: NotificationsApiCreateSubscriptionRequest, options?: any): Promise<import("axios").AxiosResponse<CreateSubscriptionResponse>>;
|
|
348
|
+
createSubscription(requestParameters: NotificationsApiCreateSubscriptionRequest, options?: any): Promise<import("axios").AxiosResponse<CreateSubscriptionResponse, any>>;
|
|
349
349
|
/**
|
|
350
350
|
* Deletes the destination that you specify. The deleteDestination API is grantless. For more information, see \"Grantless operations\" in the Selling Partner API Developer Guide. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
|
|
351
351
|
* @param {NotificationsApiDeleteDestinationRequest} requestParameters Request parameters.
|
|
@@ -353,7 +353,7 @@ export declare class NotificationsApi extends BaseAPI {
|
|
|
353
353
|
* @throws {RequiredError}
|
|
354
354
|
* @memberof NotificationsApi
|
|
355
355
|
*/
|
|
356
|
-
deleteDestination(requestParameters: NotificationsApiDeleteDestinationRequest, options?: any): Promise<import("axios").AxiosResponse<DeleteDestinationResponse>>;
|
|
356
|
+
deleteDestination(requestParameters: NotificationsApiDeleteDestinationRequest, options?: any): Promise<import("axios").AxiosResponse<DeleteDestinationResponse, any>>;
|
|
357
357
|
/**
|
|
358
358
|
* Deletes the subscription indicated by the subscription identifier and notification type that you specify. The subscription identifier can be for any subscription associated with your application. After you successfully call this operation, notifications will stop being sent for the associated subscription. The deleteSubscriptionById API is grantless. For more information, see \"Grantless operations\" in the Selling Partner API Developer Guide. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
|
|
359
359
|
* @param {NotificationsApiDeleteSubscriptionByIdRequest} requestParameters Request parameters.
|
|
@@ -361,7 +361,7 @@ export declare class NotificationsApi extends BaseAPI {
|
|
|
361
361
|
* @throws {RequiredError}
|
|
362
362
|
* @memberof NotificationsApi
|
|
363
363
|
*/
|
|
364
|
-
deleteSubscriptionById(requestParameters: NotificationsApiDeleteSubscriptionByIdRequest, options?: any): Promise<import("axios").AxiosResponse<DeleteSubscriptionByIdResponse>>;
|
|
364
|
+
deleteSubscriptionById(requestParameters: NotificationsApiDeleteSubscriptionByIdRequest, options?: any): Promise<import("axios").AxiosResponse<DeleteSubscriptionByIdResponse, any>>;
|
|
365
365
|
/**
|
|
366
366
|
* Returns information about the destination that you specify. The getDestination API is grantless. For more information, see \"Grantless operations\" in the Selling Partner API Developer Guide. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
|
|
367
367
|
* @param {NotificationsApiGetDestinationRequest} requestParameters Request parameters.
|
|
@@ -369,14 +369,14 @@ export declare class NotificationsApi extends BaseAPI {
|
|
|
369
369
|
* @throws {RequiredError}
|
|
370
370
|
* @memberof NotificationsApi
|
|
371
371
|
*/
|
|
372
|
-
getDestination(requestParameters: NotificationsApiGetDestinationRequest, options?: any): Promise<import("axios").AxiosResponse<GetDestinationResponse>>;
|
|
372
|
+
getDestination(requestParameters: NotificationsApiGetDestinationRequest, options?: any): Promise<import("axios").AxiosResponse<GetDestinationResponse, any>>;
|
|
373
373
|
/**
|
|
374
374
|
* Returns information about all destinations. The getDestinations API is grantless. For more information, see \"Grantless operations\" in the Selling Partner API Developer Guide. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
|
|
375
375
|
* @param {*} [options] Override http request option.
|
|
376
376
|
* @throws {RequiredError}
|
|
377
377
|
* @memberof NotificationsApi
|
|
378
378
|
*/
|
|
379
|
-
getDestinations(options?: any): Promise<import("axios").AxiosResponse<GetDestinationsResponse>>;
|
|
379
|
+
getDestinations(options?: any): Promise<import("axios").AxiosResponse<GetDestinationsResponse, any>>;
|
|
380
380
|
/**
|
|
381
381
|
* Returns information about subscriptions of the specified notification type. You can use this API to get subscription information when you do not have a subscription identifier. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
|
|
382
382
|
* @param {NotificationsApiGetSubscriptionRequest} requestParameters Request parameters.
|
|
@@ -384,7 +384,7 @@ export declare class NotificationsApi extends BaseAPI {
|
|
|
384
384
|
* @throws {RequiredError}
|
|
385
385
|
* @memberof NotificationsApi
|
|
386
386
|
*/
|
|
387
|
-
getSubscription(requestParameters: NotificationsApiGetSubscriptionRequest, options?: any): Promise<import("axios").AxiosResponse<GetSubscriptionResponse>>;
|
|
387
|
+
getSubscription(requestParameters: NotificationsApiGetSubscriptionRequest, options?: any): Promise<import("axios").AxiosResponse<GetSubscriptionResponse, any>>;
|
|
388
388
|
/**
|
|
389
389
|
* Returns information about a subscription for the specified notification type. The getSubscriptionById API is grantless. For more information, see \"Grantless operations\" in the Selling Partner API Developer Guide. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
|
|
390
390
|
* @param {NotificationsApiGetSubscriptionByIdRequest} requestParameters Request parameters.
|
|
@@ -392,5 +392,5 @@ export declare class NotificationsApi extends BaseAPI {
|
|
|
392
392
|
* @throws {RequiredError}
|
|
393
393
|
* @memberof NotificationsApi
|
|
394
394
|
*/
|
|
395
|
-
getSubscriptionById(requestParameters: NotificationsApiGetSubscriptionByIdRequest, options?: any): Promise<import("axios").AxiosResponse<GetSubscriptionByIdResponse>>;
|
|
395
|
+
getSubscriptionById(requestParameters: NotificationsApiGetSubscriptionByIdRequest, options?: any): Promise<import("axios").AxiosResponse<GetSubscriptionByIdResponse, any>>;
|
|
396
396
|
}
|
|
@@ -62,4 +62,4 @@ export declare const toPathString: (url: URL) => string;
|
|
|
62
62
|
*
|
|
63
63
|
* @export
|
|
64
64
|
*/
|
|
65
|
-
export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration | undefined) => (axios?: AxiosInstance, basePath?: string) => Promise<import("axios").AxiosResponse<any>>;
|
|
65
|
+
export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration | undefined) => (axios?: AxiosInstance, basePath?: string) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { ClientConfiguration, RateLimit } from '@sp-api-sdk/common';
|
|
1
|
+
import type { ClientConfiguration, SellingPartnerRegion, RateLimit, OnRetryHandler } from '@sp-api-sdk/common';
|
|
3
2
|
import { NotificationsApi } from './api-model';
|
|
4
|
-
export declare const
|
|
3
|
+
export declare const clientRateLimits: RateLimit[];
|
|
5
4
|
export interface ClientParameters extends Omit<ClientConfiguration, 'rateLimits' | 'onRetry'> {
|
|
5
|
+
region: SellingPartnerRegion;
|
|
6
6
|
rateLimiting?: {
|
|
7
7
|
retry: boolean;
|
|
8
|
-
onRetry?:
|
|
8
|
+
onRetry?: OnRetryHandler;
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
export declare class NotificationsApiClient extends NotificationsApi {
|
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.4",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
7
7
|
"module": "dist/es/index.js",
|
|
8
8
|
"types": "dist/types/index.d.ts",
|
|
@@ -25,9 +25,9 @@
|
|
|
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.
|
|
30
|
-
"axios": "^0.
|
|
28
|
+
"@sp-api-sdk/auth": "^1.9.7",
|
|
29
|
+
"@sp-api-sdk/common": "^1.7.9",
|
|
30
|
+
"axios": "^0.24.0"
|
|
31
31
|
},
|
|
32
32
|
"repository": {
|
|
33
33
|
"type": "git",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"sp sdk",
|
|
49
49
|
"notifications api"
|
|
50
50
|
],
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "dd52e8a895f590c62d06f19f4d8715eb7740df66"
|
|
52
52
|
}
|