Skip to content

Commit 523e180

Browse files
Add block as parent for page and database
1 parent 220ca1b commit 523e180

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

Src/Notion.Client/Models/Database/IDatabaseParent.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace Notion.Client
66
[JsonConverter(typeof(JsonSubtypes), "type")]
77
[JsonSubtypes.KnownSubType(typeof(PageParent), ParentType.PageId)]
88
[JsonSubtypes.KnownSubType(typeof(WorkspaceParent), ParentType.Workspace)]
9+
[JsonSubtypes.KnownSubType(typeof(BlockParent), ParentType.BlockId)]
910
public interface IDatabaseParent : IParent
1011
{
1112
}

Src/Notion.Client/Models/Page/IPageParent.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace Notion.Client
77
[JsonSubtypes.KnownSubType(typeof(DatabaseParent), ParentType.DatabaseId)]
88
[JsonSubtypes.KnownSubType(typeof(PageParent), ParentType.PageId)]
99
[JsonSubtypes.KnownSubType(typeof(WorkspaceParent), ParentType.Workspace)]
10+
[JsonSubtypes.KnownSubType(typeof(BlockParent), ParentType.BlockId)]
1011
public interface IPageParent : IParent
1112
{
1213
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
4+
{
5+
public class BlockParent : IPageParent, IDatabaseParent
6+
{
7+
/// <summary>
8+
/// Always has a value "block_id"
9+
/// </summary>
10+
public ParentType Type { get; set; }
11+
12+
/// <summary>
13+
/// The ID of the block that the element belongs to.
14+
/// </summary>
15+
[JsonProperty("block_id")]
16+
public string BlockId { get; set; }
17+
}
18+
}

Src/Notion.Client/Models/Parents/ParentType.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ public enum ParentType
1414
PageId,
1515

1616
[EnumMember(Value = "workspace")]
17-
Workspace
17+
Workspace,
18+
19+
[EnumMember(Value = "block_id")]
20+
BlockId,
1821
}
1922
}

0 commit comments

Comments
 (0)