Skip to content

Commit 0fb7a03

Browse files
Add parent property in Database object ✨
1 parent 9d71596 commit 0fb7a03

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace Notion.Client
77
public class Database : IObject
88
{
99
public ObjectType Object => ObjectType.Database;
10+
1011
public string Id { get; set; }
1112

1213
[JsonProperty("created_time")]
@@ -18,5 +19,7 @@ public class Database : IObject
1819
public List<RichTextBase> Title { get; set; }
1920

2021
public Dictionary<string, Property> Properties { get; set; }
22+
23+
public IDatabaseParent Parent { get; set; }
2124
}
2225
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using JsonSubTypes;
2+
using Newtonsoft.Json;
3+
4+
namespace Notion.Client
5+
{
6+
[JsonConverter(typeof(JsonSubtypes), "type")]
7+
[JsonSubtypes.KnownSubType(typeof(PageParent), ParentType.PageId)]
8+
[JsonSubtypes.KnownSubType(typeof(WorkspaceParent), ParentType.Workspace)]
9+
public interface IDatabaseParent : IParent
10+
{
11+
}
12+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Notion.Client
44
{
5-
public class PageParent : IPageParent
5+
public class PageParent : IPageParent, IDatabaseParent
66
{
77
[JsonProperty("page_id")]
88
public string PageId { get; set; }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Notion.Client
22
{
3-
public class WorkspaceParent : IPageParent
3+
public class WorkspaceParent : IPageParent, IDatabaseParent
44
{
55
public ParentType Type { get; set; }
66
}

0 commit comments

Comments
 (0)