@sp-api-sdk/services-api-v1 1.6.17 → 1.6.21
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,15 @@
|
|
|
2
2
|
|
|
3
3
|
With the Services API, you can build applications that help service providers get and modify their service orders.
|
|
4
4
|
|
|
5
|
+
[](https://www.npmjs.com/package/@sp-api-sdk/services-api-v1)
|
|
6
|
+
[](https://github.com/xojs/xo)
|
|
7
|
+
|
|
8
|
+
## Documentation
|
|
9
|
+
|
|
10
|
+
Learn more about this Selling Partner API by visiting the [official documentation](https://github.com/amzn/selling-partner-api-docs/tree/main/references/services-api/services.md).
|
|
11
|
+
|
|
12
|
+
Also, see the [generated documentation](https://bizon.github.io/selling-partner-api-sdk/modules/_sp_api_sdk_services_api_v1.html) for this API client.
|
|
13
|
+
|
|
5
14
|
## Installing
|
|
6
15
|
|
|
7
16
|
```sh
|
|
@@ -19,26 +28,25 @@ import {SellingPartnerApiAuth} from '@sp-api-sdk/auth'
|
|
|
19
28
|
import {ServicesApiClient} from '@sp-api-sdk/services-api-v1'
|
|
20
29
|
|
|
21
30
|
const auth = new SellingPartnerApiAuth({
|
|
22
|
-
clientId:
|
|
23
|
-
clientSecret:
|
|
24
|
-
refreshToken: '',
|
|
25
|
-
secretAccessKey: '',
|
|
31
|
+
clientId: process.env.LWA_CLIENT_ID,
|
|
32
|
+
clientSecret: process.env.LWA_CLIENT_SECRET,
|
|
33
|
+
refreshToken: 'Atzr|…',
|
|
26
34
|
accessKeyId: '',
|
|
27
|
-
|
|
35
|
+
secretAccessKey: '',
|
|
28
36
|
role: {
|
|
29
|
-
arn: '',
|
|
30
|
-
}
|
|
37
|
+
arn: 'arn:aws:iam::…',
|
|
38
|
+
},
|
|
31
39
|
})
|
|
32
40
|
|
|
33
41
|
const client = new ServicesApiClient({
|
|
34
42
|
auth,
|
|
35
|
-
region: 'eu'
|
|
43
|
+
region: 'eu',
|
|
36
44
|
})
|
|
37
45
|
```
|
|
38
46
|
|
|
39
|
-
##
|
|
47
|
+
## Rate Limiting
|
|
40
48
|
|
|
41
|
-
|
|
49
|
+
In order to retry rate limited requests (HTTP 429), you can configure the API client as such:
|
|
42
50
|
|
|
43
51
|
```javascript
|
|
44
52
|
const client = new ServicesApiClient({
|
|
@@ -46,13 +54,28 @@ const client = new ServicesApiClient({
|
|
|
46
54
|
region: 'eu',
|
|
47
55
|
rateLimiting: {
|
|
48
56
|
retry: true,
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
// Optionally specify a callback that will be called on every retry.
|
|
58
|
+
onRetry: (retryInfo) => {
|
|
59
|
+
console.log(retryInfo)
|
|
60
|
+
},
|
|
61
|
+
},
|
|
51
62
|
})
|
|
52
63
|
```
|
|
53
64
|
|
|
54
|
-
The
|
|
65
|
+
The rate limits used for each route are specified in the [API documentation]((https://github.com/amzn/selling-partner-api-docs/tree/main/references/services-api/services.md)).
|
|
66
|
+
|
|
67
|
+
## License
|
|
68
|
+
|
|
69
|
+
MIT
|
|
55
70
|
|
|
56
|
-
##
|
|
71
|
+
## Miscellaneous
|
|
57
72
|
|
|
58
|
-
|
|
73
|
+
```
|
|
74
|
+
╚⊙ ⊙╝
|
|
75
|
+
╚═(███)═╝
|
|
76
|
+
╚═(███)═╝
|
|
77
|
+
╚═(███)═╝
|
|
78
|
+
╚═(███)═╝
|
|
79
|
+
╚═(███)═╝
|
|
80
|
+
╚═(███)═╝
|
|
81
|
+
```
|
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.ServicesApiClient = exports.
|
|
3
|
+
exports.ServicesApiClient = 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('^/service/v1/serviceJobs/[^/]*$'),
|
|
@@ -45,20 +45,23 @@ exports.RATE_LIMITS = [
|
|
|
45
45
|
];
|
|
46
46
|
class ServicesApiClient extends api_model_1.ServiceApi {
|
|
47
47
|
constructor(parameters) {
|
|
48
|
-
const
|
|
48
|
+
const config = common_1.sellingPartnerRegions[parameters.region];
|
|
49
|
+
if (!config) {
|
|
50
|
+
throw new error_1.ServicesApiError(`Unknown region: ${parameters.region}`);
|
|
51
|
+
}
|
|
49
52
|
const { rateLimiting, ...clientParameters } = parameters;
|
|
50
|
-
const axiosParameters = {
|
|
53
|
+
const axiosParameters = {
|
|
54
|
+
...clientParameters,
|
|
55
|
+
region: config.awsRegion,
|
|
56
|
+
};
|
|
51
57
|
if (rateLimiting?.retry) {
|
|
52
|
-
axiosParameters.rateLimits = exports.
|
|
58
|
+
axiosParameters.rateLimits = exports.clientRateLimits;
|
|
53
59
|
axiosParameters.onRetry = rateLimiting.onRetry;
|
|
54
60
|
}
|
|
55
61
|
const axiosInstance = (0, common_1.createAxiosInstance)(axiosParameters);
|
|
56
62
|
const configuration = new api_model_1.Configuration();
|
|
57
63
|
const environment = parameters.sandbox ? 'sandbox' : 'production';
|
|
58
|
-
const endpoint =
|
|
59
|
-
if (!endpoint) {
|
|
60
|
-
throw new error_1.ServicesApiError(`Unknown region : ${region}`);
|
|
61
|
-
}
|
|
64
|
+
const endpoint = config.endpoints[environment];
|
|
62
65
|
super(configuration, endpoint, axiosInstance);
|
|
63
66
|
}
|
|
64
67
|
}
|
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, ServiceApi } from './api-model';
|
|
4
4
|
import { ServicesApiError } from './error';
|
|
5
|
-
export const
|
|
5
|
+
export const clientRateLimits = [
|
|
6
6
|
{
|
|
7
7
|
method: 'get',
|
|
8
8
|
urlRegex: new RegExp('^/service/v1/serviceJobs/[^/]*$'),
|
|
@@ -42,20 +42,23 @@ export const RATE_LIMITS = [
|
|
|
42
42
|
];
|
|
43
43
|
export class ServicesApiClient extends ServiceApi {
|
|
44
44
|
constructor(parameters) {
|
|
45
|
-
const
|
|
45
|
+
const config = sellingPartnerRegions[parameters.region];
|
|
46
|
+
if (!config) {
|
|
47
|
+
throw new ServicesApiError(`Unknown region: ${parameters.region}`);
|
|
48
|
+
}
|
|
46
49
|
const { rateLimiting, ...clientParameters } = parameters;
|
|
47
|
-
const axiosParameters = {
|
|
50
|
+
const axiosParameters = {
|
|
51
|
+
...clientParameters,
|
|
52
|
+
region: config.awsRegion,
|
|
53
|
+
};
|
|
48
54
|
if (rateLimiting?.retry) {
|
|
49
|
-
axiosParameters.rateLimits =
|
|
55
|
+
axiosParameters.rateLimits = clientRateLimits;
|
|
50
56
|
axiosParameters.onRetry = rateLimiting.onRetry;
|
|
51
57
|
}
|
|
52
58
|
const axiosInstance = createAxiosInstance(axiosParameters);
|
|
53
59
|
const configuration = new Configuration();
|
|
54
60
|
const environment = parameters.sandbox ? 'sandbox' : 'production';
|
|
55
|
-
const endpoint = endpoints[environment]
|
|
56
|
-
if (!endpoint) {
|
|
57
|
-
throw new ServicesApiError(`Unknown region : ${region}`);
|
|
58
|
-
}
|
|
61
|
+
const endpoint = config.endpoints[environment];
|
|
59
62
|
super(configuration, endpoint, axiosInstance);
|
|
60
63
|
}
|
|
61
64
|
}
|
|
@@ -399,7 +399,7 @@ export declare class ServiceApi extends BaseAPI {
|
|
|
399
399
|
* @throws {RequiredError}
|
|
400
400
|
* @memberof ServiceApi
|
|
401
401
|
*/
|
|
402
|
-
addAppointmentForServiceJobByServiceJobId(requestParameters: ServiceApiAddAppointmentForServiceJobByServiceJobIdRequest, options?: any): Promise<import("axios").AxiosResponse<SetAppointmentResponse>>;
|
|
402
|
+
addAppointmentForServiceJobByServiceJobId(requestParameters: ServiceApiAddAppointmentForServiceJobByServiceJobIdRequest, options?: any): Promise<import("axios").AxiosResponse<SetAppointmentResponse, any>>;
|
|
403
403
|
/**
|
|
404
404
|
* Cancels the service job indicated by the service job identifier you specify. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 5 | 20 | For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
|
|
405
405
|
* @param {ServiceApiCancelServiceJobByServiceJobIdRequest} requestParameters Request parameters.
|
|
@@ -407,7 +407,7 @@ export declare class ServiceApi extends BaseAPI {
|
|
|
407
407
|
* @throws {RequiredError}
|
|
408
408
|
* @memberof ServiceApi
|
|
409
409
|
*/
|
|
410
|
-
cancelServiceJobByServiceJobId(requestParameters: ServiceApiCancelServiceJobByServiceJobIdRequest, options?: any): Promise<import("axios").AxiosResponse<CancelServiceJobByServiceJobIdResponse>>;
|
|
410
|
+
cancelServiceJobByServiceJobId(requestParameters: ServiceApiCancelServiceJobByServiceJobIdRequest, options?: any): Promise<import("axios").AxiosResponse<CancelServiceJobByServiceJobIdResponse, any>>;
|
|
411
411
|
/**
|
|
412
412
|
* Completes the service job indicated by the service job identifier you specify. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 5 | 20 | For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
|
|
413
413
|
* @param {ServiceApiCompleteServiceJobByServiceJobIdRequest} requestParameters Request parameters.
|
|
@@ -415,7 +415,7 @@ export declare class ServiceApi extends BaseAPI {
|
|
|
415
415
|
* @throws {RequiredError}
|
|
416
416
|
* @memberof ServiceApi
|
|
417
417
|
*/
|
|
418
|
-
completeServiceJobByServiceJobId(requestParameters: ServiceApiCompleteServiceJobByServiceJobIdRequest, options?: any): Promise<import("axios").AxiosResponse<CompleteServiceJobByServiceJobIdResponse>>;
|
|
418
|
+
completeServiceJobByServiceJobId(requestParameters: ServiceApiCompleteServiceJobByServiceJobIdRequest, options?: any): Promise<import("axios").AxiosResponse<CompleteServiceJobByServiceJobIdResponse, any>>;
|
|
419
419
|
/**
|
|
420
420
|
* Gets service job details for the service job indicated by the service job identifier you specify. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 20 | 40 | For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
|
|
421
421
|
* @param {ServiceApiGetServiceJobByServiceJobIdRequest} requestParameters Request parameters.
|
|
@@ -423,7 +423,7 @@ export declare class ServiceApi extends BaseAPI {
|
|
|
423
423
|
* @throws {RequiredError}
|
|
424
424
|
* @memberof ServiceApi
|
|
425
425
|
*/
|
|
426
|
-
getServiceJobByServiceJobId(requestParameters: ServiceApiGetServiceJobByServiceJobIdRequest, options?: any): Promise<import("axios").AxiosResponse<GetServiceJobByServiceJobIdResponse>>;
|
|
426
|
+
getServiceJobByServiceJobId(requestParameters: ServiceApiGetServiceJobByServiceJobIdRequest, options?: any): Promise<import("axios").AxiosResponse<GetServiceJobByServiceJobIdResponse, any>>;
|
|
427
427
|
/**
|
|
428
428
|
* Gets service job details for the specified filter query. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 40 | For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
|
|
429
429
|
* @param {ServiceApiGetServiceJobsRequest} requestParameters Request parameters.
|
|
@@ -431,7 +431,7 @@ export declare class ServiceApi extends BaseAPI {
|
|
|
431
431
|
* @throws {RequiredError}
|
|
432
432
|
* @memberof ServiceApi
|
|
433
433
|
*/
|
|
434
|
-
getServiceJobs(requestParameters: ServiceApiGetServiceJobsRequest, options?: any): Promise<import("axios").AxiosResponse<GetServiceJobsResponse>>;
|
|
434
|
+
getServiceJobs(requestParameters: ServiceApiGetServiceJobsRequest, options?: any): Promise<import("axios").AxiosResponse<GetServiceJobsResponse, any>>;
|
|
435
435
|
/**
|
|
436
436
|
* Reschedules an appointment for the service job indicated by the service job identifier you specify. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 5 | 20 | For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
|
|
437
437
|
* @param {ServiceApiRescheduleAppointmentForServiceJobByServiceJobIdRequest} requestParameters Request parameters.
|
|
@@ -439,5 +439,5 @@ export declare class ServiceApi extends BaseAPI {
|
|
|
439
439
|
* @throws {RequiredError}
|
|
440
440
|
* @memberof ServiceApi
|
|
441
441
|
*/
|
|
442
|
-
rescheduleAppointmentForServiceJobByServiceJobId(requestParameters: ServiceApiRescheduleAppointmentForServiceJobByServiceJobIdRequest, options?: any): Promise<import("axios").AxiosResponse<SetAppointmentResponse>>;
|
|
442
|
+
rescheduleAppointmentForServiceJobByServiceJobId(requestParameters: ServiceApiRescheduleAppointmentForServiceJobByServiceJobIdRequest, options?: any): Promise<import("axios").AxiosResponse<SetAppointmentResponse, any>>;
|
|
443
443
|
}
|
|
@@ -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 { ServiceApi } 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 ServicesApiClient extends ServiceApi {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@sp-api-sdk/services-api-v1",
|
|
3
3
|
"author": "Vincent Mesquita <vincent.mesquita@bizon.solutions>",
|
|
4
4
|
"description": "With the Services API, you can build applications that help service providers get and modify their service orders.",
|
|
5
|
-
"version": "1.6.
|
|
5
|
+
"version": "1.6.21",
|
|
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.6",
|
|
29
|
+
"@sp-api-sdk/common": "^1.7.8",
|
|
30
|
+
"axios": "^0.24.0"
|
|
31
31
|
},
|
|
32
32
|
"repository": {
|
|
33
33
|
"type": "git",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"sp sdk",
|
|
49
49
|
"services api"
|
|
50
50
|
],
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "f21b5cb511abd110bf1f07843558719993f36187"
|
|
52
52
|
}
|