Skip to content

Commit c4b52ee

Browse files
committed
fix: UniqueId property support
1 parent f5c40c6 commit c4b52ee

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace Notion.Client
2525
[JsonSubtypes.KnownSubTypeAttribute(typeof(StatusProperty), PropertyType.Status)]
2626
[JsonSubtypes.KnownSubTypeAttribute(typeof(TitleProperty), PropertyType.Title)]
2727
[JsonSubtypes.KnownSubTypeAttribute(typeof(UrlProperty), PropertyType.Url)]
28+
[JsonSubtypes.KnownSubTypeAttribute(typeof(UniqueIdProperty), PropertyType.UniqueId)]
2829
public class Property
2930
{
3031
[JsonProperty("id")]

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ public enum PropertyType
6767
LastEditedTime,
6868

6969
[EnumMember(Value = "status")]
70-
Status
70+
Status,
71+
72+
[EnumMember(Value = "unique_id")]
73+
UniqueId,
7174
}
7275
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Newtonsoft.Json;
4+
5+
namespace Notion.Client
6+
{
7+
public class UniqueIdProperty : Property
8+
{
9+
public override PropertyType Type => PropertyType.UniqueId;
10+
11+
[JsonProperty("unique_id")]
12+
public Dictionary<string, object> UniqueId { get; set; }
13+
}
14+
}
15+

Test/Notion.UnitTests/PropertyTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class PropertyTests
2626
[InlineData(typeof(SelectProperty), PropertyType.Select)]
2727
[InlineData(typeof(TitleProperty), PropertyType.Title)]
2828
[InlineData(typeof(UrlProperty), PropertyType.Url)]
29+
[InlineData(typeof(UniqueIdProperty), PropertyType.UniqueId)]
2930
public void TestPropertyType(Type type, PropertyType expectedPropertyType)
3031
{
3132
var typeInstance = (Property)Activator.CreateInstance(type);
@@ -54,6 +55,7 @@ public void TestPropertyType(Type type, PropertyType expectedPropertyType)
5455
[InlineData(typeof(SelectProperty), "select")]
5556
[InlineData(typeof(TitleProperty), "title")]
5657
[InlineData(typeof(UrlProperty), "url")]
58+
[InlineData(typeof(UniqueIdProperty), "unique_id")]
5759
public void TestPropertyTypeText(Type type, string expectedPropertyType)
5860
{
5961
var typeInstance = (Property)Activator.CreateInstance(type);

0 commit comments

Comments
 (0)