@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.
- package/README.md +1 -1
- package/helper/DefaultRateLimitFetcher.mjs +2 -35
- package/helper/DefaultRateLimitMap.mjs +266 -0
- package/helper/SuperagentRateLimiter.mjs +26 -14
- package/package.json +1 -1
- package/sample-node-app/index.js +27 -13
- package/src/apluscontent_v2020_11_01/ApiClient.js +48 -38
- package/src/apluscontent_v2020_11_01/api/AplusContentApi.js +50 -11
- package/src/appintegrations_v2024_04_01/ApiClient.js +48 -38
- package/src/appintegrations_v2024_04_01/api/AppIntegrationsApi.js +36 -4
- package/src/applications_v2023_11_30/ApiClient.js +48 -38
- package/src/applications_v2023_11_30/api/ApplicationsApi.js +32 -2
- package/src/awd_v2024_05_09/ApiClient.js +48 -38
- package/src/awd_v2024_05_09/api/AwdApi.js +52 -12
- package/src/catalogitems_v2022_04_01/ApiClient.js +48 -38
- package/src/catalogitems_v2022_04_01/api/CatalogApi.js +34 -3
- package/src/datakiosk_v2023_11_15/ApiClient.js +48 -38
- package/src/datakiosk_v2023_11_15/api/QueriesApi.js +40 -6
- package/src/easyship_v2022_03_23/ApiClient.js +48 -38
- package/src/easyship_v2022_03_23/api/EasyShipApi.js +40 -6
- package/src/fbaeligibility_v1/ApiClient.js +48 -38
- package/src/fbaeligibility_v1/api/FbaInboundApi.js +32 -2
- package/src/fbainventory_v1/ApiClient.js +48 -38
- package/src/fbainventory_v1/api/FbaInventoryApi.js +38 -5
- package/src/feeds_v2021_06_30/ApiClient.js +48 -38
- package/src/feeds_v2021_06_30/api/FeedsApi.js +42 -7
- package/src/finances_2024_06_19/ApiClient.js +48 -38
- package/src/finances_2024_06_19/api/DefaultApi.js +32 -2
- package/src/finances_v0/ApiClient.js +48 -38
- package/src/finances_v0/api/DefaultApi.js +38 -5
- package/src/fulfillmentinbound_v0/ApiClient.js +48 -38
- package/src/fulfillmentinbound_v0/api/FbaInboundApi.js +42 -7
- package/src/fulfillmentinbound_v2024_03_20/ApiClient.js +48 -38
- package/src/fulfillmentinbound_v2024_03_20/api/FbaInboundApi.js +120 -46
- package/src/fulfillmentoutbound_v2020_07_01/ApiClient.js +48 -38
- package/src/fulfillmentoutbound_v2020_07_01/api/FbaOutboundApi.js +58 -15
- package/src/invoices_v2024_06_19/ApiClient.js +48 -38
- package/src/invoices_v2024_06_19/api/InvoicesApi.js +44 -8
- package/src/invoicing_v0/ApiClient.js +48 -38
- package/src/invoicing_v0/api/ShipmentInvoiceApi.js +36 -4
- package/src/listingsitems_v2021_08_01/ApiClient.js +48 -38
- package/src/listingsitems_v2021_08_01/api/ListingsApi.js +40 -6
- package/src/listingsrestrictions_v2021_08_01/ApiClient.js +48 -38
- package/src/listingsrestrictions_v2021_08_01/api/ListingsApi.js +32 -2
- package/src/merchantfulfillment_v0/ApiClient.js +48 -38
- package/src/merchantfulfillment_v0/api/MerchantFulfillmentApi.js +40 -6
- package/src/messaging_v1/ApiClient.js +48 -38
- package/src/messaging_v1/api/MessagingApi.js +56 -14
- package/src/notifications_v1/ApiClient.js +48 -38
- package/src/notifications_v1/api/NotificationsApi.js +46 -9
- package/src/orders_v0/ApiClient.js +48 -38
- package/src/orders_v0/api/OrdersV0Api.js +48 -10
- package/src/orders_v0/api/ShipmentApi.js +32 -2
- package/src/pricing_v0/ApiClient.js +48 -38
- package/src/pricing_v0/api/ProductPricingApi.js +42 -7
- package/src/pricing_v2022_05_01/ApiClient.js +48 -38
- package/src/pricing_v2022_05_01/api/ProductPricingApi.js +34 -3
- package/src/productfees_v0/ApiClient.js +48 -38
- package/src/productfees_v0/api/FeesApi.js +36 -4
- package/src/producttypedefinitions_v2020_09_01/ApiClient.js +48 -38
- package/src/producttypedefinitions_v2020_09_01/api/DefinitionsApi.js +34 -3
- package/src/replenishment_v2022_11_07/ApiClient.js +48 -38
- package/src/replenishment_v2022_11_07/api/OffersApi.js +34 -3
- package/src/replenishment_v2022_11_07/api/SellingpartnersApi.js +32 -2
- package/src/reports_v2021_06_30/ApiClient.js +48 -38
- package/src/reports_v2021_06_30/api/ReportsApi.js +48 -10
- package/src/sales_v1/ApiClient.js +48 -38
- package/src/sales_v1/api/SalesApi.js +32 -2
- package/src/sellers_v1/ApiClient.js +48 -38
- package/src/sellers_v1/api/SellersApi.js +34 -3
- package/src/services_v1/ApiClient.js +48 -38
- package/src/services_v1/api/ServiceApi.js +64 -18
- package/src/shipping_v2/ApiClient.js +48 -38
- package/src/shipping_v2/api/ShippingApi.js +70 -21
- package/src/solicitations_v1/ApiClient.js +48 -38
- package/src/solicitations_v1/api/SolicitationsApi.js +34 -3
- package/src/supplysources_v2020_07_01/ApiClient.js +48 -38
- package/src/supplysources_v2020_07_01/api/SupplySourcesApi.js +42 -7
- package/src/tokens_v2021_03_01/ApiClient.js +48 -38
- package/src/tokens_v2021_03_01/api/TokensApi.js +32 -2
- package/src/transfers_v2024_06_01/ApiClient.js +48 -38
- package/src/transfers_v2024_06_01/api/DefaultApi.js +34 -3
- package/src/uploads_v2020_11_01/ApiClient.js +48 -38
- package/src/uploads_v2020_11_01/api/UploadsApi.js +32 -2
- package/src/vehicles_v2024_11_01/ApiClient.js +48 -38
- package/src/vehicles_v2024_11_01/api/AutomotiveApi.js +32 -2
- package/src/vehicles_v2024_11_01/api/VehiclesApi.js +32 -2
- package/src/vendordfinventory_v1/ApiClient.js +48 -38
- package/src/vendordfinventory_v1/api/UpdateInventoryApi.js +32 -2
- package/src/vendordforders_v2021_12_28/ApiClient.js +48 -38
- package/src/vendordforders_v2021_12_28/api/VendorOrdersApi.js +36 -4
- package/src/vendordfpayments_v1/ApiClient.js +48 -38
- package/src/vendordfpayments_v1/api/VendorInvoiceApi.js +32 -2
- package/src/vendordfshipping_v2021_12_28/ApiClient.js +48 -38
- package/src/vendordfshipping_v2021_12_28/api/CreateContainerLabelApi.js +32 -2
- package/src/vendordfshipping_v2021_12_28/api/CustomerInvoicesApi.js +34 -3
- package/src/vendordfshipping_v2021_12_28/api/VendorShippingApi.js +38 -5
- package/src/vendordfshipping_v2021_12_28/api/VendorShippingLabelsApi.js +38 -5
- package/src/vendordftransactions_v2021_12_28/ApiClient.js +48 -38
- package/src/vendordftransactions_v2021_12_28/api/VendorTransactionApi.js +32 -2
- package/src/vendorinvoices_v1/ApiClient.js +48 -38
- package/src/vendorinvoices_v1/api/VendorPaymentsApi.js +32 -2
- package/src/vendororders_v1/ApiClient.js +48 -38
- package/src/vendororders_v1/api/VendorOrdersApi.js +38 -5
- package/src/vendorshipments_v1/ApiClient.js +48 -38
- package/src/vendorshipments_v1/api/VendorShippingApi.js +38 -5
- package/src/vendortransactionstatus_v1/ApiClient.js +48 -38
- package/src/vendortransactionstatus_v1/api/VendorTransactionApi.js +32 -2
- package/helper/rate-limits.yml +0 -874
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import {ApiClient} from
|
|
14
|
+
import {ApiClient} from '../ApiClient.js';
|
|
15
15
|
import {CancelShipmentResponse} from '../model/CancelShipmentResponse.js';
|
|
16
16
|
import {CreateClaimRequest} from '../model/CreateClaimRequest.js';
|
|
17
17
|
import {CreateClaimResponse} from '../model/CreateClaimResponse.js';
|
|
@@ -43,6 +43,8 @@ import {PurchaseShipmentResponse} from '../model/PurchaseShipmentResponse.js';
|
|
|
43
43
|
import {SubmitNdrFeedbackRequest} from '../model/SubmitNdrFeedbackRequest.js';
|
|
44
44
|
import {UnlinkCarrierAccountRequest} from '../model/UnlinkCarrierAccountRequest.js';
|
|
45
45
|
import {UnlinkCarrierAccountResponse} from '../model/UnlinkCarrierAccountResponse.js';
|
|
46
|
+
import {SuperagentRateLimiter} from '../../../helper/SuperagentRateLimiter.mjs';
|
|
47
|
+
import {DefaultRateLimitFetcher} from '../../../helper/DefaultRateLimitFetcher.mjs';
|
|
46
48
|
|
|
47
49
|
/**
|
|
48
50
|
* Shipping service.
|
|
@@ -51,6 +53,9 @@ import {UnlinkCarrierAccountResponse} from '../model/UnlinkCarrierAccountRespons
|
|
|
51
53
|
*/
|
|
52
54
|
export class ShippingApi {
|
|
53
55
|
|
|
56
|
+
// Private memeber stores the default rate limiters
|
|
57
|
+
#defaultRateLimiterMap;
|
|
58
|
+
|
|
54
59
|
/**
|
|
55
60
|
* Constructs a new ShippingApi.
|
|
56
61
|
* @alias module:shipping_v2/api/ShippingApi
|
|
@@ -60,6 +65,50 @@ export class ShippingApi {
|
|
|
60
65
|
*/
|
|
61
66
|
constructor(apiClient) {
|
|
62
67
|
this.apiClient = apiClient || ApiClient.instance;
|
|
68
|
+
this.initializeDefaultRateLimiterMap();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Initialize rate limiters for API operations
|
|
73
|
+
*/
|
|
74
|
+
initializeDefaultRateLimiterMap() {
|
|
75
|
+
this.#defaultRateLimiterMap = new Map()
|
|
76
|
+
const defaultRateLimitFetcher = new DefaultRateLimitFetcher();
|
|
77
|
+
const operations = [
|
|
78
|
+
'ShippingApi-cancelShipment',
|
|
79
|
+
'ShippingApi-createClaim',
|
|
80
|
+
'ShippingApi-directPurchaseShipment',
|
|
81
|
+
'ShippingApi-generateCollectionForm',
|
|
82
|
+
'ShippingApi-getAccessPoints',
|
|
83
|
+
'ShippingApi-getAdditionalInputs',
|
|
84
|
+
'ShippingApi-getCarrierAccountFormInputs',
|
|
85
|
+
'ShippingApi-getCarrierAccounts',
|
|
86
|
+
'ShippingApi-getCollectionForm',
|
|
87
|
+
'ShippingApi-getCollectionFormHistory',
|
|
88
|
+
'ShippingApi-getRates',
|
|
89
|
+
'ShippingApi-getShipmentDocuments',
|
|
90
|
+
'ShippingApi-getTracking',
|
|
91
|
+
'ShippingApi-getUnmanifestedShipments',
|
|
92
|
+
'ShippingApi-linkCarrierAccount',
|
|
93
|
+
'ShippingApi-linkCarrierAccount_0',
|
|
94
|
+
'ShippingApi-oneClickShipment',
|
|
95
|
+
'ShippingApi-purchaseShipment',
|
|
96
|
+
'ShippingApi-submitNdrFeedback',
|
|
97
|
+
'ShippingApi-unlinkCarrierAccount',
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
for (const operation of operations) {
|
|
101
|
+
const config = defaultRateLimitFetcher.getLimit(operation);
|
|
102
|
+
this.#defaultRateLimiterMap.set(operation, new SuperagentRateLimiter(config));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Get rate limiter for a specific operation
|
|
108
|
+
* @param {String} operation name
|
|
109
|
+
*/
|
|
110
|
+
getRateLimiter(operation) {
|
|
111
|
+
return this.#defaultRateLimiterMap.get(operation);
|
|
63
112
|
}
|
|
64
113
|
|
|
65
114
|
|
|
@@ -99,7 +148,7 @@ export class ShippingApi {
|
|
|
99
148
|
return this.apiClient.callApi( 'ShippingApi-cancelShipment',
|
|
100
149
|
'/shipping/v2/shipments/{shipmentId}/cancel', 'PUT',
|
|
101
150
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
102
|
-
contentTypes, accepts, returnType
|
|
151
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-cancelShipment')
|
|
103
152
|
);
|
|
104
153
|
}
|
|
105
154
|
|
|
@@ -152,7 +201,7 @@ export class ShippingApi {
|
|
|
152
201
|
return this.apiClient.callApi( 'ShippingApi-createClaim',
|
|
153
202
|
'/shipping/v2/claims', 'POST',
|
|
154
203
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
155
|
-
contentTypes, accepts, returnType
|
|
204
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-createClaim')
|
|
156
205
|
);
|
|
157
206
|
}
|
|
158
207
|
|
|
@@ -209,7 +258,7 @@ export class ShippingApi {
|
|
|
209
258
|
return this.apiClient.callApi( 'ShippingApi-directPurchaseShipment',
|
|
210
259
|
'/shipping/v2/shipments/directPurchase', 'POST',
|
|
211
260
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
212
|
-
contentTypes, accepts, returnType
|
|
261
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-directPurchaseShipment')
|
|
213
262
|
);
|
|
214
263
|
}
|
|
215
264
|
|
|
@@ -266,7 +315,7 @@ export class ShippingApi {
|
|
|
266
315
|
return this.apiClient.callApi( 'ShippingApi-generateCollectionForm',
|
|
267
316
|
'/shipping/v2/collectionForms', 'POST',
|
|
268
317
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
269
|
-
contentTypes, accepts, returnType
|
|
318
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-generateCollectionForm')
|
|
270
319
|
);
|
|
271
320
|
}
|
|
272
321
|
|
|
@@ -335,7 +384,7 @@ export class ShippingApi {
|
|
|
335
384
|
return this.apiClient.callApi( 'ShippingApi-getAccessPoints',
|
|
336
385
|
'/shipping/v2/accessPoints', 'GET',
|
|
337
386
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
338
|
-
contentTypes, accepts, returnType
|
|
387
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-getAccessPoints')
|
|
339
388
|
);
|
|
340
389
|
}
|
|
341
390
|
|
|
@@ -398,7 +447,7 @@ export class ShippingApi {
|
|
|
398
447
|
return this.apiClient.callApi( 'ShippingApi-getAdditionalInputs',
|
|
399
448
|
'/shipping/v2/shipments/additionalInputs/schema', 'GET',
|
|
400
449
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
401
|
-
contentTypes, accepts, returnType
|
|
450
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-getAdditionalInputs')
|
|
402
451
|
);
|
|
403
452
|
}
|
|
404
453
|
|
|
@@ -446,7 +495,7 @@ export class ShippingApi {
|
|
|
446
495
|
return this.apiClient.callApi( 'ShippingApi-getCarrierAccountFormInputs',
|
|
447
496
|
'/shipping/v2/carrierAccountFormInputs', 'GET',
|
|
448
497
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
449
|
-
contentTypes, accepts, returnType
|
|
498
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-getCarrierAccountFormInputs')
|
|
450
499
|
);
|
|
451
500
|
}
|
|
452
501
|
|
|
@@ -498,7 +547,7 @@ export class ShippingApi {
|
|
|
498
547
|
return this.apiClient.callApi( 'ShippingApi-getCarrierAccounts',
|
|
499
548
|
'/shipping/v2/carrierAccounts', 'PUT',
|
|
500
549
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
501
|
-
contentTypes, accepts, returnType
|
|
550
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-getCarrierAccounts')
|
|
502
551
|
);
|
|
503
552
|
}
|
|
504
553
|
|
|
@@ -552,7 +601,7 @@ export class ShippingApi {
|
|
|
552
601
|
return this.apiClient.callApi( 'ShippingApi-getCollectionForm',
|
|
553
602
|
'/shipping/v2/collectionForms/{collectionFormId}', 'GET',
|
|
554
603
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
555
|
-
contentTypes, accepts, returnType
|
|
604
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-getCollectionForm')
|
|
556
605
|
);
|
|
557
606
|
}
|
|
558
607
|
|
|
@@ -605,7 +654,7 @@ export class ShippingApi {
|
|
|
605
654
|
return this.apiClient.callApi( 'ShippingApi-getCollectionFormHistory',
|
|
606
655
|
'/shipping/v2/collectionForms/history', 'PUT',
|
|
607
656
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
608
|
-
contentTypes, accepts, returnType
|
|
657
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-getCollectionFormHistory')
|
|
609
658
|
);
|
|
610
659
|
}
|
|
611
660
|
|
|
@@ -658,7 +707,7 @@ export class ShippingApi {
|
|
|
658
707
|
return this.apiClient.callApi( 'ShippingApi-getRates',
|
|
659
708
|
'/shipping/v2/shipments/rates', 'POST',
|
|
660
709
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
661
|
-
contentTypes, accepts, returnType
|
|
710
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-getRates')
|
|
662
711
|
);
|
|
663
712
|
}
|
|
664
713
|
|
|
@@ -723,7 +772,7 @@ export class ShippingApi {
|
|
|
723
772
|
return this.apiClient.callApi( 'ShippingApi-getShipmentDocuments',
|
|
724
773
|
'/shipping/v2/shipments/{shipmentId}/documents', 'GET',
|
|
725
774
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
726
|
-
contentTypes, accepts, returnType
|
|
775
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-getShipmentDocuments')
|
|
727
776
|
);
|
|
728
777
|
}
|
|
729
778
|
|
|
@@ -787,7 +836,7 @@ export class ShippingApi {
|
|
|
787
836
|
return this.apiClient.callApi( 'ShippingApi-getTracking',
|
|
788
837
|
'/shipping/v2/tracking', 'GET',
|
|
789
838
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
790
|
-
contentTypes, accepts, returnType
|
|
839
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-getTracking')
|
|
791
840
|
);
|
|
792
841
|
}
|
|
793
842
|
|
|
@@ -841,7 +890,7 @@ export class ShippingApi {
|
|
|
841
890
|
return this.apiClient.callApi( 'ShippingApi-getUnmanifestedShipments',
|
|
842
891
|
'/shipping/v2/unmanifestedShipments', 'PUT',
|
|
843
892
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
844
|
-
contentTypes, accepts, returnType
|
|
893
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-getUnmanifestedShipments')
|
|
845
894
|
);
|
|
846
895
|
}
|
|
847
896
|
|
|
@@ -901,7 +950,7 @@ export class ShippingApi {
|
|
|
901
950
|
return this.apiClient.callApi( 'ShippingApi-linkCarrierAccount',
|
|
902
951
|
'/shipping/v2/carrierAccounts/{carrierId}', 'PUT',
|
|
903
952
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
904
|
-
contentTypes, accepts, returnType
|
|
953
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-linkCarrierAccount')
|
|
905
954
|
);
|
|
906
955
|
}
|
|
907
956
|
|
|
@@ -962,7 +1011,7 @@ export class ShippingApi {
|
|
|
962
1011
|
return this.apiClient.callApi( 'ShippingApi-linkCarrierAccount_0',
|
|
963
1012
|
'/shipping/v2/carrierAccounts/{carrierId}', 'POST',
|
|
964
1013
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
965
|
-
contentTypes, accepts, returnType
|
|
1014
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-linkCarrierAccount_0')
|
|
966
1015
|
);
|
|
967
1016
|
}
|
|
968
1017
|
|
|
@@ -1016,7 +1065,7 @@ export class ShippingApi {
|
|
|
1016
1065
|
return this.apiClient.callApi( 'ShippingApi-oneClickShipment',
|
|
1017
1066
|
'/shipping/v2/oneClickShipment', 'POST',
|
|
1018
1067
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
1019
|
-
contentTypes, accepts, returnType
|
|
1068
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-oneClickShipment')
|
|
1020
1069
|
);
|
|
1021
1070
|
}
|
|
1022
1071
|
|
|
@@ -1071,7 +1120,7 @@ export class ShippingApi {
|
|
|
1071
1120
|
return this.apiClient.callApi( 'ShippingApi-purchaseShipment',
|
|
1072
1121
|
'/shipping/v2/shipments', 'POST',
|
|
1073
1122
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
1074
|
-
contentTypes, accepts, returnType
|
|
1123
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-purchaseShipment')
|
|
1075
1124
|
);
|
|
1076
1125
|
}
|
|
1077
1126
|
|
|
@@ -1125,7 +1174,7 @@ export class ShippingApi {
|
|
|
1125
1174
|
return this.apiClient.callApi( 'ShippingApi-submitNdrFeedback',
|
|
1126
1175
|
'/shipping/v2/ndrFeedback', 'POST',
|
|
1127
1176
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
1128
|
-
contentTypes, accepts, returnType
|
|
1177
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-submitNdrFeedback')
|
|
1129
1178
|
);
|
|
1130
1179
|
}
|
|
1131
1180
|
|
|
@@ -1185,7 +1234,7 @@ export class ShippingApi {
|
|
|
1185
1234
|
return this.apiClient.callApi( 'ShippingApi-unlinkCarrierAccount',
|
|
1186
1235
|
'/shipping/v2/carrierAccounts/{carrierId}/unlink', 'PUT',
|
|
1187
1236
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
1188
|
-
contentTypes, accepts, returnType
|
|
1237
|
+
contentTypes, accepts, returnType, this.getRateLimiter('ShippingApi-unlinkCarrierAccount')
|
|
1189
1238
|
);
|
|
1190
1239
|
}
|
|
1191
1240
|
|
|
@@ -11,12 +11,11 @@
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import superagent from
|
|
15
|
-
import querystring from
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
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 solicitations_v1/ApiClient
|
|
@@ -193,9 +192,8 @@ export class ApiClient {
|
|
|
193
192
|
#tokenForApiCall = null;
|
|
194
193
|
#lwaClient = null;
|
|
195
194
|
#rdtClient = null;
|
|
196
|
-
#
|
|
197
|
-
#
|
|
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
|
-
*
|
|
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
|
-
|
|
268
|
-
|
|
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
|
-
*
|
|
279
|
+
* Disable customized rate limiter for one operation
|
|
280
|
+
* Fall back to default rate limiter
|
|
281
|
+
* @param {String} operationName
|
|
277
282
|
*/
|
|
278
|
-
|
|
279
|
-
this.#
|
|
280
|
-
this.#customizedRateLimiter = null;
|
|
283
|
+
disableCustomizedRatelimiterForOperation(operationName) {
|
|
284
|
+
this.#customizedRateLimiterMap.delete(operationName);
|
|
281
285
|
}
|
|
282
286
|
|
|
283
287
|
/**
|
|
284
|
-
*
|
|
285
|
-
*
|
|
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
|
-
|
|
288
|
-
this.#
|
|
289
|
-
this.#useDefaultRateLimiter = false;
|
|
299
|
+
disableRateLimiter() {
|
|
300
|
+
this.#useRateLimiter = false;
|
|
290
301
|
}
|
|
291
302
|
|
|
292
303
|
/**
|
|
293
|
-
*
|
|
304
|
+
* Enable default or customized rate limiter for all operations
|
|
294
305
|
*/
|
|
295
|
-
|
|
296
|
-
this.#
|
|
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
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
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
|
|
14
|
+
import {ApiClient} from '../ApiClient.js';
|
|
15
15
|
import {CreateProductReviewAndSellerFeedbackSolicitationResponse} from '../model/CreateProductReviewAndSellerFeedbackSolicitationResponse.js';
|
|
16
16
|
import {GetSolicitationActionsForOrderResponse} from '../model/GetSolicitationActionsForOrderResponse.js';
|
|
17
|
+
import {SuperagentRateLimiter} from '../../../helper/SuperagentRateLimiter.mjs';
|
|
18
|
+
import {DefaultRateLimitFetcher} from '../../../helper/DefaultRateLimitFetcher.mjs';
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* Solicitations service.
|
|
@@ -22,6 +24,9 @@ import {GetSolicitationActionsForOrderResponse} from '../model/GetSolicitationAc
|
|
|
22
24
|
*/
|
|
23
25
|
export class SolicitationsApi {
|
|
24
26
|
|
|
27
|
+
// Private memeber stores the default rate limiters
|
|
28
|
+
#defaultRateLimiterMap;
|
|
29
|
+
|
|
25
30
|
/**
|
|
26
31
|
* Constructs a new SolicitationsApi.
|
|
27
32
|
* @alias module:solicitations_v1/api/SolicitationsApi
|
|
@@ -31,6 +36,32 @@ export class SolicitationsApi {
|
|
|
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
|
+
'SolicitationsApi-createProductReviewAndSellerFeedbackSolicitation',
|
|
50
|
+
'SolicitationsApi-getSolicitationActionsForOrder',
|
|
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);
|
|
34
65
|
}
|
|
35
66
|
|
|
36
67
|
|
|
@@ -73,7 +104,7 @@ export class SolicitationsApi {
|
|
|
73
104
|
return this.apiClient.callApi( 'SolicitationsApi-createProductReviewAndSellerFeedbackSolicitation',
|
|
74
105
|
'/solicitations/v1/orders/{amazonOrderId}/solicitations/productReviewAndSellerFeedback', 'POST',
|
|
75
106
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
76
|
-
contentTypes, accepts, returnType
|
|
107
|
+
contentTypes, accepts, returnType, this.getRateLimiter('SolicitationsApi-createProductReviewAndSellerFeedbackSolicitation')
|
|
77
108
|
);
|
|
78
109
|
}
|
|
79
110
|
|
|
@@ -129,7 +160,7 @@ export class SolicitationsApi {
|
|
|
129
160
|
return this.apiClient.callApi( 'SolicitationsApi-getSolicitationActionsForOrder',
|
|
130
161
|
'/solicitations/v1/orders/{amazonOrderId}', 'GET',
|
|
131
162
|
pathParams, queryParams, headerParams, formParams, postBody,
|
|
132
|
-
contentTypes, accepts, returnType
|
|
163
|
+
contentTypes, accepts, returnType, this.getRateLimiter('SolicitationsApi-getSolicitationActionsForOrder')
|
|
133
164
|
);
|
|
134
165
|
}
|
|
135
166
|
|
|
@@ -11,12 +11,11 @@
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import superagent from
|
|
15
|
-
import querystring from
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
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 supplysources_v2020_07_01/ApiClient
|
|
@@ -193,9 +192,8 @@ export class ApiClient {
|
|
|
193
192
|
#tokenForApiCall = null;
|
|
194
193
|
#lwaClient = null;
|
|
195
194
|
#rdtClient = null;
|
|
196
|
-
#
|
|
197
|
-
#
|
|
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
|
-
*
|
|
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
|
-
|
|
268
|
-
|
|
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
|
-
*
|
|
279
|
+
* Disable customized rate limiter for one operation
|
|
280
|
+
* Fall back to default rate limiter
|
|
281
|
+
* @param {String} operationName
|
|
277
282
|
*/
|
|
278
|
-
|
|
279
|
-
this.#
|
|
280
|
-
this.#customizedRateLimiter = null;
|
|
283
|
+
disableCustomizedRatelimiterForOperation(operationName) {
|
|
284
|
+
this.#customizedRateLimiterMap.delete(operationName);
|
|
281
285
|
}
|
|
282
286
|
|
|
283
287
|
/**
|
|
284
|
-
*
|
|
285
|
-
*
|
|
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
|
-
|
|
288
|
-
this.#
|
|
289
|
-
this.#useDefaultRateLimiter = false;
|
|
299
|
+
disableRateLimiter() {
|
|
300
|
+
this.#useRateLimiter = false;
|
|
290
301
|
}
|
|
291
302
|
|
|
292
303
|
/**
|
|
293
|
-
*
|
|
304
|
+
* Enable default or customized rate limiter for all operations
|
|
294
305
|
*/
|
|
295
|
-
|
|
296
|
-
this.#
|
|
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
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
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) {
|