Skip to content

Commit b3f8591

Browse files
Add support to pagination query params to List Users
1 parent feec5eb commit b3f8591

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

Src/Notion.Client/Api/Users/IUsersClient.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Threading;
22
using System.Threading.Tasks;
3+
using Notion.Client.List.Request;
34

45
namespace Notion.Client
56
{
@@ -23,6 +24,11 @@ public interface IUsersClient
2324
/// </returns>
2425
Task<PaginatedList<User>> ListAsync(CancellationToken cancellationToken = default);
2526

27+
Task<PaginatedList<User>> ListAsync(
28+
ListUsersParameters listUsersParameters,
29+
CancellationToken cancellationToken = default
30+
);
31+
2632
/// <summary>
2733
/// Retrieves the bot User associated with the API token provided in the authorization header.
2834
/// </summary>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace Notion.Client.List.Request
2+
{
3+
public interface IListUsersQueryParameters : IPaginationParameters
4+
{
5+
}
6+
7+
public class ListUsersParameters : IListUsersQueryParameters
8+
{
9+
public string StartCursor { get; set; }
10+
11+
public int? PageSize { get; set; }
12+
}
13+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Collections.Generic;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
using Notion.Client.List.Request;
5+
6+
namespace Notion.Client
7+
{
8+
public partial class UsersClient
9+
{
10+
public async Task<PaginatedList<User>> ListAsync(
11+
ListUsersParameters listUsersParameters,
12+
CancellationToken cancellationToken = default
13+
)
14+
{
15+
var queryParameters = (IListUsersQueryParameters)listUsersParameters;
16+
17+
var queryParams = new Dictionary<string, string>
18+
{
19+
{ "start_cursor", queryParameters?.StartCursor },
20+
{ "page_size", queryParameters?.PageSize?.ToString() }
21+
};
22+
23+
return await _client.GetAsync<PaginatedList<User>>(
24+
ApiEndpoints.UsersApiUrls.List(),
25+
queryParams,
26+
cancellationToken: cancellationToken
27+
);
28+
}
29+
}
30+
}

Src/Notion.Client/Api/Users/UsersClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Notion.Client
66
{
7-
public class UsersClient : IUsersClient
7+
public partial class UsersClient : IUsersClient
88
{
99
private readonly IRestClient _client;
1010

0 commit comments

Comments
 (0)