From cd31175c278b050981c94c75c5ed0b4997857bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=B6rner?= Date: Sat, 25 Apr 2026 09:07:05 +0200 Subject: [PATCH] Add cancellation token support in TurnierplanClient --- src/Turnierplan.Adapter/TurnierplanClient.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Turnierplan.Adapter/TurnierplanClient.cs b/src/Turnierplan.Adapter/TurnierplanClient.cs index 9931c9a5..8ab9a591 100644 --- a/src/Turnierplan.Adapter/TurnierplanClient.cs +++ b/src/Turnierplan.Adapter/TurnierplanClient.cs @@ -64,6 +64,7 @@ public TurnierplanClient(TurnierplanClientOptions options) /// Fetches a single tournament from the API and returns the deserialized . /// /// The ID of the tournament to request. + /// The cancellation token to cancel operation. /// An instance of the class which contains the data returned by the API. /// /// @@ -71,10 +72,10 @@ public TurnierplanClient(TurnierplanClientOptions options) /// Thrown if the version of the server does not match the version of the Turnierplan.Adapter library. /// /// - public async Task GetTournament(string tournamentId) + public async Task GetTournament(string tournamentId, CancellationToken cancellationToken = default) { var request = new HttpRequestMessage(HttpMethod.Get, $"/api/tournaments/{tournamentId}"); - var response = await _httpClient.SendAsync(request).ConfigureAwait(false); + var response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false); EnsureSuccessResponse(response); VerifyServerVersion(response); @@ -87,6 +88,7 @@ public async Task GetTournament(string tournamentId) /// 0..n entries of the type . /// /// The ID of the folder to request. + /// The cancellation token to cancel operation. /// A list of instances which contains the data returned by the API. /// /// @@ -94,11 +96,11 @@ public async Task GetTournament(string tournamentId) /// Thrown if the version of the server does not match the version of the Turnierplan.Adapter library. /// /// - public async Task> GetTournaments(string folderId) + public async Task> GetTournaments(string folderId, CancellationToken cancellationToken = default) { var query = new QueryBuilder { { "folderId", folderId } }; var request = new HttpRequestMessage(HttpMethod.Get, $"/api/tournaments{query}"); - var response = await _httpClient.SendAsync(request).ConfigureAwait(false); + var response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false); EnsureSuccessResponse(response); VerifyServerVersion(response);