1
- using FikaAmazonAPI . AmazonSpApiSDK . Models . FbaInventory ;
1
+ using FikaAmazonAPI . AmazonSpApiSDK . Models . FbaInventory ;
2
2
using FikaAmazonAPI . Parameter . FbaInventory ;
3
3
using System ;
4
4
using System . Collections . Generic ;
@@ -22,15 +22,26 @@ public List<InventorySummaries> GetInventorySummaries(ParameterGetInventorySumma
22
22
23
23
CreateAuthorizedRequest ( FbaInventoriesApiUrls . GetInventorySummaries , RestSharp . Method . GET , param ) ;
24
24
var response = ExecuteRequest < GetInventorySummariesResponse > ( ) ;
25
- var nextToken = response . Pagination . NextToken ;
25
+ var nextToken = response . Pagination ? . NextToken ; // Pagination is Null at last page
26
26
list . Add ( response . Payload . InventorySummaries ) ;
27
- // while (!string.IsNullOrEmpty(nextToken))
28
- // {
29
- // var orderPayload = GetInventorySummariesByNextToken(nextToken);
30
- // list.AddRange(orderPayload.Orders );
31
- // nextToken = orderPayload .NextToken;
32
- // }
27
+ while ( ! string . IsNullOrEmpty ( nextToken ) )
28
+ {
29
+ var nextresponse = GetInventorySummariesByNextToken ( nextToken , ParameterGetInventorySummaries ) ;
30
+ list . Add ( nextresponse . Payload . InventorySummaries ) ;
31
+ nextToken = nextresponse . Pagination ? . NextToken ;
32
+ }
33
33
return list ;
34
34
}
35
+
36
+ private GetInventorySummariesResponse GetInventorySummariesByNextToken ( string nextToken , ParameterGetInventorySummaries parameterGetInventorySummaries )
37
+ {
38
+ parameterGetInventorySummaries . nextToken = nextToken ;
39
+ var param = parameterGetInventorySummaries . getParameters ( ) ;
40
+
41
+ CreateAuthorizedRequest ( FbaInventoriesApiUrls . GetInventorySummaries , RestSharp . Method . GET , param ) ;
42
+ var response = ExecuteRequest < GetInventorySummariesResponse > ( ) ;
43
+
44
+ return response ;
45
+ }
35
46
}
36
47
}
0 commit comments