Skip to content

Commit

Permalink
(GH-367) ApiKeys.GetAllAsync must return PaginatedResponseWithLinks
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Aug 4, 2024
1 parent d61c939 commit 9cebd7e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Source/StrongGrid.IntegrationTests/Tests/ApiKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public async Task RunAsync(IBaseClient client, TextWriter log, CancellationToken

// GET ALL THE API KEYS
var apiKeys = await client.ApiKeys.GetAllAsync(50, 0, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"There are {apiKeys.Length} Api Keys").ConfigureAwait(false);
await log.WriteLineAsync($"There are {apiKeys.Records.Length} Api Keys").ConfigureAwait(false);

// CLEANUP PREVIOUS INTEGRATION TESTS THAT MIGHT HAVE BEEN INTERRUPTED BEFORE THEY HAD TIME TO CLEANUP AFTER THEMSELVES
var cleanUpTasks = apiKeys
var cleanUpTasks = apiKeys.Records
.Where(k => k.Name.StartsWith("StrongGrid Integration Testing:"))
.Select(async oldApiKey =>
{
Expand Down
6 changes: 3 additions & 3 deletions Source/StrongGrid/Resources/ApiKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@ public Task<ApiKey> GetAsync(string keyId, string onBehalfOf = null, Cancellatio
/// <param name="onBehalfOf">The user to impersonate.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>
/// An array of <see cref="ApiKey" />.
/// The <see cref="PaginatedResponseWithLinks{ApiKey}" />.
/// </returns>
/// <remarks>
/// The response does not include the permissions associated with each api key.
/// In order to get the permission for a given key, you need to <see cref="GetAsync(string, string, CancellationToken)">retrieve keys one at a time</see>.
/// </remarks>
public Task<ApiKey[]> GetAllAsync(int limit = 50, int offset = 0, string onBehalfOf = null, CancellationToken cancellationToken = default)
public Task<PaginatedResponseWithLinks<ApiKey>> GetAllAsync(int limit = 50, int offset = 0, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
return _client
.GetAsync(_endpoint)
.WithArgument("limit", limit)
.WithArgument("offset", offset)
.OnBehalfOf(onBehalfOf)
.WithCancellationToken(cancellationToken)
.AsObject<ApiKey[]>("result");
.AsPaginatedResponseWithLinks<ApiKey>("result");
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Source/StrongGrid/Resources/IApiKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public interface IApiKeys
/// <param name="onBehalfOf">The user to impersonate.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>
/// An array of <see cref="ApiKey" />.
/// The <see cref="PaginatedResponseWithLinks{ApiKey}" />.
/// </returns>
/// <remarks>
/// The response does not include the permissions associated with each api key.
/// In order to get the permission for a given key, you need to <see cref="GetAsync(string, string, CancellationToken)">retrieve keys one at a time</see>.
/// </remarks>
Task<ApiKey[]> GetAllAsync(int limit = 50, int offset = 0, string onBehalfOf = null, CancellationToken cancellationToken = default);
Task<PaginatedResponseWithLinks<ApiKey>> GetAllAsync(int limit = 50, int offset = 0, string onBehalfOf = null, CancellationToken cancellationToken = default);

/// <summary>
/// Generate a new API Key.
Expand Down

0 comments on commit 9cebd7e

Please sign in to comment.