Skip to content

Commit

Permalink
(GH-367) IpAddresses.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 34ddb3d commit 706f0d8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Source/StrongGrid.IntegrationTests/Tests/IpAddresses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions Source/StrongGrid/Resources/IIpAddresses.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using StrongGrid.Models;
using StrongGrid.Models;
using System.Threading;
using System.Threading.Tasks;

Expand Down Expand Up @@ -50,9 +50,9 @@ public interface IIpAddresses
/// <param name="offset">The offset for the number of IPs that you are requesting.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>
/// An array of <see cref="IpAddress">IP addresses</see>.
/// The <see cref="PaginatedResponseWithLinks{IpAddress}">IP addresses</see>.
/// </returns>
Task<IpAddress[]> GetAllAsync(bool excludeWhitelabels = false, string subuser = null, int limit = 10, int offset = 0, CancellationToken cancellationToken = default);
Task<PaginatedResponseWithLinks<IpAddress>> GetAllAsync(bool excludeWhitelabels = false, string subuser = null, int limit = 10, int offset = 0, CancellationToken cancellationToken = default);

/// <summary>
/// Retrieve assigned IP addresses.
Expand Down
6 changes: 3 additions & 3 deletions Source/StrongGrid/Resources/IpAddresses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ public Task<IpAddress> GetAsync(string address, CancellationToken cancellationTo
/// <param name="offset">The offset for the number of IPs that you are requesting.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>
/// An array of <see cref="IpAddress">IP addresses</see>.
/// The <see cref="PaginatedResponseWithLinks{IpAddress}">IP addresses</see>.
/// </returns>
public Task<IpAddress[]> GetAllAsync(bool excludeWhitelabels = false, string subuser = null, int limit = 10, int offset = 0, CancellationToken cancellationToken = default)
public Task<PaginatedResponseWithLinks<IpAddress>> GetAllAsync(bool excludeWhitelabels = false, string subuser = null, int limit = 10, int offset = 0, CancellationToken cancellationToken = default)
{
var request = _client
.GetAsync(_endpoint)
Expand All @@ -113,7 +113,7 @@ public Task<IpAddress[]> GetAllAsync(bool excludeWhitelabels = false, string sub

if (!string.IsNullOrEmpty(subuser)) request.WithArgument("subuser", subuser);

return request.AsObject<IpAddress[]>();
return request.AsPaginatedResponseWithLinks<IpAddress>();
}

/// <summary>
Expand Down

0 comments on commit 706f0d8

Please sign in to comment.