diff --git a/Amazon-SP-API-CSharp.sln b/Amazon-SP-API-CSharp.sln index cf60c551..5341cd64 100644 --- a/Amazon-SP-API-CSharp.sln +++ b/Amazon-SP-API-CSharp.sln @@ -18,8 +18,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FikaAmazonAPI.SampleCode", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FikaAmazonAPI", "Source\FikaAmazonAPI\FikaAmazonAPI.csproj", "{D6BE954D-174D-4C19-A0B6-46F020878E72}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Source\Tests\Tests.csproj", "{4CB44101-8A9E-454A-B272-038C5FAF9F23}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -34,10 +32,6 @@ Global {D6BE954D-174D-4C19-A0B6-46F020878E72}.Debug|Any CPU.Build.0 = Debug|Any CPU {D6BE954D-174D-4C19-A0B6-46F020878E72}.Release|Any CPU.ActiveCfg = Release|Any CPU {D6BE954D-174D-4C19-A0B6-46F020878E72}.Release|Any CPU.Build.0 = Release|Any CPU - {4CB44101-8A9E-454A-B272-038C5FAF9F23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4CB44101-8A9E-454A-B272-038C5FAF9F23}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4CB44101-8A9E-454A-B272-038C5FAF9F23}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4CB44101-8A9E-454A-B272-038C5FAF9F23}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -45,7 +39,6 @@ Global GlobalSection(NestedProjects) = preSolution {FC494085-19C4-4835-B053-F9B74FFB978A} = {3472E85C-6C29-4196-AA16-B95898241C04} {D6BE954D-174D-4C19-A0B6-46F020878E72} = {3472E85C-6C29-4196-AA16-B95898241C04} - {4CB44101-8A9E-454A-B272-038C5FAF9F23} = {3472E85C-6C29-4196-AA16-B95898241C04} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {F072E7DD-BF35-43CC-BF83-E5947CA2D772} diff --git a/README.md b/README.md index cd2b7731..5b1c064d 100644 --- a/README.md +++ b/README.md @@ -120,41 +120,7 @@ AmazonConnection amazonConnection = new AmazonConnection(new AmazonCredential() ``` -### Multithreaded connections -If multithreading, the following should be done to avoid inadvertantly passing incorrect token data between different threads: -```CSharp - -// Note - you may also write and pass your own implementation of the IRateLimitingHandler interface if required - -var connectionFactory = new AmazonMultithreadedConnectionFactory( - ClientId: "amzn1.application-XXX-client.XXXXXXXXXXXXXXXXXXXXXXXXXXXX", - ClientSecret: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - RefreshToken: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - // a singleton that handles rate limiting across multiple threads - rateLimitingHandler: new RateLimitingHandler()); - -// Then in each concurrent thread/request scope, a new connection can be created like so -var amazonConnection = connectionFactory.RequestScopedConnection( - marketPlaceId: "A2VIGQ35RCS4UG", - sellerId: "MySellerId", - // credentialConfiguration is an optional parameter that allows additional configuration of the AmazonCredential - credentialConfiguration: cred => - { - cred.IsActiveLimitRate = true; - cred.IsDebugMode = true; - }); -// or (remember either Marketplace OR Marketplace ID must be provided) -var amazonConnection = connectionFactory.RequestScopedConnection( - sellerId: "MySellerId", - credentialConfiguration: cred => - { - cred.IsActiveLimitRate = true; - cred.IsDebugMode = true; - cred.Marketplace = MarketPlace.UnitedArabEmirates - }); - -``` ### Configuration using a proxy Please see [here](https://github.com/abuzuhri/Amazon-SP-API-CSharp/blob/main/Source/FikaAmazonAPI.SampleCode/Program.cs) for the relevant code file. diff --git a/Source/FikaAmazonAPI.SampleCode/Program.cs b/Source/FikaAmazonAPI.SampleCode/Program.cs index 447349d7..1af6ad1e 100644 --- a/Source/FikaAmazonAPI.SampleCode/Program.cs +++ b/Source/FikaAmazonAPI.SampleCode/Program.cs @@ -1,6 +1,5 @@ -using FikaAmazonAPI.AmazonSpApiSDK.Models.FbaSmallandLight; -using FikaAmazonAPI.Utils; -using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.SampleCode { @@ -14,32 +13,27 @@ static async Task Main(string[] args) .AddUserSecrets() .Build(); - var connectionFactory = new AmazonMultithreadedConnectionFactory( - ClientId: config.GetSection("FikaAmazonAPI:ClientId").Value, - ClientSecret: config.GetSection("FikaAmazonAPI:ClientSecret").Value, - RefreshToken: config.GetSection("FikaAmazonAPI:RefreshToken").Value, - rateLimitingHandler: new RateLimitingHandler()); + var factory = LoggerFactory.Create(builder => builder.AddConsole()); - var tasks = Enumerable.Range(1, 10).Select(x => - Task.Run(() => + AmazonConnection amazonConnection = new AmazonConnection(new AmazonCredential() { - var amazonConnection = connectionFactory.RequestScopedConnection( - marketPlaceId: config.GetSection("FikaAmazonAPI:MarketPlaceID").Value, - sellerId: config.GetSection("FikaAmazonAPI:SellerId").Value, - credentialConfiguration: cred => - { - cred.IsActiveLimitRate = true; - cred.IsDebugMode = true; - }); - - ReportManagerSample reportManagerSample = new ReportManagerSample(amazonConnection); - reportManagerSample.CallReport(); - })); - - await Task.WhenAll(tasks); - - //var loggingExamples = new SerilogLoggingExamples(config); - //await loggingExamples.ConsoleLoggerExample(); + ClientId = config.GetSection("FikaAmazonAPI:ClientId").Value, + ClientSecret = config.GetSection("FikaAmazonAPI:ClientSecret").Value, + RefreshToken = config.GetSection("FikaAmazonAPI:RefreshToken").Value, + MarketPlaceID = config.GetSection("FikaAmazonAPI:MarketPlaceID").Value, + SellerID = config.GetSection("FikaAmazonAPI:SellerId").Value, + IsDebugMode = true + }, loggerFactory: factory); + + + ReportManagerSample reportManagerSample = new ReportManagerSample(amazonConnection); + reportManagerSample.CallReport(); + //var error = amazonConnection.Reports.CreateReportAndDownloadFile(Utils.Constants.ReportTypes.GET_STRANDED_INVENTORY_UI_DATA); + //var dddd = amazonConnection.Reports.CreateReportAndDownloadFile(Utils.Constants.ReportTypes.GET_FBA_MYI_ALL_INVENTORY_DATA); + //var dddd = amazonConnection.Reports.CreateReportAndDownloadFile(Utils.Constants.ReportTypes.GET_FBA_MYI_UNSUPPRESSED_INVENTORY_DATA); + //ReportManager reportManager = new ReportManager(amazonConnection); + + //var dddddd = reportManager.GetAFNInventoryQtyAsync().ConfigureAwait(false).GetAwaiter().GetResult(); Console.ReadLine(); diff --git a/Source/FikaAmazonAPI/AmazonConnection.cs b/Source/FikaAmazonAPI/AmazonConnection.cs index 4f027648..cf51cc02 100644 --- a/Source/FikaAmazonAPI/AmazonConnection.cs +++ b/Source/FikaAmazonAPI/AmazonConnection.cs @@ -1,10 +1,10 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.Exceptions; using FikaAmazonAPI.Services; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System; using System.Globalization; using System.Threading; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI { @@ -12,9 +12,6 @@ public class AmazonConnection { private readonly ILoggerFactory _loggerFactory; private AmazonCredential Credentials { get; set; } - - private IRateLimitingHandler RateLimitingHandler { get; } - public AppIntegrationsServiceV20240401 AppIntegrationsServiceV20240401 => this._AppIntegrationsServiceV20240401 ?? throw _NoCredentials; public OrderService Orders => this._Orders ?? throw _NoCredentials; public ReportService Reports => this._Reports ?? throw _NoCredentials; @@ -95,12 +92,11 @@ public class AmazonConnection private UnauthorizedAccessException _NoCredentials = new UnauthorizedAccessException($"Error, you cannot make calls to Amazon without credentials!"); public string RefNumber { get; set; } - public AmazonConnection(AmazonCredential Credentials, IRateLimitingHandler rateLimitingHandler = null, string RefNumber = null, CultureInfo? cultureInfo = null, ILoggerFactory? loggerFactory = null) + public AmazonConnection(AmazonCredential Credentials, string RefNumber = null, CultureInfo? cultureInfo = null, ILoggerFactory? loggerFactory = null) { _loggerFactory = loggerFactory; this.Authenticate(Credentials); this.RefNumber = RefNumber; - this.RateLimitingHandler = rateLimitingHandler ?? new RateLimitingHandler(); Thread.CurrentThread.CurrentCulture = cultureInfo ?? CultureInfo.CurrentCulture; } @@ -127,35 +123,35 @@ private void Init(AmazonCredential Credentials) this._CatalogItems = new CatalogItemService(this.Credentials, _loggerFactory); this._ProductPricing = new ProductPricingService(this.Credentials, _loggerFactory); - this._FbaInbound = new FbaInboundService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._FbaInventory = new FbaInventoryService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._FbaOutbound = new FbaOutboundService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._FbaSmallandLight = new FbaSmallandLightService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._FbaInboundEligibility = new FbaInboundEligibilityService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._EasyShip20220323 = new EasyShip20220323Service(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._AplusContent = new AplusContentService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._Feed = new FeedService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._ListingsItem = new ListingsItemService(this.Credentials, _loggerFactory, this.RateLimitingHandler ); - this._Restrictions = new RestrictionService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._MerchantFulfillment = new MerchantFulfillmentService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._Messaging = new MessagingService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._Notification = new NotificationService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._ProductFee = new ProductFeeService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._ProductType = new ProductTypeService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._Sales = new SalesService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._Seller = new SellerService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._Services = new ServicesService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._ShipmentInvoicing = new ShipmentInvoicingService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._Shipping = new ShippingService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._ShippingV2 = new ShippingServiceV2(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._Upload = new UploadService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._Tokens = new TokenService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._FulFillmentInbound = new FulFillmentInboundService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._FulFillmentInboundv20240320 = new FulFillmentInboundServicev20240320(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._FulFillmentOutbound = new FulFillmentOutboundService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._VendorDirectFulfillmentOrders = new VendorDirectFulfillmentOrderService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._VendorOrders = new VendorOrderService(this.Credentials, _loggerFactory, this.RateLimitingHandler); - this._VendorTransactionStatus = new VendorTransactionStatusService(this.Credentials, _loggerFactory, this.RateLimitingHandler); + this._FbaInbound = new FbaInboundService(this.Credentials, _loggerFactory); + this._FbaInventory = new FbaInventoryService(this.Credentials, _loggerFactory); + this._FbaOutbound = new FbaOutboundService(this.Credentials, _loggerFactory); + this._FbaSmallandLight = new FbaSmallandLightService(this.Credentials, _loggerFactory); + this._FbaInboundEligibility = new FbaInboundEligibilityService(this.Credentials, _loggerFactory); + this._EasyShip20220323 = new EasyShip20220323Service(this.Credentials, _loggerFactory); + this._AplusContent = new AplusContentService(this.Credentials, _loggerFactory); + this._Feed = new FeedService(this.Credentials, _loggerFactory); + this._ListingsItem = new ListingsItemService(this.Credentials, _loggerFactory); + this._Restrictions = new RestrictionService(this.Credentials, _loggerFactory); + this._MerchantFulfillment = new MerchantFulfillmentService(this.Credentials, _loggerFactory); + this._Messaging = new MessagingService(this.Credentials, _loggerFactory); + this._Notification = new NotificationService(this.Credentials, _loggerFactory); + this._ProductFee = new ProductFeeService(this.Credentials, _loggerFactory); + this._ProductType = new ProductTypeService(this.Credentials, _loggerFactory); + this._Sales = new SalesService(this.Credentials, _loggerFactory); + this._Seller = new SellerService(this.Credentials, _loggerFactory); + this._Services = new ServicesService(this.Credentials, _loggerFactory); + this._ShipmentInvoicing = new ShipmentInvoicingService(this.Credentials, _loggerFactory); + this._Shipping = new ShippingService(this.Credentials, _loggerFactory); + this._ShippingV2 = new ShippingServiceV2(this.Credentials, _loggerFactory); + this._Upload = new UploadService(this.Credentials, _loggerFactory); + this._Tokens = new TokenService(this.Credentials, _loggerFactory); + this._FulFillmentInbound = new FulFillmentInboundService(this.Credentials, _loggerFactory); + this._FulFillmentInboundv20240320 = new FulFillmentInboundServicev20240320(this.Credentials, _loggerFactory); + this._FulFillmentOutbound = new FulFillmentOutboundService(this.Credentials, _loggerFactory); + this._VendorDirectFulfillmentOrders = new VendorDirectFulfillmentOrderService(this.Credentials, _loggerFactory); + this._VendorOrders = new VendorOrderService(this.Credentials, _loggerFactory); + this._VendorTransactionStatus = new VendorTransactionStatusService(this.Credentials, _loggerFactory); AmazonCredential.DebugMode = this.Credentials.IsDebugMode; } diff --git a/Source/FikaAmazonAPI/AmazonCredential.cs b/Source/FikaAmazonAPI/AmazonCredential.cs index 5ac49fb2..8caa8ddf 100644 --- a/Source/FikaAmazonAPI/AmazonCredential.cs +++ b/Source/FikaAmazonAPI/AmazonCredential.cs @@ -1,5 +1,6 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.Token; using FikaAmazonAPI.Utils; +using System.Collections.Generic; using static FikaAmazonAPI.AmazonSpApiSDK.Models.Token.CacheTokenData; using static FikaAmazonAPI.Utils.Constants; @@ -57,5 +58,7 @@ public void SetAWSAuthenticationTokenData(AWSAuthenticationTokenData tokenData) { CacheTokenData.SetAWSAuthenticationTokenData(tokenData); } + + internal Dictionary UsagePlansTimings { get; set; } = RateLimitsDefinitions.RateLimitsTime(); } } diff --git a/Source/FikaAmazonAPI/AmazonMultithreadedConnectionFactory.cs b/Source/FikaAmazonAPI/AmazonMultithreadedConnectionFactory.cs deleted file mode 100644 index 73a5e399..00000000 --- a/Source/FikaAmazonAPI/AmazonMultithreadedConnectionFactory.cs +++ /dev/null @@ -1,58 +0,0 @@ -using FikaAmazonAPI.Utils; -using System; -using System.Globalization; - -namespace FikaAmazonAPI -{ - public class AmazonMultithreadedConnectionFactory - { - private readonly string _accessKey; - private readonly string _secretKey; - private readonly string _roleArn; - private readonly string _clientId; - private readonly string _clientSecret; - private readonly string _refreshToken; - private readonly string _proxyAddress; - - private readonly IRateLimitingHandler _rateLimitingHandler; - - public AmazonMultithreadedConnectionFactory( - string ClientId, - string ClientSecret, - string RefreshToken, - string AccessKey = null, - string SecretKey = null, - string RoleArn = null, - string ProxyAddress = null, - IRateLimitingHandler rateLimitingHandler = null) - { - _accessKey = AccessKey; - _secretKey = SecretKey; - _roleArn = RoleArn; - _clientId = ClientId; - _clientSecret = ClientSecret; - _refreshToken = RefreshToken; - _proxyAddress = ProxyAddress; - - _rateLimitingHandler = rateLimitingHandler ?? new RateLimitingHandler(); - } - - public AmazonConnection RequestScopedConnection( - string marketPlaceId = null, - string sellerId = null, - string refCode = null, - Action credentialConfiguration = null, - CultureInfo cultureInfo = null) - { - // need to create distinct credential/connection here so that token caching in credential is predicably kept within scope - var credential = new AmazonCredential(_accessKey, _secretKey, _roleArn, _clientId, _clientSecret, _refreshToken, _proxyAddress) - { - MarketPlaceID = marketPlaceId, - SellerID = sellerId, - }; - credentialConfiguration?.Invoke(credential); - - return new AmazonConnection(credential, _rateLimitingHandler, refCode, cultureInfo); - } - } -} diff --git a/Source/FikaAmazonAPI/Services/AplusContentService.cs b/Source/FikaAmazonAPI/Services/AplusContentService.cs index fe4ecdb7..4b7519e0 100644 --- a/Source/FikaAmazonAPI/Services/AplusContentService.cs +++ b/Source/FikaAmazonAPI/Services/AplusContentService.cs @@ -1,5 +1,4 @@ -using FikaAmazonAPI.Utils; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { @@ -7,7 +6,7 @@ namespace FikaAmazonAPI.Services public class AplusContentService : RequestService { - public AplusContentService(AmazonCredential amazonCredential,ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public AplusContentService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/AppIntegrationsV20240401.cs b/Source/FikaAmazonAPI/Services/AppIntegrationsV20240401.cs index 9f82b0f4..cf0d9be2 100644 --- a/Source/FikaAmazonAPI/Services/AppIntegrationsV20240401.cs +++ b/Source/FikaAmazonAPI/Services/AppIntegrationsV20240401.cs @@ -1,17 +1,14 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.AppIntegrationsV20240401; using FikaAmazonAPI.Utils; -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; -using System.Threading; using Microsoft.Extensions.Logging; +using System.Threading; +using System.Threading.Tasks; namespace FikaAmazonAPI.Services { - public class AppIntegrationsServiceV20240401: RequestService + public class AppIntegrationsServiceV20240401 : RequestService { - public AppIntegrationsServiceV20240401(AmazonCredential amazonCredential,ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public AppIntegrationsServiceV20240401(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/AuthorizationService.cs b/Source/FikaAmazonAPI/Services/AuthorizationService.cs index 379e2bb7..c404b4c6 100644 --- a/Source/FikaAmazonAPI/Services/AuthorizationService.cs +++ b/Source/FikaAmazonAPI/Services/AuthorizationService.cs @@ -1,17 +1,16 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.Authorization; using FikaAmazonAPI.AmazonSpApiSDK.Models.Token; using FikaAmazonAPI.Parameter.Authorization; -using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; using static FikaAmazonAPI.AmazonSpApiSDK.Models.Token.CacheTokenData; namespace FikaAmazonAPI.Services { public class AuthorizationService : RequestService { - public AuthorizationService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public AuthorizationService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } public string GetAuthorizationCode(ParameterAuthorizationCode parameterGetOrderMetrics) => diff --git a/Source/FikaAmazonAPI/Services/CatalogItemService.cs b/Source/FikaAmazonAPI/Services/CatalogItemService.cs index 6dd32466..3b1e25ea 100644 --- a/Source/FikaAmazonAPI/Services/CatalogItemService.cs +++ b/Source/FikaAmazonAPI/Services/CatalogItemService.cs @@ -2,32 +2,32 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.CatalogItems.V20220401; using FikaAmazonAPI.Parameter.CatalogItems; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; using Item = FikaAmazonAPI.AmazonSpApiSDK.Models.CatalogItems.Item; namespace FikaAmazonAPI.Services { public class CatalogItemService : RequestService { - public CatalogItemService(AmazonCredential amazonCredential,ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public CatalogItemService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } [Obsolete("This method deprecated in June 2022. Please use SearchCatalogItems202204 instead.", false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public IList ListCatalogItems(ParameterListCatalogItems parameterListCatalogItems) => + [EditorBrowsable(EditorBrowsableState.Never)] + public IList ListCatalogItems(ParameterListCatalogItems parameterListCatalogItems) => Task.Run(() => ListCatalogItemsAsync(parameterListCatalogItems)).ConfigureAwait(false).GetAwaiter().GetResult(); [Obsolete("This method deprecated in June 2022. Please use SearchCatalogItems202204Async instead.", false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public async Task> ListCatalogItemsAsync(ParameterListCatalogItems parameterListCatalogItems) + [EditorBrowsable(EditorBrowsableState.Never)] + public async Task> ListCatalogItemsAsync(ParameterListCatalogItems parameterListCatalogItems) { if (string.IsNullOrEmpty(parameterListCatalogItems.MarketplaceId)) parameterListCatalogItems.MarketplaceId = AmazonCredential.MarketPlace.ID; @@ -75,12 +75,12 @@ public async Task GetCatalogItemAsyncJson(string asin) return null; } [Obsolete("This method deprecated in June 2022. Please use GetCatalogItem(ParameterGetCatalogItem parameterListCatalogItem) instead.", true)] - [EditorBrowsable(EditorBrowsableState.Never)] - public Item GetCatalogItem(string asin) => + [EditorBrowsable(EditorBrowsableState.Never)] + public Item GetCatalogItem(string asin) => Task.Run(() => GetCatalogItemAsync(asin)).ConfigureAwait(false).GetAwaiter().GetResult(); [Obsolete("This method deprecated in June 2022. Please use GetCatalogItem(ParameterGetCatalogItem parameterListCatalogItem) instead.", true)] - [EditorBrowsable(EditorBrowsableState.Never)] - public async Task GetCatalogItemAsync(string asin) + [EditorBrowsable(EditorBrowsableState.Never)] + public async Task GetCatalogItemAsync(string asin) { if (string.IsNullOrEmpty(asin)) @@ -180,7 +180,7 @@ public AmazonSpApiSDK.Models.CatalogItems.V20220401.Item GetCatalogItem202204(Pa var nextToken = response.Pagination.NextToken; while (!string.IsNullOrEmpty(nextToken) && (!parameter.maxPages.HasValue || totalPages < parameter.maxPages.Value)) { - parameter.pageToken = nextToken; + parameter.pageToken = nextToken; var getItemNextPage = await SearchCatalogItemsByNextToken202204Async(parameter, cancellationToken); list.AddRange(getItemNextPage.Items); nextToken = getItemNextPage.Pagination?.NextToken; diff --git a/Source/FikaAmazonAPI/Services/EasyShip20220323Service.cs b/Source/FikaAmazonAPI/Services/EasyShip20220323Service.cs index 7c81d849..48df976d 100644 --- a/Source/FikaAmazonAPI/Services/EasyShip20220323Service.cs +++ b/Source/FikaAmazonAPI/Services/EasyShip20220323Service.cs @@ -1,15 +1,15 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.EasyShip20220323; using FikaAmazonAPI.Parameter.EasyShip; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class EasyShip20220323Service : RequestService { - public EasyShip20220323Service(AmazonCredential amazonCredential,ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public EasyShip20220323Service(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/FbaInboundEligibilityService.cs b/Source/FikaAmazonAPI/Services/FbaInboundEligibilityService.cs index 06e527da..5a7e9663 100644 --- a/Source/FikaAmazonAPI/Services/FbaInboundEligibilityService.cs +++ b/Source/FikaAmazonAPI/Services/FbaInboundEligibilityService.cs @@ -1,15 +1,15 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.FbaInbound; using FikaAmazonAPI.Parameter.FbaInboundEligibility; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class FbaInboundEligibilityService : RequestService { - public FbaInboundEligibilityService(AmazonCredential amazonCredential,ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public FbaInboundEligibilityService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/FbaInboundService.cs b/Source/FikaAmazonAPI/Services/FbaInboundService.cs index 6f9994c4..ad687b1a 100644 --- a/Source/FikaAmazonAPI/Services/FbaInboundService.cs +++ b/Source/FikaAmazonAPI/Services/FbaInboundService.cs @@ -1,11 +1,10 @@ -using FikaAmazonAPI.Utils; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class FbaInboundService : RequestService { - public FbaInboundService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public FbaInboundService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/FbaInventoryService.cs b/Source/FikaAmazonAPI/Services/FbaInventoryService.cs index 0aeeb718..b2b6ac04 100644 --- a/Source/FikaAmazonAPI/Services/FbaInventoryService.cs +++ b/Source/FikaAmazonAPI/Services/FbaInventoryService.cs @@ -1,17 +1,17 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.FbaInventory; using FikaAmazonAPI.Parameter.FbaInventory; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class FbaInventoryService : RequestService { - public FbaInventoryService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public FbaInventoryService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } @@ -39,7 +39,7 @@ public async Task> GetInventorySummariesAsync(Parameter var nextToken = response.Pagination.NextToken; while (!string.IsNullOrEmpty(nextToken)) { - var getInventorySummaries = await GetInventorySummariesByNextTokenAsync(nextToken, parameter, cancellationToken); + var getInventorySummaries = await GetInventorySummariesByNextTokenAsync(nextToken, parameter, cancellationToken); list.Add(getInventorySummaries.Payload.InventorySummaries); nextToken = getInventorySummaries.Pagination?.NextToken; } diff --git a/Source/FikaAmazonAPI/Services/FbaOutboundService.cs b/Source/FikaAmazonAPI/Services/FbaOutboundService.cs index ef20da54..a040f50f 100644 --- a/Source/FikaAmazonAPI/Services/FbaOutboundService.cs +++ b/Source/FikaAmazonAPI/Services/FbaOutboundService.cs @@ -1,11 +1,10 @@ -using FikaAmazonAPI.Utils; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class FbaOutboundService : RequestService { - public FbaOutboundService(AmazonCredential amazonCredential,ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public FbaOutboundService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/FbaSmallandLightService.cs b/Source/FikaAmazonAPI/Services/FbaSmallandLightService.cs index 6dae01fb..23787d42 100644 --- a/Source/FikaAmazonAPI/Services/FbaSmallandLightService.cs +++ b/Source/FikaAmazonAPI/Services/FbaSmallandLightService.cs @@ -1,16 +1,16 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.FbaSmallandLight; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class FbaSmallandLightService : RequestService { - public FbaSmallandLightService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory,IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential,loggerFactory, rateLimitingHandler) + public FbaSmallandLightService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/FeedService.cs b/Source/FikaAmazonAPI/Services/FeedService.cs index 3b462531..692c318b 100644 --- a/Source/FikaAmazonAPI/Services/FeedService.cs +++ b/Source/FikaAmazonAPI/Services/FeedService.cs @@ -4,6 +4,7 @@ using FikaAmazonAPI.ConstructFeed.Messages; using FikaAmazonAPI.Parameter.Feed; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.ComponentModel; @@ -12,7 +13,6 @@ using System.Net; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; using static FikaAmazonAPI.Utils.Constants; namespace FikaAmazonAPI.Services @@ -20,7 +20,7 @@ namespace FikaAmazonAPI.Services public class FeedService : RequestService { - public FeedService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public FeedService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/FinancialService.cs b/Source/FikaAmazonAPI/Services/FinancialService.cs index 4269f021..0792d2fc 100644 --- a/Source/FikaAmazonAPI/Services/FinancialService.cs +++ b/Source/FikaAmazonAPI/Services/FinancialService.cs @@ -1,16 +1,16 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.Finances; using FikaAmazonAPI.Parameter.Finance; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class FinancialService : RequestService { - public FinancialService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public FinancialService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/FulFillmentInboundService.cs b/Source/FikaAmazonAPI/Services/FulFillmentInboundService.cs index 9fab6f67..357c0a29 100644 --- a/Source/FikaAmazonAPI/Services/FulFillmentInboundService.cs +++ b/Source/FikaAmazonAPI/Services/FulFillmentInboundService.cs @@ -1,17 +1,17 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.FulfillmentInbound; using FikaAmazonAPI.Parameter.FulFillmentInbound; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class FulFillmentInboundService : RequestService { - public FulFillmentInboundService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public FulFillmentInboundService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/FulFillmentInboundServicev20240320.cs b/Source/FikaAmazonAPI/Services/FulFillmentInboundServicev20240320.cs index 948761d4..37892c9b 100644 --- a/Source/FikaAmazonAPI/Services/FulFillmentInboundServicev20240320.cs +++ b/Source/FikaAmazonAPI/Services/FulFillmentInboundServicev20240320.cs @@ -1,16 +1,16 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.FulfillmentInboundv20240320; using FikaAmazonAPI.Parameter.FulFillmentInbound.v20240320; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class FulFillmentInboundServicev20240320 : RequestService { - public FulFillmentInboundServicev20240320(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public FulFillmentInboundServicev20240320(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } @@ -752,7 +752,7 @@ public async Task> GetSelfShipAppoint var nextToken = response.Pagination.NextToken; while (!string.IsNullOrEmpty(nextToken) && (!parameterListShipmentBase.maxPages.HasValue || totalPages < parameterListShipmentBase.maxPages.Value)) { - parameterListShipmentBase.PaginationToken = nextToken; + parameterListShipmentBase.PaginationToken = nextToken; var getItemNextPage = await GetSelfShipAppointmentSlotsByNextTokenAsync(parameterListShipmentBase, cancellationToken); list.Add(getItemNextPage.SelfShipAppointmentSlotsAvailability); nextToken = getItemNextPage.Pagination?.NextToken; @@ -950,11 +950,11 @@ public SetPrepDetailsResponse SetPrepDetails(SetPrepDetailsRequest setPrepDetail public async Task SetPrepDetailsAsync(SetPrepDetailsRequest setPrepDetailsRequest, CancellationToken cancellationToken = default) { - if (string.IsNullOrWhiteSpace(setPrepDetailsRequest.MarketplaceId)) + if (string.IsNullOrWhiteSpace(setPrepDetailsRequest.MarketplaceId)) { setPrepDetailsRequest.MarketplaceId = AmazonCredential.MarketPlace.ID; } - + await CreateAuthorizedRequestAsync(FulFillmentInboundApiUrls.SetPrepDetails, RestSharp.Method.Post, postJsonObj: setPrepDetailsRequest, cancellationToken: cancellationToken); return await ExecuteRequestAsync(RateLimitType.FulFillmentInboundV20240320_SetPrepDetails, cancellationToken); } @@ -970,6 +970,6 @@ public async Task GetInboundOperationStatusAsync(string return await ExecuteRequestAsync(RateLimitType.FulFillmentInboundV20240320_GetInboundOperationStatus, cancellationToken); } #endregion - } } +} diff --git a/Source/FikaAmazonAPI/Services/FulFillmentOutboundService.cs b/Source/FikaAmazonAPI/Services/FulFillmentOutboundService.cs index 64be45af..1f8c20c3 100644 --- a/Source/FikaAmazonAPI/Services/FulFillmentOutboundService.cs +++ b/Source/FikaAmazonAPI/Services/FulFillmentOutboundService.cs @@ -2,16 +2,16 @@ using FikaAmazonAPI.Parameter.FulFillmentInbound; using FikaAmazonAPI.Parameter.FulFillmentOutbound; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class FulFillmentOutboundService : RequestService { - public FulFillmentOutboundService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory,IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public FulFillmentOutboundService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/ListingsItemService.cs b/Source/FikaAmazonAPI/Services/ListingsItemService.cs index 71d26598..52b66727 100644 --- a/Source/FikaAmazonAPI/Services/ListingsItemService.cs +++ b/Source/FikaAmazonAPI/Services/ListingsItemService.cs @@ -1,16 +1,16 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.ListingsItems; using FikaAmazonAPI.Parameter.ListingItem; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class ListingsItemService : RequestService { - public ListingsItemService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null ) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public ListingsItemService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/MerchantFulfillmentService.cs b/Source/FikaAmazonAPI/Services/MerchantFulfillmentService.cs index c4988332..61bfbdbf 100644 --- a/Source/FikaAmazonAPI/Services/MerchantFulfillmentService.cs +++ b/Source/FikaAmazonAPI/Services/MerchantFulfillmentService.cs @@ -2,17 +2,17 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.Token; using FikaAmazonAPI.Search; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class MerchantFulfillmentService : RequestService { - public MerchantFulfillmentService(AmazonCredential amazonCredential,ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public MerchantFulfillmentService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/MessagingService.cs b/Source/FikaAmazonAPI/Services/MessagingService.cs index 9c6ed8bf..425f28c8 100644 --- a/Source/FikaAmazonAPI/Services/MessagingService.cs +++ b/Source/FikaAmazonAPI/Services/MessagingService.cs @@ -1,16 +1,16 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.Messaging; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class MessagingService : RequestService { - public MessagingService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public MessagingService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/NotificationService.cs b/Source/FikaAmazonAPI/Services/NotificationService.cs index 3753b61b..93c66382 100644 --- a/Source/FikaAmazonAPI/Services/NotificationService.cs +++ b/Source/FikaAmazonAPI/Services/NotificationService.cs @@ -4,13 +4,13 @@ using FikaAmazonAPI.NotificationMessages; using FikaAmazonAPI.Parameter.Notification; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; using static FikaAmazonAPI.AmazonSpApiSDK.Models.Token.CacheTokenData; using static FikaAmazonAPI.Utils.Constants; @@ -18,7 +18,7 @@ namespace FikaAmazonAPI.Services { public class NotificationService : RequestService { - public NotificationService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public NotificationService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/OrderService.cs b/Source/FikaAmazonAPI/Services/OrderService.cs index dabd8202..0d50f25f 100644 --- a/Source/FikaAmazonAPI/Services/OrderService.cs +++ b/Source/FikaAmazonAPI/Services/OrderService.cs @@ -1,19 +1,18 @@ -using System; -using FikaAmazonAPI.AmazonSpApiSDK.Models.Orders; +using FikaAmazonAPI.AmazonSpApiSDK.Models.Orders; using FikaAmazonAPI.AmazonSpApiSDK.Models.Token; using FikaAmazonAPI.Parameter.Order; using FikaAmazonAPI.Search; +using Microsoft.Extensions.Logging; +using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using FikaAmazonAPI.Utils; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class OrderService : RequestService { - public OrderService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public OrderService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } @@ -98,7 +97,7 @@ public async Task GetGetOrdersByNextTokenAsync(string nextToken, Par #endregion #region GetOrders - + public async Task GetOrdersAsync(ParameterOrderList searchOrderList) { var orderList = new OrderList(); @@ -138,7 +137,7 @@ public async Task GetOrdersAsync(ParameterOrderList searchOrderList) return orderList; } - + public async Task GetGetOrdersByNextTokenAsync(string nextToken, ParameterOrderList searchOrderList) { var parameterOrderList = new ParameterOrderList @@ -146,18 +145,18 @@ public async Task GetGetOrdersByNextTokenAsync(string nextToken, Par MarketplaceIds = searchOrderList.MarketplaceIds, NextToken = nextToken, IsNeedRestrictedDataToken = searchOrderList.IsNeedRestrictedDataToken, - RestrictedDataTokenRequest = searchOrderList.RestrictedDataTokenRequest + RestrictedDataTokenRequest = searchOrderList.RestrictedDataTokenRequest }; List> queryParameters = parameterOrderList.getParameters(); - + await CreateAuthorizedRequestAsync(OrdersApiUrls.Orders, RestSharp.Method.Get, queryParameters, parameter: parameterOrderList); - + var response = await ExecuteRequestAsync(Utils.RateLimitType.Order_GetOrders); - + return response.Payload; } - + public OrdersList GetOrdersList(ParameterOrderList searchOrderList) => Task.Run(() => GetOrdersListAsync(searchOrderList)).ConfigureAwait(false).GetAwaiter().GetResult(); public async Task GetOrdersListAsync(ParameterOrderList searchOrderList) diff --git a/Source/FikaAmazonAPI/Services/ProductFeeService.cs b/Source/FikaAmazonAPI/Services/ProductFeeService.cs index 9f74bea1..3d4a855a 100644 --- a/Source/FikaAmazonAPI/Services/ProductFeeService.cs +++ b/Source/FikaAmazonAPI/Services/ProductFeeService.cs @@ -1,15 +1,15 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.ProductFees; using FikaAmazonAPI.Parameter.ProductFee; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class ProductFeeService : RequestService { - public ProductFeeService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public ProductFeeService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/ProductPricingService.cs b/Source/FikaAmazonAPI/Services/ProductPricingService.cs index d17da835..291af69f 100644 --- a/Source/FikaAmazonAPI/Services/ProductPricingService.cs +++ b/Source/FikaAmazonAPI/Services/ProductPricingService.cs @@ -1,21 +1,21 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.ProductPricing; +using FikaAmazonAPI.AmazonSpApiSDK.Models.ProductPricing.v2022_05_01; using FikaAmazonAPI.Parameter.ProductPricing; +using FikaAmazonAPI.Parameter.ProductPricing.v2022_05_01; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; -using FikaAmazonAPI.AmazonSpApiSDK.Models.ProductPricing.v2022_05_01; -using FikaAmazonAPI.Parameter.ProductPricing.v2022_05_01; -using Microsoft.Extensions.Logging; using Price = FikaAmazonAPI.AmazonSpApiSDK.Models.ProductPricing.Price; namespace FikaAmazonAPI.Services { public class ProductPricingService : RequestService { - public ProductPricingService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public ProductPricingService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } @@ -146,7 +146,7 @@ public async Task GetListingOffersBatchAsync(ParameterGe public GetFeaturedOfferExpectedPriceBatchResponse GetFeaturedOfferExpectedPriceBatch( GetFeaturedOfferExpectedPriceBatchRequest getFeaturedOfferExpectedPriceBatchRequest) { - return Task.Run(() => GetFeaturedOfferExpectedPriceBatchAsync(getFeaturedOfferExpectedPriceBatchRequest)).ConfigureAwait(false).GetAwaiter().GetResult(); + return Task.Run(() => GetFeaturedOfferExpectedPriceBatchAsync(getFeaturedOfferExpectedPriceBatchRequest)).ConfigureAwait(false).GetAwaiter().GetResult(); } /// @@ -174,6 +174,6 @@ public async Task GetFeaturedOfferEx } #endregion - + } } diff --git a/Source/FikaAmazonAPI/Services/ProductTypeService.cs b/Source/FikaAmazonAPI/Services/ProductTypeService.cs index 6bacb4e1..e9890ad3 100644 --- a/Source/FikaAmazonAPI/Services/ProductTypeService.cs +++ b/Source/FikaAmazonAPI/Services/ProductTypeService.cs @@ -1,15 +1,15 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.ProductTypes; using FikaAmazonAPI.Parameter.ProductTypes; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class ProductTypeService : RequestService { - public ProductTypeService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public ProductTypeService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/ReportService.cs b/Source/FikaAmazonAPI/Services/ReportService.cs index c15ca639..ac528900 100644 --- a/Source/FikaAmazonAPI/Services/ReportService.cs +++ b/Source/FikaAmazonAPI/Services/ReportService.cs @@ -4,20 +4,20 @@ using FikaAmazonAPI.Parameter; using FikaAmazonAPI.Parameter.Report; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; using static FikaAmazonAPI.Utils.Constants; namespace FikaAmazonAPI.Services { public class ReportService : RequestService { - public ReportService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public ReportService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } #region GetReport diff --git a/Source/FikaAmazonAPI/Services/RequestService.cs b/Source/FikaAmazonAPI/Services/RequestService.cs index 1339ef1c..a513a496 100644 --- a/Source/FikaAmazonAPI/Services/RequestService.cs +++ b/Source/FikaAmazonAPI/Services/RequestService.cs @@ -4,18 +4,17 @@ using FikaAmazonAPI.AmazonSpApiSDK.Services; using FikaAmazonAPI.Search; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using RestSharp; using RestSharp.Serializers.NewtonsoftJson; using System; using System.Collections.Generic; -using System.Diagnostics; using System.Globalization; using System.Linq; using System.Net; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; using static FikaAmazonAPI.AmazonSpApiSDK.Models.Token.CacheTokenData; using static FikaAmazonAPI.Utils.Constants; @@ -25,6 +24,7 @@ public class RequestService : ApiUrls { public static readonly string AccessTokenHeaderName = "x-amz-access-token"; public static readonly string SecurityTokenHeaderName = "x-amz-security-token"; + private readonly string RateLimitLimitHeaderName = "x-amzn-RateLimit-Limit"; public static readonly string ShippingBusinessIdHeaderName = "x-amzn-shipping-business-id"; protected RestClient RequestClient { get; set; } protected RestRequest Request { get; set; } @@ -33,7 +33,6 @@ public class RequestService : ApiUrls protected string AmazonProductionUrl { get; set; } protected string AccessToken { get; set; } protected IList> LastHeaders { get; set; } - private IRateLimitingHandler RateLimitingHandler { get; } protected string ApiBaseUrl { @@ -49,11 +48,9 @@ protected string ApiBaseUrl /// Creates request base service /// /// A credential containing the API user's information and cached token values - /// A singleton designed to handle concurrent requests based on the rate limiting policy - public RequestService(AmazonCredential amazonCredential,ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) + /// A singleton + public RequestService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) { - RateLimitingHandler = rateLimitingHandler ?? new RateLimitingHandler(); - _logger = loggerFactory?.CreateLogger(); AmazonCredential = amazonCredential; AmazonSandboxUrl = amazonCredential.MarketPlace.Region.SandboxHostUrl; @@ -121,8 +118,7 @@ protected void CreateAuthorizedPagedRequest(AmazonFilter filter, string url, Res /// /// Type to parse response to /// Returns data of T type - protected async Task ExecuteRequestTry( - RateLimitType rateLimitType = RateLimitType.UNSET, + protected async Task ExecuteRequestTry(RateLimitType rateLimitType = RateLimitType.UNSET, CancellationToken cancellationToken = default) where T : new() { RestHeader(); @@ -131,18 +127,10 @@ protected async Task ExecuteRequestTry( //Remove AWS authorization //Request = await TokenGeneration.SignWithSTSKeysAndSecurityTokenAsync(Request, RequestClient.Options.BaseUrl.Host, AmazonCredential, cancellationToken); - var response = await RateLimitingHandler.SafelyExecuteRequestAsync( - RequestClient, - Request, - AmazonCredential, - rateLimitType, - responseCallback: response => - { - LogRequest(Request, response); - SaveLastRequestHeader(response.Headers); - }, - cancellationToken: cancellationToken); - + var response = await RequestClient.ExecuteAsync(Request, cancellationToken); + LogRequest(Request, response); + SaveLastRequestHeader(response.Headers); + await SleepForRateLimit(response.Headers, rateLimitType, cancellationToken); ParseResponse(response); if (response.StatusCode == HttpStatusCode.OK && !string.IsNullOrEmpty(response.Content) && @@ -169,39 +157,42 @@ private void SaveLastRequestHeader(IReadOnlyCollection new + var requestToLog = new { - name = parameter.Name, - value = parameter.Value, - type = parameter.Type.ToString() - }).ToList(), - // ToString() here to have the method as a nice string otherwise it will just show the enum value - method = request.Method.ToString(), - // This will generate the actual Uri used in the request - //uri = request. _restClient.BuildUri(request), - }; - - //remove the access token from the headers - requestToLog.parameters.RemoveAll(p => p.name == "x-amz-access-token"); - - var responseToLog = new - { - statusCode = response.StatusCode, - content = response.Content, - headers = response.Headers.Select(h => new + resource = request.Resource, + parameters = request.Parameters.Select(parameter => new + { + name = parameter.Name, + value = parameter.Value, + type = parameter.Type.ToString() + }).ToList(), + // ToString() here to have the method as a nice string otherwise it will just show the enum value + method = request.Method.ToString(), + // This will generate the actual Uri used in the request + //uri = request. _restClient.BuildUri(request), + }; + + //remove the access token from the headers + requestToLog.parameters.RemoveAll(p => p.name == "x-amz-access-token"); + + var responseToLog = new { - name = h.Name, - value = h.Value - }), - // The Uri that actually responded (could be different from the requestUri if a redirection occurred) - responseUri = response.ResponseUri, - errorMessage = response.ErrorMessage, - }; - //There are PII considerations here - _logger?.LogInformation("Request completed, \nRequest: {@request} \n\nResponse: {@response}", requestToLog, responseToLog); + statusCode = response.StatusCode, + content = response.Content, + headers = response.Headers.Select(h => new + { + name = h.Name, + value = h.Value + }), + // The Uri that actually responded (could be different from the requestUri if a redirection occurred) + responseUri = response.ResponseUri, + errorMessage = response.ErrorMessage, + }; + //There are PII considerations here + _logger?.LogInformation("Request completed, \nRequest: {@request} \n\nResponse: {@response}", requestToLog, responseToLog); + } } private void RestHeader() @@ -234,20 +225,60 @@ public async Task ExecuteRequestAsync(RateLimitType rateLimitType = RateLi catch (AmazonQuotaExceededException ex) { if (tryCount >= AmazonCredential.MaxThrottledRetryCount) - { - _logger?.LogWarning("Throttle max try count reached"); + { + if (AmazonCredential.IsDebugMode) + _logger?.LogWarning("Throttle max try count reached"); throw; } cancellationToken.ThrowIfCancellationRequested(); - await RateLimitingHandler.WaitForLimitTypeAsync(AmazonCredential, rateLimitType, cancellationToken); + await AmazonCredential.UsagePlansTimings[rateLimitType].Delay(); tryCount++; } } } + private async Task SleepForRateLimit(IReadOnlyCollection headers, + RateLimitType rateLimitType = RateLimitType.UNSET, CancellationToken cancellationToken = default) + { + try + { + decimal rate = 0; + var limitHeader = headers.FirstOrDefault(a => a.Name == RateLimitLimitHeaderName); + if (limitHeader != null) + { + var RateLimitValue = limitHeader.Value.ToString(); + decimal.TryParse(RateLimitValue, NumberStyles.Any, CultureInfo.InvariantCulture, out rate); + } + + if (AmazonCredential.IsActiveLimitRate) + { + if (rateLimitType == RateLimitType.UNSET) + { + if (rate > 0) + { + int sleepTime = (int)(1 / rate * 1000); + await Task.Delay(sleepTime, cancellationToken); + } + } + else + { + if (rate > 0) + { + AmazonCredential.UsagePlansTimings[rateLimitType].SetRateLimit(rate); + } + + await AmazonCredential.UsagePlansTimings[rateLimitType].NextRate(rateLimitType); + } + } + } + catch (Exception e) + { + } + } + protected void ParseResponse(RestResponse response) { if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Accepted || @@ -259,8 +290,8 @@ protected void ParseResponse(RestResponse response) } else { - - _logger?.LogWarning("Amazon Api didn't respond with Okay, see exception for more details: {content}", response.Content); + if (AmazonCredential.IsDebugMode) + _logger?.LogWarning("Amazon Api didn't respond with Okay, see exception for more details: {content}", response.Content); var errorResponse = response.Content.ConvertToErrorResponse(); if (errorResponse != null) diff --git a/Source/FikaAmazonAPI/Services/RestrictionService.cs b/Source/FikaAmazonAPI/Services/RestrictionService.cs index aeca705b..9debb808 100644 --- a/Source/FikaAmazonAPI/Services/RestrictionService.cs +++ b/Source/FikaAmazonAPI/Services/RestrictionService.cs @@ -1,15 +1,14 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.Restrictions; using FikaAmazonAPI.Parameter.Restrictions; -using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class RestrictionService : RequestService { - public RestrictionService(AmazonCredential amazonCredential,ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public RestrictionService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/SalesService.cs b/Source/FikaAmazonAPI/Services/SalesService.cs index 7b009c10..2073789e 100644 --- a/Source/FikaAmazonAPI/Services/SalesService.cs +++ b/Source/FikaAmazonAPI/Services/SalesService.cs @@ -1,16 +1,15 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.Sales; using FikaAmazonAPI.Parameter.Sales; -using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class SalesService : RequestService { - public SalesService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public SalesService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/SellerService.cs b/Source/FikaAmazonAPI/Services/SellerService.cs index f610b668..d2198970 100644 --- a/Source/FikaAmazonAPI/Services/SellerService.cs +++ b/Source/FikaAmazonAPI/Services/SellerService.cs @@ -1,15 +1,15 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.Sellers; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class SellerService : RequestService { - public SellerService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public SellerService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/ServicesService.cs b/Source/FikaAmazonAPI/Services/ServicesService.cs index fc2b538f..7ff8851e 100644 --- a/Source/FikaAmazonAPI/Services/ServicesService.cs +++ b/Source/FikaAmazonAPI/Services/ServicesService.cs @@ -1,11 +1,10 @@ -using FikaAmazonAPI.Utils; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class ServicesService : RequestService { - public ServicesService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public ServicesService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/ShipmentInvoicingService.cs b/Source/FikaAmazonAPI/Services/ShipmentInvoicingService.cs index e5f7347e..db7a1375 100644 --- a/Source/FikaAmazonAPI/Services/ShipmentInvoicingService.cs +++ b/Source/FikaAmazonAPI/Services/ShipmentInvoicingService.cs @@ -1,15 +1,15 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.ShipmentInvoicing; using FikaAmazonAPI.Parameter; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public partial class ShipmentInvoicingService : RequestService { - public ShipmentInvoicingService(AmazonCredential amazonCredential,ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public ShipmentInvoicingService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/ShippingService.cs b/Source/FikaAmazonAPI/Services/ShippingService.cs index 55511e82..8a494734 100644 --- a/Source/FikaAmazonAPI/Services/ShippingService.cs +++ b/Source/FikaAmazonAPI/Services/ShippingService.cs @@ -1,15 +1,15 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.Shipping; using FikaAmazonAPI.Parameter; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class ShippingService : RequestService { - public ShippingService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public ShippingService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/ShippingServiceV2.cs b/Source/FikaAmazonAPI/Services/ShippingServiceV2.cs index 2cd54488..84ea20bc 100644 --- a/Source/FikaAmazonAPI/Services/ShippingServiceV2.cs +++ b/Source/FikaAmazonAPI/Services/ShippingServiceV2.cs @@ -1,15 +1,14 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2; -using FikaAmazonAPI.Parameter; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class ShippingServiceV2 : RequestService { - public ShippingServiceV2(AmazonCredential amazonCredential,ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public ShippingServiceV2(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/SolicitationService.cs b/Source/FikaAmazonAPI/Services/SolicitationService.cs index 80fbcee7..fe163267 100644 --- a/Source/FikaAmazonAPI/Services/SolicitationService.cs +++ b/Source/FikaAmazonAPI/Services/SolicitationService.cs @@ -1,15 +1,15 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.Solicitations; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class SolicitationService : RequestService { - public SolicitationService(AmazonCredential amazonCredential,ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory,rateLimitingHandler) + public SolicitationService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/TokenService.cs b/Source/FikaAmazonAPI/Services/TokenService.cs index d8f68e42..c5badc72 100644 --- a/Source/FikaAmazonAPI/Services/TokenService.cs +++ b/Source/FikaAmazonAPI/Services/TokenService.cs @@ -1,11 +1,10 @@ -using FikaAmazonAPI.Utils; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class TokenService : RequestService { - public TokenService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public TokenService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/UploadService.cs b/Source/FikaAmazonAPI/Services/UploadService.cs index 59fcfadf..0db8dd0e 100644 --- a/Source/FikaAmazonAPI/Services/UploadService.cs +++ b/Source/FikaAmazonAPI/Services/UploadService.cs @@ -1,22 +1,22 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.Upload; using FikaAmazonAPI.Parameter.Upload; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class UploadService : RequestService { - public UploadService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public UploadService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } public UploadDestination CreateUploadDestinationForResource(ParameterCreateUploadDestinationForResource parameterObj) => Task.Run(() => CreateUploadDestinationForResourceAsync(parameterObj)).ConfigureAwait(false).GetAwaiter().GetResult(); - + public async Task CreateUploadDestinationForResourceAsync(ParameterCreateUploadDestinationForResource parameterObj, CancellationToken cancellationToken = default) { if (parameterObj.marketplaceIds == null || parameterObj.marketplaceIds.Count == 0) diff --git a/Source/FikaAmazonAPI/Services/VendorDirectFulfillmentOrderService.cs b/Source/FikaAmazonAPI/Services/VendorDirectFulfillmentOrderService.cs index 603217d7..e318595c 100644 --- a/Source/FikaAmazonAPI/Services/VendorDirectFulfillmentOrderService.cs +++ b/Source/FikaAmazonAPI/Services/VendorDirectFulfillmentOrderService.cs @@ -1,16 +1,16 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.VendorDirectFulfillmentOrders; using FikaAmazonAPI.Parameter.VendorDirectFulfillmentOrders; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class VendorDirectFulfillmentOrderService : RequestService { - public VendorDirectFulfillmentOrderService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public VendorDirectFulfillmentOrderService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/VendorOrders.cs b/Source/FikaAmazonAPI/Services/VendorOrders.cs index 8f49adbf..3db3e524 100644 --- a/Source/FikaAmazonAPI/Services/VendorOrders.cs +++ b/Source/FikaAmazonAPI/Services/VendorOrders.cs @@ -2,16 +2,16 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.VendorTransactions; using FikaAmazonAPI.Parameter.VendorOrders; using FikaAmazonAPI.Utils; +using Microsoft.Extensions.Logging; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class VendorOrderService : RequestService { - public VendorOrderService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public VendorOrderService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Services/VendorTransactionStatus.cs b/Source/FikaAmazonAPI/Services/VendorTransactionStatus.cs index 7656b538..32a320d2 100644 --- a/Source/FikaAmazonAPI/Services/VendorTransactionStatus.cs +++ b/Source/FikaAmazonAPI/Services/VendorTransactionStatus.cs @@ -1,16 +1,14 @@ using FikaAmazonAPI.AmazonSpApiSDK.Models.VendorTransactions; -using FikaAmazonAPI.Parameter.VendorOrders; using FikaAmazonAPI.Utils; -using System.Collections.Generic; +using Microsoft.Extensions.Logging; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace FikaAmazonAPI.Services { public class VendorTransactionStatusService : RequestService { - public VendorTransactionStatusService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory, IRateLimitingHandler rateLimitingHandler = null) : base(amazonCredential, loggerFactory, rateLimitingHandler) + public VendorTransactionStatusService(AmazonCredential amazonCredential, ILoggerFactory? loggerFactory) : base(amazonCredential, loggerFactory) { } diff --git a/Source/FikaAmazonAPI/Utils/IRateLimitingHandler.cs b/Source/FikaAmazonAPI/Utils/IRateLimitingHandler.cs deleted file mode 100644 index 2d4f32db..00000000 --- a/Source/FikaAmazonAPI/Utils/IRateLimitingHandler.cs +++ /dev/null @@ -1,25 +0,0 @@ -using RestSharp; -using System; -using System.Threading; -using System.Threading.Tasks; - -namespace FikaAmazonAPI.Utils -{ - /// - /// This is designed to be used as a singleton, for the purposes of coordinating rate limiting between separate concurrent requests - ///

