diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/DividerUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/DividerUpdateBlock.cs new file mode 100644 index 00000000..eb21ca28 --- /dev/null +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/DividerUpdateBlock.cs @@ -0,0 +1,21 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class DividerUpdateBlock : IUpdateBlock + { + public bool Archived { get; set; } + + [JsonProperty("divider")] + public Data Divider { get; set; } + + public class Data + { + } + + public DividerUpdateBlock() + { + Divider = new Data(); + } + } +} diff --git a/Src/Notion.Client/Models/Blocks/BlockType.cs b/Src/Notion.Client/Models/Blocks/BlockType.cs index 89b74db7..7a29fbe9 100644 --- a/Src/Notion.Client/Models/Blocks/BlockType.cs +++ b/Src/Notion.Client/Models/Blocks/BlockType.cs @@ -61,6 +61,9 @@ public enum BlockType [EnumMember(Value = "breadcrumb")] Breadcrumb, + [EnumMember(Value = "divider")] + Divider, + [EnumMember(Value = "unsupported")] Unsupported } diff --git a/Src/Notion.Client/Models/Blocks/DividerBlock.cs b/Src/Notion.Client/Models/Blocks/DividerBlock.cs new file mode 100644 index 00000000..1b7bb447 --- /dev/null +++ b/Src/Notion.Client/Models/Blocks/DividerBlock.cs @@ -0,0 +1,16 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class DividerBlock : Block + { + public override BlockType Type => BlockType.Divider; + + [JsonProperty("divider")] + public Data Divider { get; set; } + + public class Data + { + } + } +} diff --git a/Test/Notion.IntegrationTests/IBlocksClientTests.cs b/Test/Notion.IntegrationTests/IBlocksClientTests.cs index 58297d42..88294504 100644 --- a/Test/Notion.IntegrationTests/IBlocksClientTests.cs +++ b/Test/Notion.IntegrationTests/IBlocksClientTests.cs @@ -20,8 +20,18 @@ public async Task AppendChildrenAsync_AppendsBlocksGivenBlocks() INotionClient _client = NotionClientFactory.Create(options); var pageId = "3c357473a28149a488c010d2b245a589"; + + var page = await _client.Pages.CreateAsync( + PagesCreateParametersBuilder.Create( + new ParentPageInput() + { + PageId = pageId + } + ).Build() + ); + var blocks = await _client.Blocks.AppendChildrenAsync( - pageId, + page.Id, new BlocksAppendChildrenParameters { Children = new List() @@ -29,20 +39,26 @@ public async Task AppendChildrenAsync_AppendsBlocksGivenBlocks() new BreadcrumbBlock { Breadcrumb = new BreadcrumbBlock.Data() + }, + new DividerBlock + { + Divider = new DividerBlock.Data() } } } ); - blocks.Results.Should().HaveCount(1); + blocks.Results.Should().HaveCount(2); // cleanup - var tasks = blocks.Results.Select(x => _client.Blocks.DeleteAsync(x.Id)); - await Task.WhenAll(tasks); + await _client.Pages.UpdateAsync(page.Id, new PagesUpdateParameters + { + Archived = true + }); } [Fact] - public async Task UpdateBlobkAsync_UpdatesGivenBlock() + public async Task UpdateBlockAsync_UpdatesGivenBlock() { var options = new ClientOptions { @@ -51,8 +67,18 @@ public async Task UpdateBlobkAsync_UpdatesGivenBlock() INotionClient _client = NotionClientFactory.Create(options); var pageId = "3c357473a28149a488c010d2b245a589"; + + var page = await _client.Pages.CreateAsync( + PagesCreateParametersBuilder.Create( + new ParentPageInput() + { + PageId = pageId + } + ).Build() + ); + var blocks = await _client.Blocks.AppendChildrenAsync( - pageId, + page.Id, new BlocksAppendChildrenParameters { Children = new List() @@ -72,8 +98,53 @@ public async Task UpdateBlobkAsync_UpdatesGivenBlock() blocks.Results.Should().HaveCount(1); // cleanup - var tasks = blocks.Results.Select(x => _client.Blocks.DeleteAsync(x.Id)); - await Task.WhenAll(tasks); + await _client.Pages.UpdateAsync(page.Id, new PagesUpdateParameters + { + Archived = true + }); + } + + [Fact] + public async Task DeleteAsync_DeleteBlockWithGivenId() + { + var options = new ClientOptions + { + AuthToken = Environment.GetEnvironmentVariable("NOTION_AUTH_TOKEN") + }; + INotionClient _client = NotionClientFactory.Create(options); + + var pageId = "3c357473a28149a488c010d2b245a589"; + + var page = await _client.Pages.CreateAsync( + PagesCreateParametersBuilder.Create( + new ParentPageInput() + { + PageId = pageId + } + ).Build() + ); + + var blocks = await _client.Blocks.AppendChildrenAsync( + page.Id, + new BlocksAppendChildrenParameters + { + Children = new List() + { + new DividerBlock + { + Divider = new DividerBlock.Data() + } + } + } + ); + + blocks.Results.Should().HaveCount(1); + + // cleanup + await _client.Pages.UpdateAsync(page.Id, new PagesUpdateParameters + { + Archived = true + }); } } }