Skip to content

Commit

Permalink
(GH-367) SpamReports.GetAllAsync must return PaginatedResponseWithLinks
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Jan 23, 2021
1 parent 4df7f51 commit ac7f429
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/SpamReports.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 spamReports = await client.SpamReports.GetAllAsync(startDate, endDate, 25, 0, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"All spam reports retrieved. There are {spamReports.Length} reports in {lastYear} and {thisYear}").ConfigureAwait(false);
await log.WriteLineAsync($"All spam reports retrieved. There are {spamReports.Records.Length} reports in {lastYear} and {thisYear}").ConfigureAwait(false);
}
}
}
6 changes: 3 additions & 3 deletions Source/StrongGrid/Resources/ISpamReports.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 Down Expand Up @@ -35,9 +35,9 @@ public interface ISpamReports
/// <param name="onBehalfOf">The user to impersonate.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>
/// An array of <see cref="SpamReport" />.
/// The <see cref="PaginatedResponseWithLinks{SpamReport}" />.
/// </returns>
Task<SpamReport[]> GetAllAsync(DateTime? startDate = null, DateTime? endDate = null, int limit = 25, int offset = 0, string onBehalfOf = null, CancellationToken cancellationToken = default);
Task<PaginatedResponseWithLinks<SpamReport>> GetAllAsync(DateTime? startDate = null, DateTime? endDate = null, int limit = 25, int offset = 0, string onBehalfOf = null, CancellationToken cancellationToken = default);

/// <summary>
/// Delete all spam reports.
Expand Down
9 changes: 4 additions & 5 deletions Source/StrongGrid/Resources/SpamReports.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 @@ -59,9 +58,9 @@ public Task<SpamReport[]> GetAsync(string emailAddress, string onBehalfOf = null
/// <param name="onBehalfOf">The user to impersonate.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>
/// An array of <see cref="SpamReport" />.
/// The <see cref="PaginatedResponseWithLinks{SpamReport}" />.
/// </returns>
public Task<SpamReport[]> GetAllAsync(DateTime? startDate = null, DateTime? endDate = null, int limit = 25, int offset = 0, string onBehalfOf = null, CancellationToken cancellationToken = default)
public Task<PaginatedResponseWithLinks<SpamReport>> 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 @@ -71,7 +70,7 @@ public Task<SpamReport[]> GetAllAsync(DateTime? startDate = null, DateTime? endD
.WithArgument("limit", limit)
.WithArgument("offset", offset)
.WithCancellationToken(cancellationToken)
.AsObject<SpamReport[]>();
.AsPaginatedResponseWithLinks<SpamReport>();
}

/// <summary>
Expand Down

0 comments on commit ac7f429

Please sign in to comment.