Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class Enhancement #691

Merged
merged 3 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// The quantity of reserved inventory.
/// </summary>
[DataContract]
public partial class FutureSupplyQuantity : IEquatable<FutureSupplyQuantity>, IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="FutureSupplyQuantity" /> class.
/// </summary>
/// <param name="ReservedFutureSupplyQuantity">The total number of units in Amazon&#39;s fulfillment network that are currently being picked, packed, and shipped; or are sidelined for measurement, sampling, or other internal processes..</param>
/// <param name="FutureSupplyBuyableQuantity">The number of units reserved for customer orders..</param>
public FutureSupplyQuantity(int? ReservedFutureSupplyQuantity = default(int?), int? FutureSupplyBuyableQuantity = default(int?))
{
this.ReservedFutureSupplyQuantity = ReservedFutureSupplyQuantity;
this.FutureSupplyBuyableQuantity = FutureSupplyBuyableQuantity;
}

/// <summary>
/// The total number of units in Amazon&#39;s fulfillment network that are currently being picked, packed, and shipped; or are sidelined for measurement, sampling, or other internal processes.
/// </summary>
/// <value>The total number of units in Amazon&#39;s fulfillment network that are currently being picked, packed, and shipped; or are sidelined for measurement, sampling, or other internal processes.</value>
[DataMember(Name = "reservedFutureSupplyQuantity", EmitDefaultValue = false)]
public int? ReservedFutureSupplyQuantity { get; set; }

/// <summary>
/// The number of units reserved for customer orders.
/// </summary>
/// <value>The number of units reserved for customer orders.</value>
[DataMember(Name = "futureSupplyBuyableQuantity", EmitDefaultValue = false)]
public int? FutureSupplyBuyableQuantity { get; set; }

/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
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();
}

/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}

/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="input">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object input)
{
return this.Equals(input as FutureSupplyQuantity);
}

/// <summary>
/// Returns true if FutureSupplyQuantity instances are equal
/// </summary>
/// <param name="input">Instance of FutureSupplyQuantity to be compared</param>
/// <returns>Boolean</returns>
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))
);
}

/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
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;
}
}

/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public partial class InventoryDetails : IEquatable<InventoryDetails>, IValidatab
/// <param name="ReservedQuantity">ReservedQuantity.</param>
/// <param name="ResearchingQuantity">ResearchingQuantity.</param>
/// <param name="UnfulfillableQuantity">UnfulfillableQuantity.</param>
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))
/// <param name="FutureSupplyQuantity">FutureSupplyQuantity.</param>
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;
Expand All @@ -42,6 +43,7 @@ public partial class InventoryDetails : IEquatable<InventoryDetails>, IValidatab
this.ReservedQuantity = ReservedQuantity;
this.ResearchingQuantity = ResearchingQuantity;
this.UnfulfillableQuantity = UnfulfillableQuantity;
this.FutureSupplyQuantity = FutureSupplyQuantity;
}

/// <summary>
Expand Down Expand Up @@ -90,6 +92,12 @@ public partial class InventoryDetails : IEquatable<InventoryDetails>, IValidatab
[DataMember(Name = "unfulfillableQuantity", EmitDefaultValue = false)]
public UnfulfillableQuantity UnfulfillableQuantity { get; set; }

/// <summary>
/// Gets or Sets FutureSupplyQuantity
/// </summary>
[DataMember(Name = "futureSupplyQuantity", EmitDefaultValue = false)]
public FutureSupplyQuantity FutureSupplyQuantity { get; set; }

/// <summary>
/// Returns the string presentation of the object
/// </summary>
Expand All @@ -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();
}
Expand Down Expand Up @@ -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))
);
}

Expand All @@ -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;
}
}
Expand Down
19 changes: 19 additions & 0 deletions Source/FikaAmazonAPI/Services/CatalogItemService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,26 @@ public async Task<IList<Item>> ListCatalogItemsAsync(ParameterListCatalogItems p

return list;
}
public String GetCatalogItemJson(string asin) =>
Task.Run(() => GetCatalogItemAsyncJson(asin)).ConfigureAwait(false).GetAwaiter().GetResult();

public async Task<String> GetCatalogItemAsyncJson(string asin)
{

if (string.IsNullOrEmpty(asin))
throw new InvalidDataException("asin is a required property and cannot be null");

var param = new List<KeyValuePair<string, string>>();
param.Add(new KeyValuePair<string, string>("MarketplaceId", AmazonCredential.MarketPlace.ID));

await CreateAuthorizedRequestAsync(CategoryApiUrls.GetCatalogItem(asin), RestSharp.Method.Get, param);
var response = await ExecuteRequestAsync<GetCatalogItemResponse>(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) =>
Expand Down
70 changes: 70 additions & 0 deletions Source/FikaAmazonAPI/Services/OrderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,77 @@ public async Task<OrdersList> GetGetOrdersByNextTokenAsync(string nextToken, Par
}

#endregion
#region GetOrders


public async Task<OrderList> GetOrdersAsync(ParameterOrderList searchOrderList)
{
var orderList = new OrderList();

if (searchOrderList.MarketplaceIds == null || searchOrderList.MarketplaceIds.Count == 0)
{
searchOrderList.MarketplaceIds = new List<string>();
searchOrderList.MarketplaceIds.Add(AmazonCredential.MarketPlace.ID);
}
var queryParameters = searchOrderList.getParameters();

await CreateAuthorizedRequestAsync(OrdersApiUrls.Orders, RestSharp.Method.Get, queryParameters, parameter: searchOrderList);
var response = await ExecuteRequestAsync<GetOrdersResponse>(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<OrdersList> GetGetOrdersByNextTokenAsync(string nextToken, ParameterOrderList searchOrderList)
{
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>();
queryParameters.Add(new KeyValuePair<string, string>("NextToken", nextToken));
queryParameters.Add(new KeyValuePair<string, string>("MarketplaceIds", string.Join(",", searchOrderList.MarketplaceIds)));

await CreateAuthorizedRequestAsync(OrdersApiUrls.Orders, RestSharp.Method.Get, queryParameters);
var response = await ExecuteRequestAsync<GetOrdersResponse>(Utils.RateLimitType.Order_GetOrders);
return response.Payload;
}
public OrdersList GetOrdersList(ParameterOrderList searchOrderList) =>
Task.Run(() => GetOrdersListAsync(searchOrderList)).ConfigureAwait(false).GetAwaiter().GetResult();
public async Task<OrdersList> GetOrdersListAsync(ParameterOrderList searchOrderList)
{
if (searchOrderList.MarketplaceIds == null || searchOrderList.MarketplaceIds.Count == 0)
{
searchOrderList.MarketplaceIds = new List<string>();
searchOrderList.MarketplaceIds.Add(AmazonCredential.MarketPlace.ID);
}
var queryParameters = searchOrderList.getParameters();

await CreateAuthorizedRequestAsync(OrdersApiUrls.Orders, RestSharp.Method.Get, queryParameters, parameter: searchOrderList);
var response = await ExecuteRequestAsync<GetOrdersResponse>(Utils.RateLimitType.Order_GetOrders);
return response.Payload;
}

#endregion
public Order GetOrder(ParameterGetOrder parameter) =>
Task.Run(() => GetOrderAsync(parameter)).ConfigureAwait(false).GetAwaiter().GetResult();
public async Task<Order> GetOrderAsync(ParameterGetOrder parameter, CancellationToken cancellationToken = default)
Expand Down
Loading