Skip to content

Commit

Permalink
(GH-368) Add missing 'limit' and 'offset' parameters to Teammates.Get…
Browse files Browse the repository at this point in the history
…AllPendingInvitationsAsync
  • Loading branch information
Jericho committed Jan 14, 2022
1 parent 30603eb commit 891ba30
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Source/StrongGrid.IntegrationTests/Tests/Teammates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public async Task RunAsync(IBaseClient client, TextWriter log, CancellationToken
await log.WriteLineAsync("\n***** TEAMMATES *****\n").ConfigureAwait(false);

// GET ALL THE PENDING INVITATIONS
var pendingInvitation = await client.Teammates.GetAllPendingInvitationsAsync(cancellationToken).ConfigureAwait(false);
var pendingInvitation = await client.Teammates.GetAllPendingInvitationsAsync(50, 0, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"There are {pendingInvitation.Length} pending invitations").ConfigureAwait(false);

// GET ALL THE TEAMMATES
Expand Down
2 changes: 1 addition & 1 deletion Source/StrongGrid.UnitTests/Resources/TeammatesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public async Task GetAllPendingInvitationsAsync()
var teammates = new Teammates(client);

// Act
var result = await teammates.GetAllPendingInvitationsAsync(CancellationToken.None).ConfigureAwait(false);
var result = await teammates.GetAllPendingInvitationsAsync(50, 0, CancellationToken.None).ConfigureAwait(false);

// Assert
mockHttp.VerifyNoOutstandingExpectation();
Expand Down
6 changes: 4 additions & 2 deletions Source/StrongGrid/Resources/ITeammates.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using StrongGrid.Models;
using StrongGrid.Models;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -62,13 +62,15 @@ public interface ITeammates
/// <summary>
/// Retrieve a list of all pending teammate invitations.
/// </summary>
/// <param name="limit">The limit.</param>
/// <param name="offset">The offset.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>An array of <see cref="TeammateInvitation" />.</returns>
/// <remarks>
/// Each teammate invitation is valid for 7 days.
/// Users may resend the invite to refresh the expiration date.
/// </remarks>
Task<TeammateInvitation[]> GetAllPendingInvitationsAsync(CancellationToken cancellationToken = default);
Task<TeammateInvitation[]> GetAllPendingInvitationsAsync(int limit = 10, int offset = 0, CancellationToken cancellationToken = default);

/// <summary>
/// Delete a pending teammate invite.
Expand Down
9 changes: 6 additions & 3 deletions Source/StrongGrid/Resources/Teammates.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.Collections.Generic;
using System.Linq;
using System.Threading;
Expand Down Expand Up @@ -105,16 +104,20 @@ public Task ResendInvitationAsync(string token, CancellationToken cancellationTo
/// <summary>
/// Retrieve a list of all pending teammate invitations.
/// </summary>
/// <param name="limit">The limit.</param>
/// <param name="offset">The offset.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>An array of <see cref="TeammateInvitation" />.</returns>
/// <remarks>
/// Each teammate invitation is valid for 7 days.
/// Users may resend the invite to refresh the expiration date.
/// </remarks>
public Task<TeammateInvitation[]> GetAllPendingInvitationsAsync(CancellationToken cancellationToken = default)
public Task<TeammateInvitation[]> GetAllPendingInvitationsAsync(int limit = 10, int offset = 0, CancellationToken cancellationToken = default)
{
return _client
.GetAsync($"{_endpoint}/pending")
.WithArgument("limit", limit)
.WithArgument("offset", offset)
.WithCancellationToken(cancellationToken)
.AsObject<TeammateInvitation[]>("result");
}
Expand Down

0 comments on commit 891ba30

Please sign in to comment.