Skip to content

Commit e164e33

Browse files
authored
Merge pull request #691 from faizanahmad1094/main
Class Enhancement
2 parents 45e8cbf + 4a483cf commit e164e33

File tree

4 files changed

+241
-1
lines changed

4 files changed

+241
-1
lines changed
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/*
2+
* Selling Partner API for FBA Inventory
3+
*
4+
* The Selling Partner API for FBA Inventory lets you programmatically retrieve information about inventory in Amazon's fulfillment network.
5+
*
6+
* OpenAPI spec version: v1
7+
*
8+
* Generated by: https://github.com/swagger-api/swagger-codegen.git
9+
*/
10+
11+
using Newtonsoft.Json;
12+
using System;
13+
using System.Collections.Generic;
14+
using System.ComponentModel.DataAnnotations;
15+
using System.Runtime.Serialization;
16+
using System.Text;
17+
18+
namespace FikaAmazonAPI.AmazonSpApiSDK.Models.FbaInventory
19+
{
20+
/// <summary>
21+
/// The quantity of reserved inventory.
22+
/// </summary>
23+
[DataContract]
24+
public partial class FutureSupplyQuantity : IEquatable<FutureSupplyQuantity>, IValidatableObject
25+
{
26+
/// <summary>
27+
/// Initializes a new instance of the <see cref="FutureSupplyQuantity" /> class.
28+
/// </summary>
29+
/// <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>
30+
/// <param name="FutureSupplyBuyableQuantity">The number of units reserved for customer orders..</param>
31+
public FutureSupplyQuantity(int? ReservedFutureSupplyQuantity = default(int?), int? FutureSupplyBuyableQuantity = default(int?))
32+
{
33+
this.ReservedFutureSupplyQuantity = ReservedFutureSupplyQuantity;
34+
this.FutureSupplyBuyableQuantity = FutureSupplyBuyableQuantity;
35+
}
36+
37+
/// <summary>
38+
/// 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.
39+
/// </summary>
40+
/// <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>
41+
[DataMember(Name = "reservedFutureSupplyQuantity", EmitDefaultValue = false)]
42+
public int? ReservedFutureSupplyQuantity { get; set; }
43+
44+
/// <summary>
45+
/// The number of units reserved for customer orders.
46+
/// </summary>
47+
/// <value>The number of units reserved for customer orders.</value>
48+
[DataMember(Name = "futureSupplyBuyableQuantity", EmitDefaultValue = false)]
49+
public int? FutureSupplyBuyableQuantity { get; set; }
50+
51+
/// <summary>
52+
/// Returns the string presentation of the object
53+
/// </summary>
54+
/// <returns>String presentation of the object</returns>
55+
public override string ToString()
56+
{
57+
var sb = new StringBuilder();
58+
sb.Append("class FutureSupplyQuantity {\n");
59+
sb.Append(" ReservedFutureSupplyQuantity: ").Append(ReservedFutureSupplyQuantity).Append("\n");
60+
sb.Append(" FutureSupplyBuyableQuantity: ").Append(FutureSupplyBuyableQuantity).Append("\n");
61+
sb.Append("}\n");
62+
return sb.ToString();
63+
}
64+
65+
/// <summary>
66+
/// Returns the JSON string presentation of the object
67+
/// </summary>
68+
/// <returns>JSON string presentation of the object</returns>
69+
public string ToJson()
70+
{
71+
return JsonConvert.SerializeObject(this, Formatting.Indented);
72+
}
73+
74+
/// <summary>
75+
/// Returns true if objects are equal
76+
/// </summary>
77+
/// <param name="input">Object to be compared</param>
78+
/// <returns>Boolean</returns>
79+
public override bool Equals(object input)
80+
{
81+
return this.Equals(input as FutureSupplyQuantity);
82+
}
83+
84+
/// <summary>
85+
/// Returns true if FutureSupplyQuantity instances are equal
86+
/// </summary>
87+
/// <param name="input">Instance of FutureSupplyQuantity to be compared</param>
88+
/// <returns>Boolean</returns>
89+
public bool Equals(FutureSupplyQuantity input)
90+
{
91+
if (input == null)
92+
return false;
93+
94+
return
95+
(
96+
this.ReservedFutureSupplyQuantity == input.ReservedFutureSupplyQuantity ||
97+
(this.ReservedFutureSupplyQuantity != null &&
98+
this.ReservedFutureSupplyQuantity.Equals(input.ReservedFutureSupplyQuantity))
99+
) &&
100+
(
101+
this.FutureSupplyBuyableQuantity == input.FutureSupplyBuyableQuantity ||
102+
(this.FutureSupplyBuyableQuantity != null &&
103+
this.FutureSupplyBuyableQuantity.Equals(input.FutureSupplyBuyableQuantity))
104+
);
105+
}
106+
107+
/// <summary>
108+
/// Gets the hash code
109+
/// </summary>
110+
/// <returns>Hash code</returns>
111+
public override int GetHashCode()
112+
{
113+
unchecked // Overflow is fine, just wrap
114+
{
115+
int hashCode = 41;
116+
if (this.ReservedFutureSupplyQuantity != null)
117+
hashCode = hashCode * 59 + this.ReservedFutureSupplyQuantity.GetHashCode();
118+
if (this.FutureSupplyBuyableQuantity != null)
119+
hashCode = hashCode * 59 + this.FutureSupplyBuyableQuantity.GetHashCode();
120+
return hashCode;
121+
}
122+
}
123+
124+
/// <summary>
125+
/// To validate all properties of the instance
126+
/// </summary>
127+
/// <param name="validationContext">Validation context</param>
128+
/// <returns>Validation Result</returns>
129+
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
130+
{
131+
yield break;
132+
}
133+
}
134+
135+
}

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/FbaInventory/InventoryDetails.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public partial class InventoryDetails : IEquatable<InventoryDetails>, IValidatab
3333
/// <param name="ReservedQuantity">ReservedQuantity.</param>
3434
/// <param name="ResearchingQuantity">ResearchingQuantity.</param>
3535
/// <param name="UnfulfillableQuantity">UnfulfillableQuantity.</param>
36-
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))
36+
/// <param name="FutureSupplyQuantity">FutureSupplyQuantity.</param>
37+
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))
3738
{
3839
this.FulfillableQuantity = FulfillableQuantity;
3940
this.InboundWorkingQuantity = InboundWorkingQuantity;
@@ -42,6 +43,7 @@ public partial class InventoryDetails : IEquatable<InventoryDetails>, IValidatab
4243
this.ReservedQuantity = ReservedQuantity;
4344
this.ResearchingQuantity = ResearchingQuantity;
4445
this.UnfulfillableQuantity = UnfulfillableQuantity;
46+
this.FutureSupplyQuantity = FutureSupplyQuantity;
4547
}
4648

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

