Skip to content

Commit 6c4e614

Browse files
Merge pull request #304 from notion-dotnet/302-make-color-enum-property-nullable
Make color enum property nullable
2 parents 5023e2c + a7eef15 commit 6c4e614

File tree

16 files changed

+26
-18
lines changed

16 files changed

+26
-18
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ public class SelectOptionSchema
1010

1111
[JsonProperty("color")]
1212
[JsonConverter(typeof(StringEnumConverter))]
13-
public Color Color { get; set; }
13+
public Color? Color { get; set; }
1414
}
1515
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class Info
1818

1919
[JsonProperty("color")]
2020
[JsonConverter(typeof(StringEnumConverter))]
21-
public Color Color { get; set; }
21+
public Color? Color { get; set; }
2222

2323
[JsonProperty("children")]
2424
public IEnumerable<INonColumnBlock> Children { get; set; }

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class Info
2121

2222
[JsonProperty("color")]
2323
[JsonConverter(typeof(StringEnumConverter))]
24-
public Color Color { get; set; }
24+
public Color? Color { get; set; }
2525

2626
[JsonProperty("children")]
2727
public IEnumerable<INonColumnBlock> Children { get; set; }

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class Info
2020

2121
[JsonProperty("color")]
2222
[JsonConverter(typeof(StringEnumConverter))]
23-
public Color Color { get; set; }
23+
public Color? Color { get; set; }
2424
}
2525
}
2626
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class Info
2020

2121
[JsonProperty("color")]
2222
[JsonConverter(typeof(StringEnumConverter))]
23-
public Color Color { get; set; }
23+
public Color? Color { get; set; }
2424
}
2525
}
2626
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class Info
2020

2121
[JsonProperty("color")]
2222
[JsonConverter(typeof(StringEnumConverter))]
23-
public Color Color { get; set; }
23+
public Color? Color { get; set; }
2424
}
2525
}
2626
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class Info
1818

1919
[JsonProperty("color")]
2020
[JsonConverter(typeof(StringEnumConverter))]
21-
public Color Color { get; set; }
21+
public Color? Color { get; set; }
2222

2323
[JsonProperty("children")]
2424
public IEnumerable<INonColumnBlock> Children { get; set; }

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class Info
1818

1919
[JsonProperty("color")]
2020
[JsonConverter(typeof(StringEnumConverter))]
21-
public Color Color { get; set; }
21+
public Color? Color { get; set; }
2222

2323
[JsonProperty("children")]
2424
public IEnumerable<INonColumnBlock> Children { get; set; }

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class Info
1818

1919
[JsonProperty("color")]
2020
[JsonConverter(typeof(StringEnumConverter))]
21-
public Color Color { get; set; }
21+
public Color? Color { get; set; }
2222

2323
[JsonProperty("children")]
2424
public IEnumerable<INonColumnBlock> Children { get; set; }

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class Data
1414
{
1515
[JsonProperty("color")]
1616
[JsonConverter(typeof(StringEnumConverter))]
17-
public Color Color { get; set; }
17+
public Color? Color { get; set; }
1818
}
1919
}
2020
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class Info
2121

2222
[JsonProperty("color")]
2323
[JsonConverter(typeof(StringEnumConverter))]
24-
public Color Color { get; set; }
24+
public Color? Color { get; set; }
2525

2626
[JsonProperty("children")]
2727
public IEnumerable<INonColumnBlock> Children { get; set; }

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class Info
1818

1919
[JsonProperty("color")]
2020
[JsonConverter(typeof(StringEnumConverter))]
21-
public Color Color { get; set; }
21+
public Color? Color { get; set; }
2222

2323
[JsonProperty("children")]
2424
public IEnumerable<INonColumnBlock> Children { get; set; }

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class SelectOption
3535
/// </summary>
3636
[JsonProperty("color")]
3737
[JsonConverter(typeof(StringEnumConverter))]
38-
public Color Color { get; set; }
38+
public Color? Color { get; set; }
3939
}
4040

4141
public class MultiSelectProperty : Property

Src/Notion.Client/Models/Database/RichText/RichTextBase.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ public class Annotations
4343

4444
[JsonProperty("color")]
4545
[JsonConverter(typeof(StringEnumConverter))]
46-
public Color Color { get; set; }
46+
public Color? Color { get; set; }
4747
}
4848
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class Data
3333
/// </summary>
3434
[JsonProperty("color")]
3535
[JsonConverter(typeof(StringEnumConverter))]
36-
public Color Color { get; set; }
36+
public Color? Color { get; set; }
3737
}
3838

3939
public enum Color

Test/Notion.IntegrationTests/IPageClientTests.cs

+11-3
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public async Task Test_RetrievePagePropertyItemAsync()
142142

143143
var listProperty = (ListPropertyItem)property;
144144

145-
listProperty.Type.Should().BeNull();
145+
listProperty.Type.Should().NotBeNull();
146146
listProperty.Results.Should().SatisfyRespectively(p =>
147147
{
148148
p.Should().BeOfType<TitlePropertyItem>();
@@ -202,7 +202,11 @@ public async Task Test_UpdatePageProperty_with_date_as_null()
202202

203203
var page = await _client.Pages.CreateAsync(pagesCreateParameters);
204204

205-
var setDate = page.Properties[datePropertyName] as DatePropertyValue;
205+
var setDate = (DatePropertyItem)await _client.Pages.RetrievePagePropertyItem(new RetrievePropertyItemParameters
206+
{
207+
PageId = page.Id,
208+
PropertyId = page.Properties[datePropertyName].Id
209+
});
206210

207211
setDate?.Date?.Start.Should().Be(Convert.ToDateTime("2020-12-08T12:00:00Z"));
208212

@@ -215,7 +219,11 @@ public async Task Test_UpdatePageProperty_with_date_as_null()
215219
Properties = testProps
216220
});
217221

218-
var verifyDate = updatedPage.Properties[datePropertyName] as DatePropertyValue;
222+
var verifyDate = (DatePropertyItem)await _client.Pages.RetrievePagePropertyItem(new RetrievePropertyItemParameters
223+
{
224+
PageId = page.Id,
225+
PropertyId = updatedPage.Properties[datePropertyName].Id
226+
});
219227

220228
verifyDate?.Date.Should().BeNull();
221229

0 commit comments

Comments
 (0)