Skip to content

358 support passing query params to list users api #376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Src/Notion.Client/Api/Users/IUsersClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Threading;
using System.Threading.Tasks;
using Notion.Client.List.Request;

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

Task<PaginatedList<User>> ListAsync(
ListUsersParameters listUsersParameters,
CancellationToken cancellationToken = default
);

/// <summary>
/// Retrieves the bot User associated with the API token provided in the authorization header.
/// </summary>
Expand Down
13 changes: 13 additions & 0 deletions Src/Notion.Client/Api/Users/List/Request/ListUsersParameters.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Notion.Client.List.Request
{
public interface IListUsersQueryParameters : IPaginationParameters
{
}

public class ListUsersParameters : IListUsersQueryParameters
{
public string StartCursor { get; set; }

public int? PageSize { get; set; }
}
}
30 changes: 30 additions & 0 deletions Src/Notion.Client/Api/Users/List/UsersClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Notion.Client.List.Request;

namespace Notion.Client
{
public partial class UsersClient
{
public async Task<PaginatedList<User>> ListAsync(
ListUsersParameters listUsersParameters,
CancellationToken cancellationToken = default
)
{
var queryParameters = (IListUsersQueryParameters)listUsersParameters;

var queryParams = new Dictionary<string, string>
{
{ "start_cursor", queryParameters?.StartCursor },
{ "page_size", queryParameters?.PageSize?.ToString() }
};

return await _client.GetAsync<PaginatedList<User>>(
ApiEndpoints.UsersApiUrls.List(),
queryParams,
cancellationToken: cancellationToken
);
}
}
}
2 changes: 1 addition & 1 deletion Src/Notion.Client/Api/Users/UsersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Notion.Client
{
public class UsersClient : IUsersClient
public partial class UsersClient : IUsersClient
{
private readonly IRestClient _client;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ public enum PropertyType
Status,

[EnumMember(Value = "unique_id")]
UniqueId,
UniqueId,
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Notion.Client
{
{
public class UniqueIdProperty : Property
{
public override PropertyType Type => PropertyType.UniqueId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json;

namespace Notion.Client
{
Expand Down
16 changes: 8 additions & 8 deletions Test/Notion.IntegrationTests/IBlocksClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private static IEnumerable<object[]> BlockData()
new Action<IBlock, INotionClient>((block, client) =>
{
block.Should().NotBeNull();

block.Should().BeOfType<AudioBlock>().Subject
.Audio.Should().BeOfType<ExternalFile>().Subject
.External.Url.Should().Be("https://www.soundhelix.com/examples/mp3/SoundHelix-Song-3.mp3");
Expand Down Expand Up @@ -252,7 +252,7 @@ private static IEnumerable<object[]> BlockData()
{
Assert.NotNull(block);
var calloutBlock = Assert.IsType<CalloutBlock>(block);

Assert.Equal("Test 2", calloutBlock.Callout.RichText.OfType<RichTextText>().First().Text.Content);
})
},
Expand Down Expand Up @@ -282,7 +282,7 @@ private static IEnumerable<object[]> BlockData()
{
Assert.NotNull(block);
var quoteBlock = Assert.IsType<QuoteBlock>(block);

Assert.Equal("Test 2", quoteBlock.Quote.RichText.OfType<RichTextText>().First().Text.Content);
})
},
Expand Down Expand Up @@ -314,7 +314,7 @@ private static IEnumerable<object[]> BlockData()
Assert.NotNull(block);
var imageBlock = Assert.IsType<ImageBlock>(block);
var imageFile = Assert.IsType<ExternalFile>(imageBlock.Image);

Assert.Equal("https://www.iaspaper.net/wp-content/uploads/2017/09/TNEA-Online-Application.jpg",
imageFile.External.Url);
})
Expand All @@ -339,7 +339,7 @@ private static IEnumerable<object[]> BlockData()
{
Assert.NotNull(block);
var embedBlock = Assert.IsType<EmbedBlock>(block);

Assert.Equal("https://www.iaspaper.net/wp-content/uploads/2017/09/TNEA-Online-Application.jpg",
embedBlock.Embed.Url);
})
Expand Down Expand Up @@ -381,10 +381,10 @@ private static IEnumerable<object[]> BlockData()
{
Assert.NotNull(block);
var templateBlock = Assert.IsType<TemplateBlock>(block);

Assert.Single(templateBlock.Template.RichText);
Assert.Null(templateBlock.Template.Children);

Assert.Equal("Test Template 2",
templateBlock.Template.RichText.OfType<RichTextText>().First().Text.Content);
})
Expand All @@ -407,7 +407,7 @@ private static IEnumerable<object[]> BlockData()
{
Assert.NotNull(block);
var linkToPageBlock = Assert.IsType<LinkToPageBlock>(block);

var pageParent = Assert.IsType<PageParent>(linkToPageBlock.LinkToPage);

// TODO: Currently the api doesn't allow to update the link_to_page block type
Expand Down
4 changes: 2 additions & 2 deletions Test/Notion.IntegrationTests/IPageClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,11 @@ public async Task Bug_exception_when_attempting_to_set_select_property_to_nothin
};

var updatedPage = await Client.Pages.UpdateAsync(page.Id, updatePageRequest);

// Assert
page.Properties["Colors1"].As<SelectPropertyValue>().Select.Name.Should().Be("Red");
page.Properties["Colors2"].As<SelectPropertyValue>().Select.Name.Should().Be("Green");

updatedPage.Properties["Colors1"].As<SelectPropertyValue>().Select.Name.Should().Be("Blue");
updatedPage.Properties["Colors2"].As<SelectPropertyValue>().Select.Should().BeNull();

Expand Down