Skip to content

Commit 9d6052a

Browse files
Merge pull request #281 from Sphere10/main
Added Color abstraction (#251) 💖
2 parents 7da517e + 0024ce7 commit 9d6052a

File tree

16 files changed

+138
-16
lines changed

16 files changed

+138
-16
lines changed

Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/SelectOptionSchema.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Converters;
23

34
namespace Notion.Client
45
{
@@ -8,6 +9,7 @@ public class SelectOptionSchema
89
public string Name { get; set; }
910

1011
[JsonProperty("color")]
11-
public string Color { get; set; }
12+
[JsonConverter(typeof(StringEnumConverter))]
13+
public Color Color { get; set; }
1214
}
1315
}

Src/Notion.Client/Models/Blocks/BulletedListItemBlock.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using Newtonsoft.Json;
3+
using Newtonsoft.Json.Converters;
34

45
namespace Notion.Client
56
{
@@ -15,6 +16,10 @@ public class Info
1516
[JsonProperty("rich_text")]
1617
public IEnumerable<RichTextBase> RichText { get; set; }
1718

19+
[JsonProperty("color")]
20+
[JsonConverter(typeof(StringEnumConverter))]
21+
public Color Color { get; set; }
22+
1823
[JsonProperty("children")]
1924
public IEnumerable<INonColumnBlock> Children { get; set; }
2025
}

Src/Notion.Client/Models/Blocks/CalloutBlock.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using Newtonsoft.Json;
3+
using Newtonsoft.Json.Converters;
34

45
namespace Notion.Client
56
{
@@ -18,6 +19,10 @@ public class Info
1819
[JsonProperty("icon")]
1920
public IPageIcon Icon { get; set; }
2021

22+
[JsonProperty("color")]
23+
[JsonConverter(typeof(StringEnumConverter))]
24+
public Color Color { get; set; }
25+
2126
[JsonProperty("children")]
2227
public IEnumerable<INonColumnBlock> Children { get; set; }
2328
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using System.Runtime.Serialization;
2+
3+
namespace Notion.Client
4+
{
5+
public enum Color
6+
{
7+
[EnumMember(Value = "default")]
8+
Default,
9+
10+
[EnumMember(Value = "gray")]
11+
Gray,
12+
13+
[EnumMember(Value = "brown")]
14+
Brown,
15+
16+
[EnumMember(Value = "orange")]
17+
Orange,
18+
19+
[EnumMember(Value = "yellow")]
20+
Yellow,
21+
22+
[EnumMember(Value = "green")]
23+
Green,
24+
25+
[EnumMember(Value = "blue")]
26+
Blue,
27+
28+
[EnumMember(Value = "purple")]
29+
Purple,
30+
31+
[EnumMember(Value = "pink")]
32+
Pink,
33+
34+
[EnumMember(Value = "red")]
35+
Red,
36+
37+
[EnumMember(Value = "gray_background")]
38+
GrayBackground,
39+
40+
[EnumMember(Value = "brown_background")]
41+
BrownBackground,
42+
43+
[EnumMember(Value = "orange_background")]
44+
OrangeBackground,
45+
46+
[EnumMember(Value = "yellow_background")]
47+
YellowBackground,
48+
49+
[EnumMember(Value = "green_background")]
50+
GreenBackground,
51+
52+
[EnumMember(Value = "blue_background")]
53+
BlueBackground,
54+
55+
[EnumMember(Value = "purple_background")]
56+
PurpleBackground,
57+
58+
[EnumMember(Value = "pink_background")]
59+
PinkBackground,
60+
61+
[EnumMember(Value = "red_background")]
62+
RedBackground,
63+
}
64+
}

Src/Notion.Client/Models/Blocks/HeadingOneBlock.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using Newtonsoft.Json;
3+
using Newtonsoft.Json.Converters;
34

45
namespace Notion.Client
56
{
@@ -16,6 +17,10 @@ public class Info
1617
{
1718
[JsonProperty("rich_text")]
1819
public IEnumerable<RichTextBase> RichText { get; set; }
20+
21+
[JsonProperty("color")]
22+
[JsonConverter(typeof(StringEnumConverter))]
23+
public Color Color { get; set; }
1924
}
2025
}
2126
}

Src/Notion.Client/Models/Blocks/HeadingThreeeBlock.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using Newtonsoft.Json;
3+
using Newtonsoft.Json.Converters;
34

45
namespace Notion.Client
56
{
@@ -16,6 +17,10 @@ public class Info
1617
{
1718
[JsonProperty("rich_text")]
1819
public IEnumerable<RichTextBase> RichText { get; set; }
20+
21+
[JsonProperty("color")]
22+
[JsonConverter(typeof(StringEnumConverter))]
23+
public Color Color { get; set; }
1924
}
2025
}
2126
}

Src/Notion.Client/Models/Blocks/HeadingTwoBlock.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using Newtonsoft.Json;
3+
using Newtonsoft.Json.Converters;
34

45
namespace Notion.Client
56
{
@@ -16,6 +17,10 @@ public class Info
1617
{
1718
[JsonProperty("rich_text")]
1819
public IEnumerable<RichTextBase> RichText { get; set; }
20+
21+
[JsonProperty("color")]
22+
[JsonConverter(typeof(StringEnumConverter))]
23+
public Color Color { get; set; }
1924
}
2025
}
2126
}

Src/Notion.Client/Models/Blocks/NumberedListItemBlock.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using Newtonsoft.Json;
3+
using Newtonsoft.Json.Converters;
34

45
namespace Notion.Client
56
{
@@ -15,6 +16,10 @@ public class Info
1516
[JsonProperty("rich_text")]
1617
public IEnumerable<RichTextBase> RichText { get; set; }
1718

19+
[JsonProperty("color")]
20+
[JsonConverter(typeof(StringEnumConverter))]
21+
public Color Color { get; set; }
22+
1823
[JsonProperty("children")]
1924
public IEnumerable<INonColumnBlock> Children { get; set; }
2025
}

Src/Notion.Client/Models/Blocks/ParagraphBlock.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using Newtonsoft.Json;
3+
using Newtonsoft.Json.Converters;
34

45
namespace Notion.Client
56
{
@@ -15,6 +16,10 @@ public class Info
1516
[JsonProperty("rich_text")]
1617
public IEnumerable<RichTextBase> RichText { get; set; }
1718

19+
[JsonProperty("color")]
20+
[JsonConverter(typeof(StringEnumConverter))]
21+
public Color Color { get; set; }
22+
1823
[JsonProperty("children")]
1924
public IEnumerable<INonColumnBlock> Children { get; set; }
2025
}

Src/Notion.Client/Models/Blocks/QuoteBlock.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using Newtonsoft.Json;
3+
using Newtonsoft.Json.Converters;
34

45
namespace Notion.Client
56
{
@@ -15,6 +16,10 @@ public class Info
1516
[JsonProperty("rich_text")]
1617
public IEnumerable<RichTextBase> RichText { get; set; }
1718

19+
[JsonProperty("color")]
20+
[JsonConverter(typeof(StringEnumConverter))]
21+
public Color Color { get; set; }
22+
1823
[JsonProperty("children")]
1924
public IEnumerable<INonColumnBlock> Children { get; set; }
2025
}

0 commit comments

Comments
 (0)