Skip to content

Commit 535b161

Browse files
Add User property to ListUsers response
1 parent 063723d commit 535b161

File tree

5 files changed

+38
-14
lines changed

5 files changed

+38
-14
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,23 @@ public interface IUsersClient
1919
/// Returns a paginated list of Users for the workspace.
2020
/// The response may contain fewer than page_size of results.
2121
/// </summary>
22+
/// <param name="cancellationToken"></param>
2223
/// <returns>
23-
/// <see cref="PaginatedList{User}" />
24+
/// <see cref="ListUsersResponse" />
2425
/// </returns>
25-
Task<PaginatedList<User>> ListAsync(CancellationToken cancellationToken = default);
26+
Task<ListUsersResponse> ListAsync(CancellationToken cancellationToken = default);
2627

27-
Task<PaginatedList<User>> ListAsync(
28-
ListUsersParameters listUsersParameters,
28+
/// <summary>
29+
/// Returns a paginated list of Users for the workspace.
30+
/// The response may contain fewer than page_size of results.
31+
/// </summary>
32+
/// <param name="listUsersRequest"></param>
33+
/// <param name="cancellationToken"></param>
34+
/// <returns>
35+
/// <see cref="ListUsersResponse" />
36+
/// </returns>
37+
Task<ListUsersResponse> ListAsync(
38+
ListUsersRequest listUsersRequest,
2939
CancellationToken cancellationToken = default
3040
);
3141

Src/Notion.Client/Api/Users/List/Request/ListUsersParameters.cs renamed to Src/Notion.Client/Api/Users/List/Request/ListUsersRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public interface IListUsersQueryParameters : IPaginationParameters
44
{
55
}
66

7-
public class ListUsersParameters : IListUsersQueryParameters
7+
public class ListUsersRequest : IListUsersQueryParameters
88
{
99
public string StartCursor { get; set; }
1010

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.Collections.Generic;
2+
using Newtonsoft.Json;
3+
4+
namespace Notion.Client
5+
{
6+
public class ListUsersResponse : PaginatedList<User>
7+
{
8+
[JsonProperty("user")]
9+
public Dictionary<string, object> User { get; set; }
10+
}
11+
}

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,28 @@ namespace Notion.Client
77
{
88
public partial class UsersClient
99
{
10-
public async Task<PaginatedList<User>> ListAsync(
11-
ListUsersParameters listUsersParameters,
10+
public async Task<ListUsersResponse> ListAsync(CancellationToken cancellationToken = default)
11+
{
12+
return await _client.GetAsync<ListUsersResponse>(
13+
ApiEndpoints.UsersApiUrls.List(),
14+
cancellationToken: cancellationToken
15+
);
16+
}
17+
18+
public async Task<ListUsersResponse> ListAsync(
19+
ListUsersRequest listUsersRequest,
1220
CancellationToken cancellationToken = default
1321
)
1422
{
15-
var queryParameters = (IListUsersQueryParameters)listUsersParameters;
23+
var queryParameters = (IListUsersQueryParameters)listUsersRequest;
1624

1725
var queryParams = new Dictionary<string, string>
1826
{
1927
{ "start_cursor", queryParameters?.StartCursor },
2028
{ "page_size", queryParameters?.PageSize?.ToString() }
2129
};
2230

23-
return await _client.GetAsync<PaginatedList<User>>(
31+
return await _client.GetAsync<ListUsersResponse>(
2432
ApiEndpoints.UsersApiUrls.List(),
2533
queryParams,
2634
cancellationToken: cancellationToken

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ public async Task<User> RetrieveAsync(string userId, CancellationToken cancellat
1818
return await _client.GetAsync<User>(UsersApiUrls.Retrieve(userId), cancellationToken: cancellationToken);
1919
}
2020

21-
public async Task<PaginatedList<User>> ListAsync(CancellationToken cancellationToken = default)
22-
{
23-
return await _client.GetAsync<PaginatedList<User>>(UsersApiUrls.List(), cancellationToken: cancellationToken);
24-
}
25-
2621
/// <summary>
2722
/// Retrieves the bot User associated with the API token provided in the authorization header.
2823
/// </summary>

0 commit comments

Comments
 (0)