Skip to content

Commit 90c99f8

Browse files
Add IObject interface ➕
It is implenented by every notion object
1 parent 9876201 commit 90c99f8

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Notion.Client
1515
[JsonSubtypes.KnownSubType(typeof(ToDoBlock), BlockType.ToDo)]
1616
[JsonSubtypes.KnownSubType(typeof(ToggleBlock), BlockType.Toggle)]
1717
[JsonSubtypes.KnownSubType(typeof(UnsupportedBlock), BlockType.Unsupported)]
18-
public class Block
18+
public class Block : IObject
1919
{
2020
public ObjectType Object => ObjectType.Block;
2121
public string Id { get; set; }

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

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

55
namespace Notion.Client
66
{
7-
public class Database
7+
public class Database : IObject
88
{
99
public ObjectType Object => ObjectType.Database;
1010
public string Id { get; set; }
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using JsonSubTypes;
2+
using Newtonsoft.Json;
3+
4+
namespace Notion.Client
5+
{
6+
[JsonConverter(typeof(JsonSubtypes), "object")]
7+
[JsonSubtypes.KnownSubType(typeof(Page), ObjectType.Page)]
8+
[JsonSubtypes.KnownSubType(typeof(Database), ObjectType.Database)]
9+
[JsonSubtypes.KnownSubType(typeof(Block), ObjectType.Block)]
10+
[JsonSubtypes.KnownSubType(typeof(User), ObjectType.User)]
11+
public interface IObject
12+
{
13+
string Id { get; set; }
14+
ObjectType Object { get; }
15+
}
16+
}

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

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

55
namespace Notion.Client
66
{
7-
public class Page
7+
public class Page : IObject
88
{
99
public ObjectType Object => ObjectType.Page;
1010
public string Id { get; set; }

Src/Notion.Client/Models/User.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 User
5+
public class User : IObject
66
{
77
public ObjectType Object => ObjectType.User;
88
public string Id { get; set; }

0 commit comments

Comments
 (0)