@sp-api-sdk/finances-api-v0 1.7.3 → 1.7.7

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
  The Selling Partner API for Finances helps you obtain financial information relevant to a seller's business. You can obtain financial events for a given order, financial event group, or date range without having to wait until a statement period closes. You can also obtain financial event groups for a given date range.
4
4
 
5
+ [![npm version](https://badgen.net/npm/v/@sp-api-sdk/finances-api-v0)](https://www.npmjs.com/package/@sp-api-sdk/finances-api-v0)
6
+ [![XO code style](https://badgen.net/badge/code%20style/XO/cyan)](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/finances-api/financesV0.md).
11
+
12
+ Also, see the [generated documentation](https://bizon.github.io/selling-partner-api-sdk/modules/_sp_api_sdk_finances_api_v0.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 {FinancesApiClient} from '@sp-api-sdk/finances-api-v0'
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
- region: '',
35
+ secretAccessKey: '',
28
36
  role: {
29
- arn: '',
30
- }
37
+ arn: 'arn:aws:iam::…',
38
+ },
31
39
  })
32
40
 
33
41
  const client = new FinancesApiClient({
34
42
  auth,
35
- region: 'eu' // or 'eu-west-1'
43
+ region: 'eu',
36
44
  })
37
45
  ```
38
46
 
39
- ## Handle Rate Limiting
47
+ ## Rate Limiting
40
48
 
41
- If you want to let the SDK retry after each 429 responses, instanciate the client like this:
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 FinancesApiClient({
@@ -46,13 +54,28 @@ const client = new FinancesApiClient({
46
54
  region: 'eu',
47
55
  rateLimiting: {
48
56
  retry: true,
49
- onRetry: (retryInfo) => console.log(retryInfo) // Optional
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 SDK gets the rate limits for each routes from the API documentation
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/finances-api/financesV0.md)).
66
+
67
+ ## License
68
+
69
+ MIT
55
70
 
56
- ## API documentation
71
+ ## Miscellaneous
57
72
 
58
- See [here](https://github.com/amzn/selling-partner-api-docs/tree/main/references/finances-api/financesV0.md)
73
+ ```
74
+ ╚⊙ ⊙╝
75
+ ╚═(███)═╝
76
+ ╚═(███)═╝
77
+ ╚═(███)═╝
78
+ ╚═(███)═╝
79
+ ╚═(███)═╝
80
+ ╚═(███)═╝
81
+ ```
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FinancesApiClient = exports.RATE_LIMITS = void 0;
3
+ exports.FinancesApiClient = 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('^/finances/v0/financialEventGroups$'),
@@ -33,20 +33,23 @@ exports.RATE_LIMITS = [
33
33
  ];
34
34
  class FinancesApiClient extends api_model_1.DefaultApi {
35
35
  constructor(parameters) {
36
- const region = common_1.awsRegionByCode[parameters.region] ?? parameters.region;
36
+ const config = common_1.sellingPartnerRegions[parameters.region];
37
+ if (!config) {
38
+ throw new error_1.FinancesApiError(`Unknown region: ${parameters.region}`);
39
+ }
37
40
  const { rateLimiting, ...clientParameters } = parameters;
38
- const axiosParameters = { ...clientParameters, region };
41
+ const axiosParameters = {
42
+ ...clientParameters,
43
+ region: config.awsRegion,
44
+ };
39
45
  if (rateLimiting?.retry) {
40
- axiosParameters.rateLimits = exports.RATE_LIMITS;
46
+ axiosParameters.rateLimits = exports.clientRateLimits;
41
47
  axiosParameters.onRetry = rateLimiting.onRetry;
42
48
  }
43
49
  const axiosInstance = (0, common_1.createAxiosInstance)(axiosParameters);
44
50
  const configuration = new api_model_1.Configuration();
45
51
  const environment = parameters.sandbox ? 'sandbox' : 'production';
46
- const endpoint = common_1.endpoints[environment][region];
47
- if (!endpoint) {
48
- throw new error_1.FinancesApiError(`Unknown region : ${region}`);
49
- }
52
+ const endpoint = config.endpoints[environment];
50
53
  super(configuration, endpoint, axiosInstance);
51
54
  }
52
55
  }
@@ -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, DefaultApi } from './api-model';
4
4
  import { FinancesApiError } from './error';
5
- export const RATE_LIMITS = [
5
+ export const clientRateLimits = [
6
6
  {
7
7
  method: 'get',
8
8
  urlRegex: new RegExp('^/finances/v0/financialEventGroups$'),
@@ -30,20 +30,23 @@ export const RATE_LIMITS = [
30
30
  ];
31
31
  export class FinancesApiClient extends DefaultApi {
32
32
  constructor(parameters) {
33
- const region = awsRegionByCode[parameters.region] ?? parameters.region;
33
+ const config = sellingPartnerRegions[parameters.region];
34
+ if (!config) {
35
+ throw new FinancesApiError(`Unknown region: ${parameters.region}`);
36
+ }
34
37
  const { rateLimiting, ...clientParameters } = parameters;
35
- const axiosParameters = { ...clientParameters, region };
38
+ const axiosParameters = {
39
+ ...clientParameters,
40
+ region: config.awsRegion,
41
+ };
36
42
  if (rateLimiting?.retry) {
37
- axiosParameters.rateLimits = RATE_LIMITS;
43
+ axiosParameters.rateLimits = clientRateLimits;
38
44
  axiosParameters.onRetry = rateLimiting.onRetry;
39
45
  }
40
46
  const axiosInstance = createAxiosInstance(axiosParameters);
41
47
  const configuration = new Configuration();
42
48
  const environment = parameters.sandbox ? 'sandbox' : 'production';
43
- const endpoint = endpoints[environment][region];
44
- if (!endpoint) {
45
- throw new FinancesApiError(`Unknown region : ${region}`);
46
- }
49
+ const endpoint = config.endpoints[environment];
47
50
  super(configuration, endpoint, axiosInstance);
48
51
  }
49
52
  }
@@ -272,7 +272,7 @@ export declare class DefaultApi extends BaseAPI {
272
272
  * @throws {RequiredError}
273
273
  * @memberof DefaultApi
274
274
  */
275
- listFinancialEventGroups(requestParameters?: DefaultApiListFinancialEventGroupsRequest, options?: any): Promise<import("axios").AxiosResponse<ListFinancialEventGroupsResponse>>;
275
+ listFinancialEventGroups(requestParameters?: DefaultApiListFinancialEventGroupsRequest, options?: any): Promise<import("axios").AxiosResponse<ListFinancialEventGroupsResponse, any>>;
276
276
  /**
277
277
  * Returns financial events for the specified data range. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 0.5 | 30 | For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
278
278
  * @param {DefaultApiListFinancialEventsRequest} requestParameters Request parameters.
@@ -280,7 +280,7 @@ export declare class DefaultApi extends BaseAPI {
280
280
  * @throws {RequiredError}
281
281
  * @memberof DefaultApi
282
282
  */
283
- listFinancialEvents(requestParameters?: DefaultApiListFinancialEventsRequest, options?: any): Promise<import("axios").AxiosResponse<ListFinancialEventsResponse>>;
283
+ listFinancialEvents(requestParameters?: DefaultApiListFinancialEventsRequest, options?: any): Promise<import("axios").AxiosResponse<ListFinancialEventsResponse, any>>;
284
284
  /**
285
285
  * Returns all financial events for the specified financial event group. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 0.5 | 30 | For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
286
286
  * @param {DefaultApiListFinancialEventsByGroupIdRequest} requestParameters Request parameters.
@@ -288,7 +288,7 @@ export declare class DefaultApi extends BaseAPI {
288
288
  * @throws {RequiredError}
289
289
  * @memberof DefaultApi
290
290
  */
291
- listFinancialEventsByGroupId(requestParameters: DefaultApiListFinancialEventsByGroupIdRequest, options?: any): Promise<import("axios").AxiosResponse<ListFinancialEventsResponse>>;
291
+ listFinancialEventsByGroupId(requestParameters: DefaultApiListFinancialEventsByGroupIdRequest, options?: any): Promise<import("axios").AxiosResponse<ListFinancialEventsResponse, any>>;
292
292
  /**
293
293
  * Returns all financial events for the specified order. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 0.5 | 30 | For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
294
294
  * @param {DefaultApiListFinancialEventsByOrderIdRequest} requestParameters Request parameters.
@@ -296,5 +296,5 @@ export declare class DefaultApi extends BaseAPI {
296
296
  * @throws {RequiredError}
297
297
  * @memberof DefaultApi
298
298
  */
299
- listFinancialEventsByOrderId(requestParameters: DefaultApiListFinancialEventsByOrderIdRequest, options?: any): Promise<import("axios").AxiosResponse<ListFinancialEventsResponse>>;
299
+ listFinancialEventsByOrderId(requestParameters: DefaultApiListFinancialEventsByOrderIdRequest, options?: any): Promise<import("axios").AxiosResponse<ListFinancialEventsResponse, any>>;
300
300
  }
@@ -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 { onRetry } from '@sp-api-sdk/common';
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 { DefaultApi } from './api-model';
4
- export declare const RATE_LIMITS: RateLimit[];
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?: onRetry;
8
+ onRetry?: OnRetryHandler;
9
9
  };
10
10
  }
11
11
  export declare class FinancesApiClient extends DefaultApi {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@sp-api-sdk/finances-api-v0",
3
3
  "author": "Vincent Mesquita <vincent.mesquita@bizon.solutions>",
4
4
  "description": "The Selling Partner API for Finances helps you obtain financial information relevant to a seller's business. You can obtain financial events for a given order, financial event group, or date range without having to wait until a statement period closes. You can also obtain financial event groups for a given date range.",
5
- "version": "1.7.3",
5
+ "version": "1.7.7",
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.4",
29
- "@sp-api-sdk/common": "^1.7.5",
30
- "axios": "^0.21.1"
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
  "finances api"
50
50
  ],
51
- "gitHead": "634245dca301dd9c49f6b53447e0aa9bdb752c1a"
51
+ "gitHead": "c3e42b71400941563ab1e3ec689fada6111e629d"
52
52
  }
@@ -1,15 +0,0 @@
1
- "use strict";
2
- /* tslint:disable */
3
- /* eslint-disable */
4
- /**
5
- * Selling Partner API for Finances
6
- * The Selling Partner API for Finances helps you obtain financial information relevant to a seller\'s business. You can obtain financial events for a given order, financial event group, or date range without having to wait until a statement period closes. You can also obtain financial event groups for a given date range.
7
- *
8
- * The version of the OpenAPI document: v0
9
- *
10
- *
11
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
- * https://openapi-generator.tech
13
- * Do not edit the class manually.
14
- */
15
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,14 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- /**
4
- * Selling Partner API for Finances
5
- * The Selling Partner API for Finances helps you obtain financial information relevant to a seller\'s business. You can obtain financial events for a given order, financial event group, or date range without having to wait until a statement period closes. You can also obtain financial event groups for a given date range.
6
- *
7
- * The version of the OpenAPI document: v0
8
- *
9
- *
10
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
- * https://openapi-generator.tech
12
- * Do not edit the class manually.
13
- */
14
- export {};
@@ -1,37 +0,0 @@
1
- /**
2
- * Selling Partner API for Finances
3
- * The Selling Partner API for Finances helps you obtain financial information relevant to a seller\'s business. You can obtain financial events for a given order, financial event group, or date range without having to wait until a statement period closes. You can also obtain financial event groups for a given date range.
4
- *
5
- * The version of the OpenAPI document: v0
6
- *
7
- *
8
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
- * https://openapi-generator.tech
10
- * Do not edit the class manually.
11
- */
12
- import { Currency } from './currency';
13
- /**
14
- * A tax deduction at source (TDS) claim reimbursement event on the seller\'s account.
15
- * @export
16
- * @interface TDSReimbursementEvent
17
- */
18
- export interface TDSReimbursementEvent {
19
- /**
20
- *
21
- * @type {string}
22
- * @memberof TDSReimbursementEvent
23
- */
24
- PostedDate?: string;
25
- /**
26
- * A tax deduction at source (TDS) claim identifier.
27
- * @type {string}
28
- * @memberof TDSReimbursementEvent
29
- */
30
- TdsOrderId?: string;
31
- /**
32
- *
33
- * @type {Currency}
34
- * @memberof TDSReimbursementEvent
35
- */
36
- ReimbursedAmount?: Currency;
37
- }