Skip to content

Commit facdbde

Browse files
Add IObjectModification interface
1 parent 7927dce commit facdbde

File tree

5 files changed

+28
-12
lines changed

5 files changed

+28
-12
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace Notion.Client
1+
using System;
2+
3+
namespace Notion.Client
24
{
35
public abstract class Block : IBlock
46
{
@@ -8,9 +10,9 @@ public abstract class Block : IBlock
810

911
public virtual BlockType Type { get; set; }
1012

11-
public string CreatedTime { get; set; }
13+
public DateTime CreatedTime { get; set; }
1214

13-
public string LastEditedTime { get; set; }
15+
public DateTime LastEditedTime { get; set; }
1416

1517
public virtual bool HasChildren { get; set; }
1618
}

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,12 @@ namespace Notion.Client
3636
[JsonSubtypes.KnownSubType(typeof(ToggleBlock), BlockType.Toggle)]
3737
[JsonSubtypes.KnownSubType(typeof(VideoBlock), BlockType.Video)]
3838
[JsonSubtypes.KnownSubType(typeof(UnsupportedBlock), BlockType.Unsupported)]
39-
public interface IBlock : IObject
39+
public interface IBlock : IObject, IObjectModificationData
4040
{
4141
[JsonProperty("type")]
4242
[JsonConverter(typeof(StringEnumConverter))]
4343
BlockType Type { get; set; }
4444

45-
[JsonProperty("created_time")]
46-
string CreatedTime { get; set; }
47-
48-
[JsonProperty("last_edited_time")]
49-
string LastEditedTime { get; set; }
50-
5145
[JsonProperty("has_children")]
5246
bool HasChildren { get; set; }
5347
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using Newtonsoft.Json;
3+
4+
namespace Notion.Client
5+
{
6+
public interface IObjectModificationData
7+
{
8+
/// <summary>
9+
/// Date and time when this object was created.
10+
/// </summary>
11+
[JsonProperty("created_time")]
12+
DateTime CreatedTime { get; set; }
13+
14+
/// <summary>
15+
/// Date and time when this object was updated.
16+
/// </summary>
17+
[JsonProperty("last_edited_time")]
18+
DateTime LastEditedTime { get; set; }
19+
}
20+
}

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 : IObject
7+
public class Database : IObject, IObjectModificationData
88
{
99
public ObjectType Object => ObjectType.Database;
1010

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 : IObject
7+
public class Page : IObject, IObjectModificationData
88
{
99
/// <summary>
1010
/// Object type

0 commit comments

Comments
 (0)