95+
/// <summary>
96+
/// Gets or Sets FutureSupplyQuantity
97+
/// </summary>
98+
[DataMember(Name = "futureSupplyQuantity", EmitDefaultValue = false)]
99+
public FutureSupplyQuantity FutureSupplyQuantity { get; set; }
100+
93101
/// <summary>
94102
/// Returns the string presentation of the object
95103
/// </summary>
@@ -105,6 +113,7 @@ public override string ToString()
105113
sb.Append(" ReservedQuantity: ").Append(ReservedQuantity).Append("\n");
106114
sb.Append(" ResearchingQuantity: ").Append(ResearchingQuantity).Append("\n");
107115
sb.Append(" UnfulfillableQuantity: ").Append(UnfulfillableQuantity).Append("\n");
116+
sb.Append(" FutureSupplyQuantity: ").Append(FutureSupplyQuantity).Append("\n");
108117
sb.Append("}\n");
109118
return sb.ToString();
110119
}
@@ -173,6 +182,11 @@ public bool Equals(InventoryDetails input)
173182
this.UnfulfillableQuantity == input.UnfulfillableQuantity ||
174183
(this.UnfulfillableQuantity != null &&
175184
this.UnfulfillableQuantity.Equals(input.UnfulfillableQuantity))
185+
) &&
186+
(
187+
this.FutureSupplyQuantity == input.FutureSupplyQuantity ||
188+
(this.FutureSupplyQuantity != null &&
189+
this.FutureSupplyQuantity.Equals(input.FutureSupplyQuantity))
176190
);
177191
}
178192

@@ -199,6 +213,8 @@ public override int GetHashCode()
199213
hashCode = hashCode * 59 + this.ResearchingQuantity.GetHashCode();
200214
if (this.UnfulfillableQuantity != null)
201215
hashCode = hashCode * 59 + this.UnfulfillableQuantity.GetHashCode();
216+
if (this.FutureSupplyQuantity != null)
217+
hashCode = hashCode * 59 + this.FutureSupplyQuantity.GetHashCode();
202218
return hashCode;
203219
}
204220
}

Source/FikaAmazonAPI/Services/CatalogItemService.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,26 @@ public async Task<IList<Item>> ListCatalogItemsAsync(ParameterListCatalogItems p
5353

5454
return list;
5555
}
56+
public String GetCatalogItemJson(string asin) =>
57+
Task.Run(() => GetCatalogItemAsyncJson(asin)).ConfigureAwait(false).GetAwaiter().GetResult();
5658