- /// See - ///
- public interface IRateLimitingHandler - { - Task> SafelyExecuteRequestAsync( - IRestClient restClient, - RestRequest restRequest, - AmazonCredential credential, - RateLimitType rateLimitType = RateLimitType.UNSET, - Action responseCallback = null, - CancellationToken cancellationToken = default) where TResponse : new(); - - Task WaitForLimitTypeAsync(AmazonCredential credential, RateLimitType rateLimitType, CancellationToken cancellationToken = default); - } -} diff --git a/Source/FikaAmazonAPI/Utils/RateLimitingHandler.cs b/Source/FikaAmazonAPI/Utils/RateLimitingHandler.cs deleted file mode 100644 index ccb64212..00000000 --- a/Source/FikaAmazonAPI/Utils/RateLimitingHandler.cs +++ /dev/null @@ -1,94 +0,0 @@ -using RestSharp; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace FikaAmazonAPI.Utils -{ - /// - /// This is designed to be used as a singleton, for the purposes of coordinating rate limiting between separate concurrent requests - ///

- /// See - ///
- public class RateLimitingHandler : IRateLimitingHandler - { - private const string RateLimitLimitHeaderName = "x-amzn-RateLimit-Limit"; - private const int FallbackDefaultBurstRate = 1; - - public async Task> SafelyExecuteRequestAsync( - IRestClient restClient, - RestRequest restRequest, - AmazonCredential credential, - RateLimitType rateLimitType = RateLimitType.UNSET, - Action action = null, - CancellationToken cancellationToken = default) where TResponse : new() - { - await WaitForLimitTypeAsync(credential, rateLimitType, cancellationToken: default); - - var response = await restClient.ExecuteAsync(restRequest, cancellationToken); - - action?.Invoke(response); - - if (response != null && TryGetRateFromHeaders(response.Headers, out var headersRate)) - { - UpdateRateLimitPolicy(credential, rateLimitType, headersRate); - } - - return response; - } - - public async Task WaitForLimitTypeAsync( - AmazonCredential credential, - RateLimitType rateLimitType, - CancellationToken cancellationToken = default) - { - if (!credential.IsActiveLimitRate) - { - return; - } - - var policies = RateLimitsDefinitions.RateLimitsTimeForCredential(credential); - - if (policies.TryGetValue(rateLimitType, out var policy)) - { - await policy.WaitForPermittedRequest(cancellationToken, credential.IsDebugMode); - } - } - - private void UpdateRateLimitPolicy(AmazonCredential credential, RateLimitType rateLimitType, decimal updatedRateLimit) - { - if (updatedRateLimit <= 0) - { - return; - } - - var rateLimitPolicies = RateLimitsDefinitions.RateLimitsTimeForCredential(credential); - - if (!rateLimitPolicies.TryGetValue(rateLimitType, out var planTimings)) - { - Console.WriteLine( - $"No rate limit policy found for {rateLimitType} for seller {credential.SellerID}, will create new policy for seller with default burst rate of {FallbackDefaultBurstRate}"); - rateLimitPolicies.TryAdd(rateLimitType, new RateLimits(Rate: updatedRateLimit, Burst: FallbackDefaultBurstRate, type: rateLimitType)); - return; - } - - planTimings.SetRateLimit(updatedRateLimit); - } - - private bool TryGetRateFromHeaders(IEnumerable headers, out decimal rate) - { - rate = 0; - var limitHeader = headers.FirstOrDefault(a => a.Name == RateLimitLimitHeaderName); - if (limitHeader != null) - { - var RateLimitValue = limitHeader.Value.ToString(); - return decimal.TryParse(RateLimitValue, NumberStyles.Any, CultureInfo.InvariantCulture, out rate); - } - - return false; - } - } -} diff --git a/Source/FikaAmazonAPI/Utils/RateLimits.cs b/Source/FikaAmazonAPI/Utils/RateLimits.cs index 65f55c72..58571a4d 100644 --- a/Source/FikaAmazonAPI/Utils/RateLimits.cs +++ b/Source/FikaAmazonAPI/Utils/RateLimits.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.CompilerServices; -using System.Threading; using System.Threading.Tasks; [assembly: InternalsVisibleTo("Tests")] @@ -8,26 +7,22 @@ namespace FikaAmazonAPI.Utils { internal class RateLimits { - private object _locker = new object(); - internal decimal Rate { get; private set; } - internal int Burst { get; } - internal DateTime LastRequestReplenished { get; private set; } - internal int RequestsUsed { get; private set; } - internal RateLimitType RateLimitType { get; } + internal decimal Rate { get; set; } + internal int Burst { get; set; } + internal DateTime LastRequest { get; set; } + internal int RequestsSent { get; set; } /// /// Constructor for rate limits configuration object /// /// The number of permitted requests which will be added to the "Token bucket" per second /// The maximum number of requests which can exist in the "Token bucket" at any time - /// An enum representing the resource for which the rate limit policy is being set - internal RateLimits(decimal Rate, int Burst, RateLimitType type) + internal RateLimits(decimal Rate, int Burst) { this.Rate = Rate; this.Burst = Burst; - this.RateLimitType = type; - this.LastRequestReplenished = DateTime.UtcNow; - this.RequestsUsed = 0; + this.LastRequest = DateTime.UtcNow; + this.RequestsSent = 0; } private int GetRatePeriodMs() { return (int)(((1 / Rate) * 1000) / 1); } @@ -40,111 +35,64 @@ internal RateLimits(decimal Rate, int Burst, RateLimitType type) /// An enum representing the rate limit policy for the resource in use /// The cancellation token /// - public async Task WaitForPermittedRequest(CancellationToken cancellationToken = default, bool debugMode = true) + public async Task NextRate(RateLimitType rateLimitType) { - if (RequestsUsed < 0) - { - RequestsUsed = 0; - } + if (RequestsSent < 0) + RequestsSent = 0; int ratePeriodMs = GetRatePeriodMs(); - // when requests used more than zero, replenish according to time elapsed - DecrementRequestsUsed(debugMode); - - var nextRequestsSent = RequestsUsed + 1; + var nextRequestsSent = RequestsSent + 1; var nextRequestsSentTxt = (nextRequestsSent > Burst) ? "FULL" : nextRequestsSent.ToString(); + if (AmazonCredential.DebugMode) + { + string output = $"[RateLimits ,{rateLimitType,15}]: {DateTime.UtcNow.ToString(),10}\t Request/Burst: {nextRequestsSentTxt}/{Burst}\t Rate: {Rate}/{ratePeriodMs}ms"; + Console.WriteLine(output); + } - WriteDebug($"[RateLimits ,{this.RateLimitType,15}]: {DateTime.UtcNow.ToString(),10}\t Request/Burst: {nextRequestsSentTxt}/{Burst}\t Rate: {Rate}/{ratePeriodMs}ms", debugMode); - - var requestIsPermitted = false; - - while (!requestIsPermitted) + if (RequestsSent >= Burst) { - // if bucket is currently empty, enter wait loop for replenishment - while (RequestsUsed >= Burst) + var LastRequestTime = LastRequest; + while (true) { - var currentRequestsUsed = RequestsUsed; - // wait until predicted next token available - var incomingRequestTokenTime = LastRequestReplenished.AddMilliseconds(ratePeriodMs); - if (incomingRequestTokenTime > DateTime.UtcNow) - { - WriteDebug($"Next token expected at {incomingRequestTokenTime}, waiting", debugMode); - await Task.Delay(100); - continue; - } + LastRequestTime = LastRequestTime.AddMilliseconds(ratePeriodMs); + if (LastRequestTime > DateTime.UtcNow) + break; else + RequestsSent -= 1; + if (RequestsSent <= 0) { - // replenish token - DecrementRequestsUsed(debugMode); - } - - if (RequestsUsed <= 0) - { - RequestsUsed = 0; + RequestsSent = 0; break; } } - - // now remove token from bucket for pending request - requestIsPermitted = TryIncrementRequestsUsed(debugMode); } - } - internal void SetRateLimit(decimal rate) - { - Rate = rate; - } - - // increments available tokens, unless another thread has already incremented them. - private void DecrementRequestsUsed(bool isDebug) - { - WriteDebug($"Attempting to increment tokens", isDebug); - lock (_locker) + if (RequestsSent >= Burst) { - var ratePeriodMilliseconds = GetRatePeriodMs(); - var requestsToReplenish = ratePeriodMilliseconds == 0 ? 0 : (int)((DateTime.UtcNow - LastRequestReplenished).TotalMilliseconds / ratePeriodMilliseconds); - WriteDebug($"{requestsToReplenish} tokens to replenish since {LastRequestReplenished}", isDebug); - if (requestsToReplenish == 0 || RequestsUsed == 0) - { - return; - } - - RequestsUsed = Math.Max(RequestsUsed - requestsToReplenish, 0); - LastRequestReplenished = DateTime.UtcNow; + LastRequest = LastRequest.AddMilliseconds(ratePeriodMs); + var TempLastRequest = LastRequest; + while (TempLastRequest >= DateTime.UtcNow) //.AddMilliseconds(-100) + await Task.Delay(100); - WriteDebug($"Incremented tokens by {requestsToReplenish}", isDebug); } + + if (RequestsSent + 1 <= Burst) + RequestsSent += 1; + LastRequest = DateTime.UtcNow; + + return this; } - // will try to decrement available tokens, will fail if another thread has used last of burst quota - private bool TryIncrementRequestsUsed(bool isDebug) + internal void SetRateLimit(decimal rate) { - var succeeded = false; - - lock (_locker) - { - if (RequestsUsed < Burst) - { - WriteDebug($"Token is available for use, requests used = {RequestsUsed}", isDebug); - RequestsUsed++; - succeeded = true; - } - else - { - WriteDebug($"Caller will need to wait for token, {Burst} requests used", isDebug); - } - } + Rate = rate; - return succeeded; } - private void WriteDebug(string message, bool isDebug) + internal Task Delay() { - if (isDebug) - { - Console.WriteLine(message); - } + return Task.Delay(GetRatePeriodMs()); } } -} +} \ No newline at end of file diff --git a/Source/FikaAmazonAPI/Utils/RateLimitsDefinitions.cs b/Source/FikaAmazonAPI/Utils/RateLimitsDefinitions.cs index c3c566e6..23f35111 100644 --- a/Source/FikaAmazonAPI/Utils/RateLimitsDefinitions.cs +++ b/Source/FikaAmazonAPI/Utils/RateLimitsDefinitions.cs @@ -1,236 +1,252 @@ -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; namespace FikaAmazonAPI.Utils { internal static class RateLimitsDefinitions { - private static ConcurrentDictionary> RateLimitsByCredentialKey = new ConcurrentDictionary>(); - - /// - /// Returns a concurrent dictionary of rate limit policies by rate limit type based on the credential's client and seller Id - /// - /// The credential to use - /// A concurrent dictionary of rate limit policies by rate limit type - internal static ConcurrentDictionary RateLimitsTimeForCredential(AmazonCredential credential) + internal static Dictionary RateLimitsTime() { - var credentialKey = $"{credential.ClientId}_{credential.SellerID}"; + //This has to create a new list for each connection, so that rate limits are per seller, not overall. + return new Dictionary() + { + { RateLimitType.AppIntegrationsV20240401_CreateNotification, new RateLimits(1.0M, 5) }, + { RateLimitType.AppIntegrationsV20240401_DeleteNotifications, new RateLimits(1.0M, 5) }, + { RateLimitType.AppIntegrationsV20240401_RecordActionFeedback, new RateLimits(1.0M, 5) }, - if (RateLimitsByCredentialKey.TryGetValue(credentialKey, out var rateLimits)) { return rateLimits; } + { RateLimitType.Order_GetOrders, new RateLimits(0.0167M, 20) }, + { RateLimitType.Order_GetOrder, new RateLimits(0.0167M, 20) }, + { RateLimitType.Order_GetOrderBuyerInfo, new RateLimits(0.0167M, 20) }, + { RateLimitType.Order_GetOrderAddress, new RateLimits(0.0167M, 20) }, + { RateLimitType.Order_GetOrderItems, new RateLimits(0.5M, 20) }, + { RateLimitType.Order_GetOrderItemsBuyerInfo, new RateLimits(0.5M, 30) }, + { RateLimitType.Order_UpdateShipmentStatus, new RateLimits(5M, 15) }, + { RateLimitType.Order_GetOrderRegulatedInfo, new RateLimits(0.5M, 15) }, + { RateLimitType.Order_UpdateVerificationStatus, new RateLimits(0.5M, 30) }, + { RateLimitType.Order_UpdateOrderItemsApprovals, new RateLimits(5M, 15) }, + { RateLimitType.Order_ShipmentConfirmation, new RateLimits(2M, 10) }, - var rateLimitsForSeller = new ConcurrentDictionary(RateLimitsTime()); - RateLimitsByCredentialKey.TryAdd(credentialKey, rateLimitsForSeller); - return RateLimitsTimeForCredential(credential); - } + { RateLimitType.Report_GetReports, new RateLimits(0.0222M, 10) }, + { RateLimitType.Report_GetReport, new RateLimits(2.0M, 15) }, + { RateLimitType.Report_CreateReport, new RateLimits(0.0167M, 15) }, + { RateLimitType.Report_CancelReport, new RateLimits(0.0222M, 10) }, + { RateLimitType.Report_GetReportSchedules, new RateLimits(0.0222M, 10) }, + { RateLimitType.Report_CreateReportSchedule, new RateLimits(0.0222M, 10) }, + { RateLimitType.Report_GetReportSchedule, new RateLimits(0.0222M, 10) }, + { RateLimitType.Report_CancelReportSchedule, new RateLimits(0.0222M, 10) }, + { RateLimitType.Report_GetReportDocument, new RateLimits(0.0167M, 15) }, + + { RateLimitType.Financial_ListFinancialEventGroups, new RateLimits(0.5M, 30) }, + { RateLimitType.Financial_ListFinancialEventsByGroupId, new RateLimits(0.5M, 30) }, + { RateLimitType.Financial_ListFinancialEventsByOrderId, new RateLimits(0.5M, 30) }, + { RateLimitType.Financial_ListFinancialEvents, new RateLimits(0.5M, 30) }, + + { RateLimitType.Feed_GetFeeds, new RateLimits(0.0222M, 10) }, + { RateLimitType.Feed_CreateFeed, new RateLimits(0.0083M, 15) }, + { RateLimitType.Feed_GetFeed, new RateLimits(2.0M, 15) }, + { RateLimitType.Feed_CancelFeed, new RateLimits(0.0222M, 10) }, + { RateLimitType.Feed_CreateFeedDocument, new RateLimits(0.0083M, 15) }, + { RateLimitType.Feed_GetFeedDocument, new RateLimits(0.0222M, 10) }, + + { RateLimitType.ListingsItem_GetListingsItem, new RateLimits(5.0M, 10) }, + { RateLimitType.ListingsItem_PutListingsItem, new RateLimits(5.0M, 10) }, + { RateLimitType.ListingsItem_DeleteListingsItem, new RateLimits(5.0M, 10) }, + { RateLimitType.ListingsItem_PatchListingsItem, new RateLimits(5.0M, 10) }, + + { RateLimitType.Upload_CreateUploadDestinationForResource, new RateLimits(0.1M, 5) }, + + { RateLimitType.ShipmentInvoicing_GetShipmentDetails, new RateLimits(1.133M, 25) }, + { RateLimitType.ShipmentInvoicing_SubmitInvoice, new RateLimits(1.133M, 25) }, + { RateLimitType.ShipmentInvoicing_GetInvoiceStatus, new RateLimits(1.133M, 25) }, + + { RateLimitType.Shipping_CreateShipment, new RateLimits(5.0M, 15) }, + { RateLimitType.Shipping_GetShipment, new RateLimits(5.0M, 15) }, + { RateLimitType.Shipping_CancelShipment, new RateLimits(5.0M, 15) }, + { RateLimitType.Shipping_PurchaseLabels, new RateLimits(5.0M, 15) }, + { RateLimitType.Shipping_RetrieveShippingLabel, new RateLimits(5.0M, 15) }, + { RateLimitType.Shipping_PurchaseShipment, new RateLimits(5.0M, 15) }, + { RateLimitType.Shipping_GetRates, new RateLimits(5.0M, 15) }, + { RateLimitType.Shipping_GetAccount, new RateLimits(5.0M, 15) }, + { RateLimitType.Shipping_GetTrackingInformation, new RateLimits(1.0M, 1) }, + + { RateLimitType.ShippingV2_CancelShipment, new RateLimits(80.0M, 100) }, + { RateLimitType.ShippingV2_DirectPurchaseShipment, new RateLimits(80.0M, 100) }, + { RateLimitType.ShippingV2_GetAdditionalInputs, new RateLimits(80.0M, 100) }, + { RateLimitType.ShippingV2_GetRates, new RateLimits(80.0M, 100) }, + { RateLimitType.ShippingV2_GetShipmentDocument, new RateLimits(80.0M, 100) }, + { RateLimitType.ShippingV2_GetTracking, new RateLimits(80.0M, 100) }, + { RateLimitType.ShippingV2_PurchaseShipment, new RateLimits(80.0M, 100) }, + + { RateLimitType.CatalogItems_ListCatalogItems, new RateLimits(6.0M, 40) }, + { RateLimitType.CatalogItems_GetCatalogItem, new RateLimits(2.0M, 20) }, + { RateLimitType.CatalogItems_ListCatalogCategories, new RateLimits(1.0M, 40) }, + { RateLimitType.CatalogItems20220401_GetCatalogItem, new RateLimits(2.0M, 2) }, + { RateLimitType.CatalogItems20220401_SearchCatalogItems, new RateLimits(2.0M, 2) }, + + { RateLimitType.FbaInventory_GetInventorySummaries, new RateLimits(2.0M, 2) }, + + { RateLimitType.Authorization_GetAuthorizationCode, new RateLimits(1.0M, 5) }, + + { RateLimitType.FbaSmallandLight_GetSmallAndLightEnrollmentBySellerSKU, new RateLimits(2.0M, 10) }, + { RateLimitType.FbaSmallandLight_PutSmallAndLightEnrollmentBySellerSKU, new RateLimits(2.0M, 5) }, + { RateLimitType.FbaSmallandLight_DeleteSmallAndLightEnrollmentBySellerSKU, new RateLimits(2.0M, 5) }, + { RateLimitType.FbaSmallandLight_GetSmallAndLightEligibilityBySellerSKU, new RateLimits(2.0M, 10) }, + { RateLimitType.FbaSmallandLight_GetSmallAndLightFeePreview, new RateLimits(1.0M, 3) }, + + { RateLimitType.Restrictions_GetListingsRestrictions, new RateLimits(5.0M, 10) }, + + { RateLimitType.ProductTypes_GetDefinitionsProductType, new RateLimits(5.0M, 10) }, + { RateLimitType.ProductTypes_SearchDefinitionsProductTypes, new RateLimits(5.0M, 10) }, + + { RateLimitType.FBAInboundEligibility_GetItemEligibilityPreview, new RateLimits(1.0M, 1) }, + + + { RateLimitType.EasyShip_CreateScheduledPackage, new RateLimits(1.0M, 5) }, + { RateLimitType.EasyShip_GetScheduledPackage, new RateLimits(1.0M, 5) }, + { RateLimitType.EasyShip_ListHandoverSlots, new RateLimits(1.0M, 5) }, + { RateLimitType.EasyShip_UpdateScheduledPackages, new RateLimits(1.0M, 5) }, + + { RateLimitType.FulFillmentInbound_GetInboundGuidance, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInbound_CreateInboundShipmentPlan, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInbound_UpdateInboundShipment, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInbound_CreateInboundShipment, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInbound_GetPreorderInfo, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInbound_ConfirmPreorder, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInbound_GetPrepInstructions, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInbound_GetTransportDetails, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInbound_PutTransportDetails, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInbound_VoidTransport, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInbound_EstimateTransport, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInbound_ConfirmTransport, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInbound_GetLabels, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInbound_GetBillOfLading, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInbound_GetShipments, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInbound_GetShipmentItemsByShipmentId,new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInbound_GetShipmentItems, new RateLimits(2.0M, 30) }, + + { RateLimitType.FulFillmentInboundV20240320_ListInboundPlans, new RateLimits(2.0M, 6) }, + { RateLimitType.FulFillmentInboundV20240320_CreateInboundPlan, new RateLimits(2.0M, 2) }, + { RateLimitType.FulFillmentInboundV20240320_GetInboundPlan, new RateLimits(2.0M, 6) }, + { RateLimitType.FulFillmentInboundV20240320_ListInboundPlanBoxes, new RateLimits(2.0M, 6) }, + { RateLimitType.FulFillmentInboundV20240320_CancelInboundPlan, new RateLimits(2.0M, 2) }, + { RateLimitType.FulFillmentInboundV20240320_ListInboundPlanItems, new RateLimits(2.0M, 6) }, + { RateLimitType.FulFillmentInboundV20240320_UpdateInboundPlanName, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInboundV20240320_ListPackingGroupBoxes, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInboundV20240320_ListPackingGroupItems, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInboundV20240320_SetPackingInformation, new RateLimits(2.0M, 2) }, + { RateLimitType.FulFillmentInboundV20240320_ListPackingOptions, new RateLimits(2.0M, 6) }, + { RateLimitType.FulFillmentInboundV20240320_GeneratePackingOptions, new RateLimits(2.0M, 2) }, + { RateLimitType.FulFillmentInboundV20240320_ConfirmPackingOption, new RateLimits(2.0M, 2) }, + { RateLimitType.FulFillmentInboundV20240320_ListInboundPlanPallets, new RateLimits(2.0M, 6) }, + { RateLimitType.FulFillmentInboundV20240320_ListPlacementOptions, new RateLimits(2.0M, 6) }, + { RateLimitType.FulFillmentInboundV20240320_GeneratePlacementOptions, new RateLimits(2.0M, 2) }, + { RateLimitType.FulFillmentInboundV20240320_ConfirmPlacementOption, new RateLimits(2.0M, 2) }, + { RateLimitType.FulFillmentInboundV20240320_GetShipment, new RateLimits(2.0M, 6) }, + { RateLimitType.FulFillmentInboundV20240320_ListShipmentBoxes, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInboundV20240320_ListShipmentContentUpdatePreviews, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInboundV20240320_GenerateShipmentContentUpdatePreviews,new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInboundV20240320_GetShipmentContentUpdatePreview, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInboundV20240320_ConfirmShipmentContentUpdatePreview, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInboundV20240320_GetDeliveryChallanDocument, new RateLimits(2.0M, 6) }, + { RateLimitType.FulFillmentInboundV20240320_ListDeliveryWindowOptions, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInboundV20240320_GenerateDeliveryWindowOptions, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInboundV20240320_ConfirmDeliveryWindowOption, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInboundV20240320_ListShipmentItems, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInboundV20240320_UpdateShipmentName, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInboundV20240320_ListShipmentPallets, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInboundV20240320_CancelSelfShipAppointment, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInboundV20240320_GetSelfShipAppointmentSlots, new RateLimits(2.0M, 6) }, + { RateLimitType.FulFillmentInboundV20240320_GenerateSelfShipAppointmentSlots, new RateLimits(2.0M, 2) }, + { RateLimitType.FulFillmentInboundV20240320_ScheduleSelfShipAppointment, new RateLimits(2.0M, 2) }, + { RateLimitType.FulFillmentInboundV20240320_UpdateShipmentSourceAddress, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInboundV20240320_UpdateShipmentTrackingDetails, new RateLimits(2.0M, 2) }, + { RateLimitType.FulFillmentInboundV20240320_ListTransportationOptions, new RateLimits(2.0M, 6) }, + { RateLimitType.FulFillmentInboundV20240320_GenerateTransportationOptions, new RateLimits(2.0M, 2) }, + { RateLimitType.FulFillmentInboundV20240320_ConfirmTransportationOptions, new RateLimits(2.0M, 2) }, + { RateLimitType.FulFillmentInboundV20240320_ListItemComplianceDetails, new RateLimits(2.0M, 6) }, + { RateLimitType.FulFillmentInboundV20240320_UpdateItemComplianceDetails, new RateLimits(2.0M, 2) }, + { RateLimitType.FulFillmentInboundV20240320_CreateMarketplaceItemLabels, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInboundV20240320_ListPrepDetails, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInboundV20240320_SetPrepDetails, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentInboundV20240320_GetInboundOperationStatus, new RateLimits(2.0M, 6) }, + + + { RateLimitType.FulFillmentOutbound_GetFulfillmentPreview, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentOutbound_ListAllFulfillmentOrders, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentOutbound_CreateFulfillmentOrder, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentOutbound_GetPackageTrackingDetails, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentOutbound_ListReturnReasonCodes, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentOutbound_CreateFulfillmentReturn, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentOutbound_GetFulfillmentOrder, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentOutbound_UpdateFulfillmentOrder, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentOutbound_CancelFulfillmentOrder, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentOutbound_GetFeatures, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentOutbound_GetFeatureInventory, new RateLimits(2.0M, 30) }, + { RateLimitType.FulFillmentOutbound_GetFeatureSKU, new RateLimits(2.0M, 30) }, + + { RateLimitType.MerchantFulFillment_GetEligibleShipmentServicesOld,new RateLimits(1.0M, 1) }, + { RateLimitType.MerchantFulFillment_GetEligibleShipmentServices,new RateLimits(5.0M, 10) }, + { RateLimitType.MerchantFulFillment_GetShipment, new RateLimits(1.0M, 1) }, + { RateLimitType.MerchantFulFillment_CancelShipment, new RateLimits(1.0M, 1) }, + { RateLimitType.MerchantFulFillment_CancelShipmentOld, new RateLimits(1.0M, 1) }, + { RateLimitType.MerchantFulFillment_CreateShipment, new RateLimits(1.0M, 1) }, + { RateLimitType.MerchantFulFillment_GetAdditionalSellerInputsOld,new RateLimits(1.0M, 1) }, + { RateLimitType.MerchantFulFillment_GetAdditionalSellerInputs, new RateLimits(1.0M, 1) }, + + { RateLimitType.Messaging_GetMessagingActionsForOrder, new RateLimits(1.0M, 5) }, + { RateLimitType.Messaging_ConfirmCustomizationDetails, new RateLimits(1.0M, 5) }, + { RateLimitType.Messaging_CreateConfirmDeliveryDetails, new RateLimits(1.0M, 5) }, + { RateLimitType.Messaging_CreateLegalDisclosure, new RateLimits(1.0M, 5) }, + { RateLimitType.Messaging_CreateNegativeFeedbackRemoval, new RateLimits(1.0M, 5) }, + { RateLimitType.Messaging_CreateConfirmOrderDetails, new RateLimits(1.0M, 5) }, + { RateLimitType.Messaging_CreateConfirmServiceDetails, new RateLimits(1.0M, 5) }, + { RateLimitType.Messaging_CreateAmazonMotors, new RateLimits(1.0M, 5) }, + { RateLimitType.Messaging_CreateWarranty, new RateLimits(1.0M, 5) }, + { RateLimitType.Messaging_GetAttributes, new RateLimits(1.0M, 5) }, + { RateLimitType.Messaging_CreateDigitalAccessKey, new RateLimits(1.0M, 5) }, + { RateLimitType.Messaging_CreateUnexpectedProblem, new RateLimits(1.0M, 5) }, + + { RateLimitType.Notifications_GetSubscription, new RateLimits(1.0M, 5) }, + { RateLimitType.Notifications_CreateSubscription, new RateLimits(1.0M, 5) }, + { RateLimitType.Notifications_GetSubscriptionById, new RateLimits(1.0M, 5) }, + { RateLimitType.Notifications_DeleteSubscriptionById, new RateLimits(1.0M, 5) }, + { RateLimitType.Notifications_GetDestinations, new RateLimits(1.0M, 5) }, + { RateLimitType.Notifications_CreateDestination, new RateLimits(1.0M, 5) }, + { RateLimitType.Notifications_GetDestination, new RateLimits(1.0M, 5) }, + { RateLimitType.Notifications_DeleteDestination, new RateLimits(1.0M, 5) }, + + { RateLimitType.ProductFees_GetMyFeesEstimateForSKU, new RateLimits(1M, 2) }, + { RateLimitType.ProductFees_GetMyFeesEstimateForASIN, new RateLimits(1M, 2) }, + { RateLimitType.ProductFees_GetMyFeesEstimate, new RateLimits(0.5M, 1) }, + + { RateLimitType.ProductPricing_GetPricing, new RateLimits(0.5M, 1) }, + { RateLimitType.ProductPricing_GetCompetitivePricing, new RateLimits(0.5M, 1) }, + { RateLimitType.ProductPricing_GetListingOffers, new RateLimits(1M, 2) }, + { RateLimitType.ProductPricing_GetItemOffers, new RateLimits(0.5M, 1) }, + + { RateLimitType.ProductPricing_GetItemOffersBatch, new RateLimits(0.1M, 1) }, + { RateLimitType.ProductPricing_GetListingOffersBatch, new RateLimits(0.5M, 1) }, + + { RateLimitType.Sales_GetOrderMetrics, new RateLimits(0.5M, 15) }, + + { RateLimitType.Sellers_GetMarketplaceParticipations, new RateLimits(0.016M, 15) }, + + { RateLimitType.Solicitations_GetSolicitationActionsForOrder, new RateLimits(1.0M, 5) }, + { RateLimitType.Solicitations_CreateProductReviewAndSellerFeedbackSolicitation, new RateLimits(1.0M, 5) }, + + { RateLimitType.Token_CreateRestrictedDataToken, new RateLimits(1.0M, 10) }, + + { RateLimitType.VendorDirectFulfillmentOrdersV1_GetOrders, new RateLimits(10.0M, 10) }, + { RateLimitType.VendorDirectFulfillmentOrdersV1_GetOrder, new RateLimits(10.0M, 10) }, + { RateLimitType.VendorDirectFulfillmentOrdersV1_SubmitAcknowledgement, new RateLimits(10.0M, 10) }, + + { RateLimitType.VendorOrdersV1_GetPurchaseOrders, new RateLimits(10.0M, 10) }, + { RateLimitType.VendorOrdersV1_GetPurchaseOrder, new RateLimits(10.0M, 10) }, + { RateLimitType.VendorOrdersV1_SubmitAcknowledgement, new RateLimits(10.0M, 10) }, + { RateLimitType.VendorOrdersV1_GetPurchaseOrdersStatus, new RateLimits(10.0M, 10) }, + + { RateLimitType.VendorTransactionStatus_GetTransaction, new RateLimits(10.0M, 10) }, + }; - private static Dictionary RateLimitsTime() - { - //This has to create a new list for each connection, so that rate limits are per seller, not overall. - return new List - { - new RateLimits(1.0M, 5, RateLimitType.AppIntegrationsV20240401_CreateNotification), - new RateLimits(1.0M, 5, RateLimitType.AppIntegrationsV20240401_DeleteNotifications), - new RateLimits(1.0M, 5, RateLimitType.AppIntegrationsV20240401_RecordActionFeedback), - new RateLimits(0.0167M, 20, RateLimitType.Order_GetOrder), - new RateLimits(0.0167M, 20, RateLimitType.Order_GetOrders), - new RateLimits(0.0167M, 20, RateLimitType.Order_GetOrderBuyerInfo), - new RateLimits(0.0167M, 20, RateLimitType.Order_GetOrderAddress), - new RateLimits(0.5M, 20, RateLimitType.Order_GetOrderItems), - new RateLimits(0.5M, 20, RateLimitType.Order_GetOrderItemsBuyerInfo), - new RateLimits(5M, 15, RateLimitType.Order_UpdateShipmentStatus), - new RateLimits(0.5M, 15, RateLimitType.Order_GetOrderRegulatedInfo), - new RateLimits(0.5M, 30, RateLimitType.Order_UpdateVerificationStatus), - new RateLimits(5M, 15, RateLimitType.Order_UpdateOrderItemsApprovals), - new RateLimits(2M, 10, RateLimitType.Order_ShipmentConfirmation), - new RateLimits(0.0222M, 10, RateLimitType.Report_GetReports), - new RateLimits(2.0M, 15, RateLimitType.Report_GetReport), - new RateLimits(0.0167M, 15, RateLimitType.Report_CreateReport), - new RateLimits(0.0222M, 10, RateLimitType.Report_CancelReport), - new RateLimits(0.0222M, 10, RateLimitType.Report_GetReportSchedules), - new RateLimits(0.0222M, 10, RateLimitType.Report_CreateReportSchedule), - new RateLimits(0.0222M, 10, RateLimitType.Report_GetReportSchedule), - new RateLimits(0.0222M, 10, RateLimitType.Report_CancelReportSchedule), - new RateLimits(0.0167M, 15, RateLimitType.Report_GetReportDocument), - new RateLimits(0.5M, 30, RateLimitType.Financial_ListFinancialEventGroups), - new RateLimits(0.5M, 30, RateLimitType.Financial_ListFinancialEventsByGroupId), - new RateLimits(0.5M, 30, RateLimitType.Financial_ListFinancialEventsByOrderId), - new RateLimits(0.5M, 30, RateLimitType.Financial_ListFinancialEvents), - new RateLimits(0.0222M, 10, RateLimitType.Feed_GetFeeds), - new RateLimits(0.0083M, 15, RateLimitType.Feed_CreateFeed), - new RateLimits(2.0M, 15, RateLimitType.Feed_GetFeed), - new RateLimits(0.0222M, 10, RateLimitType.Feed_CancelFeed), - new RateLimits(0.0083M, 15, RateLimitType.Feed_CreateFeedDocument), - new RateLimits(0.0222M, 10, RateLimitType.Feed_GetFeedDocument), - new RateLimits(5.0M, 10, RateLimitType.ListingsItem_GetListingsItem), - new RateLimits(5.0M, 10, RateLimitType.ListingsItem_PutListingsItem), - new RateLimits(5.0M, 10, RateLimitType.ListingsItem_DeleteListingsItem), - new RateLimits(5.0M, 10, RateLimitType.ListingsItem_PatchListingsItem), - new RateLimits(0.1M, 5, RateLimitType.Upload_CreateUploadDestinationForResource), - new RateLimits(1.133M, 25, RateLimitType.ShipmentInvoicing_GetShipmentDetails), - new RateLimits(1.133M, 25, RateLimitType.ShipmentInvoicing_SubmitInvoice), - new RateLimits(1.133M, 25, RateLimitType.ShipmentInvoicing_GetInvoiceStatus), - new RateLimits(5.0M, 15, RateLimitType.Shipping_CreateShipment), - new RateLimits(5.0M, 15, RateLimitType.Shipping_GetShipment), - new RateLimits(5.0M, 15, RateLimitType.Shipping_CancelShipment), - new RateLimits(5.0M, 15, RateLimitType.Shipping_PurchaseLabels), - new RateLimits(5.0M, 15, RateLimitType.Shipping_RetrieveShippingLabel), - new RateLimits(5.0M, 15, RateLimitType.Shipping_PurchaseShipment), - new RateLimits(5.0M, 15, RateLimitType.Shipping_GetRates), - new RateLimits(5.0M, 15, RateLimitType.Shipping_GetAccount), - new RateLimits(1.0M, 1, RateLimitType.Shipping_GetTrackingInformation), - new RateLimits(80.0M, 100, RateLimitType.ShippingV2_CancelShipment), - new RateLimits(80.0M, 100, RateLimitType.ShippingV2_DirectPurchaseShipment), - new RateLimits(80.0M, 100, RateLimitType.ShippingV2_GetAdditionalInputs), - new RateLimits(80.0M, 100, RateLimitType.ShippingV2_GetRates), - new RateLimits(80.0M, 100, RateLimitType.ShippingV2_GetShipmentDocument), - new RateLimits(80.0M, 100, RateLimitType.ShippingV2_GetTracking), - new RateLimits(80.0M, 100, RateLimitType.ShippingV2_PurchaseShipment), - new RateLimits(6.0M, 40, RateLimitType.CatalogItems_ListCatalogItems), - new RateLimits(2.0M, 20, RateLimitType.CatalogItems_GetCatalogItem), - new RateLimits(1.0M, 40, RateLimitType.CatalogItems_ListCatalogCategories), - new RateLimits(2.0M, 2, RateLimitType.CatalogItems20220401_GetCatalogItem), - new RateLimits(2.0M, 2, RateLimitType.CatalogItems20220401_SearchCatalogItems), - new RateLimits(2.0M, 2, RateLimitType.FbaInventory_GetInventorySummaries), - new RateLimits(1.0M, 5, RateLimitType.Authorization_GetAuthorizationCode), - new RateLimits(2.0M, 10, RateLimitType.FbaSmallandLight_GetSmallAndLightEnrollmentBySellerSKU), - new RateLimits(2.0M, 5, RateLimitType.FbaSmallandLight_PutSmallAndLightEnrollmentBySellerSKU), - new RateLimits(2.0M, 5, RateLimitType.FbaSmallandLight_DeleteSmallAndLightEnrollmentBySellerSKU), - new RateLimits(2.0M, 10, RateLimitType.FbaSmallandLight_GetSmallAndLightEligibilityBySellerSKU), - new RateLimits(1.0M, 3, RateLimitType.FbaSmallandLight_GetSmallAndLightFeePreview), - new RateLimits(5.0M, 10, RateLimitType.Restrictions_GetListingsRestrictions), - new RateLimits(5.0M, 10, RateLimitType.ProductTypes_GetDefinitionsProductType), - new RateLimits(5.0M, 10, RateLimitType.ProductTypes_SearchDefinitionsProductTypes), - new RateLimits(1.0M, 1, RateLimitType.FBAInboundEligibility_GetItemEligibilityPreview), - new RateLimits(1.0M, 5, RateLimitType.EasyShip_CreateScheduledPackage), - new RateLimits(1.0M, 5, RateLimitType.EasyShip_GetScheduledPackage), - new RateLimits(1.0M, 5, RateLimitType.EasyShip_ListHandoverSlots), - new RateLimits(1.0M, 5, RateLimitType.EasyShip_UpdateScheduledPackages), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInbound_GetInboundGuidance), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInbound_CreateInboundShipmentPlan), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInbound_UpdateInboundShipment), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInbound_CreateInboundShipment), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInbound_GetPreorderInfo), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInbound_ConfirmPreorder), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInbound_GetPrepInstructions), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInbound_GetTransportDetails), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInbound_PutTransportDetails), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInbound_VoidTransport), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInbound_EstimateTransport), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInbound_ConfirmTransport), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInbound_GetLabels), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInbound_GetBillOfLading), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInbound_GetShipments), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInbound_GetShipmentItemsByShipmentId), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInbound_GetShipmentItems), - new RateLimits(2.0M, 6, RateLimitType.FulFillmentInboundV20240320_ListInboundPlans), - new RateLimits(2.0M, 2, RateLimitType.FulFillmentInboundV20240320_CreateInboundPlan), - new RateLimits(2.0M, 6, RateLimitType.FulFillmentInboundV20240320_GetInboundPlan), - new RateLimits(2.0M, 6, RateLimitType.FulFillmentInboundV20240320_ListInboundPlanBoxes), - new RateLimits(2.0M, 2, RateLimitType.FulFillmentInboundV20240320_CancelInboundPlan), - new RateLimits(2.0M, 6, RateLimitType.FulFillmentInboundV20240320_ListInboundPlanItems), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInboundV20240320_UpdateInboundPlanName), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInboundV20240320_ListPackingGroupBoxes), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInboundV20240320_ListPackingGroupItems), - new RateLimits(2.0M, 2, RateLimitType.FulFillmentInboundV20240320_SetPackingInformation), - new RateLimits(2.0M, 6, RateLimitType.FulFillmentInboundV20240320_ListPackingOptions), - new RateLimits(2.0M, 2, RateLimitType.FulFillmentInboundV20240320_GeneratePackingOptions), - new RateLimits(2.0M, 2, RateLimitType.FulFillmentInboundV20240320_ConfirmPackingOption), - new RateLimits(2.0M, 6, RateLimitType.FulFillmentInboundV20240320_ListInboundPlanPallets), - new RateLimits(2.0M, 6, RateLimitType.FulFillmentInboundV20240320_ListPlacementOptions), - new RateLimits(2.0M, 2, RateLimitType.FulFillmentInboundV20240320_GeneratePlacementOptions), - new RateLimits(2.0M, 2, RateLimitType.FulFillmentInboundV20240320_ConfirmPlacementOption), - new RateLimits(2.0M, 6, RateLimitType.FulFillmentInboundV20240320_GetShipment), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInboundV20240320_ListShipmentBoxes), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInboundV20240320_ListShipmentContentUpdatePreviews), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInboundV20240320_GenerateShipmentContentUpdatePreviews), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInboundV20240320_GetShipmentContentUpdatePreview), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInboundV20240320_ConfirmShipmentContentUpdatePreview), - new RateLimits(2.0M, 6, RateLimitType.FulFillmentInboundV20240320_GetDeliveryChallanDocument), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInboundV20240320_ListDeliveryWindowOptions), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInboundV20240320_GenerateDeliveryWindowOptions), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInboundV20240320_ConfirmDeliveryWindowOption), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInboundV20240320_ListShipmentItems), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInboundV20240320_UpdateShipmentName), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInboundV20240320_ListShipmentPallets), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInboundV20240320_CancelSelfShipAppointment), - new RateLimits(2.0M, 6, RateLimitType.FulFillmentInboundV20240320_GetSelfShipAppointmentSlots), - new RateLimits(2.0M, 2, RateLimitType.FulFillmentInboundV20240320_GenerateSelfShipAppointmentSlots), - new RateLimits(2.0M, 2, RateLimitType.FulFillmentInboundV20240320_ScheduleSelfShipAppointment), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInboundV20240320_UpdateShipmentSourceAddress), - new RateLimits(2.0M, 2, RateLimitType.FulFillmentInboundV20240320_UpdateShipmentTrackingDetails), - new RateLimits(2.0M, 6, RateLimitType.FulFillmentInboundV20240320_ListTransportationOptions), - new RateLimits(2.0M, 2, RateLimitType.FulFillmentInboundV20240320_GenerateTransportationOptions), - new RateLimits(2.0M, 2, RateLimitType.FulFillmentInboundV20240320_ConfirmTransportationOptions), - new RateLimits(2.0M, 6, RateLimitType.FulFillmentInboundV20240320_ListItemComplianceDetails), - new RateLimits(2.0M, 2, RateLimitType.FulFillmentInboundV20240320_UpdateItemComplianceDetails), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInboundV20240320_CreateMarketplaceItemLabels), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInboundV20240320_ListPrepDetails), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentInboundV20240320_SetPrepDetails), - new RateLimits(2.0M, 6, RateLimitType.FulFillmentInboundV20240320_GetInboundOperationStatus), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentOutbound_GetFulfillmentPreview), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentOutbound_ListAllFulfillmentOrders), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentOutbound_CreateFulfillmentOrder), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentOutbound_GetPackageTrackingDetails), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentOutbound_ListReturnReasonCodes), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentOutbound_CreateFulfillmentReturn), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentOutbound_GetFulfillmentOrder), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentOutbound_UpdateFulfillmentOrder), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentOutbound_CancelFulfillmentOrder), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentOutbound_GetFeatures), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentOutbound_GetFeatureInventory), - new RateLimits(2.0M, 30, RateLimitType.FulFillmentOutbound_GetFeatureSKU), - new RateLimits(1.0M, 1, RateLimitType.MerchantFulFillment_GetEligibleShipmentServicesOld), - new RateLimits(5.0M, 10, RateLimitType.MerchantFulFillment_GetEligibleShipmentServices), - new RateLimits(1.0M, 1, RateLimitType.MerchantFulFillment_GetShipment), - new RateLimits(1.0M, 1, RateLimitType.MerchantFulFillment_CancelShipment), - new RateLimits(1.0M, 1, RateLimitType.MerchantFulFillment_CancelShipmentOld), - new RateLimits(1.0M, 1, RateLimitType.MerchantFulFillment_CreateShipment), - new RateLimits(1.0M, 1, RateLimitType.MerchantFulFillment_GetAdditionalSellerInputsOld), - new RateLimits(1.0M, 1, RateLimitType.MerchantFulFillment_GetAdditionalSellerInputs), - new RateLimits(1.0M, 5, RateLimitType.Messaging_GetMessagingActionsForOrder), - new RateLimits(1.0M, 5, RateLimitType.Messaging_ConfirmCustomizationDetails), - new RateLimits(1.0M, 5, RateLimitType.Messaging_CreateConfirmDeliveryDetails), - new RateLimits(1.0M, 5, RateLimitType.Messaging_CreateLegalDisclosure), - new RateLimits(1.0M, 5, RateLimitType.Messaging_CreateNegativeFeedbackRemoval), - new RateLimits(1.0M, 5, RateLimitType.Messaging_CreateConfirmOrderDetails), - new RateLimits(1.0M, 5, RateLimitType.Messaging_CreateConfirmServiceDetails), - new RateLimits(1.0M, 5, RateLimitType.Messaging_CreateAmazonMotors), - new RateLimits(1.0M, 5, RateLimitType.Messaging_CreateWarranty), - new RateLimits(1.0M, 5, RateLimitType.Messaging_GetAttributes), - new RateLimits(1.0M, 5, RateLimitType.Messaging_CreateDigitalAccessKey), - new RateLimits(1.0M, 5, RateLimitType.Messaging_CreateUnexpectedProblem), - new RateLimits(1.0M, 5, RateLimitType.Notifications_GetSubscription), - new RateLimits(1.0M, 5, RateLimitType.Notifications_CreateSubscription), - new RateLimits(1.0M, 5, RateLimitType.Notifications_GetSubscriptionById), - new RateLimits(1.0M, 5, RateLimitType.Notifications_DeleteSubscriptionById), - new RateLimits(1.0M, 5, RateLimitType.Notifications_GetDestinations), - new RateLimits(1.0M, 5, RateLimitType.Notifications_CreateDestination), - new RateLimits(1.0M, 5, RateLimitType.Notifications_GetDestination), - new RateLimits(1.0M, 5, RateLimitType.Notifications_DeleteDestination), - new RateLimits(1M, 2, RateLimitType.ProductFees_GetMyFeesEstimateForSKU), - new RateLimits(1M, 2, RateLimitType.ProductFees_GetMyFeesEstimateForASIN), - new RateLimits(0.5M, 1, RateLimitType.ProductFees_GetMyFeesEstimate), - new RateLimits(0.5M, 1, RateLimitType.ProductPricing_GetPricing), - new RateLimits(0.5M, 1, RateLimitType.ProductPricing_GetCompetitivePricing), - new RateLimits(1M, 2, RateLimitType.ProductPricing_GetListingOffers), - new RateLimits(0.5M, 1, RateLimitType.ProductPricing_GetItemOffers), - new RateLimits(0.1M, 1, RateLimitType.ProductPricing_GetItemOffersBatch), - new RateLimits(0.5M, 1, RateLimitType.ProductPricing_GetListingOffersBatch), - new RateLimits(0.5M, 15, RateLimitType.Sales_GetOrderMetrics), - new RateLimits(0.016M, 15, RateLimitType.Sellers_GetMarketplaceParticipations), - new RateLimits(1.0M, 5, RateLimitType.Solicitations_GetSolicitationActionsForOrder), - new RateLimits(1.0M, 5, RateLimitType.Solicitations_CreateProductReviewAndSellerFeedbackSolicitation), - new RateLimits(1.0M, 10, RateLimitType.Token_CreateRestrictedDataToken), - new RateLimits(10.0M, 10, RateLimitType.VendorDirectFulfillmentOrdersV1_GetOrders), - new RateLimits(10.0M, 10, RateLimitType.VendorDirectFulfillmentOrdersV1_GetOrder), - new RateLimits(10.0M, 10, RateLimitType.VendorDirectFulfillmentOrdersV1_SubmitAcknowledgement), - new RateLimits(10.0M, 10, RateLimitType.VendorOrdersV1_GetPurchaseOrders), - new RateLimits(10.0M, 10, RateLimitType.VendorOrdersV1_GetPurchaseOrder), - new RateLimits(10.0M, 10, RateLimitType.VendorOrdersV1_SubmitAcknowledgement), - new RateLimits(10.0M, 10, RateLimitType.VendorOrdersV1_GetPurchaseOrdersStatus), - new RateLimits(10.0M, 10, RateLimitType.VendorTransactionStatus_GetTransaction), - }.ToDictionary(x => x.RateLimitType); } } -} +} \ No newline at end of file