Skip to content

Commit 7b77b78

Browse files
Add Single and Dual Relation Property type
1 parent 317d13b commit 7b77b78

File tree

6 files changed

+80
-25
lines changed

6 files changed

+80
-25
lines changed

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

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
4+
{
5+
public class DualPropertyRelation : RelationData
6+
{
7+
public override RelationType Type => RelationType.Dual;
8+
9+
[JsonProperty("dual_property")]
10+
public Data DualProperty { get; set; }
11+
12+
public class Data
13+
{
14+
[JsonProperty("synced_property_name")]
15+
public string SyncedPropertyName { get; set; }
16+
17+
[JsonProperty("synced_property_id")]
18+
public string SyncedPropertyId { get; set; }
19+
}
20+
}
21+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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(SinglePropertyRelation), RelationType.Single)]
9+
[JsonSubtypes.KnownSubType(typeof(DualPropertyRelation), RelationType.Dual)]
10+
public abstract class RelationData
11+
{
12+
[JsonProperty("database_id")]
13+
public string DatabaseId { get; set; }
14+
15+
[JsonProperty("type")]
16+
[JsonConverter(typeof(StringEnumConverter))]
17+
public virtual RelationType Type { get; set; }
18+
}
19+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Collections.Generic;
2+
using System.Runtime.Serialization;
3+
using Newtonsoft.Json;
4+
5+
namespace Notion.Client
6+
{
7+
public class RelationProperty : Property
8+
{
9+
public override PropertyType Type => PropertyType.Relation;
10+
11+
[JsonProperty("relation")]
12+
public RelationData Relation { get; set; }
13+
}
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Runtime.Serialization;
2+
3+
namespace Notion.Client
4+
{
5+
public enum RelationType
6+
{
7+
[EnumMember(Value = "single_property")]
8+
Single,
9+
10+
[EnumMember(Value = "dual_property")]
11+
Dual
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Collections.Generic;
2+
using Newtonsoft.Json;
3+
4+
namespace Notion.Client
5+
{
6+
public class SinglePropertyRelation : RelationData
7+
{
8+
public override RelationType Type => RelationType.Single;
9+
10+
[JsonProperty("single_property")]
11+
public Dictionary<string, object> SingleProperty { get; set; }
12+
}
13+
}

0 commit comments

Comments
 (0)