From 82db19253051183532e1c16ea3d2f52b63a57458 Mon Sep 17 00:00:00 2001 From: Jericho Date: Tue, 11 Jan 2022 10:33:23 -0500 Subject: [PATCH] (GH-368) Add missing 'limit' and 'offset' parameters --- Source/StrongGrid.IntegrationTests/Tests/ApiKeys.cs | 2 +- Source/StrongGrid/Resources/ApiKeys.cs | 8 ++++++-- Source/StrongGrid/Resources/IApiKeys.cs | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Source/StrongGrid.IntegrationTests/Tests/ApiKeys.cs b/Source/StrongGrid.IntegrationTests/Tests/ApiKeys.cs index f3a8d4ca..5b4576f3 100644 --- a/Source/StrongGrid.IntegrationTests/Tests/ApiKeys.cs +++ b/Source/StrongGrid.IntegrationTests/Tests/ApiKeys.cs @@ -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(50, 0, null, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"There are {apiKeys.Length} Api Keys").ConfigureAwait(false); // CLEANUP PREVIOUS INTEGRATION TESTS THAT MIGHT HAVE BEEN INTERRUPTED BEFORE THEY HAD TIME TO CLEANUP AFTER THEMSELVES diff --git a/Source/StrongGrid/Resources/ApiKeys.cs b/Source/StrongGrid/Resources/ApiKeys.cs index a7f3f8e2..2ad0df22 100644 --- a/Source/StrongGrid/Resources/ApiKeys.cs +++ b/Source/StrongGrid/Resources/ApiKeys.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Linq; using Pathoschild.Http.Client; using StrongGrid.Models; using StrongGrid.Utilities; @@ -52,6 +52,8 @@ public Task GetAsync(string keyId, string onBehalfOf = null, Cancellatio /// /// Get all API Keys belonging to the authenticated user. /// + /// The limit. + /// The offset. /// The user to impersonate. /// Cancellation token. /// @@ -61,10 +63,12 @@ public Task 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 retrieve keys one at a time. /// - public Task GetAllAsync(string onBehalfOf = null, CancellationToken cancellationToken = default) + public Task 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("result"); diff --git a/Source/StrongGrid/Resources/IApiKeys.cs b/Source/StrongGrid/Resources/IApiKeys.cs index 77580d37..c8537c7c 100644 --- a/Source/StrongGrid/Resources/IApiKeys.cs +++ b/Source/StrongGrid/Resources/IApiKeys.cs @@ -1,4 +1,4 @@ -using StrongGrid.Models; +using StrongGrid.Models; using StrongGrid.Utilities; using System.Collections.Generic; using System.Threading; @@ -28,6 +28,8 @@ public interface IApiKeys /// /// Get all API Keys belonging to the authenticated user. /// + /// The limit. + /// The offset. /// The user to impersonate. /// Cancellation token. /// @@ -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 retrieve keys one at a time. /// - Task GetAllAsync(string onBehalfOf = null, CancellationToken cancellationToken = default); + Task GetAllAsync(int limit = 50, int offset = 0, string onBehalfOf = null, CancellationToken cancellationToken = default); /// /// Generate a new API Key.