8000 Add parent prop on Block object · notion-dotnet/notion-sdk-net@317d13b · GitHub
[go: up one dir, main page]

Skip to content

Commit 317d13b

Browse files
Add parent prop on Block object
1 parent 523e180 commit 317d13b

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

Src/Notion.Client/Models/Blocks/Block.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using Notion.Client.Models.Blocks;
23

34
namespace Notion.Client
45
{
@@ -19,5 +20,10 @@ public abstract class Block : IBlock
1920
public PartialUser CreatedBy { get; set; }
2021

2122
public PartialUser LastEditedBy { get; set; }
23+
24+
/// <summary>
25+
/// Information about the block's parent.
26+
/// </summary>
27+
public IBlockParent Parent { get; set; }
2228
}
2329
}

Src/Notion.Client/Models/Blocks/IBlock.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using JsonSubTypes;
22
using Newtonsoft.Json;
33
using Newtonsoft.Json.Converters;
4+
using Notion.Client.Models.Blocks;
45

56
namespace Notion.Client
67
{
@@ -44,5 +45,8 @@ public interface IBlock : IObject, IObjectModificationData
4445

4546
[JsonProperty("has_children")]
4647
bool HasChildren { get; set; }
48+
49+
[JsonProperty("parent")]
50+
IBlockParent Parent { get; set; }
4751
}
4852
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using JsonSubTypes;
2+
using Newtonsoft.Json;
3+
4+
namespace Notion.Client.Models.Blocks
5+
{
6+
[JsonConverter(typeof(JsonSubtypes), "type")]
7+
[JsonSubtypes.KnownSubType(typeof(DatabaseParent), ParentType.DatabaseId)]
8+
[JsonSubtypes.KnownSubType(typeof(PageParent), ParentType.PageId)]
9+
[JsonSubtypes.KnownSubType(typeof(WorkspaceParent), ParentType.Workspace)]
10+
[JsonSubtypes.KnownSubType(typeof(BlockParent), ParentType.BlockId)]
11+
public interface IBlockParent
12+
{
13+
}
14+
}

0 commit comments

Comments
 (0)
0