File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 4
4
5
5
namespace FikaAmazonAPI . Parameter . CatalogItems
6
6
{
7
- public class ParameterSearchCatalogItems202204 : ParameterBased
7
+ public class ParameterSearchCatalogItems202204 : PaginationParameter
8
8
{
9
9
public IList < string > identifiers { get ; set ; }
10
10
public IList < string > marketplaceIds { get ; set ; } = new List < string > ( ) ;
@@ -16,7 +16,6 @@ public class ParameterSearchCatalogItems202204 : ParameterBased
16
16
public IList < string > brandNames { get ; set ; } = new List < string > ( ) ;
17
17
public IList < string > classificationIds { get ; set ; } = new List < string > ( ) ;
18
18
public string pageToken { get ; set ; }
19
- public string keywordsLocale { get ; set ; }
20
- public int ? pageSize { get ; set ; } = 20 ;
19
+ public string keywordsLocale { get ; set ; }
21
20
}
22
21
}
Original file line number Diff line number Diff line change
1
+ using FikaAmazonAPI . AmazonSpApiSDK . Models . Token ;
2
+ using FikaAmazonAPI . Search ;
3
+
4
+ namespace FikaAmazonAPI . Parameter
5
+ {
6
+ public class PaginationParameter : ParameterBased
7
+ {
8
+ public int ? pageSize { get ; set ; } = 20 ;
9
+ [ IgnoreToAddParameterAttribute ]
10
+ public int ? maxPages { get ; set ; } = 20 ;
11
+ }
12
+ }
Original file line number Diff line number Diff line change @@ -164,15 +164,17 @@ public AmazonSpApiSDK.Models.CatalogItems.V20220401.Item GetCatalogItem202204(Pa
164
164
await CreateAuthorizedRequestAsync ( CategoryApiUrls . SearchCatalogItems202204 , RestSharp . Method . GET , param ) ;
165
165
var response = await ExecuteRequestAsync < ItemSearchResults > ( RateLimitType . CatalogItems20220401_SearchCatalogItems ) ;
166
166
list . AddRange ( response . Items ) ;
167
+ var totalPages = 1 ;
167
168
if ( response . Pagination != null && ! string . IsNullOrEmpty ( response . Pagination . NextToken ) )
168
169
{
169
170
var nextToken = response . Pagination . NextToken ;
170
- while ( ! string . IsNullOrEmpty ( nextToken ) )
171
+ while ( ! string . IsNullOrEmpty ( nextToken ) && ( ! parameter . maxPages . HasValue || totalPages < parameter . maxPages . Value ) )
171
172
{
172
173
parameter . pageToken = nextToken ;
173
174
var getItemNextPage = await SearchCatalogItemsByNextToken202204Async ( parameter ) ;
174
175
list . AddRange ( getItemNextPage . Items ) ;
175
176
nextToken = getItemNextPage . Pagination ? . NextToken ;
177
+ totalPages ++ ;
176
178
}
177
179
}
178
180
return list ;
You can’t perform that action at this time.
0 commit comments