public async Task <Option <IPaginatedResponse <TResult> > > ExecuteRequest <TResult>( IPaginatedNotionRequest <PaginatedResponse <TResult> > notionRequest) { var myRequest = Interlocked.Add(ref _requestNumber, 1); _logger.LogInformation("Performing paginated request {RequestNumber}", myRequest); var pageNumber = 0; IPaginatedResponse <TResult> result = null; while (true) { pageNumber++; if (_notionClientOptions.LimitPagesToRetrieve > 0 && _notionClientOptions.LimitPagesToRetrieve < pageNumber) { break; } _logger.LogDebug("Requesting page {PageNumber} for request {RequestNumber}", pageNumber, myRequest); var nextResult = await ExecuteRequest <PaginatedResponse <TResult> >(notionRequest); _logger.LogDebug("Received response for page {PageNumber} for request {RequestNumber}", pageNumber, myRequest); if (!nextResult.HasValue) { break; } var nextResultValue = nextResult.Value; if (result == null) { result = nextResultValue; } else { foreach (var additionalResult in nextResultValue.Results) { result.Results.Add(additionalResult); } } if (!nextResultValue.HasMore) { break; } notionRequest.SetStartCursor(nextResultValue.NextCursor); } _logger.LogInformation("Finished paginated request {RequestNumber}", myRequest); return(Option <IPaginatedResponse <TResult> > .From(result)); }
public void Aggregate(IPaginatedResponse other) { var otherTyped = ( OrderList )other; if (otherTyped != null) { if (otherTyped.Sale != null) { Sale = Sale.Concat(otherTyped.Sale).ToArray(); } } }
public void Aggregate(IPaginatedResponse other) { var otherTyped = ( ShopsList )other; if (otherTyped != null) { if (otherTyped.Shop != null) { Shop = Shop.Concat(otherTyped.Shop).ToArray(); } } }
public void Aggregate(IPaginatedResponse other) { var otherTyped = ( LightspeedProductList )other; if (otherTyped != null) { if (otherTyped.Item != null) { Item = Item.Concat(otherTyped.Item).ToArray(); } } }