Skip to content

Commit 08c8ddb

Browse files
Add support to read Status property value
1 parent 598316c commit 08c8ddb

File tree

3 files changed

+77
-1
lines changed

3 files changed

+77
-1
lines changed

Src/Notion.Client/Models/PropertyValue/PropertyValue.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace Notion.Client
2525
[JsonSubtypes.KnownSubType(typeof(RichTextPropertyValue), PropertyValueType.RichText)]
2626
[JsonSubtypes.KnownSubType(typeof(RollupPropertyValue), PropertyValueType.Rollup)]
2727
[JsonSubtypes.KnownSubType(typeof(SelectPropertyValue), PropertyValueType.Select)]
28+
[JsonSubtypes.KnownSubType(typeof(StatusPropertyValue), PropertyValueType.Status)]
2829
[JsonSubtypes.KnownSubType(typeof(TitlePropertyValue), PropertyValueType.Title)]
2930
[JsonSubtypes.KnownSubType(typeof(UrlPropertyValue), PropertyValueType.Url)]
3031
public class PropertyValue

Src/Notion.Client/Models/PropertyValue/PropertyValueType.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public enum PropertyValueType
6565
LastEditedTime,
6666

6767
[EnumMember(Value = "last_edited_by")]
68-
LastEditedBy
68+
LastEditedBy,
69+
70+
[EnumMember(Value = "status")]
71+
Status,
6972
}
7073
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using System.Runtime.Serialization;
2+
using Newtonsoft.Json;
3+
using Newtonsoft.Json.Converters;
4+
5+
namespace Notion.Client
6+
{
7+
/// <summary>
8+
/// Status property value objects contain page status
9+
/// </summary>
10+
public class StatusPropertyValue : PropertyValue
11+
{
12+
public override PropertyValueType Type => PropertyValueType.Status;
13+
14+
[JsonProperty("status")]
15+
public Data Status { get; set; }
16+
17+
public class Data
18+
{
19+
/// <summary>
20+
/// ID of the option.
21+
/// </summary>
22+
[JsonProperty("id")]
23+
public string Id { get; set; }
24+
25+
/// <summary>
26+
/// Name of the option as it appears in Notion.
27+
/// </summary>
28+
[JsonProperty("name")]
29+
public string Name { get; set; }
30+
31+
/// <summary>
32+
/// Color of the option.
33+
/// </summary>
34+
[JsonProperty("color")]
35+
[JsonConverter(typeof(StringEnumConverter))]
36+
public Color Color { get; set; }
37+
}
38+
39+
public enum Color
40+
{
41+
[EnumMember(Value = "default")]
42+
Default,
43+
44+
[EnumMember(Value = "gray")]
45+
Gray,
46+
47+
[EnumMember(Value = "brown")]
48+
Brown,
49+
50+
[EnumMember(Value = "orange")]
51+
Orange,
52+
53+
[EnumMember(Value = "yellow")]
54+
Yellow,
55+
56+
[EnumMember(Value = "green")]
57+
Green,
58+
59+
[EnumMember(Value = "blue")]
60+
Blue,
61+
62+
[EnumMember(Value = "purple")]
63+
Purple,
64+
65+
[EnumMember(Value = "pink")]
66+
Pink,
67+
68+
[EnumMember(Value = "red")]
69+
Red,
70+
}
71+
}
72+
}

0 commit comments

Comments
 (0)