Skip to content

Commit e256ff1

Browse files
Move Page classes into separate files 🚚
1 parent 8ea5ef4 commit e256ff1

File tree

7 files changed

+84
-67
lines changed

7 files changed

+84
-67
lines changed

Src/Notion.Client/Models/Page.cs

Lines changed: 0 additions & 67 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
4+
{
5+
public class DatabaseParent : Parent
6+
{
7+
[JsonProperty("database_id")]
8+
public string DatabaseId { get; set; }
9+
}
10+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Newtonsoft.Json;
4+
5+
namespace Notion.Client
6+
{
7+
public class Page
8+
{
9+
public string Object => "page";
10+
public string Id { get; set; }
11+
public Parent Parent { get; set; }
12+
13+
[JsonProperty("created_time")]
14+
public DateTime CreatedTime { get; set; }
15+
16+
[JsonProperty("last_edited_time")]
17+
public DateTime LastEditedTime { get; set; }
18+
19+
[JsonProperty("archived")]
20+
public bool IsArchived { get; set; }
21+
22+
public IDictionary<string, PropertyValue> Properties { get; set; }
23+
}
24+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
4+
{
5+
public class PageParent : Parent
6+
{
7+
[JsonProperty("page_id")]
8+
public string PageId { get; set; }
9+
}
10+
}
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+
using Newtonsoft.Json.Converters;
4+
5+
namespace Notion.Client
6+
{
7+
[JsonConverter(typeof(JsonSubtypes), "type")]
8+
[JsonSubtypes.KnownSubType(typeof(DatabaseParent), ParentType.DatabaseId)]
9+
[JsonSubtypes.KnownSubType(typeof(PageParent), ParentType.PageId)]
10+
[JsonSubtypes.KnownSubType(typeof(WorkspaceParent), ParentType.Workspace)]
11+
public class Parent
12+
{
13+
[JsonConverter(typeof(StringEnumConverter))]
14+
public ParentType Type { get; set; }
15+
}
16+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Runtime.Serialization;
2+
3+
namespace Notion.Client
4+
{
5+
public enum ParentType
6+
{
7+
[EnumMember(Value = null)]
8+
Unknown,
9+
10+
[EnumMember(Value = "database_id")]
11+
DatabaseId,
12+
13+
[EnumMember(Value = "page_id")]
14+
PageId,
15+
[EnumMember(Value = "workspace")]
16+
Workspace
17+
}
18+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Notion.Client
2+
{
3+
public class WorkspaceParent : Parent
4+
{
5+
}
6+
}

0 commit comments

Comments
 (0)