From 5b1684ec190393a582c2e2071d98d448c69cba41 Mon Sep 17 00:00:00 2001 From: Jericho Date: Sat, 23 Jan 2021 15:38:00 -0500 Subject: [PATCH] (GH-367) IpAddresses.GetAllAsync must return PaginatedResponseWithLinks --- Source/StrongGrid.IntegrationTests/Tests/IpAddresses.cs | 6 +++--- Source/StrongGrid/Resources/IIpAddresses.cs | 6 +++--- Source/StrongGrid/Resources/IpAddresses.cs | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/StrongGrid.IntegrationTests/Tests/IpAddresses.cs b/Source/StrongGrid.IntegrationTests/Tests/IpAddresses.cs index 19041f23..6f0009f2 100644 --- a/Source/StrongGrid.IntegrationTests/Tests/IpAddresses.cs +++ b/Source/StrongGrid.IntegrationTests/Tests/IpAddresses.cs @@ -15,12 +15,12 @@ public async Task RunAsync(IBaseClient client, TextWriter log, CancellationToken // GET ALL THE IP ADDRESSES var allIpAddresses = await client.IpAddresses.GetAllAsync(false, null, 10, 0, cancellationToken).ConfigureAwait(false); - await log.WriteLineAsync($"There are {allIpAddresses.Length} IP addresses on your account").ConfigureAwait(false); + await log.WriteLineAsync($"There are {allIpAddresses.Records.Length} IP addresses on your account").ConfigureAwait(false); // GET A SPECIFIC IP ADDRESS - if (allIpAddresses != null && allIpAddresses.Any()) + if (allIpAddresses != null && allIpAddresses.Records.Any()) { - var firstAddress = await client.IpAddresses.GetAsync(allIpAddresses.First().Address, cancellationToken).ConfigureAwait(false); + var firstAddress = await client.IpAddresses.GetAsync(allIpAddresses.Records.First().Address, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"IP address {firstAddress.Address} was retrieved").ConfigureAwait(false); } diff --git a/Source/StrongGrid/Resources/IIpAddresses.cs b/Source/StrongGrid/Resources/IIpAddresses.cs index cea52328..54c0d707 100644 --- a/Source/StrongGrid/Resources/IIpAddresses.cs +++ b/Source/StrongGrid/Resources/IIpAddresses.cs @@ -1,4 +1,4 @@ -using StrongGrid.Models; +using StrongGrid.Models; using System.Threading; using System.Threading.Tasks; @@ -50,9 +50,9 @@ public interface IIpAddresses /// The offset for the number of IPs that you are requesting. /// Cancellation token. /// - /// An array of IP addresses. + /// The IP addresses. /// - Task GetAllAsync(bool excludeWhitelabels = false, string subuser = null, int limit = 10, int offset = 0, CancellationToken cancellationToken = default); + Task> GetAllAsync(bool excludeWhitelabels = false, string subuser = null, int limit = 10, int offset = 0, CancellationToken cancellationToken = default); /// /// Retrieve assigned IP addresses. diff --git a/Source/StrongGrid/Resources/IpAddresses.cs b/Source/StrongGrid/Resources/IpAddresses.cs index 9681f36d..97703375 100644 --- a/Source/StrongGrid/Resources/IpAddresses.cs +++ b/Source/StrongGrid/Resources/IpAddresses.cs @@ -94,9 +94,9 @@ public Task GetAsync(string address, CancellationToken cancellationTo /// The offset for the number of IPs that you are requesting. /// Cancellation token. /// - /// An array of IP addresses. + /// The IP addresses. /// - public Task GetAllAsync(bool excludeWhitelabels = false, string subuser = null, int limit = 10, int offset = 0, CancellationToken cancellationToken = default) + public Task> GetAllAsync(bool excludeWhitelabels = false, string subuser = null, int limit = 10, int offset = 0, CancellationToken cancellationToken = default) { var request = _client .GetAsync(_endpoint) @@ -108,7 +108,7 @@ public Task GetAllAsync(bool excludeWhitelabels = false, string sub if (!string.IsNullOrEmpty(subuser)) request.WithArgument("subuser", subuser); - return request.AsObject(); + return request.AsPaginatedResponseWithLinks(); } /// @@ -137,7 +137,7 @@ public async Task GetUnassignedAsync(CancellationToken cancellation { var allIpAddresses = await this.GetAllAsync(cancellationToken: cancellationToken).ConfigureAwait(false); - var unassignedIpAddresses = allIpAddresses + var unassignedIpAddresses = allIpAddresses.Records .Where(ip => ip.Subusers == null || !ip.Subusers.Any()) .ToArray();