Skip to content

Commit

Permalink
Merge pull request #217 from notion-dotnet/208-add-support-for-synced…
Browse files Browse the repository at this point in the history
…-block

Add support for Syncedblock type ✨
  • Loading branch information
KoditkarVedant authored Jan 1, 2022
2 parents cb6b5c7 + 049b503 commit aec0659
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Notion.Client
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Newtonsoft.Json;

namespace Notion.Client
{
public class SyncedBlockUpdateBlock : UpdateBlock, IUpdateBlock
{
[JsonProperty("synced_block")]
public Data SyncedBlock { get; set; }

public class Data
{
[JsonProperty("synced_from")]
public SyncedFromBlockId SyncedFrom { get; set; }

public class SyncedFromBlockId
{
[JsonProperty("block_id")]
public string BlockId { get; set; }
}
}
}
}
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 @@ -88,6 +88,9 @@ public enum BlockType
[EnumMember(Value = "link_to_page")]
LinkToPage,

[EnumMember(Value = "synced_block")]
SyncedBlock,

[EnumMember(Value = "unsupported")]
Unsupported
}
Expand Down
6 changes: 5 additions & 1 deletion Src/Notion.Client/Models/Blocks/IColumnChildrenBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ public interface ITemplateChildrendBlock : IBlock
{
}

public interface IColumnChildrenBlock : IBlock, ITemplateChildrendBlock
public interface ISyncedBlockChildren : IBlock
{
}

public interface IColumnChildrenBlock : IBlock, ITemplateChildrendBlock, ISyncedBlockChildren
{
}

Expand Down
31 changes: 31 additions & 0 deletions Src/Notion.Client/Models/Blocks/SyncedBlockBlock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Notion.Client
{
public class SyncedBlockBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
public override BlockType Type => BlockType.SyncedBlock;

[JsonProperty("synced_block")]
public Data SyncedBlock { get; set; }

public class Data
{
[JsonProperty("synced_from")]
public SyncedFromBlockId SyncedFrom { get; set; }

[JsonProperty("children")]
public IEnumerable<ISyncedBlockChildren> Children { get; set; }

public class SyncedFromBlockId
{
[JsonProperty("type")]
public string Type { get; set; }

[JsonProperty("block_id")]
public string BlockId { get; set; }
}
}
}
}

0 comments on commit aec0659

Please sign in to comment.