Skip to content

Commit

Permalink
Merge pull request #304 from notion-dotnet/302-make-color-enum-proper…
Browse files Browse the repository at this point in the history
…ty-nullable

Make color enum property nullable
  • Loading branch information
KoditkarVedant authored Aug 20, 2022
2 parents 5023e2c + a7eef15 commit 6c4e614
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public class SelectOptionSchema

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
public Color? Color { get; set; }
}
}
2 changes: 1 addition & 1 deletion Src/Notion.Client/Models/Blocks/BulletedListItemBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Info

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
public Color? Color { get; set; }

[JsonProperty("children")]
public IEnumerable<INonColumnBlock> Children { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Src/Notion.Client/Models/Blocks/CalloutBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Info

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
public Color? Color { get; set; }

[JsonProperty("children")]
public IEnumerable<INonColumnBlock> Children { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Src/Notion.Client/Models/Blocks/HeadingOneBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Info

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
public Color? Color { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion Src/Notion.Client/Models/Blocks/HeadingThreeeBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Info

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
public Color? Color { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion Src/Notion.Client/Models/Blocks/HeadingTwoBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Info

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
public Color? Color { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion Src/Notion.Client/Models/Blocks/NumberedListItemBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Info

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
public Color? Color { get; set; }

[JsonProperty("children")]
public IEnumerable<INonColumnBlock> Children { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Src/Notion.Client/Models/Blocks/ParagraphBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Info

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
public Color? Color { get; set; }

[JsonProperty("children")]
public IEnumerable<INonColumnBlock> Children { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Src/Notion.Client/Models/Blocks/QuoteBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Info

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
public Color? Color { get; set; }

[JsonProperty("children")]
public IEnumerable<INonColumnBlock> Children { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Src/Notion.Client/Models/Blocks/TableOfContentsBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Data
{
[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
public Color? Color { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion Src/Notion.Client/Models/Blocks/ToDoBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Info

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
public Color? Color { get; set; }

[JsonProperty("children")]
public IEnumerable<INonColumnBlock> Children { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Src/Notion.Client/Models/Blocks/ToggleBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Info

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
public Color? Color { get; set; }

[JsonProperty("children")]
public IEnumerable<INonColumnBlock> Children { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class SelectOption
/// </summary>
[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
public Color? Color { get; set; }
}

public class MultiSelectProperty : Property
Expand Down
2 changes: 1 addition & 1 deletion Src/Notion.Client/Models/Database/RichText/RichTextBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ public class Annotations

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
public Color? Color { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Data
/// </summary>
[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color Color { get; set; }
public Color? Color { get; set; }
}

public enum Color
Expand Down
14 changes: 11 additions & 3 deletions Test/Notion.IntegrationTests/IPageClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public async Task Test_RetrievePagePropertyItemAsync()

var listProperty = (ListPropertyItem)property;

listProperty.Type.Should().BeNull();
listProperty.Type.Should().NotBeNull();
listProperty.Results.Should().SatisfyRespectively(p =>
{
p.Should().BeOfType<TitlePropertyItem>();
Expand Down Expand Up @@ -202,7 +202,11 @@ public async Task Test_UpdatePageProperty_with_date_as_null()

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

var setDate = page.Properties[datePropertyName] as DatePropertyValue;
var setDate = (DatePropertyItem)await _client.Pages.RetrievePagePropertyItem(new RetrievePropertyItemParameters
{
PageId = page.Id,
PropertyId = page.Properties[datePropertyName].Id
});

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

Expand All @@ -215,7 +219,11 @@ public async Task Test_UpdatePageProperty_with_date_as_null()
Properties = testProps
});

var verifyDate = updatedPage.Properties[datePropertyName] as DatePropertyValue;
var verifyDate = (DatePropertyItem)await _client.Pages.RetrievePagePropertyItem(new RetrievePropertyItemParameters
{
PageId = page.Id,
PropertyId = updatedPage.Properties[datePropertyName].Id
});

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

Expand Down

0 comments on commit 6c4e614

Please sign in to comment.