@amazon-sp-api-release/amazon-sp-api-sdk-js 1.0.0-rc8 → 1.0.0

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.
Files changed (109) hide show
  1. package/README.md +1 -1
  2. package/helper/DefaultRateLimitFetcher.mjs +2 -35
  3. package/helper/DefaultRateLimitMap.mjs +266 -0
  4. package/helper/SuperagentRateLimiter.mjs +26 -14
  5. package/package.json +1 -1
  6. package/sample-node-app/index.js +27 -13
  7. package/src/apluscontent_v2020_11_01/ApiClient.js +48 -38
  8. package/src/apluscontent_v2020_11_01/api/AplusContentApi.js +50 -11
  9. package/src/appintegrations_v2024_04_01/ApiClient.js +48 -38
  10. package/src/appintegrations_v2024_04_01/api/AppIntegrationsApi.js +36 -4
  11. package/src/applications_v2023_11_30/ApiClient.js +48 -38
  12. package/src/applications_v2023_11_30/api/ApplicationsApi.js +32 -2
  13. package/src/awd_v2024_05_09/ApiClient.js +48 -38
  14. package/src/awd_v2024_05_09/api/AwdApi.js +52 -12
  15. package/src/catalogitems_v2022_04_01/ApiClient.js +48 -38
  16. package/src/catalogitems_v2022_04_01/api/CatalogApi.js +34 -3
  17. package/src/datakiosk_v2023_11_15/ApiClient.js +48 -38
  18. package/src/datakiosk_v2023_11_15/api/QueriesApi.js +40 -6
  19. package/src/easyship_v2022_03_23/ApiClient.js +48 -38
  20. package/src/easyship_v2022_03_23/api/EasyShipApi.js +40 -6
  21. package/src/fbaeligibility_v1/ApiClient.js +48 -38
  22. package/src/fbaeligibility_v1/api/FbaInboundApi.js +32 -2
  23. package/src/fbainventory_v1/ApiClient.js +48 -38
  24. package/src/fbainventory_v1/api/FbaInventoryApi.js +38 -5
  25. package/src/feeds_v2021_06_30/ApiClient.js +48 -38
  26. package/src/feeds_v2021_06_30/api/FeedsApi.js +42 -7
  27. package/src/finances_2024_06_19/ApiClient.js +48 -38
  28. package/src/finances_2024_06_19/api/DefaultApi.js +32 -2
  29. package/src/finances_v0/ApiClient.js +48 -38
  30. package/src/finances_v0/api/DefaultApi.js +38 -5
  31. package/src/fulfillmentinbound_v0/ApiClient.js +48 -38
  32. package/src/fulfillmentinbound_v0/api/FbaInboundApi.js +42 -7
  33. package/src/fulfillmentinbound_v2024_03_20/ApiClient.js +48 -38
  34. package/src/fulfillmentinbound_v2024_03_20/api/FbaInboundApi.js +120 -46
  35. package/src/fulfillmentoutbound_v2020_07_01/ApiClient.js +48 -38
  36. package/src/fulfillmentoutbound_v2020_07_01/api/FbaOutboundApi.js +58 -15
  37. package/src/invoices_v2024_06_19/ApiClient.js +48 -38
  38. package/src/invoices_v2024_06_19/api/InvoicesApi.js +44 -8
  39. package/src/invoicing_v0/ApiClient.js +48 -38
  40. package/src/invoicing_v0/api/ShipmentInvoiceApi.js +36 -4
  41. package/src/listingsitems_v2021_08_01/ApiClient.js +48 -38
  42. package/src/listingsitems_v2021_08_01/api/ListingsApi.js +40 -6
  43. package/src/listingsrestrictions_v2021_08_01/ApiClient.js +48 -38
  44. package/src/listingsrestrictions_v2021_08_01/api/ListingsApi.js +32 -2
  45. package/src/merchantfulfillment_v0/ApiClient.js +48 -38
  46. package/src/merchantfulfillment_v0/api/MerchantFulfillmentApi.js +40 -6
  47. package/src/messaging_v1/ApiClient.js +48 -38
  48. package/src/messaging_v1/api/MessagingApi.js +56 -14
  49. package/src/notifications_v1/ApiClient.js +48 -38
  50. package/src/notifications_v1/api/NotificationsApi.js +46 -9
  51. package/src/orders_v0/ApiClient.js +48 -38
  52. package/src/orders_v0/api/OrdersV0Api.js +48 -10
  53. package/src/orders_v0/api/ShipmentApi.js +32 -2
  54. package/src/pricing_v0/ApiClient.js +48 -38
  55. package/src/pricing_v0/api/ProductPricingApi.js +42 -7
  56. package/src/pricing_v2022_05_01/ApiClient.js +48 -38
  57. package/src/pricing_v2022_05_01/api/ProductPricingApi.js +34 -3
  58. package/src/productfees_v0/ApiClient.js +48 -38
  59. package/src/productfees_v0/api/FeesApi.js +36 -4
  60. package/src/producttypedefinitions_v2020_09_01/ApiClient.js +48 -38
  61. package/src/producttypedefinitions_v2020_09_01/api/DefinitionsApi.js +34 -3
  62. package/src/replenishment_v2022_11_07/ApiClient.js +48 -38
  63. package/src/replenishment_v2022_11_07/api/OffersApi.js +34 -3
  64. package/src/replenishment_v2022_11_07/api/SellingpartnersApi.js +32 -2
  65. package/src/reports_v2021_06_30/ApiClient.js +48 -38
  66. package/src/reports_v2021_06_30/api/ReportsApi.js +48 -10
  67. package/src/sales_v1/ApiClient.js +48 -38
  68. package/src/sales_v1/api/SalesApi.js +32 -2
  69. package/src/sellers_v1/ApiClient.js +48 -38
  70. package/src/sellers_v1/api/SellersApi.js +34 -3
  71. package/src/services_v1/ApiClient.js +48 -38
  72. package/src/services_v1/api/ServiceApi.js +64 -18
  73. package/src/shipping_v2/ApiClient.js +48 -38
  74. package/src/shipping_v2/api/ShippingApi.js +70 -21
  75. package/src/solicitations_v1/ApiClient.js +48 -38
  76. package/src/solicitations_v1/api/SolicitationsApi.js +34 -3
  77. package/src/supplysources_v2020_07_01/ApiClient.js +48 -38
  78. package/src/supplysources_v2020_07_01/api/SupplySourcesApi.js +42 -7
  79. package/src/tokens_v2021_03_01/ApiClient.js +48 -38
  80. package/src/tokens_v2021_03_01/api/TokensApi.js +32 -2
  81. package/src/transfers_v2024_06_01/ApiClient.js +48 -38
  82. package/src/transfers_v2024_06_01/api/DefaultApi.js +34 -3
  83. package/src/uploads_v2020_11_01/ApiClient.js +48 -38
  84. package/src/uploads_v2020_11_01/api/UploadsApi.js +32 -2
  85. package/src/vehicles_v2024_11_01/ApiClient.js +48 -38
  86. package/src/vehicles_v2024_11_01/api/AutomotiveApi.js +32 -2
  87. package/src/vehicles_v2024_11_01/api/VehiclesApi.js +32 -2
  88. package/src/vendordfinventory_v1/ApiClient.js +48 -38
  89. package/src/vendordfinventory_v1/api/UpdateInventoryApi.js +32 -2
  90. package/src/vendordforders_v2021_12_28/ApiClient.js +48 -38
  91. package/src/vendordforders_v2021_12_28/api/VendorOrdersApi.js +36 -4
  92. package/src/vendordfpayments_v1/ApiClient.js +48 -38
  93. package/src/vendordfpayments_v1/api/VendorInvoiceApi.js +32 -2
  94. package/src/vendordfshipping_v2021_12_28/ApiClient.js +48 -38
  95. package/src/vendordfshipping_v2021_12_28/api/CreateContainerLabelApi.js +32 -2
  96. package/src/vendordfshipping_v2021_12_28/api/CustomerInvoicesApi.js +34 -3
  97. package/src/vendordfshipping_v2021_12_28/api/VendorShippingApi.js +38 -5
  98. package/src/vendordfshipping_v2021_12_28/api/VendorShippingLabelsApi.js +38 -5
  99. package/src/vendordftransactions_v2021_12_28/ApiClient.js +48 -38
  100. package/src/vendordftransactions_v2021_12_28/api/VendorTransactionApi.js +32 -2
  101. package/src/vendorinvoices_v1/ApiClient.js +48 -38
  102. package/src/vendorinvoices_v1/api/VendorPaymentsApi.js +32 -2
  103. package/src/vendororders_v1/ApiClient.js +48 -38
  104. package/src/vendororders_v1/api/VendorOrdersApi.js +38 -5
  105. package/src/vendorshipments_v1/ApiClient.js +48 -38
  106. package/src/vendorshipments_v1/api/VendorShippingApi.js +38 -5
  107. package/src/vendortransactionstatus_v1/ApiClient.js +48 -38
  108. package/src/vendortransactionstatus_v1/api/VendorTransactionApi.js +32 -2
  109. package/helper/rate-limits.yml +0 -874
