Skip to content

Commit

Permalink
(GH-368) Add missing 'limit' and 'offset' parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Aug 11, 2021
1 parent c50b213 commit 64b1b4c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Source/StrongGrid.IntegrationTests/Tests/ApiKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public async Task RunAsync(IBaseClient client, TextWriter log, CancellationToken
await log.WriteLineAsync("\n***** API KEYS *****\n").ConfigureAwait(false);

// GET ALL THE API KEYS
var apiKeys = await client.ApiKeys.GetAllAsync(null, cancellationToken).ConfigureAwait(false);
var apiKeys = await client.ApiKeys.GetAllAsync(100, 0, null, cancellationToken).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
Expand Down
6 changes: 5 additions & 1 deletion Source/StrongGrid/Resources/ApiKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public Task<ApiKey> GetAsync(string keyId, string onBehalfOf = null, Cancellatio
/// <summary>
/// Get all API Keys belonging to the authenticated user.
/// </summary>
/// <param name="limit">The limit.</param>
/// <param name="offset">The offset.</param>
/// <param name="onBehalfOf">The user to impersonate.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>
Expand All @@ -61,10 +63,12 @@ public Task<ApiKey> GetAsync(string keyId, string onBehalfOf = null, Cancellatio
/// 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<PaginatedResponseWithLinks<ApiKey>> GetAllAsync(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)
.AsPaginatedResponseWithLinks<ApiKey>("result");
Expand Down
4 changes: 3 additions & 1 deletion Source/StrongGrid/Resources/IApiKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public interface IApiKeys
/// <summary>
/// Get all API Keys belonging to the authenticated user.
/// </summary>
/// <param name="limit">The limit.</param>
/// <param name="offset">The offset.</param>
/// <param name="onBehalfOf">The user to impersonate.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>
Expand All @@ -37,7 +39,7 @@ public interface IApiKeys
/// 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<PaginatedResponseWithLinks<ApiKey>> GetAllAsync(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 64b1b4c

Please sign in to comment.