From e6dfce695998e871f3a3bb6ef5a2b587e9de0797 Mon Sep 17 00:00:00 2001 From: Felix Cornelissen Date: Tue, 10 Dec 2024 11:09:46 +0100 Subject: [PATCH] fix: next url van objecten niet overnemen maar paginanummer zelf ophogen --- src/Kiss.Elastic.Sync/Objecten/ObjectenClient.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Kiss.Elastic.Sync/Objecten/ObjectenClient.cs b/src/Kiss.Elastic.Sync/Objecten/ObjectenClient.cs index c746472..7289fd4 100644 --- a/src/Kiss.Elastic.Sync/Objecten/ObjectenClient.cs +++ b/src/Kiss.Elastic.Sync/Objecten/ObjectenClient.cs @@ -39,8 +39,7 @@ public ObjectenClient(Uri objectenBaseUri, string? objectenToken, string? object public IAsyncEnumerable GetObjecten(string type, CancellationToken token) { - var url = $"/api/v2/objects?type={HttpUtility.UrlEncode(type)}"; - return GetObjectenInternal(url, token); + return GetObjectenInternal(type, 1, token); } private static string GetToken(string id, string secret) @@ -70,8 +69,10 @@ private static string GetToken(string id, string secret) return tokenHandler.WriteToken(token); } - private async IAsyncEnumerable GetObjectenInternal(string url, [EnumeratorCancellation] CancellationToken token) + private async IAsyncEnumerable GetObjectenInternal(string type, int page, [EnumeratorCancellation] CancellationToken token) { + var url = $"/api/v2/objects?type={HttpUtility.UrlEncode(type)}&page={page}"; + string? next = null; using (var message = new HttpRequestMessage(HttpMethod.Get, url)) @@ -113,7 +114,7 @@ private async IAsyncEnumerable GetObjectenInternal(string url, [En if (!string.IsNullOrWhiteSpace(next)) { - await foreach (var el in GetObjectenInternal(next, token)) + await foreach (var el in GetObjectenInternal(type, page + 1, token)) { yield return el; }