diff --git a/Source/FikaAmazonAPI/AmazonSpApiSDK/Models/FbaInventory/FutureSupplyQuantity.cs b/Source/FikaAmazonAPI/AmazonSpApiSDK/Models/FbaInventory/FutureSupplyQuantity.cs new file mode 100644 index 00000000..61296493 --- /dev/null +++ b/Source/FikaAmazonAPI/AmazonSpApiSDK/Models/FbaInventory/FutureSupplyQuantity.cs @@ -0,0 +1,135 @@ +/* + * Selling Partner API for FBA Inventory + * + * The Selling Partner API for FBA Inventory lets you programmatically retrieve information about inventory in Amazon's fulfillment network. + * + * OpenAPI spec version: v1 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using System.Text; + +namespace FikaAmazonAPI.AmazonSpApiSDK.Models.FbaInventory +{ + /// + /// The quantity of reserved inventory. + /// + [DataContract] + public partial class FutureSupplyQuantity : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// The total number of units in Amazon's fulfillment network that are currently being picked, packed, and shipped; or are sidelined for measurement, sampling, or other internal processes.. + /// The number of units reserved for customer orders.. + public FutureSupplyQuantity(int? ReservedFutureSupplyQuantity = default(int?), int? FutureSupplyBuyableQuantity = default(int?)) + { + this.ReservedFutureSupplyQuantity = ReservedFutureSupplyQuantity; + this.FutureSupplyBuyableQuantity = FutureSupplyBuyableQuantity; + } + + /// + /// The total number of units in Amazon's fulfillment network that are currently being picked, packed, and shipped; or are sidelined for measurement, sampling, or other internal processes. + /// + /// The total number of units in Amazon's fulfillment network that are currently being picked, packed, and shipped; or are sidelined for measurement, sampling, or other internal processes. + [DataMember(Name = "reservedFutureSupplyQuantity", EmitDefaultValue = false)] + public int? ReservedFutureSupplyQuantity { get; set; } + + /// + /// The number of units reserved for customer orders. + /// + /// The number of units reserved for customer orders. + [DataMember(Name = "futureSupplyBuyableQuantity", EmitDefaultValue = false)] + public int? FutureSupplyBuyableQuantity { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class FutureSupplyQuantity {\n"); + sb.Append(" ReservedFutureSupplyQuantity: ").Append(ReservedFutureSupplyQuantity).Append("\n"); + sb.Append(" FutureSupplyBuyableQuantity: ").Append(FutureSupplyBuyableQuantity).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as FutureSupplyQuantity); + } + + /// + /// Returns true if FutureSupplyQuantity instances are equal + /// + /// Instance of FutureSupplyQuantity to be compared + /// Boolean + public bool Equals(FutureSupplyQuantity input) + { + if (input == null) + return false; + + return + ( + this.ReservedFutureSupplyQuantity == input.ReservedFutureSupplyQuantity || + (this.ReservedFutureSupplyQuantity != null && + this.ReservedFutureSupplyQuantity.Equals(input.ReservedFutureSupplyQuantity)) + ) && + ( + this.FutureSupplyBuyableQuantity == input.FutureSupplyBuyableQuantity || + (this.FutureSupplyBuyableQuantity != null && + this.FutureSupplyBuyableQuantity.Equals(input.FutureSupplyBuyableQuantity)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ReservedFutureSupplyQuantity != null) + hashCode = hashCode * 59 + this.ReservedFutureSupplyQuantity.GetHashCode(); + if (this.FutureSupplyBuyableQuantity != null) + hashCode = hashCode * 59 + this.FutureSupplyBuyableQuantity.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/Source/FikaAmazonAPI/AmazonSpApiSDK/Models/FbaInventory/InventoryDetails.cs b/Source/FikaAmazonAPI/AmazonSpApiSDK/Models/FbaInventory/InventoryDetails.cs index f2b89d2e..4beb4c82 100644 --- a/Source/FikaAmazonAPI/AmazonSpApiSDK/Models/FbaInventory/InventoryDetails.cs +++ b/Source/FikaAmazonAPI/AmazonSpApiSDK/Models/FbaInventory/InventoryDetails.cs @@ -33,7 +33,8 @@ public partial class InventoryDetails : IEquatable, IValidatab /// ReservedQuantity. /// ResearchingQuantity. /// UnfulfillableQuantity. - public InventoryDetails(int? FulfillableQuantity = default(int?), int? InboundWorkingQuantity = default(int?), int? InboundShippedQuantity = default(int?), int? InboundReceivingQuantity = default(int?), ReservedQuantity ReservedQuantity = default(ReservedQuantity), ResearchingQuantity ResearchingQuantity = default(ResearchingQuantity), UnfulfillableQuantity UnfulfillableQuantity = default(UnfulfillableQuantity)) + /// FutureSupplyQuantity. + public InventoryDetails(int? FulfillableQuantity = default(int?), int? InboundWorkingQuantity = default(int?), int? InboundShippedQuantity = default(int?), int? InboundReceivingQuantity = default(int?), ReservedQuantity ReservedQuantity = default(ReservedQuantity), ResearchingQuantity ResearchingQuantity = default(ResearchingQuantity), UnfulfillableQuantity UnfulfillableQuantity = default(UnfulfillableQuantity), FutureSupplyQuantity FutureSupplyQuantity = default(FutureSupplyQuantity)) { this.FulfillableQuantity = FulfillableQuantity; this.InboundWorkingQuantity = InboundWorkingQuantity; @@ -42,6 +43,7 @@ public partial class InventoryDetails : IEquatable, IValidatab this.ReservedQuantity = ReservedQuantity; this.ResearchingQuantity = ResearchingQuantity; this.UnfulfillableQuantity = UnfulfillableQuantity; + this.FutureSupplyQuantity = FutureSupplyQuantity; } /// @@ -90,6 +92,12 @@ public partial class InventoryDetails : IEquatable, IValidatab [DataMember(Name = "unfulfillableQuantity", EmitDefaultValue = false)] public UnfulfillableQuantity UnfulfillableQuantity { get; set; } + /// + /// Gets or Sets FutureSupplyQuantity + /// + [DataMember(Name = "futureSupplyQuantity", EmitDefaultValue = false)] + public FutureSupplyQuantity FutureSupplyQuantity { get; set; } + /// /// Returns the string presentation of the object /// @@ -105,6 +113,7 @@ public override string ToString() sb.Append(" ReservedQuantity: ").Append(ReservedQuantity).Append("\n"); sb.Append(" ResearchingQuantity: ").Append(ResearchingQuantity).Append("\n"); sb.Append(" UnfulfillableQuantity: ").Append(UnfulfillableQuantity).Append("\n"); + sb.Append(" FutureSupplyQuantity: ").Append(FutureSupplyQuantity).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -173,6 +182,11 @@ public bool Equals(InventoryDetails input) this.UnfulfillableQuantity == input.UnfulfillableQuantity || (this.UnfulfillableQuantity != null && this.UnfulfillableQuantity.Equals(input.UnfulfillableQuantity)) + ) && + ( + this.FutureSupplyQuantity == input.FutureSupplyQuantity || + (this.FutureSupplyQuantity != null && + this.FutureSupplyQuantity.Equals(input.FutureSupplyQuantity)) ); } @@ -199,6 +213,8 @@ public override int GetHashCode() hashCode = hashCode * 59 + this.ResearchingQuantity.GetHashCode(); if (this.UnfulfillableQuantity != null) hashCode = hashCode * 59 + this.UnfulfillableQuantity.GetHashCode(); + if (this.FutureSupplyQuantity != null) + hashCode = hashCode * 59 + this.FutureSupplyQuantity.GetHashCode(); return hashCode; } } diff --git a/Source/FikaAmazonAPI/Services/CatalogItemService.cs b/Source/FikaAmazonAPI/Services/CatalogItemService.cs index 0c6e345f..cf190dd0 100644 --- a/Source/FikaAmazonAPI/Services/CatalogItemService.cs +++ b/Source/FikaAmazonAPI/Services/CatalogItemService.cs @@ -53,7 +53,26 @@ public async Task> ListCatalogItemsAsync(ParameterListCatalogItems p return list; } + public String GetCatalogItemJson(string asin) => + Task.Run(() => GetCatalogItemAsyncJson(asin)).ConfigureAwait(false).GetAwaiter().GetResult(); + public async Task GetCatalogItemAsyncJson(string asin) + { + + if (string.IsNullOrEmpty(asin)) + throw new InvalidDataException("asin is a required property and cannot be null"); + + var param = new List>(); + param.Add(new KeyValuePair("MarketplaceId", AmazonCredential.MarketPlace.ID)); + + await CreateAuthorizedRequestAsync(CategoryApiUrls.GetCatalogItem(asin), RestSharp.Method.Get, param); + var response = await ExecuteRequestAsync(RateLimitType.CatalogItems_GetCatalogItem); + + if (response != null && response.Payload != null) + return response.Payload.ToJson(); + + return null; + } [Obsolete("This method deprecated in June 2022. Please use GetCatalogItem(ParameterGetCatalogItem parameterListCatalogItem) instead.", true)] [EditorBrowsable(EditorBrowsableState.Never)] public Item GetCatalogItem(string asin) => diff --git a/Source/FikaAmazonAPI/Services/OrderService.cs b/Source/FikaAmazonAPI/Services/OrderService.cs index 8c9fac1a..b658d0fc 100644 --- a/Source/FikaAmazonAPI/Services/OrderService.cs +++ b/Source/FikaAmazonAPI/Services/OrderService.cs @@ -94,7 +94,77 @@ public async Task GetGetOrdersByNextTokenAsync(string nextToken, Par } #endregion + #region GetOrders + + + public async Task GetOrdersAsync(ParameterOrderList searchOrderList) + { + var orderList = new OrderList(); + + if (searchOrderList.MarketplaceIds == null || searchOrderList.MarketplaceIds.Count == 0) + { + searchOrderList.MarketplaceIds = new List(); + searchOrderList.MarketplaceIds.Add(AmazonCredential.MarketPlace.ID); + } + var queryParameters = searchOrderList.getParameters(); + + await CreateAuthorizedRequestAsync(OrdersApiUrls.Orders, RestSharp.Method.Get, queryParameters, parameter: searchOrderList); + var response = await ExecuteRequestAsync(Utils.RateLimitType.Order_GetOrders); + var nextToken = response.Payload.NextToken; + orderList = response.Payload.Orders; + int PageCount = 1; + if (searchOrderList.MaxNumberOfPages.HasValue && searchOrderList.MaxNumberOfPages.Value == 1) + { + orderList.NextToken = nextToken; + } + else + { + while (!string.IsNullOrEmpty(nextToken)) + { + var orderPayload = GetGetOrdersByNextToken(nextToken, searchOrderList); + orderList.AddRange(orderPayload.Orders); + nextToken = orderPayload.NextToken; + + if (searchOrderList.MaxNumberOfPages.HasValue) + { + PageCount++; + if (PageCount >= searchOrderList.MaxNumberOfPages.Value) + break; + } + } + } + + return orderList; + } + + + public async Task GetGetOrdersByNextTokenAsync(string nextToken, ParameterOrderList searchOrderList) + { + List> queryParameters = new List>(); + queryParameters.Add(new KeyValuePair("NextToken", nextToken)); + queryParameters.Add(new KeyValuePair("MarketplaceIds", string.Join(",", searchOrderList.MarketplaceIds))); + await CreateAuthorizedRequestAsync(OrdersApiUrls.Orders, RestSharp.Method.Get, queryParameters); + 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) + { + if (searchOrderList.MarketplaceIds == null || searchOrderList.MarketplaceIds.Count == 0) + { + searchOrderList.MarketplaceIds = new List(); + searchOrderList.MarketplaceIds.Add(AmazonCredential.MarketPlace.ID); + } + var queryParameters = searchOrderList.getParameters(); + + await CreateAuthorizedRequestAsync(OrdersApiUrls.Orders, RestSharp.Method.Get, queryParameters, parameter: searchOrderList); + var response = await ExecuteRequestAsync(Utils.RateLimitType.Order_GetOrders); + return response.Payload; + } + + #endregion public Order GetOrder(ParameterGetOrder parameter) => Task.Run(() => GetOrderAsync(parameter)).ConfigureAwait(false).GetAwaiter().GetResult(); public async Task GetOrderAsync(ParameterGetOrder parameter, CancellationToken cancellationToken = default)