Skip to content
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
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
3 changes: 3 additions & 0 deletions Src/Notion.Client/Models/Blocks/BlockType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public enum BlockType
[EnumMember(Value = "equation")]
Equation,

[EnumMember(Value = "breadcrumb")]
Breadcrumb,

[EnumMember(Value = "unsupported")]
Unsupported
}
Expand Down
16 changes: 16 additions & 0 deletions Src/Notion.Client/Models/Blocks/BreadcrumbBlock.cs
Original file line number Diff line number Diff line change
@@ -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
{
}
}
}
79 changes: 79 additions & 0 deletions Test/Notion.IntegrationTests/IBlocksClientTests.cs
Original file line number Diff line number Diff line change
@@ -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<Block>()
{
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<Block>()
{
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);
}
}
}