@@ -11,10 +11,12 @@
11
11
  *
12
12
  */
13
13
 
14
- import {ApiClient} from "../ApiClient.js";
14
+ import {ApiClient} from '../ApiClient.js';
15
15
  import {CustomerInvoice} from '../model/CustomerInvoice.js';
16
16
  import {CustomerInvoiceList} from '../model/CustomerInvoiceList.js';
17
17
  import {ErrorList} from '../model/ErrorList.js';
18
+ import {SuperagentRateLimiter} from '../../../helper/SuperagentRateLimiter.mjs';
19
+ import {DefaultRateLimitFetcher} from '../../../helper/DefaultRateLimitFetcher.mjs';
18
20
 
19
21
  /**
20
22
  * CustomerInvoices service.
@@ -23,6 +25,9 @@ import {ErrorList} from '../model/ErrorList.js';
23
25
  */
24
26
  export class CustomerInvoicesApi {
25
27
 
28
+ // Private memeber stores the default rate limiters
29
+ #defaultRateLimiterMap;
30
+
26
31
  /**
27
32
  * Constructs a new CustomerInvoicesApi.
28
33
  * @alias module:vendordfshipping_v2021_12_28/api/CustomerInvoicesApi
@@ -32,6 +37,32 @@ export class CustomerInvoicesApi {
32
37
  */
33
38
  constructor(apiClient) {
34
39
  this.apiClient = apiClient || ApiClient.instance;
40
+ this.initializeDefaultRateLimiterMap();
41
+ }
42
+
43
+ /**
44
+ * Initialize rate limiters for API operations
45
+ */
46
+ initializeDefaultRateLimiterMap() {
47
+ this.#defaultRateLimiterMap = new Map()
48
+ const defaultRateLimitFetcher = new DefaultRateLimitFetcher();
49
+ const operations = [
50
+ 'CustomerInvoicesApi-getCustomerInvoice',
51
+ 'CustomerInvoicesApi-getCustomerInvoices',
52
+ ];
53
+
54
+ for (const operation of operations) {
55
+ const config = defaultRateLimitFetcher.getLimit(operation);
56
+ this.#defaultRateLimiterMap.set(operation, new SuperagentRateLimiter(config));
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Get rate limiter for a specific operation
62
+ * @param {String} operation name
63
+ */
64
+ getRateLimiter(operation) {
65
+ return this.#defaultRateLimiterMap.get(operation);
35
66
  }
36
67
 
37
68
 
@@ -68,7 +99,7 @@ export class CustomerInvoicesApi {
68
99
  return this.apiClient.callApi( 'CustomerInvoicesApi-getCustomerInvoice',
69
100
  '/vendor/directFulfillment/shipping/2021-12-28/customerInvoices/{purchaseOrderNumber}', 'GET',
70
101
  pathParams, queryParams, headerParams, formParams, postBody,
71
- contentTypes, accepts, returnType
102
+ contentTypes, accepts, returnType, this.getRateLimiter('CustomerInvoicesApi-getCustomerInvoice')
72
103
  );
73
104
  }
74
105
 
@@ -135,7 +166,7 @@ export class CustomerInvoicesApi {
135
166
  return this.apiClient.callApi( 'CustomerInvoicesApi-getCustomerInvoices',
136
167
  '/vendor/directFulfillment/shipping/2021-12-28/customerInvoices', 'GET',
137
168
  pathParams, queryParams, headerParams, formParams, postBody,
138
- contentTypes, accepts, returnType
169
+ contentTypes, accepts, returnType, this.getRateLimiter('CustomerInvoicesApi-getCustomerInvoices')
139
170
  );
140
171
  }
141
172
 
@@ -11,13 +11,15 @@
11
11
  *
12
12
  */
13
13
 
14
- import {ApiClient} from "../ApiClient.js";
14
+ import {ApiClient} from '../ApiClient.js';
15
15
  import {ErrorList} from '../model/ErrorList.js';
16
16
  import {PackingSlip} from '../model/PackingSlip.js';
17
17
  import {PackingSlipList} from '../model/PackingSlipList.js';
18
18
  import {SubmitShipmentConfirmationsRequest} from '../model/SubmitShipmentConfirmationsRequest.js';
19
19
  import {SubmitShipmentStatusUpdatesRequest} from '../model/SubmitShipmentStatusUpdatesRequest.js';
20
20
  import {TransactionReference} from '../model/TransactionReference.js';
21
+ import {SuperagentRateLimiter} from '../../../helper/SuperagentRateLimiter.mjs';
22
+ import {DefaultRateLimitFetcher} from '../../../helper/DefaultRateLimitFetcher.mjs';
21
23
 
22
24
  /**
23
25
  * VendorShipping service.
@@ -26,6 +28,9 @@ import {TransactionReference} from '../model/TransactionReference.js';
26
28
  */
27
29
  export class VendorShippingApi {
28
30
 
31
+ // Private memeber stores the default rate limiters
32
+ #defaultRateLimiterMap;
33
+
29
34
  /**
30
35
  * Constructs a new VendorShippingApi.
31
36
  * @alias module:vendordfshipping_v2021_12_28/api/VendorShippingApi
@@ -35,6 +40,34 @@ export class VendorShippingApi {
35
40
  */
36
41
  constructor(apiClient) {
37
42
  this.apiClient = apiClient || ApiClient.instance;
43
+ this.initializeDefaultRateLimiterMap();
44
+ }
45
+
46
+ /**
47
+ * Initialize rate limiters for API operations
48
+ */
49
+ initializeDefaultRateLimiterMap() {
50
+ this.#defaultRateLimiterMap = new Map()
51
+ const defaultRateLimitFetcher = new DefaultRateLimitFetcher();
52
+ const operations = [
53
+ 'VendorShippingApi-getPackingSlip',
54
+ 'VendorShippingApi-getPackingSlips',
55
+ 'VendorShippingApi-submitShipmentConfirmations',
56
+ 'VendorShippingApi-submitShipmentStatusUpdates',
57
+ ];
58
+
59
+ for (const operation of operations) {
60
+ const config = defaultRateLimitFetcher.getLimit(operation);
61
+ this.#defaultRateLimiterMap.set(operation, new SuperagentRateLimiter(config));
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Get rate limiter for a specific operation
67
+ * @param {String} operation name
68
+ */
69
+ getRateLimiter(operation) {
70
+ return this.#defaultRateLimiterMap.get(operation);
38
71
  }
39
72
 
40
73
 
@@ -71,7 +104,7 @@ export class VendorShippingApi {
71
104
  return this.apiClient.callApi( 'VendorShippingApi-getPackingSlip',
72
105
  '/vendor/directFulfillment/shipping/2021-12-28/packingSlips/{purchaseOrderNumber}', 'GET',
73
106
  pathParams, queryParams, headerParams, formParams, postBody,
74
- contentTypes, accepts, returnType
107
+ contentTypes, accepts, returnType, this.getRateLimiter('VendorShippingApi-getPackingSlip')
75
108
  );
76
109
  }
77
110
 
@@ -138,7 +171,7 @@ export class VendorShippingApi {
138
171
  return this.apiClient.callApi( 'VendorShippingApi-getPackingSlips',
139
172
  '/vendor/directFulfillment/shipping/2021-12-28/packingSlips', 'GET',
140
173
  pathParams, queryParams, headerParams, formParams, postBody,
141
- contentTypes, accepts, returnType
174
+ contentTypes, accepts, returnType, this.getRateLimiter('VendorShippingApi-getPackingSlips')
142
175
  );
143
176
  }
144
177
 
@@ -193,7 +226,7 @@ export class VendorShippingApi {
193
226
  return this.apiClient.callApi( 'VendorShippingApi-submitShipmentConfirmations',
194
227
  '/vendor/directFulfillment/shipping/2021-12-28/shipmentConfirmations', 'POST',
195
228
  pathParams, queryParams, headerParams, formParams, postBody,
196
- contentTypes, accepts, returnType
229
+ contentTypes, accepts, returnType, this.getRateLimiter('VendorShippingApi-submitShipmentConfirmations')
197
230
  );
198
231
  }
199
232
 
@@ -242,7 +275,7 @@ export class VendorShippingApi {
242
275
  return this.apiClient.callApi( 'VendorShippingApi-submitShipmentStatusUpdates',
243
276
  '/vendor/directFulfillment/shipping/2021-12-28/shipmentStatusUpdates', 'POST',
244
277
  pathParams, queryParams, headerParams, formParams, postBody,
245
- contentTypes, accepts, returnType
278
+ contentTypes, accepts, returnType, this.getRateLimiter('VendorShippingApi-submitShipmentStatusUpdates')
246
279
  );
247
280
  }
248
281
 
@@ -11,13 +11,15 @@
11
11
  *
12
12
  */
13
13
 
14
- import {ApiClient} from "../ApiClient.js";
14
+ import {ApiClient} from '../ApiClient.js';
15
15
  import {CreateShippingLabelsRequest} from '../model/CreateShippingLabelsRequest.js';
16
16
  import {ErrorList} from '../model/ErrorList.js';
17
17
  import {ShippingLabel} from '../model/ShippingLabel.js';
18
18
  import {ShippingLabelList} from '../model/ShippingLabelList.js';
19
19
  import {SubmitShippingLabelsRequest} from '../model/SubmitShippingLabelsRequest.js';
20
20
  import {TransactionReference} from '../model/TransactionReference.js';
21
+ import {SuperagentRateLimiter} from '../../../helper/SuperagentRateLimiter.mjs';
22
+ import {DefaultRateLimitFetcher} from '../../../helper/DefaultRateLimitFetcher.mjs';
21
23
 
22
24
  /**
23
25
  * VendorShippingLabels service.
@@ -26,6 +28,9 @@ import {TransactionReference} from '../model/TransactionReference.js';
26
28
  */
27
29
  export class VendorShippingLabelsApi {
28
30
 
31
+ // Private memeber stores the default rate limiters
32
+ #defaultRateLimiterMap;
33
+
29
34
  /**
30
35
  * Constructs a new VendorShippingLabelsApi.
31
36
  * @alias module:vendordfshipping_v2021_12_28/api/VendorShippingLabelsApi
@@ -35,6 +40,34 @@ export class VendorShippingLabelsApi {
35
40
  */
36
41
  constructor(apiClient) {
37
42
  this.apiClient = apiClient || ApiClient.instance;
43
+ this.initializeDefaultRateLimiterMap();
44
+ }
45
+
46
+ /**
47
+ * Initialize rate limiters for API operations
48
+ */
49
+ initializeDefaultRateLimiterMap() {
50
+ this.#defaultRateLimiterMap = new Map()
51
+ const defaultRateLimitFetcher = new DefaultRateLimitFetcher();
52
+ const operations = [
53
+ 'VendorShippingLabelsApi-createShippingLabels',
54
+ 'VendorShippingLabelsApi-getShippingLabel',
55
+ 'VendorShippingLabelsApi-getShippingLabels',
56
+ 'VendorShippingLabelsApi-submitShippingLabelRequest',
57
+ ];
58
+
59
+ for (const operation of operations) {
60
+ const config = defaultRateLimitFetcher.getLimit(operation);
61
+ this.#defaultRateLimiterMap.set(operation, new SuperagentRateLimiter(config));
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Get rate limiter for a specific operation
67
+ * @param {String} operation name
68
+ */
69
+ getRateLimiter(operation) {
70
+ return this.#defaultRateLimiterMap.get(operation);
38
71
  }
39
72
 
40
73
 
@@ -77,7 +110,7 @@ export class VendorShippingLabelsApi {
77
110
  return this.apiClient.callApi( 'VendorShippingLabelsApi-createShippingLabels',
78
111
  '/vendor/directFulfillment/shipping/2021-12-28/shippingLabels/{purchaseOrderNumber}', 'POST',
79
112
  pathParams, queryParams, headerParams, formParams, postBody,
80
- contentTypes, accepts, returnType
113
+ contentTypes, accepts, returnType, this.getRateLimiter('VendorShippingLabelsApi-createShippingLabels')
81
114
  );
82
115
  }
83
116
 
@@ -128,7 +161,7 @@ export class VendorShippingLabelsApi {
128
161
  return this.apiClient.callApi( 'VendorShippingLabelsApi-getShippingLabel',
129
162
  '/vendor/directFulfillment/shipping/2021-12-28/shippingLabels/{purchaseOrderNumber}', 'GET',
130
163
  pathParams, queryParams, headerParams, formParams, postBody,
131
- contentTypes, accepts, returnType
164
+ contentTypes, accepts, returnType, this.getRateLimiter('VendorShippingLabelsApi-getShippingLabel')
132
165
  );
133
166
  }
134
167
 
@@ -195,7 +228,7 @@ export class VendorShippingLabelsApi {
195
228
  return this.apiClient.callApi( 'VendorShippingLabelsApi-getShippingLabels',
196
229
  '/vendor/directFulfillment/shipping/2021-12-28/shippingLabels', 'GET',
197
230
  pathParams, queryParams, headerParams, formParams, postBody,
198
- contentTypes, accepts, returnType
231
+ contentTypes, accepts, returnType, this.getRateLimiter('VendorShippingLabelsApi-getShippingLabels')
199
232
  );
200
233
  }
201
234
 
@@ -250,7 +283,7 @@ export class VendorShippingLabelsApi {
250
283
  return this.apiClient.callApi( 'VendorShippingLabelsApi-submitShippingLabelRequest',
251
284
  '/vendor/directFulfillment/shipping/2021-12-28/shippingLabels', 'POST',
252
285
  pathParams, queryParams, headerParams, formParams, postBody,
253
- contentTypes, accepts, returnType
286
+ contentTypes, accepts, returnType, this.getRateLimiter('VendorShippingLabelsApi-submitShippingLabelRequest')
254
287
  );
255
288
  }
256
289
 
@@ -11,12 +11,11 @@
11
11
  *
12
12
  */
13
13
 
14
- import superagent from "superagent";
15
- import querystring from "querystring";
16
- import { URL } from 'node:url';
17
- import { RateLimitConfiguration } from "../../helper/RateLimitConfiguration.mjs";
18
- import { SuperagentRateLimiter } from "../../helper/SuperagentRateLimiter.mjs";
19
- import { DefaultRateLimitFetcher } from "../../helper/DefaultRateLimitFetcher.mjs";
14
+ import superagent from 'superagent';
15
+ import querystring from 'querystring';
16
+ import {URL} from 'node:url';
17
+ import {RateLimitConfiguration} from '../../helper/RateLimitConfiguration.mjs';
18
+ import {SuperagentRateLimiter} from '../../helper/SuperagentRateLimiter.mjs';
20
19
 
21
20
  /**
22
21
  * @module vendordftransactions_v2021_12_28/ApiClient
@@ -193,9 +192,8 @@ export class ApiClient {
193
192
  #tokenForApiCall = null;
194
193
  #lwaClient = null;
195
194
  #rdtClient = null;
196
- #defaultRateLimitFetcher = null;
197
- #customizedRateLimiter = null;
198
- #useDefaultRateLimiter = false;
195
+ #customizedRateLimiterMap = null;
196
+ #useRateLimiter = true;
199
197
 
200
198
  /**
201
199
  * Constructs a new ApiClient.
@@ -259,42 +257,54 @@ export class ApiClient {
259
257
  * Allow user to override superagent agent
260
258
  */
261
259
  this.requestAgent = null;
260
+
261
+ /*
262
+ * Initialize customized rate limiter map
263
+ */
264
+ this.#customizedRateLimiterMap = new Map();
262
265
  }
263
266
 
264
267
  /**
265
- * Initialize #defaultRateLimitFetcher
268
+ * Set customized rate limiter for one operation
269
+ * For operations that customized rate limiter are not set
270
+ * Will use default rate limiter
271
+ * @param {String} operationName
272
+ * @param {RateLimitConfiguration} config
266
273
  */
267
- async initializeDefaultRateLimit() {
268
- try {
269
- this.#defaultRateLimitFetcher = await DefaultRateLimitFetcher.getInstance();
270
- } catch (err) {
271
- throw new Error('Error reading default rate limit:', err);
272
- }
274
+ setCustomizedRateLimiterForOperation(operationName, config) {
275
+ this.#customizedRateLimiterMap.set(operationName, new SuperagentRateLimiter(config));
273
276
  }
274
277
 
275
278
  /**
276
- * Enable default rate limiter
279
+ * Disable customized rate limiter for one operation
280
+ * Fall back to default rate limiter
281
+ * @param {String} operationName
277
282
  */
278
- enableDefaultRateLimiter() {
279
- this.#useDefaultRateLimiter = true;
280
- this.#customizedRateLimiter = null;
283
+ disableCustomizedRatelimiterForOperation(operationName) {
284
+ this.#customizedRateLimiterMap.delete(operationName);
281
285
  }
282
286
 
283
287
  /**
284
- * Set customized rate limiter
285
- * @param {RateLimitConfiguration} config
288
+ * Clear customized rate limiter for all operations
289
+ * All operations will fall back to default rate limiter
290
+ * @param {String} operationName
291
+ */
292
+ disableCustomizedRatelimiterForAll() {
293
+ this.#customizedRateLimiterMap.clear();
294
+ }
295
+
296
+ /**
297
+ * Disable both default and customized rate limiter for all operations
286
298
  */
287
- enableCustomizedRateLimiter(config) {
288
- this.#customizedRateLimiter = new SuperagentRateLimiter(config);
289
- this.#useDefaultRateLimiter = false;
299
+ disableRateLimiter() {
300
+ this.#useRateLimiter = false;
290
301
  }
291
302
 
292
303
  /**
293
- * Disable both customized and default rate limiter
304
+ * Enable default or customized rate limiter for all operations
294
305
  */
295
- disableRatelimiter() {
296
- this.#customizedRateLimiter = null;
297
- this.defaultRateLimiter = false;
306
+ enableRateLimiter() {
307
+ this.#useRateLimiter = true;
298
308
  }
299
309
 
300
310
  /**
@@ -597,11 +607,12 @@ export class ApiClient {
597
607
  * @param {Array<String>} accepts An array of acceptable response MIME types.
598
608
  * @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the
599
609
  * constructor for a complex type.
610
+ * @param {SuperagentRateLimiter} defaultRateLimiter The default rate limiter.
600
611
  * @returns {Promise} A {@link https://www.promisejs.org/|Promise} object.
601
612
  */
602
613
  async callApi(operation, path, httpMethod, pathParams,
603
614
  queryParams, headerParams, formParams, bodyParam, contentTypes, accepts,
604
- returnType) {
615
+ returnType, defaultRateLimiter) {
605
616
 
606
617
  var url = this.buildUrl(path, pathParams);
607
618
  var request = superagent(httpMethod, url);
@@ -609,15 +620,14 @@ export class ApiClient {
609
620
  throw new Error('none of accessToken, RDT token and auto-retrieval is set.');
610
621
  }
611
622
 
612
- //Set rate limiter
613
- if (this.#useDefaultRateLimiter) {
614
- await this.initializeDefaultRateLimit();
615
- const defaultRateLimiter = new SuperagentRateLimiter(this.#defaultRateLimitFetcher.getLimit(operation));
616
- request.use(defaultRateLimiter.getPlugin());
617
- } else if (this.#customizedRateLimiter) {
618
- request.use(this.#customizedRateLimiter.getPlugin());
623
+ if (this.#useRateLimiter) {
624
+ //Set rate limiter
625
+ if (this.#customizedRateLimiterMap.get(operation)) {
626
+ request.use(this.#customizedRateLimiterMap.get(operation).getPlugin());
627
+ } else if (defaultRateLimiter) {
628
+ request.use(defaultRateLimiter.getPlugin());
629
+ }
619
630
  }
620
-
621
631
 
622
632
  // set query parameters
623
633
  if (httpMethod.toUpperCase() === 'GET' && this.cache === false) {
@@ -11,10 +11,12 @@
11
11
  *
12
12
  */
13
13
 
14
- import {ApiClient} from "../ApiClient.js";
14
+ import {ApiClient} from '../ApiClient.js';
15
15
  import {Error} from '../model/Error.js';
16
16
  import {ErrorList} from '../model/ErrorList.js';
17
17
  import {TransactionStatus} from '../model/TransactionStatus.js';
18
+ import {SuperagentRateLimiter} from '../../../helper/SuperagentRateLimiter.mjs';
19
+ import {DefaultRateLimitFetcher} from '../../../helper/DefaultRateLimitFetcher.mjs';
18
20
 
19
21
  /**
20
22
  * VendorTransaction service.
@@ -23,6 +25,9 @@ import {TransactionStatus} from '../model/TransactionStatus.js';
23
25
  */
24
26
  export class VendorTransactionApi {
25
27
 
28
+ // Private memeber stores the default rate limiters
29
+ #defaultRateLimiterMap;
30
+
26
31
  /**
27
32
  * Constructs a new VendorTransactionApi.
28
33
  * @alias module:vendordftransactions_v2021_12_28/api/VendorTransactionApi
@@ -32,6 +37,31 @@ export class VendorTransactionApi {
32
37
  */
33
38
  constructor(apiClient) {
34
39
  this.apiClient = apiClient || ApiClient.instance;
40
+ this.initializeDefaultRateLimiterMap();
41
+ }
42
+
43
+ /**
44
+ * Initialize rate limiters for API operations
45
+ */
46
+ initializeDefaultRateLimiterMap() {
47
+ this.#defaultRateLimiterMap = new Map()
48
+ const defaultRateLimitFetcher = new DefaultRateLimitFetcher();
49
+ const operations = [
50
+ 'VendorTransactionApi-getTransactionStatus',
51
+ ];
52
+
53
+ for (const operation of operations) {
54
+ const config = defaultRateLimitFetcher.getLimit(operation);
55
+ this.#defaultRateLimiterMap.set(operation, new SuperagentRateLimiter(config));
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Get rate limiter for a specific operation
61
+ * @param {String} operation name
62
+ */
63
+ getRateLimiter(operation) {
64
+ return this.#defaultRateLimiterMap.get(operation);
35
65
  }
36
66
 
37
67
 
@@ -67,7 +97,7 @@ export class VendorTransactionApi {
67
97
  return this.apiClient.callApi( 'VendorTransactionApi-getTransactionStatus',
68
98
  '/vendor/directFulfillment/transactions/2021-12-28/transactions/{transactionId}', 'GET',
69
99
  pathParams, queryParams, headerParams, formParams, postBody,
70
- contentTypes, accepts, returnType
100
+ contentTypes, accepts, returnType, this.getRateLimiter('VendorTransactionApi-getTransactionStatus')
71
101
  );
72
102
  }
73
103
 
@@ -11,12 +11,11 @@
11
11
  *
12
12
  */
13
13
 
14
- import superagent from "superagent";
15
- import querystring from "querystring";
16
- import { URL } from 'node:url';
17
- import { RateLimitConfiguration } from "../../helper/RateLimitConfiguration.mjs";
18
- import { SuperagentRateLimiter } from "../../helper/SuperagentRateLimiter.mjs";
19
- import { DefaultRateLimitFetcher } from "../../helper/DefaultRateLimitFetcher.mjs";
14
+ import superagent from 'superagent';
15
+ import querystring from 'querystring';
16
+ import {URL} from 'node:url';
17
+ import {RateLimitConfiguration} from '../../helper/RateLimitConfiguration.mjs';
18
+ import {SuperagentRateLimiter} from '../../helper/SuperagentRateLimiter.mjs';
20
19
 
21
20
  /**
22
21
  * @module vendorinvoices_v1/ApiClient
@@ -193,9 +192,8 @@ export class ApiClient {
193
192
  #tokenForApiCall = null;
194
193
  #lwaClient = null;
195
194
  #rdtClient = null;
196
- #defaultRateLimitFetcher = null;
197
- #customizedRateLimiter = null;
198
- #useDefaultRateLimiter = false;
195
+ #customizedRateLimiterMap = null;
196
+ #useRateLimiter = true;
199
197
 
200
198
  /**
201
199
  * Constructs a new ApiClient.
@@ -259,42 +257,54 @@ export class ApiClient {
259
257
  * Allow user to override superagent agent
260
258
  */
261
259
  this.requestAgent = null;
260
+
261
+ /*
262
+ * Initialize customized rate limiter map
263
+ */
264
+ this.#customizedRateLimiterMap = new Map();
262
265
  }
263
266
 
264
267
  /**
265
- * Initialize #defaultRateLimitFetcher
268
+ * Set customized rate limiter for one operation
269
+ * For operations that customized rate limiter are not set
270
+ * Will use default rate limiter
271
+ * @param {String} operationName
272
+ * @param {RateLimitConfiguration} config
266
273
  */
267
- async initializeDefaultRateLimit() {
268
- try {
269
- this.#defaultRateLimitFetcher = await DefaultRateLimitFetcher.getInstance();
270
- } catch (err) {
271
- throw new Error('Error reading default rate limit:', err);
272
- }
274
+ setCustomizedRateLimiterForOperation(operationName, config) {
275
+ this.#customizedRateLimiterMap.set(operationName, new SuperagentRateLimiter(config));
273
276
  }
274
277
 
275
278
  /**
276
- * Enable default rate limiter
279
+ * Disable customized rate limiter for one operation
280
+ * Fall back to default rate limiter
281
+ * @param {String} operationName
277
282
  */
278
- enableDefaultRateLimiter() {
279
- this.#useDefaultRateLimiter = true;
280
- this.#customizedRateLimiter = null;
283
+ disableCustomizedRatelimiterForOperation(operationName) {
284
+ this.#customizedRateLimiterMap.delete(operationName);
281
285
  }
282
286
 
283
287
  /**
284
- * Set customized rate limiter
285
- * @param {RateLimitConfiguration} config
288
+ * Clear customized rate limiter for all operations
289
+ * All operations will fall back to default rate limiter
290
+ * @param {String} operationName
291
+ */
292
+ disableCustomizedRatelimiterForAll() {
293
+ this.#customizedRateLimiterMap.clear();
294
+ }
295
+
296
+ /**
297
+ * Disable both default and customized rate limiter for all operations
286
298
  */
287
- enableCustomizedRateLimiter(config) {
288
- this.#customizedRateLimiter = new SuperagentRateLimiter(config);
289
- this.#useDefaultRateLimiter = false;
299
+ disableRateLimiter() {
300
+ this.#useRateLimiter = false;
290
301
  }
291
302
 
292
303
  /**
293
- * Disable both customized and default rate limiter
304
+ * Enable default or customized rate limiter for all operations
294
305
  */
295
- disableRatelimiter() {
296
- this.#customizedRateLimiter = null;
297
- this.defaultRateLimiter = false;
306
+ enableRateLimiter() {
307
+ this.#useRateLimiter = true;
298
308
  }
299
309
 
300
310
  /**
@@ -597,11 +607,12 @@ export class ApiClient {
597
607
  * @param {Array<String>} accepts An array of acceptable response MIME types.
598
608
  * @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the
599
609
  * constructor for a complex type.
610
+ * @param {SuperagentRateLimiter} defaultRateLimiter The default rate limiter.
600
611
  * @returns {Promise} A {@link https://www.promisejs.org/|Promise} object.
601
612
  */
602
613
  async callApi(operation, path, httpMethod, pathParams,
603
614
  queryParams, headerParams, formParams, bodyParam, contentTypes, accepts,
604
- returnType) {
615
+ returnType, defaultRateLimiter) {
605
616
 
606
617
  var url = this.buildUrl(path, pathParams);
607
618
  var request = superagent(httpMethod, url);
@@ -609,15 +620,14 @@ export class ApiClient {
609
620
  throw new Error('none of accessToken, RDT token and auto-retrieval is set.');
610
621
  }
611
622
 
612
- //Set rate limiter
613
- if (this.#useDefaultRateLimiter) {
614
- await this.initializeDefaultRateLimit();
615
- const defaultRateLimiter = new SuperagentRateLimiter(this.#defaultRateLimitFetcher.getLimit(operation));
616
- request.use(defaultRateLimiter.getPlugin());
617
- } else if (this.#customizedRateLimiter) {
618
- request.use(this.#customizedRateLimiter.getPlugin());
623
+ if (this.#useRateLimiter) {
624
+ //Set rate limiter
625
+ if (this.#customizedRateLimiterMap.get(operation)) {
626
+ request.use(this.#customizedRateLimiterMap.get(operation).getPlugin());
627
+ } else if (defaultRateLimiter) {
628
+ request.use(defaultRateLimiter.getPlugin());
629
+ }
619
630
  }
620
-
621
631
 
622
632
  // set query parameters
623
633
  if (httpMethod.toUpperCase() === 'GET' && this.cache === false) {
@@ -11,9 +11,11 @@
11
11
  *
12
12
  */
13
13
 
14
- import {ApiClient} from "../ApiClient.js";
14
+ import {ApiClient} from '../ApiClient.js';
15
15
  import {SubmitInvoicesRequest} from '../model/SubmitInvoicesRequest.js';
16
16
  import {SubmitInvoicesResponse} from '../model/SubmitInvoicesResponse.js';
17
+ import {SuperagentRateLimiter} from '../../../helper/SuperagentRateLimiter.mjs';
18
+ import {DefaultRateLimitFetcher} from '../../../helper/DefaultRateLimitFetcher.mjs';
17
19
 
18
20
  /**
19
21
  * VendorPayments service.
@@ -22,6 +24,9 @@ import {SubmitInvoicesResponse} from '../model/SubmitInvoicesResponse.js';
22
24
  */
23
25
  export class VendorPaymentsApi {
24
26
 
27
+ // Private memeber stores the default rate limiters
28
+ #defaultRateLimiterMap;
29
+
25
30
  /**
26
31
  * Constructs a new VendorPaymentsApi.
27
32
  * @alias module:vendorinvoices_v1/api/VendorPaymentsApi
@@ -31,6 +36,31 @@ export class VendorPaymentsApi {
31
36
  */
32
37
  constructor(apiClient) {
33
38
  this.apiClient = apiClient || ApiClient.instance;
39
+ this.initializeDefaultRateLimiterMap();
40
+ }
41
+
42
+ /**
43
+ * Initialize rate limiters for API operations
44
+ */
45
+ initializeDefaultRateLimiterMap() {
46
+ this.#defaultRateLimiterMap = new Map()
47
+ const defaultRateLimitFetcher = new DefaultRateLimitFetcher();
48
+ const operations = [
49
+ 'VendorPaymentsApi-submitInvoices',
50
+ ];
51
+
52
+ for (const operation of operations) {
53
+ const config = defaultRateLimitFetcher.getLimit(operation);
54
+ this.#defaultRateLimiterMap.set(operation, new SuperagentRateLimiter(config));
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Get rate limiter for a specific operation
60
+ * @param {String} operation name
61
+ */
62
+ getRateLimiter(operation) {
63
+ return this.#defaultRateLimiterMap.get(operation);
34
64
  }
35
65
 
36
66
 
@@ -65,7 +95,7 @@ export class VendorPaymentsApi {
65
95
  return this.apiClient.callApi( 'VendorPaymentsApi-submitInvoices',
66
96
  '/vendor/payments/v1/invoices', 'POST',
67
97
  pathParams, queryParams, headerParams, formParams, postBody,
68
- contentTypes, accepts, returnType
98
+ contentTypes, accepts, returnType, this.getRateLimiter('VendorPaymentsApi-submitInvoices')
69
99
  );
70
100
  }
71
101