diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BreadcrumbUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BreadcrumbUpdateBlock.cs new file mode 100644 index 00000000..2e504dff --- /dev/null +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BreadcrumbUpdateBlock.cs @@ -0,0 +1,21 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class BreadcrumbUpdateBlock : IUpdateBlock + { + public bool Archived { get; set; } + + [JsonProperty("breadcrumb")] + public Data Breadcrumb { get; set; } + + public class Data + { + } + + public BreadcrumbUpdateBlock() + { + Breadcrumb = new Data(); + } + } +} diff --git a/Src/Notion.Client/Models/Blocks/BlockType.cs b/Src/Notion.Client/Models/Blocks/BlockType.cs index 1c37f205..89b74db7 100644 --- a/Src/Notion.Client/Models/Blocks/BlockType.cs +++ b/Src/Notion.Client/Models/Blocks/BlockType.cs @@ -58,6 +58,9 @@ public enum BlockType [EnumMember(Value = "equation")] Equation, + [EnumMember(Value = "breadcrumb")] + Breadcrumb, + [EnumMember(Value = "unsupported")] Unsupported } diff --git a/Src/Notion.Client/Models/Blocks/BreadcrumbBlock.cs b/Src/Notion.Client/Models/Blocks/BreadcrumbBlock.cs new file mode 100644 index 00000000..197122bc --- /dev/null +++ b/Src/Notion.Client/Models/Blocks/BreadcrumbBlock.cs @@ -0,0 +1,16 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class BreadcrumbBlock : Block + { + public override BlockType Type => BlockType.Breadcrumb; + + [JsonProperty("breadcrumb")] + public Data Breadcrumb { get; set; } + + public class Data + { + } + } +} diff --git a/Test/Notion.IntegrationTests/IBlocksClientTests.cs b/Test/Notion.IntegrationTests/IBlocksClientTests.cs new file mode 100644 index 00000000..58297d42 --- /dev/null +++ b/Test/Notion.IntegrationTests/IBlocksClientTests.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using FluentAssertions; +using Notion.Client; +using Xunit; + +namespace Notion.IntegrationTests +{ + public class IBlocksClientTests + { + [Fact] + public async Task AppendChildrenAsync_AppendsBlocksGivenBlocks() + { + var options = new ClientOptions + { + AuthToken = Environment.GetEnvironmentVariable("NOTION_AUTH_TOKEN") + }; + INotionClient _client = NotionClientFactory.Create(options); + + var pageId = "3c357473a28149a488c010d2b245a589"; + var blocks = await _client.Blocks.AppendChildrenAsync( + pageId, + new BlocksAppendChildrenParameters + { + Children = new List() + { + new BreadcrumbBlock + { + Breadcrumb = new BreadcrumbBlock.Data() + } + } + } + ); + + blocks.Results.Should().HaveCount(1); + + // cleanup + var tasks = blocks.Results.Select(x => _client.Blocks.DeleteAsync(x.Id)); + await Task.WhenAll(tasks); + } + + [Fact] + public async Task UpdateBlobkAsync_UpdatesGivenBlock() + { + var options = new ClientOptions + { + AuthToken = Environment.GetEnvironmentVariable("NOTION_AUTH_TOKEN") + }; + INotionClient _client = NotionClientFactory.Create(options); + + var pageId = "3c357473a28149a488c010d2b245a589"; + var blocks = await _client.Blocks.AppendChildrenAsync( + pageId, + new BlocksAppendChildrenParameters + { + Children = new List() + { + new BreadcrumbBlock + { + Breadcrumb = new BreadcrumbBlock.Data() + } + } + } + ); + + var blockId = blocks.Results.First().Id; + await _client.Blocks.UpdateAsync(blockId, new BreadcrumbUpdateBlock()); + + blocks = await _client.Blocks.RetrieveChildrenAsync(pageId); + blocks.Results.Should().HaveCount(1); + + // cleanup + var tasks = blocks.Results.Select(x => _client.Blocks.DeleteAsync(x.Id)); + await Task.WhenAll(tasks); + } + } +}