@amazon-sp-api-release/amazon-sp-api-sdk-js 1.0.0-rc6 → 1.0.0-rc8
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 +22 -25
- package/helper/DefaultRateLimitFetcher.mjs +59 -0
- package/helper/LwaAuthClient.mjs +56 -22
- package/helper/RateLimitConfiguration.mjs +53 -0
- package/helper/ScopeConstants.mjs +8 -0
- package/helper/SuperagentRateLimiter.mjs +51 -0
- package/helper/rate-limits.yml +874 -0
- package/index.js +51 -49
- package/package.json +6 -6
- package/sample-node-app/app.config.mjs +4 -3
- package/sample-node-app/index.js +155 -24
- package/src/apluscontent_v2020_11_01/ApiClient.js +152 -70
- package/src/apluscontent_v2020_11_01/api/AplusContentApi.js +10 -10
- package/src/appintegrations_v2024_04_01/ApiClient.js +152 -70
- package/src/appintegrations_v2024_04_01/api/AppIntegrationsApi.js +3 -3
- package/src/applications_v2023_11_30/ApiClient.js +152 -70
- package/src/applications_v2023_11_30/api/ApplicationsApi.js +1 -1
- package/src/awd_v2024_05_09/ApiClient.js +152 -70
- package/src/awd_v2024_05_09/api/AwdApi.js +11 -11
- package/src/catalogitems_v2022_04_01/ApiClient.js +152 -70
- package/src/catalogitems_v2022_04_01/api/CatalogApi.js +2 -2
- package/src/datakiosk_v2023_11_15/ApiClient.js +152 -70
- package/src/datakiosk_v2023_11_15/api/QueriesApi.js +5 -5
- package/src/easyship_v2022_03_23/ApiClient.js +152 -70
- package/src/easyship_v2022_03_23/api/EasyShipApi.js +5 -5
- package/src/fbaeligibility_v1/ApiClient.js +152 -70
- package/src/fbaeligibility_v1/api/FbaInboundApi.js +1 -1
- package/src/fbainventory_v1/ApiClient.js +152 -70
- package/src/fbainventory_v1/api/FbaInventoryApi.js +4 -4
- package/src/feeds_v2021_06_30/ApiClient.js +152 -70
- package/src/feeds_v2021_06_30/api/FeedsApi.js +6 -6
- package/src/finances_2024_06_19/ApiClient.js +152 -70
- package/src/finances_2024_06_19/api/DefaultApi.js +1 -1
- package/src/finances_v0/ApiClient.js +152 -70
- package/src/finances_v0/api/DefaultApi.js +4 -4
- package/src/fulfillmentinbound_v0/ApiClient.js +152 -70
- package/src/fulfillmentinbound_v0/api/FbaInboundApi.js +6 -6
- package/src/fulfillmentinbound_v2024_03_20/ApiClient.js +152 -70
- package/src/fulfillmentinbound_v2024_03_20/api/FbaInboundApi.js +45 -45
- package/src/fulfillmentoutbound_v2020_07_01/ApiClient.js +152 -70
- package/src/fulfillmentoutbound_v2020_07_01/api/FbaOutboundApi.js +14 -14
- package/src/invoices_v2024_06_19/ApiClient.js +152 -70
- package/src/invoices_v2024_06_19/api/InvoicesApi.js +7 -7
- package/src/invoicing_v0/ApiClient.js +152 -70
- package/src/invoicing_v0/api/ShipmentInvoiceApi.js +3 -3
- package/src/listingsitems_v2021_08_01/ApiClient.js +152 -70
- package/src/listingsitems_v2021_08_01/api/ListingsApi.js +5 -5
- package/src/listingsrestrictions_v2021_08_01/ApiClient.js +152 -70
- package/src/listingsrestrictions_v2021_08_01/api/ListingsApi.js +1 -1
- package/src/merchantfulfillment_v0/ApiClient.js +152 -70
- package/src/merchantfulfillment_v0/api/MerchantFulfillmentApi.js +5 -5
- package/src/messaging_v1/ApiClient.js +152 -70
- package/src/messaging_v1/api/MessagingApi.js +13 -13
- package/src/notifications_v1/ApiClient.js +152 -70
- package/src/notifications_v1/api/NotificationsApi.js +8 -8
- package/src/orders_v0/ApiClient.js +152 -70
- package/src/orders_v0/api/OrdersV0Api.js +9 -9
- package/src/orders_v0/api/ShipmentApi.js +1 -1
- package/src/pricing_v0/ApiClient.js +152 -70
- package/src/pricing_v0/api/ProductPricingApi.js +6 -6
- package/src/pricing_v2022_05_01/ApiClient.js +152 -70
- package/src/pricing_v2022_05_01/api/ProductPricingApi.js +2 -2
- package/src/productfees_v0/ApiClient.js +152 -70
- package/src/productfees_v0/api/FeesApi.js +3 -3
- package/src/producttypedefinitions_v2020_09_01/ApiClient.js +152 -70
- package/src/producttypedefinitions_v2020_09_01/api/DefinitionsApi.js +2 -2
- package/src/replenishment_v2022_11_07/ApiClient.js +152 -70
- package/src/replenishment_v2022_11_07/api/OffersApi.js +2 -2
- package/src/replenishment_v2022_11_07/api/SellingpartnersApi.js +1 -1
- package/src/reports_v2021_06_30/ApiClient.js +152 -70
- package/src/reports_v2021_06_30/api/ReportsApi.js +9 -9
- package/src/sales_v1/ApiClient.js +152 -70
- package/src/sales_v1/api/SalesApi.js +1 -1
- package/src/sellers_v1/ApiClient.js +152 -70
- package/src/sellers_v1/api/SellersApi.js +2 -2
- package/src/services_v1/ApiClient.js +152 -70
- package/src/services_v1/api/ServiceApi.js +17 -17
- package/src/shipping_v2/ApiClient.js +152 -70
- package/src/shipping_v2/api/ShippingApi.js +20 -20
- package/src/solicitations_v1/ApiClient.js +152 -70
- package/src/solicitations_v1/api/SolicitationsApi.js +2 -2
- package/src/supplysources_v2020_07_01/ApiClient.js +152 -70
- package/src/supplysources_v2020_07_01/api/SupplySourcesApi.js +6 -6
- package/src/tokens_v2021_03_01/ApiClient.js +152 -70
- package/src/tokens_v2021_03_01/api/TokensApi.js +1 -1
- package/src/transfers_v2024_06_01/ApiClient.js +152 -70
- package/src/transfers_v2024_06_01/api/DefaultApi.js +2 -2
- package/src/uploads_v2020_11_01/ApiClient.js +152 -70
- package/src/uploads_v2020_11_01/api/UploadsApi.js +1 -1
- package/src/vehicles_v2024_11_01/ApiClient.js +152 -70
- package/src/vehicles_v2024_11_01/api/AutomotiveApi.js +1 -1
- package/src/vehicles_v2024_11_01/api/VehiclesApi.js +1 -1
- package/src/vendordfinventory_v1/ApiClient.js +152 -70
- package/src/vendordfinventory_v1/api/UpdateInventoryApi.js +1 -1
- package/src/vendordforders_v2021_12_28/ApiClient.js +152 -70
- package/src/vendordforders_v2021_12_28/api/VendorOrdersApi.js +3 -3
- package/src/vendordfpayments_v1/ApiClient.js +152 -70
- package/src/vendordfpayments_v1/api/VendorInvoiceApi.js +1 -1
- package/src/vendordfshipping_v2021_12_28/ApiClient.js +152 -70
- package/src/vendordfshipping_v2021_12_28/api/CreateContainerLabelApi.js +1 -1
- package/src/vendordfshipping_v2021_12_28/api/CustomerInvoicesApi.js +2 -2
- package/src/vendordfshipping_v2021_12_28/api/VendorShippingApi.js +4 -4
- package/src/vendordfshipping_v2021_12_28/api/VendorShippingLabelsApi.js +4 -4
- package/src/vendordftransactions_v2021_12_28/ApiClient.js +152 -70
- package/src/vendordftransactions_v2021_12_28/api/VendorTransactionApi.js +1 -1
- package/src/vendorinvoices_v1/ApiClient.js +152 -70
- package/src/vendorinvoices_v1/api/VendorPaymentsApi.js +1 -1
- package/src/vendororders_v1/ApiClient.js +152 -70
- package/src/vendororders_v1/api/VendorOrdersApi.js +4 -4
- package/src/vendorshipments_v1/ApiClient.js +152 -70
- package/src/vendorshipments_v1/api/VendorShippingApi.js +4 -4
- package/src/vendortransactionstatus_v1/ApiClient.js +152 -70
- package/src/vendortransactionstatus_v1/api/VendorTransactionApi.js +1 -1
package/index.js
CHANGED
|
@@ -1,50 +1,52 @@
|
|
|
1
|
-
export * as ApluscontentSpApi from './src/apluscontent_v2020_11_01/index.js'
|
|
2
|
-
export * as AppintegrationsSpApi from './src/appintegrations_v2024_04_01/index.js'
|
|
3
|
-
export * as ApplicationsSpApi from './src/applications_v2023_11_30/index.js'
|
|
4
|
-
export * as AwdSpApi from './src/awd_v2024_05_09/index.js'
|
|
5
|
-
export * as CatalogitemsSpApi from './src/catalogitems_v2022_04_01/index.js'
|
|
6
|
-
export * as DatakioskSpApi from './src/datakiosk_v2023_11_15/index.js'
|
|
7
|
-
export * as EasyshipSpApi from './src/easyship_v2022_03_23/index.js'
|
|
8
|
-
export * as FbaeligibilitySpApi from './src/fbaeligibility_v1/index.js'
|
|
9
|
-
export * as FbainventorySpApi from './src/fbainventory_v1/index.js'
|
|
10
|
-
export * as FeedsSpApi from './src/feeds_v2021_06_30/index.js'
|
|
11
|
-
export * as Finances20240619SpApi from './src/finances_2024_06_19/index.js'
|
|
12
|
-
export * as FinancesSpApi from './src/finances_v0/index.js'
|
|
13
|
-
export * as FulfillmentinboundSpApi from './src/fulfillmentinbound_v2024_03_20/index.js'
|
|
14
|
-
export * as Fulfillmentinbound_v0SpApi from './src/fulfillmentinbound_v0/index.js'
|
|
15
|
-
export * as FulfillmentoutboundSpApi from './src/fulfillmentoutbound_v2020_07_01/index.js'
|
|
16
|
-
export * as InvoicesSpApi from './src/invoices_v2024_06_19/index.js'
|
|
17
|
-
export * as InvoicingSpApi from './src/invoicing_v0/index.js'
|
|
18
|
-
export * as ListingsitemsSpApi from './src/listingsitems_v2021_08_01/index.js'
|
|
19
|
-
export * as ListingsrestrictionsSpApi from './src/listingsrestrictions_v2021_08_01/index.js'
|
|
20
|
-
export * as MerchantfulfillmentSpApi from './src/merchantfulfillment_v0/index.js'
|
|
21
|
-
export * as MessagingSpApi from './src/messaging_v1/index.js'
|
|
22
|
-
export * as NotificationsSpApi from './src/notifications_v1/index.js'
|
|
23
|
-
export * as OrdersSpApi from './src/orders_v0/index.js'
|
|
24
|
-
export * as PricingSpApi from './src/pricing_v2022_05_01/index.js'
|
|
25
|
-
export * as Pricing_v0SpApi from './src/pricing_v0/index.js'
|
|
26
|
-
export * as ProductfeesSpApi from './src/productfees_v0/index.js'
|
|
27
|
-
export * as ProducttypedefinitionsSpApi from './src/producttypedefinitions_v2020_09_01/index.js'
|
|
28
|
-
export * as ReplenishmentSpApi from './src/replenishment_v2022_11_07/index.js'
|
|
29
|
-
export * as ReportsSpApi from './src/reports_v2021_06_30/index.js'
|
|
30
|
-
export * as SalesSpApi from './src/sales_v1/index.js'
|
|
31
|
-
export * as SellersSpApi from './src/sellers_v1/index.js'
|
|
32
|
-
export * as ServicesSpApi from './src/services_v1/index.js'
|
|
33
|
-
export * as ShippingSpApi from './src/shipping_v2/index.js'
|
|
34
|
-
export * as SolicitationsSpApi from './src/solicitations_v1/index.js'
|
|
35
|
-
export * as SupplysourcesSpApi from './src/supplysources_v2020_07_01/index.js'
|
|
36
|
-
export * as TokensSpApi from './src/tokens_v2021_03_01/index.js'
|
|
37
|
-
export * as TransfersSpApi from './src/transfers_v2024_06_01/index.js'
|
|
38
|
-
export * as UploadsSpApi from './src/uploads_v2020_11_01/index.js'
|
|
39
|
-
export * as VehiclesSpApi from './src/vehicles_v2024_11_01/index.js'
|
|
40
|
-
export * as VendordfinventorySpApi from './src/vendordfinventory_v1/index.js'
|
|
41
|
-
export * as VendordfordersSpApi from './src/vendordforders_v2021_12_28/index.js'
|
|
42
|
-
export * as VendordfpaymentsSpApi from './src/vendordfpayments_v1/index.js'
|
|
43
|
-
export * as VendordfshippingSpApi from './src/vendordfshipping_v2021_12_28/index.js'
|
|
44
|
-
export * as VendordftransactionsSpApi from './src/vendordftransactions_v2021_12_28/index.js'
|
|
45
|
-
export * as VendorinvoicesSpApi from './src/vendorinvoices_v1/index.js'
|
|
46
|
-
export * as VendorordersSpApi from './src/vendororders_v1/index.js'
|
|
47
|
-
export * as VendorshipmentsSpApi from './src/vendorshipments_v1/index.js'
|
|
48
|
-
export * as VendortransactionstatusSpApi from './src/vendortransactionstatus_v1/index.js'
|
|
1
|
+
export * as ApluscontentSpApi from './src/apluscontent_v2020_11_01/index.js';
|
|
2
|
+
export * as AppintegrationsSpApi from './src/appintegrations_v2024_04_01/index.js';
|
|
3
|
+
export * as ApplicationsSpApi from './src/applications_v2023_11_30/index.js';
|
|
4
|
+
export * as AwdSpApi from './src/awd_v2024_05_09/index.js';
|
|
5
|
+
export * as CatalogitemsSpApi from './src/catalogitems_v2022_04_01/index.js';
|
|
6
|
+
export * as DatakioskSpApi from './src/datakiosk_v2023_11_15/index.js';
|
|
7
|
+
export * as EasyshipSpApi from './src/easyship_v2022_03_23/index.js';
|
|
8
|
+
export * as FbaeligibilitySpApi from './src/fbaeligibility_v1/index.js';
|
|
9
|
+
export * as FbainventorySpApi from './src/fbainventory_v1/index.js';
|
|
10
|
+
export * as FeedsSpApi from './src/feeds_v2021_06_30/index.js';
|
|
11
|
+
export * as Finances20240619SpApi from './src/finances_2024_06_19/index.js';
|
|
12
|
+
export * as FinancesSpApi from './src/finances_v0/index.js';
|
|
13
|
+
export * as FulfillmentinboundSpApi from './src/fulfillmentinbound_v2024_03_20/index.js';
|
|
14
|
+
export * as Fulfillmentinbound_v0SpApi from './src/fulfillmentinbound_v0/index.js';
|
|
15
|
+
export * as FulfillmentoutboundSpApi from './src/fulfillmentoutbound_v2020_07_01/index.js';
|
|
16
|
+
export * as InvoicesSpApi from './src/invoices_v2024_06_19/index.js';
|
|
17
|
+
export * as InvoicingSpApi from './src/invoicing_v0/index.js';
|
|
18
|
+
export * as ListingsitemsSpApi from './src/listingsitems_v2021_08_01/index.js';
|
|
19
|
+
export * as ListingsrestrictionsSpApi from './src/listingsrestrictions_v2021_08_01/index.js';
|
|
20
|
+
export * as MerchantfulfillmentSpApi from './src/merchantfulfillment_v0/index.js';
|
|
21
|
+
export * as MessagingSpApi from './src/messaging_v1/index.js';
|
|
22
|
+
export * as NotificationsSpApi from './src/notifications_v1/index.js';
|
|
23
|
+
export * as OrdersSpApi from './src/orders_v0/index.js';
|
|
24
|
+
export * as PricingSpApi from './src/pricing_v2022_05_01/index.js';
|
|
25
|
+
export * as Pricing_v0SpApi from './src/pricing_v0/index.js';
|
|
26
|
+
export * as ProductfeesSpApi from './src/productfees_v0/index.js';
|
|
27
|
+
export * as ProducttypedefinitionsSpApi from './src/producttypedefinitions_v2020_09_01/index.js';
|
|
28
|
+
export * as ReplenishmentSpApi from './src/replenishment_v2022_11_07/index.js';
|
|
29
|
+
export * as ReportsSpApi from './src/reports_v2021_06_30/index.js';
|
|
30
|
+
export * as SalesSpApi from './src/sales_v1/index.js';
|
|
31
|
+
export * as SellersSpApi from './src/sellers_v1/index.js';
|
|
32
|
+
export * as ServicesSpApi from './src/services_v1/index.js';
|
|
33
|
+
export * as ShippingSpApi from './src/shipping_v2/index.js';
|
|
34
|
+
export * as SolicitationsSpApi from './src/solicitations_v1/index.js';
|
|
35
|
+
export * as SupplysourcesSpApi from './src/supplysources_v2020_07_01/index.js';
|
|
36
|
+
export * as TokensSpApi from './src/tokens_v2021_03_01/index.js';
|
|
37
|
+
export * as TransfersSpApi from './src/transfers_v2024_06_01/index.js';
|
|
38
|
+
export * as UploadsSpApi from './src/uploads_v2020_11_01/index.js';
|
|
39
|
+
export * as VehiclesSpApi from './src/vehicles_v2024_11_01/index.js';
|
|
40
|
+
export * as VendordfinventorySpApi from './src/vendordfinventory_v1/index.js';
|
|
41
|
+
export * as VendordfordersSpApi from './src/vendordforders_v2021_12_28/index.js';
|
|
42
|
+
export * as VendordfpaymentsSpApi from './src/vendordfpayments_v1/index.js';
|
|
43
|
+
export * as VendordfshippingSpApi from './src/vendordfshipping_v2021_12_28/index.js';
|
|
44
|
+
export * as VendordftransactionsSpApi from './src/vendordftransactions_v2021_12_28/index.js';
|
|
45
|
+
export * as VendorinvoicesSpApi from './src/vendorinvoices_v1/index.js';
|
|
46
|
+
export * as VendorordersSpApi from './src/vendororders_v1/index.js';
|
|
47
|
+
export * as VendorshipmentsSpApi from './src/vendorshipments_v1/index.js';
|
|
48
|
+
export * as VendortransactionstatusSpApi from './src/vendortransactionstatus_v1/index.js';
|
|
49
49
|
|
|
50
|
-
export * from './helper/LwaAuthClient.mjs'
|
|
50
|
+
export * from './helper/LwaAuthClient.mjs';
|
|
51
|
+
export * from './helper/ScopeConstants.mjs';
|
|
52
|
+
export * from './helper/RateLimitConfiguration.mjs';
|
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"license": "Apache License 2.0",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"version": "1.0.0-rc8",
|
|
7
8
|
"scripts": {
|
|
8
9
|
"test": "echo \"No test specified\" && exit 1"
|
|
9
10
|
},
|
|
@@ -12,7 +13,9 @@
|
|
|
12
13
|
},
|
|
13
14
|
"dependencies": {
|
|
14
15
|
"@babel/cli": "^7.0.0",
|
|
15
|
-
"superagent": "^9.0.0"
|
|
16
|
+
"superagent": "^9.0.0",
|
|
17
|
+
"bottleneck": "^2.19.5",
|
|
18
|
+
"yaml": "^2.4.0"
|
|
16
19
|
},
|
|
17
20
|
"devDependencies": {
|
|
18
21
|
"@babel/core": "^7.0.0",
|
|
@@ -36,9 +39,7 @@
|
|
|
36
39
|
"@babel/register": "^7.0.0",
|
|
37
40
|
"expect.js": "^0.3.1",
|
|
38
41
|
"mocha": "^11.1.0",
|
|
39
|
-
"sinon": "^16.1.1"
|
|
40
|
-
"mocha-junit-reporter": "^2.2.0",
|
|
41
|
-
"mocha-multi-reporters": "1.5.1"
|
|
42
|
+
"sinon": "^16.1.1"
|
|
42
43
|
},
|
|
43
44
|
"files": [
|
|
44
45
|
"src/",
|
|
@@ -55,6 +56,5 @@
|
|
|
55
56
|
},
|
|
56
57
|
"engines": {
|
|
57
58
|
"node": ">=14.18.0"
|
|
58
|
-
}
|
|
59
|
-
"version": "1.0.0-rc6"
|
|
59
|
+
}
|
|
60
60
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const AppConfig = {
|
|
2
|
-
lwaClientId: '<
|
|
3
|
-
lwaClientSecret: '<
|
|
4
|
-
lwaRefreshToken: '<
|
|
2
|
+
lwaClientId: '<REPLACE_WITH_YOUR_CLIENT_ID>',
|
|
3
|
+
lwaClientSecret: '<REPLACE_WITH_YOUR_CLIENT_SECRET>',
|
|
4
|
+
lwaRefreshToken: '<REPLACE_WITH_YOUR_REFRESH_TOKEN>',
|
|
5
|
+
spApiNAEndpoint: 'https://sellingpartnerapi-na.amazon.com'
|
|
5
6
|
}
|
package/sample-node-app/index.js
CHANGED
|
@@ -1,27 +1,158 @@
|
|
|
1
|
-
import { AppConfig } from './app.config.mjs';
|
|
2
|
-
import { LwaAuthClient } from '@amazon-sp-api-release/amazon-sp-api-sdk-js';
|
|
3
|
-
|
|
4
1
|
import {
|
|
5
|
-
|
|
2
|
+
OrdersSpApi,
|
|
3
|
+
SellersSpApi,
|
|
4
|
+
NotificationsSpApi,
|
|
5
|
+
LwaAuthClient,
|
|
6
|
+
ScopeConstants,
|
|
7
|
+
RateLimitConfiguration
|
|
6
8
|
} from '@amazon-sp-api-release/amazon-sp-api-sdk-js';
|
|
9
|
+
import { AppConfig } from './app.config.mjs';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Sample SDK usage of calling Sellers getMarketplaceParticipations API.
|
|
13
|
+
* For Auth&Auth, It uses SDK built in LWA token retriever.
|
|
14
|
+
* All you need to do is call enableAutoRetrivalAccessToken when setting up your ApiClient.
|
|
15
|
+
* Please provide client_id, client_secret and refresh_token when calling this function.
|
|
16
|
+
*/
|
|
17
|
+
async function getMarketplaceParticipations() {
|
|
18
|
+
try {
|
|
19
|
+
//Configure Sellers ApiClient
|
|
20
|
+
const sellersApiClient = new SellersSpApi.ApiClient(AppConfig.spApiNAEndpoint);
|
|
21
|
+
sellersApiClient.enableAutoRetrievalAccessToken(AppConfig.lwaClientId, AppConfig.lwaClientSecret, AppConfig.lwaRefreshToken, null);
|
|
22
|
+
const sellersApi = new SellersSpApi.SellersApi(sellersApiClient);
|
|
23
|
+
|
|
24
|
+
//Call GetMarkerplaceParticipations API
|
|
25
|
+
const participations = await sellersApi.getMarketplaceParticipations();
|
|
26
|
+
console.log(
|
|
27
|
+
JSON.stringify(participations, null, ' ') +
|
|
28
|
+
'\n**********************************'
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error('Exception when calling getMarketplaceParticipations API', error.message);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Sample SDK usage of calling Notifications createDestination API (grantless operation).
|
|
38
|
+
* For Auth&Auth, It uses SDK built in LWA retriever.
|
|
39
|
+
* All you need to do is call enableAutoRetrivalAccessToken when setting up your ApiClient.
|
|
40
|
+
* Please provide client_is, client_secret and scope when calling this function.
|
|
41
|
+
*/
|
|
42
|
+
async function createDestination() {
|
|
43
|
+
try {
|
|
44
|
+
//Configure Notifications ApiClient
|
|
45
|
+
const notificationsApiClient = new NotificationsSpApi.ApiClient(AppConfig.spApiNAEndpoint);
|
|
46
|
+
notificationsApiClient.enableAutoRetrievalAccessToken(AppConfig.lwaClientId, AppConfig.lwaClientSecret, null, ScopeConstants.SCOPE_NOTIFICATION_API);
|
|
47
|
+
const notificationsApi = new NotificationsSpApi.NotificationsApi(notificationsApiClient);
|
|
48
|
+
|
|
49
|
+
//Build createDestination request
|
|
50
|
+
const sqsResource = new NotificationsSpApi.SqsResource('<REPLACE_WITH_YOUR_SQS_QUEUE_ARN>');
|
|
51
|
+
const destinationResourceSpecification = new NotificationsSpApi.DestinationResourceSpecification();
|
|
52
|
+
destinationResourceSpecification.sqs = sqsResource;
|
|
53
|
+
const createDestinationRequest = new NotificationsSpApi.CreateDestinationRequest(destinationResourceSpecification, 'test-destination-name');
|
|
54
|
+
|
|
55
|
+
//Call CreateDestination API
|
|
56
|
+
const createDestinationResponse = await notificationsApi.createDestination(createDestinationRequest);
|
|
57
|
+
console.log(
|
|
58
|
+
JSON.stringify(createDestinationResponse, null, ' ') +
|
|
59
|
+
'\n**********************************'
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
} catch(error) {
|
|
63
|
+
console.error('Exception when calling createDestination API ---', error.message);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Alternatively, you can use our LwaAuthClient helper to maintain your own token cache.
|
|
69
|
+
* This is a sample SDK usage of calling Orders getOrders API.
|
|
70
|
+
* It uses LwaAuthClient in helpr/ to get acess token
|
|
71
|
+
*/
|
|
72
|
+
async function getOrders() {
|
|
73
|
+
try {
|
|
74
|
+
//Set up LwaAuthClient instance
|
|
75
|
+
const lwaAuthClient = new LwaAuthClient(AppConfig.lwaClientId, AppConfig.lwaClientSecret, AppConfig.lwaRefreshToken, null);
|
|
76
|
+
|
|
77
|
+
//Configure Orders ApiClient
|
|
78
|
+
const ordersApiClient = new OrdersSpApi.ApiClient(AppConfig.spApiNAEndpoint);
|
|
79
|
+
ordersApiClient.applyXAmzAccessTokenToRequest(
|
|
80
|
+
await lwaAuthClient.getAccessToken()
|
|
81
|
+
);
|
|
82
|
+
const ordersApi = new OrdersSpApi.OrdersV0Api(ordersApiClient);
|
|
83
|
+
|
|
84
|
+
//Call GetOrders API
|
|
85
|
+
const marketPlaceIds = ['ATVPDKIKX0DER'];
|
|
86
|
+
const opts = {
|
|
87
|
+
createdAfter: '2024-01-01'
|
|
88
|
+
};
|
|
89
|
+
const orders = await ordersApi.getOrders(marketPlaceIds, opts);
|
|
90
|
+
console.log(
|
|
91
|
+
JSON.stringify(orders, null, ' ') +
|
|
92
|
+
'\n**********************************'
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
} catch (error) {
|
|
96
|
+
console.error('Exception when calling getOrders API', error.message);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* We support a built in rate limiter.
|
|
102
|
+
* Here is a sample SDK usage of calling Orders listTransactions API with a rate limiter and retry logic.
|
|
103
|
+
*/
|
|
104
|
+
async function getOrdersWithRateLimiterAndRetry(rateLimitPermit, waitTimeOutInMilliSeconds, burstRequests, retryCount) {
|
|
105
|
+
const ordersApiClient = new OrdersSpApi.ApiClient(AppConfig.spApiNAEndpoint);
|
|
106
|
+
ordersApiClient.enableAutoRetrievalAccessToken(AppConfig.lwaClientId, AppConfig.lwaClientSecret, AppConfig.lwaRefreshToken);
|
|
107
|
+
|
|
108
|
+
// Option1: Use our default rate limiter. Our rate limiter uses the rate limit and burst values in our official document.
|
|
109
|
+
ordersApiClient.enableDefaultRateLimiter();
|
|
110
|
+
|
|
111
|
+
// Option2: Use your customized rate limiter, you need to replace <RateLimit> and <BurstValue> with actual numbers.
|
|
112
|
+
// const rateLimitConfig = new RateLimitConfiguration(<RateLimit>, <BurstValue>);
|
|
113
|
+
// ordersApiClient.enableCustomizedRateLimiter(rateLimitConfig);
|
|
114
|
+
|
|
115
|
+
// Option3: Disable rate limit
|
|
116
|
+
// ordersApiClient.disableRatelimiter();
|
|
117
|
+
|
|
118
|
+
const ordersApi = new OrdersSpApi.OrdersV0Api(ordersApiClient);
|
|
119
|
+
const marketPlaceIds = ['ATVPDKIKX0DER'];
|
|
120
|
+
const opts = {
|
|
121
|
+
createdAfter: '2024-01-01'
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
for (let attempt = 1; attempt <= retryCount; attempt++) {
|
|
125
|
+
try {
|
|
126
|
+
const response = await ordersApi.getOrders(marketPlaceIds, opts);
|
|
127
|
+
console.log(
|
|
128
|
+
JSON.stringify(response, null, ' ') +
|
|
129
|
+
'\n**********************************'
|
|
130
|
+
)
|
|
131
|
+
return response.body;
|
|
132
|
+
} catch (error) {
|
|
133
|
+
const isRateLimit = error.message.includes('Rate limit');
|
|
134
|
+
const isLastAttempt = attempt === retryCount;
|
|
135
|
+
|
|
136
|
+
if (isRateLimit) {
|
|
137
|
+
console.log(`Rate limit reached (Attempt ${attempt}/${retryCount})`);
|
|
138
|
+
|
|
139
|
+
if (!isLastAttempt) {
|
|
140
|
+
// Wait 60 seconds before retry (SP-API getOrders requirement)
|
|
141
|
+
console.log('Waiting 5 seconds before retry...');
|
|
142
|
+
await new Promise(resolve =>
|
|
143
|
+
setTimeout(resolve, 5000)
|
|
144
|
+
);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
7
153
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
);
|
|
14
|
-
const sellerApiClient = new SellersSpApi.ApiClient(
|
|
15
|
-
'https://sellingpartnerapi-na.amazon.com'
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
const sellerApi = new SellersSpApi.SellersApi(sellerApiClient);
|
|
19
|
-
sellerApiClient.applyXAmzAccessTokenToRequest(
|
|
20
|
-
await lwaClient.getAccessToken()
|
|
21
|
-
);
|
|
22
|
-
const participations = await sellerApi.getMarketplaceParticipations();
|
|
23
|
-
console.log(
|
|
24
|
-
JSON.stringify(participations, null, ' ') +
|
|
25
|
-
'\n**********************************'
|
|
26
|
-
);
|
|
27
|
-
})();
|
|
154
|
+
// Uncomment to execute the functions
|
|
155
|
+
// getMarketplaceParticipations();
|
|
156
|
+
// createDestination();
|
|
157
|
+
// getOrders();
|
|
158
|
+
// getOrdersWithRateLimiterAndRetry(3);
|