From 049b5034a051d0fbb6e69b2827c7a47c674dbdd4 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Fri, 31 Dec 2021 19:06:14 +0530 Subject: [PATCH] =?UTF-8?q?Add=20support=20for=20Syncedblock=20type=20?= =?UTF-8?q?=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UpdateBlocks/AudioUpdateBlock.cs | 3 +- .../UpdateBlocks/SyncedBlockUpdateBlock.cs | 22 +++++++++++++ Src/Notion.Client/Models/Blocks/BlockType.cs | 3 ++ .../Models/Blocks/IColumnChildrenBlock.cs | 6 +++- .../Models/Blocks/SyncedBlockBlock.cs | 31 +++++++++++++++++++ 5 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/SyncedBlockUpdateBlock.cs create mode 100644 Src/Notion.Client/Models/Blocks/SyncedBlockBlock.cs diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/AudioUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/AudioUpdateBlock.cs index f341e441..8747ad63 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/AudioUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/AudioUpdateBlock.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/SyncedBlockUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/SyncedBlockUpdateBlock.cs new file mode 100644 index 00000000..97f393fe --- /dev/null +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/SyncedBlockUpdateBlock.cs @@ -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; } + } + } + } +} diff --git a/Src/Notion.Client/Models/Blocks/BlockType.cs b/Src/Notion.Client/Models/Blocks/BlockType.cs index ab7fdb19..6ebec8f1 100644 --- a/Src/Notion.Client/Models/Blocks/BlockType.cs +++ b/Src/Notion.Client/Models/Blocks/BlockType.cs @@ -88,6 +88,9 @@ public enum BlockType [EnumMember(Value = "link_to_page")] LinkToPage, + [EnumMember(Value = "synced_block")] + SyncedBlock, + [EnumMember(Value = "unsupported")] Unsupported } diff --git a/Src/Notion.Client/Models/Blocks/IColumnChildrenBlock.cs b/Src/Notion.Client/Models/Blocks/IColumnChildrenBlock.cs index 35370460..673bc156 100644 --- a/Src/Notion.Client/Models/Blocks/IColumnChildrenBlock.cs +++ b/Src/Notion.Client/Models/Blocks/IColumnChildrenBlock.cs @@ -4,7 +4,11 @@ public interface ITemplateChildrendBlock : IBlock { } - public interface IColumnChildrenBlock : IBlock, ITemplateChildrendBlock + public interface ISyncedBlockChildren : IBlock + { + } + + public interface IColumnChildrenBlock : IBlock, ITemplateChildrendBlock, ISyncedBlockChildren { } diff --git a/Src/Notion.Client/Models/Blocks/SyncedBlockBlock.cs b/Src/Notion.Client/Models/Blocks/SyncedBlockBlock.cs new file mode 100644 index 00000000..33c4dd25 --- /dev/null +++ b/Src/Notion.Client/Models/Blocks/SyncedBlockBlock.cs @@ -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 Children { get; set; } + + public class SyncedFromBlockId + { + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("block_id")] + public string BlockId { get; set; } + } + } + } +}