Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: next url van objecten niet overnemen maar paginanummer zelf ophogen #21

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/Kiss.Elastic.Sync/Objecten/ObjectenClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public ObjectenClient(Uri objectenBaseUri, string? objectenToken, string? object

public IAsyncEnumerable<OverigObject> 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)
Expand Down Expand Up @@ -70,8 +69,10 @@ private static string GetToken(string id, string secret)
return tokenHandler.WriteToken(token);
}

private async IAsyncEnumerable<OverigObject> GetObjectenInternal(string url, [EnumeratorCancellation] CancellationToken token)
private async IAsyncEnumerable<OverigObject> 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))
Expand Down Expand Up @@ -113,7 +114,7 @@ private async IAsyncEnumerable<OverigObject> 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;
}
Expand Down
Loading