Skip to content

Commit

Permalink
(GH-367) Blocks.GetAllAsync must return PaginatedResponseWithLinks
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Apr 15, 2021
1 parent 5ddda64 commit 148ef70
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Source/StrongGrid.IntegrationTests/Tests/Blocks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
9 changes: 4 additions & 5 deletions Source/StrongGrid/Resources/Blocks.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -42,9 +41,9 @@ internal Blocks(Pathoschild.Http.Client.IClient client)
/// <param name="onBehalfOf">The user to impersonate.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>
/// An array of <see cref="Block">Blocks</see>.
/// The <see cref="PaginatedResponseWithLinks{Block}">Blocks</see>.
/// </returns>
public Task<Block[]> GetAllAsync(DateTime? startDate = null, DateTime? endDate = null, int limit = 25, int offset = 0, string onBehalfOf = null, CancellationToken cancellationToken = default)
public Task<PaginatedResponseWithLinks<Block>> GetAllAsync(DateTime? startDate = null, DateTime? endDate = null, int limit = 25, int offset = 0, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
return _client
.GetAsync(_endpoint)
Expand All @@ -54,7 +53,7 @@ public Task<Block[]> GetAllAsync(DateTime? startDate = null, DateTime? endDate =
.WithArgument("limit", limit)
.WithArgument("offset", offset)
.WithCancellationToken(cancellationToken)
.AsObject<Block[]>();
.AsPaginatedResponseWithLinks<Block>();
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions Source/StrongGrid/Resources/IBlocks.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using StrongGrid.Models;
using StrongGrid.Models;
using System;
using System.Collections.Generic;
using System.Threading;
Expand All @@ -24,9 +24,9 @@ public interface IBlocks
/// <param name="onBehalfOf">The user to impersonate.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>
/// An array of <see cref="Block">Blocks</see>.
/// The <see cref="PaginatedResponseWithLinks{Block}">Blocks</see>.
/// </returns>
Task<Block[]> GetAllAsync(DateTime? startDate = null, DateTime? endDate = null, int limit = 25, int offset = 0, string onBehalfOf = null, CancellationToken cancellationToken = default);
Task<PaginatedResponseWithLinks<Block>> GetAllAsync(DateTime? startDate = null, DateTime? endDate = null, int limit = 25, int offset = 0, string onBehalfOf = null, CancellationToken cancellationToken = default);

/// <summary>
/// Retrieve the blocks for a specific email address.
Expand Down

0 comments on commit 148ef70

Please sign in to comment.