Skip to content

Commit 74e57eb

Browse files
Merge pull request #282 from notion-dotnet/249-add-created-by-and-last-edited-by-properties
Add created_by and last_edited_by properties
2 parents f243992 + b63b698 commit 74e57eb

File tree

7 files changed

+63
-14
lines changed

7 files changed

+63
-14
lines changed
Lines changed: 9 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,10 +10,14 @@ 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; }
18+
19+
public PartialUser CreatedBy { get; set; }
20+
21+
public PartialUser LastEditedBy { get; set; }
1622
}
1723
}

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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
/// <summary>
21+
/// User who created the object.
22+
/// </summary>
23+
[JsonProperty("created_by")]
24+
PartialUser CreatedBy { get; set; }
25+
26+
/// <summary>
27+
/// User who last modified the object.
28+
/// </summary>
29+
[JsonProperty("last_edited_by")]
30+
PartialUser LastEditedBy { get; set; }
31+
}
32+
}

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

Lines changed: 5 additions & 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

@@ -36,5 +36,9 @@ public class Database : IObject
3636
/// </summary>
3737
[JsonProperty("url")]
3838
public string Url { get; set; }
39+
40+
public PartialUser CreatedBy { get; set; }
41+
42+
public PartialUser LastEditedBy { get; set; }
3943
}
4044
}

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

Lines changed: 5 additions & 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
@@ -63,5 +63,9 @@ public class Page : IObject
6363
/// </summary>
6464
[JsonProperty("cover")]
6565
public FileObject Cover { get; set; }
66+
67+
public PartialUser CreatedBy { get; set; }
68+
69+
public PartialUser LastEditedBy { get; set; }
6670
}
6771
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Notion.Client
2+
{
3+
public class PartialUser : IObject
4+
{
5+
public string Id { get; set; }
6+
7+
public ObjectType Object => ObjectType.User;
8+
}
9+
}

Src/Notion.Client/Notion.Client.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
</PackageReference>
2323
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
2424
<PackageReference Include="JsonSubTypes" Version="1.8.0" />
25-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0"/>
26-
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0"/>
25+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
26+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
2727
</ItemGroup>
2828

2929
<ItemGroup>

0 commit comments

Comments
 (0)