59+
public async Task<String> GetCatalogItemAsyncJson(string asin)
60+
{
61+
62+
if (string.IsNullOrEmpty(asin))
63+
throw new InvalidDataException("asin is a required property and cannot be null");
64+
65+
var param = new List<KeyValuePair<string, string>>();
66+
param.Add(new KeyValuePair<string, string>("MarketplaceId", AmazonCredential.MarketPlace.ID));
67+
68+
await CreateAuthorizedRequestAsync(CategoryApiUrls.GetCatalogItem(asin), RestSharp.Method.Get, param);
69+
var response = await ExecuteRequestAsync<GetCatalogItemResponse>(RateLimitType.CatalogItems_GetCatalogItem);
70+
71+
if (response != null && response.Payload != null)
72+
return response.Payload.ToJson();
73+
74+
return null;
75+
}
5776
[Obsolete("This method deprecated in June 2022. Please use GetCatalogItem(ParameterGetCatalogItem parameterListCatalogItem) instead.", true)]
5877
[EditorBrowsable(EditorBrowsableState.Never)]
5978
public Item GetCatalogItem(string asin) =>

Source/FikaAmazonAPI/Services/OrderService.cs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,77 @@ public async Task<OrdersList> GetGetOrdersByNextTokenAsync(string nextToken, Par
9494
}
9595

9696
#endregion
97+
#region GetOrders
98+
99+
100+
public async Task<OrderList> GetOrdersAsync(ParameterOrderList searchOrderList)
101+
{
102+
var orderList = new OrderList();
103+
104+
if (searchOrderList.MarketplaceIds == null || searchOrderList.MarketplaceIds.Count == 0)
105+
{
106+
searchOrderList.MarketplaceIds = new List<string>();
107+
searchOrderList.MarketplaceIds.Add(AmazonCredential.MarketPlace.ID);
108+
}
109+
var queryParameters = searchOrderList.getParameters();
110+
111+
await CreateAuthorizedRequestAsync(OrdersApiUrls.Orders, RestSharp.Method.Get, queryParameters, parameter: searchOrderList);
112+
var response = await ExecuteRequestAsync<GetOrdersResponse>(Utils.RateLimitType.Order_GetOrders);
113+
var nextToken = response.Payload.NextToken;
114+
orderList = response.Payload.Orders;
115+
int PageCount = 1;
116+
if (searchOrderList.MaxNumberOfPages.HasValue && searchOrderList.MaxNumberOfPages.Value == 1)
117+
{
118+
orderList.NextToken = nextToken;
119+
}
120+
else
121+
{
122+
while (!string.IsNullOrEmpty(nextToken))
123+
{
124+
var orderPayload = GetGetOrdersByNextToken(nextToken, searchOrderList);
125+
orderList.AddRange(orderPayload.Orders);
126+
nextToken = orderPayload.NextToken;
127+
128+
if (searchOrderList.MaxNumberOfPages.HasValue)
129+
{
130+
PageCount++;
131+
if (PageCount >= searchOrderList.MaxNumberOfPages.Value)
132+
break;
133+
}
134+
}
135+
}
136+
137+
return orderList;
138+
}
139+
140+
141+
public async Task<OrdersList> GetGetOrdersByNextTokenAsync(string nextToken, ParameterOrderList searchOrderList)
142+
{
143+
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>();
144+
queryParameters.Add(new KeyValuePair<string, string>("NextToken", nextToken));
145+
queryParameters.Add(new KeyValuePair<string, string>("MarketplaceIds", string.Join(",", searchOrderList.MarketplaceIds)));
97146

147+
await CreateAuthorizedRequestAsync(OrdersApiUrls.Orders, RestSharp.Method.Get, queryParameters);
148+
var response = await ExecuteRequestAsync<GetOrdersResponse>(Utils.RateLimitType.Order_GetOrders);
149+
return response.Payload;
150+
}
151+
public OrdersList GetOrdersList(ParameterOrderList searchOrderList) =>
152+
Task.Run(() => GetOrdersListAsync(searchOrderList)).ConfigureAwait(false).GetAwaiter().GetResult();
153+
public async Task<OrdersList> GetOrdersListAsync(ParameterOrderList searchOrderList)
154+
{
155+
if (searchOrderList.MarketplaceIds == null || searchOrderList.MarketplaceIds.Count == 0)
156+
{
157+
searchOrderList.MarketplaceIds = new List<string>();
158+
searchOrderList.MarketplaceIds.Add(AmazonCredential.MarketPlace.ID);
159+
}
160+
var queryParameters = searchOrderList.getParameters();
161+
162+
await CreateAuthorizedRequestAsync(OrdersApiUrls.Orders, RestSharp.Method.Get, queryParameters, parameter: searchOrderList);
163+
var response = await ExecuteRequestAsync<GetOrdersResponse>(Utils.RateLimitType.Order_GetOrders);
164+
return response.Payload;
165+
}
166+
167+
#endregion
98168
public Order GetOrder(ParameterGetOrder parameter) =>
99169
Task.Run(() => GetOrderAsync(parameter)).ConfigureAwait(false).GetAwaiter().GetResult();
100170
public async Task<Order> GetOrderAsync(ParameterGetOrder parameter, CancellationToken cancellationToken = default)

0 commit comments

Comments
 (0)