Skip to content

Commit

Permalink
Merge pull request #20 from skl-hyf/main
Browse files Browse the repository at this point in the history
Complete GetInventorySummaries
  • Loading branch information
abuzuhri authored Nov 23, 2021
2 parents b10b586 + ae2bb10 commit a03f48f
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions Source/FikaAmazonAPI/Services/FbaInventoryService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FikaAmazonAPI.AmazonSpApiSDK.Models.FbaInventory;
using FikaAmazonAPI.AmazonSpApiSDK.Models.FbaInventory;
using FikaAmazonAPI.Parameter.FbaInventory;
using System;
using System.Collections.Generic;
Expand All @@ -22,15 +22,26 @@ public List<InventorySummaries> GetInventorySummaries(ParameterGetInventorySumma

CreateAuthorizedRequest(FbaInventoriesApiUrls.GetInventorySummaries, RestSharp.Method.GET, param);
var response = ExecuteRequest<GetInventorySummariesResponse>();
var nextToken = response.Pagination.NextToken;
var nextToken = response.Pagination?.NextToken;// Pagination is Null at last page
list.Add(response.Payload.InventorySummaries);
//while (!string.IsNullOrEmpty(nextToken))
//{
// var orderPayload = GetInventorySummariesByNextToken(nextToken);
// list.AddRange(orderPayload.Orders);
// nextToken = orderPayload.NextToken;
//}
while (!string.IsNullOrEmpty(nextToken))
{
var nextresponse = GetInventorySummariesByNextToken(nextToken,ParameterGetInventorySummaries);
list.Add(nextresponse.Payload.InventorySummaries);
nextToken = nextresponse.Pagination?.NextToken;
}
return list;
}

private GetInventorySummariesResponse GetInventorySummariesByNextToken(string nextToken,ParameterGetInventorySummaries parameterGetInventorySummaries)
{
parameterGetInventorySummaries.nextToken = nextToken;
var param = parameterGetInventorySummaries.getParameters();

CreateAuthorizedRequest(FbaInventoriesApiUrls.GetInventorySummaries, RestSharp.Method.GET, param);
var response = ExecuteRequest<GetInventorySummariesResponse>();

return response;
}
}
}

0 comments on commit a03f48f

Please sign in to comment.