From 148ef705191e06512d77e829cfff0caa537c159b Mon Sep 17 00:00:00 2001 From: Jericho Date: Sat, 23 Jan 2021 15:22:51 -0500 Subject: [PATCH] (GH-367) Blocks.GetAllAsync must return PaginatedResponseWithLinks --- Source/StrongGrid.IntegrationTests/Tests/Blocks.cs | 2 +- Source/StrongGrid/Resources/Blocks.cs | 9 ++++----- Source/StrongGrid/Resources/IBlocks.cs | 6 +++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Source/StrongGrid.IntegrationTests/Tests/Blocks.cs b/Source/StrongGrid.IntegrationTests/Tests/Blocks.cs index 310cde4b..1f98481f 100644 --- a/Source/StrongGrid.IntegrationTests/Tests/Blocks.cs +++ b/Source/StrongGrid.IntegrationTests/Tests/Blocks.cs @@ -19,7 +19,7 @@ public async Task RunAsync(IBaseClient client, TextWriter log, CancellationToken var endDate = new DateTime(thisYear, 12, 31, 23, 59, 59); var blocks = await client.Blocks.GetAllAsync(startDate, endDate, 25, 0, null, cancellationToken).ConfigureAwait(false); - await log.WriteLineAsync($"All blocks retrieved. There are {blocks.Length} blocks in {lastYear} and {thisYear}").ConfigureAwait(false); + await log.WriteLineAsync($"All blocks retrieved. There are {blocks.Records.Length} blocks in {lastYear} and {thisYear}").ConfigureAwait(false); } } } diff --git a/Source/StrongGrid/Resources/Blocks.cs b/Source/StrongGrid/Resources/Blocks.cs index 9bd70df7..02dc0c8e 100644 --- a/Source/StrongGrid/Resources/Blocks.cs +++ b/Source/StrongGrid/Resources/Blocks.cs @@ -1,7 +1,6 @@ -using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Linq; using Pathoschild.Http.Client; using StrongGrid.Models; -using StrongGrid.Utilities; using System; using System.Collections.Generic; using System.Linq; @@ -42,9 +41,9 @@ internal Blocks(Pathoschild.Http.Client.IClient client) /// The user to impersonate. /// Cancellation token. /// - /// An array of Blocks. + /// The Blocks. /// - public Task GetAllAsync(DateTime? startDate = null, DateTime? endDate = null, int limit = 25, int offset = 0, string onBehalfOf = null, CancellationToken cancellationToken = default) + public Task> GetAllAsync(DateTime? startDate = null, DateTime? endDate = null, int limit = 25, int offset = 0, string onBehalfOf = null, CancellationToken cancellationToken = default) { return _client .GetAsync(_endpoint) @@ -54,7 +53,7 @@ public Task GetAllAsync(DateTime? startDate = null, DateTime? endDate = .WithArgument("limit", limit) .WithArgument("offset", offset) .WithCancellationToken(cancellationToken) - .AsObject(); + .AsPaginatedResponseWithLinks(); } /// diff --git a/Source/StrongGrid/Resources/IBlocks.cs b/Source/StrongGrid/Resources/IBlocks.cs index 8299c1d6..329caaff 100644 --- a/Source/StrongGrid/Resources/IBlocks.cs +++ b/Source/StrongGrid/Resources/IBlocks.cs @@ -1,4 +1,4 @@ -using StrongGrid.Models; +using StrongGrid.Models; using System; using System.Collections.Generic; using System.Threading; @@ -24,9 +24,9 @@ public interface IBlocks /// The user to impersonate. /// Cancellation token. /// - /// An array of Blocks. + /// The Blocks. /// - Task GetAllAsync(DateTime? startDate = null, DateTime? endDate = null, int limit = 25, int offset = 0, string onBehalfOf = null, CancellationToken cancellationToken = default); + Task> GetAllAsync(DateTime? startDate = null, DateTime? endDate = null, int limit = 25, int offset = 0, string onBehalfOf = null, CancellationToken cancellationToken = default); /// /// Retrieve the blocks for a specific email address.