From 2219fc4b74f2c79aa6c94c7aabc2f4b6f05d0324 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sun, 10 Jul 2022 23:54:25 +0530 Subject: [PATCH 01/12] rename text property of blocks to rich_text --- .../Models/Blocks/BulletedListItemBlock.cs | 4 ++-- .../Models/Blocks/CalloutBlock.cs | 4 ++-- Src/Notion.Client/Models/Blocks/CodeBlock.cs | 4 ++-- .../Models/Blocks/HeadingOneBlock.cs | 4 ++-- .../Models/Blocks/HeadingThreeeBlock.cs | 4 ++-- .../Models/Blocks/HeadingTwoBlock.cs | 4 ++-- .../Models/Blocks/NumberedListItemBlock.cs | 4 ++-- .../Models/Blocks/ParagraphBlock.cs | 4 ++-- Src/Notion.Client/Models/Blocks/QuoteBlock.cs | 4 ++-- .../Models/Blocks/TemplateBlock.cs | 4 ++-- Src/Notion.Client/Models/Blocks/ToDoBlock.cs | 4 ++-- .../Models/Blocks/ToggleBlock.cs | 4 ++-- .../IBlocksClientTests.cs | 16 +++++++-------- Test/Notion.UnitTests/BlocksClientTests.cs | 20 +++++++++---------- 14 files changed, 42 insertions(+), 42 deletions(-) diff --git a/Src/Notion.Client/Models/Blocks/BulletedListItemBlock.cs b/Src/Notion.Client/Models/Blocks/BulletedListItemBlock.cs index 15d168af..145a37e5 100644 --- a/Src/Notion.Client/Models/Blocks/BulletedListItemBlock.cs +++ b/Src/Notion.Client/Models/Blocks/BulletedListItemBlock.cs @@ -12,8 +12,8 @@ public class BulletedListItemBlock : Block, IColumnChildrenBlock, INonColumnBloc public class Info { - [JsonProperty("text")] - public IEnumerable Text { get; set; } + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } [JsonProperty("children")] public IEnumerable Children { get; set; } diff --git a/Src/Notion.Client/Models/Blocks/CalloutBlock.cs b/Src/Notion.Client/Models/Blocks/CalloutBlock.cs index 9fed148a..f995e3be 100644 --- a/Src/Notion.Client/Models/Blocks/CalloutBlock.cs +++ b/Src/Notion.Client/Models/Blocks/CalloutBlock.cs @@ -12,8 +12,8 @@ public class CalloutBlock : Block, IColumnChildrenBlock, INonColumnBlock public class Info { - [JsonProperty("text")] - public IEnumerable Text { get; set; } + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } [JsonProperty("icon")] public IPageIcon Icon { get; set; } diff --git a/Src/Notion.Client/Models/Blocks/CodeBlock.cs b/Src/Notion.Client/Models/Blocks/CodeBlock.cs index 7eb4205d..810e3864 100644 --- a/Src/Notion.Client/Models/Blocks/CodeBlock.cs +++ b/Src/Notion.Client/Models/Blocks/CodeBlock.cs @@ -12,8 +12,8 @@ public class CodeBlock : Block, IColumnChildrenBlock, INonColumnBlock public class Info { - [JsonProperty("text")] - public IEnumerable Text { get; set; } + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } [JsonProperty("language")] public string Language { get; set; } diff --git a/Src/Notion.Client/Models/Blocks/HeadingOneBlock.cs b/Src/Notion.Client/Models/Blocks/HeadingOneBlock.cs index d9c107c3..67132fe5 100644 --- a/Src/Notion.Client/Models/Blocks/HeadingOneBlock.cs +++ b/Src/Notion.Client/Models/Blocks/HeadingOneBlock.cs @@ -14,8 +14,8 @@ public class HeadingOneBlock : Block, IColumnChildrenBlock, INonColumnBlock public class Info { - [JsonProperty("text")] - public IEnumerable Text { get; set; } + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } } } } diff --git a/Src/Notion.Client/Models/Blocks/HeadingThreeeBlock.cs b/Src/Notion.Client/Models/Blocks/HeadingThreeeBlock.cs index 0728f200..2e4dde99 100644 --- a/Src/Notion.Client/Models/Blocks/HeadingThreeeBlock.cs +++ b/Src/Notion.Client/Models/Blocks/HeadingThreeeBlock.cs @@ -14,8 +14,8 @@ public class HeadingThreeeBlock : Block, IColumnChildrenBlock, INonColumnBlock public class Info { - [JsonProperty("text")] - public IEnumerable Text { get; set; } + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } } } } diff --git a/Src/Notion.Client/Models/Blocks/HeadingTwoBlock.cs b/Src/Notion.Client/Models/Blocks/HeadingTwoBlock.cs index c9caec09..82c75047 100644 --- a/Src/Notion.Client/Models/Blocks/HeadingTwoBlock.cs +++ b/Src/Notion.Client/Models/Blocks/HeadingTwoBlock.cs @@ -14,8 +14,8 @@ public class HeadingTwoBlock : Block, IColumnChildrenBlock, INonColumnBlock public class Info { - [JsonProperty("text")] - public IEnumerable Text { get; set; } + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } } } } diff --git a/Src/Notion.Client/Models/Blocks/NumberedListItemBlock.cs b/Src/Notion.Client/Models/Blocks/NumberedListItemBlock.cs index 90823f57..581d8977 100644 --- a/Src/Notion.Client/Models/Blocks/NumberedListItemBlock.cs +++ b/Src/Notion.Client/Models/Blocks/NumberedListItemBlock.cs @@ -12,8 +12,8 @@ public class NumberedListItemBlock : Block, IColumnChildrenBlock, INonColumnBloc public class Info { - [JsonProperty("text")] - public IEnumerable Text { get; set; } + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } [JsonProperty("children")] public IEnumerable Children { get; set; } diff --git a/Src/Notion.Client/Models/Blocks/ParagraphBlock.cs b/Src/Notion.Client/Models/Blocks/ParagraphBlock.cs index 4a0b5d07..02560aee 100644 --- a/Src/Notion.Client/Models/Blocks/ParagraphBlock.cs +++ b/Src/Notion.Client/Models/Blocks/ParagraphBlock.cs @@ -12,8 +12,8 @@ public class ParagraphBlock : Block, IColumnChildrenBlock, INonColumnBlock public class Info { - [JsonProperty("text")] - public IEnumerable Text { get; set; } + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } [JsonProperty("children")] public IEnumerable Children { get; set; } diff --git a/Src/Notion.Client/Models/Blocks/QuoteBlock.cs b/Src/Notion.Client/Models/Blocks/QuoteBlock.cs index 7108980c..9a8dda8e 100644 --- a/Src/Notion.Client/Models/Blocks/QuoteBlock.cs +++ b/Src/Notion.Client/Models/Blocks/QuoteBlock.cs @@ -12,8 +12,8 @@ public class QuoteBlock : Block, IColumnChildrenBlock, INonColumnBlock public class Info { - [JsonProperty("text")] - public IEnumerable Text { get; set; } + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } [JsonProperty("children")] public IEnumerable Children { get; set; } diff --git a/Src/Notion.Client/Models/Blocks/TemplateBlock.cs b/Src/Notion.Client/Models/Blocks/TemplateBlock.cs index 2fceb845..69a78b62 100644 --- a/Src/Notion.Client/Models/Blocks/TemplateBlock.cs +++ b/Src/Notion.Client/Models/Blocks/TemplateBlock.cs @@ -12,8 +12,8 @@ public class TemplateBlock : Block, IColumnChildrenBlock, INonColumnBlock public class Data { - [JsonProperty("text")] - public IEnumerable Text { get; set; } + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } [JsonProperty("children")] public IEnumerable Children { get; set; } diff --git a/Src/Notion.Client/Models/Blocks/ToDoBlock.cs b/Src/Notion.Client/Models/Blocks/ToDoBlock.cs index 2d033c95..0417827d 100644 --- a/Src/Notion.Client/Models/Blocks/ToDoBlock.cs +++ b/Src/Notion.Client/Models/Blocks/ToDoBlock.cs @@ -12,8 +12,8 @@ public class ToDoBlock : Block, IColumnChildrenBlock, INonColumnBlock public class Info { - [JsonProperty("text")] - public IEnumerable Text { get; set; } + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } [JsonProperty("checked")] public bool IsChecked { get; set; } diff --git a/Src/Notion.Client/Models/Blocks/ToggleBlock.cs b/Src/Notion.Client/Models/Blocks/ToggleBlock.cs index 95eef646..2653cd1b 100644 --- a/Src/Notion.Client/Models/Blocks/ToggleBlock.cs +++ b/Src/Notion.Client/Models/Blocks/ToggleBlock.cs @@ -12,8 +12,8 @@ public class ToggleBlock : Block, IColumnChildrenBlock, INonColumnBlock public class Info { - [JsonProperty("text")] - public IEnumerable Text { get; set; } + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } [JsonProperty("children")] public IEnumerable Children { get; set; } diff --git a/Test/Notion.IntegrationTests/IBlocksClientTests.cs b/Test/Notion.IntegrationTests/IBlocksClientTests.cs index 986ed5b6..c1e94e4e 100644 --- a/Test/Notion.IntegrationTests/IBlocksClientTests.cs +++ b/Test/Notion.IntegrationTests/IBlocksClientTests.cs @@ -58,7 +58,7 @@ public async Task AppendChildrenAsync_AppendsBlocksGivenBlocks() { Callout = new CalloutBlock.Info { - Text = new List { + RichText = new List { new RichTextTextInput { Text = new Text @@ -321,7 +321,7 @@ private static IEnumerable BlockData() { Callout = new CalloutBlock.Info { - Text = new List + RichText = new List { new RichTextTextInput { @@ -354,7 +354,7 @@ private static IEnumerable BlockData() Assert.NotNull(block); var calloutBlock = Assert.IsType(block); - Assert.Equal("Test 2", calloutBlock.Callout.Text.OfType().First().Text.Content); + Assert.Equal("Test 2", calloutBlock.Callout.RichText.OfType().First().Text.Content); }) }, new object[] @@ -363,7 +363,7 @@ private static IEnumerable BlockData() { Quote = new QuoteBlock.Info { - Text = new List + RichText = new List { new RichTextTextInput { @@ -396,7 +396,7 @@ private static IEnumerable BlockData() Assert.NotNull(block); var quoteBlock = Assert.IsType(block); - Assert.Equal("Test 2", quoteBlock.Quote.Text.OfType().First().Text.Content); + Assert.Equal("Test 2", quoteBlock.Quote.RichText.OfType().First().Text.Content); }) }, new object[] @@ -459,7 +459,7 @@ private static IEnumerable BlockData() { Template = new TemplateBlock.Data { - Text = new List + RichText = new List { new RichTextText { @@ -502,9 +502,9 @@ private static IEnumerable BlockData() Assert.NotNull(block); var templateBlock = Assert.IsType(block); - Assert.Single(templateBlock.Template.Text); + Assert.Single(templateBlock.Template.RichText); Assert.Null(templateBlock.Template.Children); - Assert.Equal("Test Template 2", templateBlock.Template.Text.OfType().First().Text.Content); + Assert.Equal("Test Template 2", templateBlock.Template.RichText.OfType().First().Text.Content); }) }, new object[] diff --git a/Test/Notion.UnitTests/BlocksClientTests.cs b/Test/Notion.UnitTests/BlocksClientTests.cs index 6f89cc7b..8bfe218e 100644 --- a/Test/Notion.UnitTests/BlocksClientTests.cs +++ b/Test/Notion.UnitTests/BlocksClientTests.cs @@ -65,7 +65,7 @@ public async Task AppendBlockChildren() { Heading_2 = new HeadingTwoBlock.Info { - Text = new List + RichText = new List { new RichTextText { @@ -81,7 +81,7 @@ public async Task AppendBlockChildren() { Paragraph = new ParagraphBlock.Info { - Text = new List + RichText = new List { new RichTextText { @@ -110,14 +110,14 @@ public async Task AppendBlockChildren() { block.Type.Should().Be(BlockType.Heading_2); var headingBlock = (HeadingTwoBlock)block; - var text = headingBlock.Heading_2.Text.OfType().FirstOrDefault(); + var text = headingBlock.Heading_2.RichText.OfType().FirstOrDefault(); text.Text.Content.Should().Be("Lacinato kale"); }, block => { block.Type.Should().Be(BlockType.Paragraph); var paragraphBlock = (ParagraphBlock)block; - var text = paragraphBlock.Paragraph.Text.OfType().LastOrDefault(); + var text = paragraphBlock.Paragraph.RichText.OfType().LastOrDefault(); text.Text.Content.Should().Be("Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm."); text.Text.Link.Url.Should().Be("https://en.wikipedia.org/wiki/Lacinato_kale"); } @@ -145,9 +145,9 @@ public async Task RetrieveAsync() block.Type.Should().Be(BlockType.ToDo); var todoBlock = ((ToDoBlock)block); - todoBlock.ToDo.Text.Should().ContainSingle(); - todoBlock.ToDo.Text.First().Should().BeAssignableTo(); - ((RichTextText)todoBlock.ToDo.Text.First()).Text.Content.Should().Be("Lacinato kale"); + todoBlock.ToDo.RichText.Should().ContainSingle(); + todoBlock.ToDo.RichText.First().Should().BeAssignableTo(); + ((RichTextText)todoBlock.ToDo.RichText.First()).Text.Content.Should().Be("Lacinato kale"); } [Fact] @@ -189,9 +189,9 @@ public async Task UpdateAsync() block.Type.Should().Be(BlockType.ToDo); var todoBlock = ((ToDoBlock)block); - todoBlock.ToDo.Text.Should().ContainSingle(); - todoBlock.ToDo.Text.First().Should().BeAssignableTo(); - ((RichTextText)todoBlock.ToDo.Text.First()).Text.Content.Should().Be("Lacinato kale"); + todoBlock.ToDo.RichText.Should().ContainSingle(); + todoBlock.ToDo.RichText.First().Should().BeAssignableTo(); + ((RichTextText)todoBlock.ToDo.RichText.First()).Text.Content.Should().Be("Lacinato kale"); } } } From 9f294d13450fe186ecab8dc1678c94b61182bf2c Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Mon, 11 Jul 2022 00:17:08 +0530 Subject: [PATCH 02/12] rename text to rich_text in updateblock models --- .../UpdateBlocks/BookmarkUpdateBlock.cs | 4 ++-- .../UpdateBlocks/BreadcrumbUpdateBlock.cs | 6 +++--- .../UpdateBlocks/BulletedListItemUpdateBlock.cs | 11 +++++++++-- .../UpdateBlocks/CalloutUpdateBlock.cs | 4 ++-- .../UpdateBlocks/CodeUpdateBlock.cs | 4 ++-- .../UpdateBlocks/DividerUpdateBlock.cs | 6 +++--- .../UpdateBlocks/EmbedUpdateBlock.cs | 4 ++-- .../UpdateBlocks/EquationUpdateBlock.cs | 4 ++-- .../UpdateBlocks/HeadingOneUpdateBlock.cs | 11 +++++++++-- .../UpdateBlocks/HeadingThreeeUpdateBlock.cs | 11 +++++++++-- .../UpdateBlocks/HeadingTwoUpdateBlock.cs | 11 +++++++++-- .../UpdateBlocks/NumberedListItemUpdateBlock.cs | 11 +++++++++-- .../UpdateBlocks/ParagraphUpdateBlock.cs | 11 +++++++++-- .../UpdateBlocks/QuoteUpdateBlock.cs | 4 ++-- .../UpdateBlocks/SyncedBlockUpdateBlock.cs | 4 ++-- .../UpdateBlocks/TableOfContentsUpdateBlock.cs | 6 +++--- .../UpdateBlocks/TemplateUpdateBlock.cs | 8 ++++---- .../UpdateBlocks/TextContentUpdate.cs | 11 ----------- .../UpdateBlocks/ToDoUpdateBlock.cs | 4 ++-- .../UpdateBlocks/ToggleUpdateBlock.cs | 11 +++++++++-- Test/Notion.IntegrationTests/IBlocksClientTests.cs | 14 +++++++------- Test/Notion.UnitTests/BlocksClientTests.cs | 2 +- 22 files changed, 100 insertions(+), 62 deletions(-) delete mode 100644 Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TextContentUpdate.cs diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BookmarkUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BookmarkUpdateBlock.cs index 71b0cec6..c3333737 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BookmarkUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BookmarkUpdateBlock.cs @@ -8,9 +8,9 @@ public class BookmarkUpdateBlock : IUpdateBlock public bool Archived { get; set; } [JsonProperty("bookmark")] - public Data Bookmark { get; set; } + public Info Bookmark { get; set; } - public class Data + public class Info { [JsonProperty("url")] public string Url { get; set; } diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BreadcrumbUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BreadcrumbUpdateBlock.cs index 2e504dff..2bb8be38 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BreadcrumbUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BreadcrumbUpdateBlock.cs @@ -7,15 +7,15 @@ public class BreadcrumbUpdateBlock : IUpdateBlock public bool Archived { get; set; } [JsonProperty("breadcrumb")] - public Data Breadcrumb { get; set; } + public Info Breadcrumb { get; set; } - public class Data + public class Info { } public BreadcrumbUpdateBlock() { - Breadcrumb = new Data(); + Breadcrumb = new Info(); } } } diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BulletedListItemUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BulletedListItemUpdateBlock.cs index 8ea533b3..9225942f 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BulletedListItemUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BulletedListItemUpdateBlock.cs @@ -1,10 +1,17 @@ -using Newtonsoft.Json; +using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class BulletedListItemUpdateBlock : UpdateBlock, IUpdateBlock { [JsonProperty("bulleted_list_item")] - public TextContentUpdate BulletedListItem { get; set; } + public Info BulletedListItem { get; set; } + + public class Info + { + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } + } } } diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/CalloutUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/CalloutUpdateBlock.cs index d26e59a9..f8562ff3 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/CalloutUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/CalloutUpdateBlock.cs @@ -10,8 +10,8 @@ public class CalloutUpdateBlock : UpdateBlock, IUpdateBlock public class Info { - [JsonProperty("text")] - public IEnumerable Text { get; set; } + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } [JsonProperty("icon")] public IPageIcon Icon { get; set; } diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/CodeUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/CodeUpdateBlock.cs index 1364adb0..b71fdf14 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/CodeUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/CodeUpdateBlock.cs @@ -10,8 +10,8 @@ public class CodeUpdateBlock : UpdateBlock, IUpdateBlock public class Info { - [JsonProperty("text")] - public IEnumerable Text { get; set; } + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } [JsonProperty("language")] public string Language { get; set; } diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/DividerUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/DividerUpdateBlock.cs index eb21ca28..6c5b447c 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/DividerUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/DividerUpdateBlock.cs @@ -7,15 +7,15 @@ public class DividerUpdateBlock : IUpdateBlock public bool Archived { get; set; } [JsonProperty("divider")] - public Data Divider { get; set; } + public Info Divider { get; set; } - public class Data + public class Info { } public DividerUpdateBlock() { - Divider = new Data(); + Divider = new Info(); } } } diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/EmbedUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/EmbedUpdateBlock.cs index 35f509e2..b0419a23 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/EmbedUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/EmbedUpdateBlock.cs @@ -5,9 +5,9 @@ namespace Notion.Client public class EmbedUpdateBlock : UpdateBlock, IUpdateBlock { [JsonProperty("embed")] - public Data Embed { get; set; } + public Info Embed { get; set; } - public class Data + public class Info { [JsonProperty("url")] public string Url { get; set; } diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/EquationUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/EquationUpdateBlock.cs index c0f32894..b7cb0ad9 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/EquationUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/EquationUpdateBlock.cs @@ -5,9 +5,9 @@ namespace Notion.Client public class EquationUpdateBlock : UpdateBlock, IUpdateBlock { [JsonProperty("equation")] - public Data Equation { get; set; } + public Info Equation { get; set; } - public class Data + public class Info { [JsonProperty("expression")] public string Expression { get; set; } diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingOneUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingOneUpdateBlock.cs index 31c3d968..aeb4e087 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingOneUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingOneUpdateBlock.cs @@ -1,10 +1,17 @@ -using Newtonsoft.Json; +using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class HeadingOneUpdateBlock : UpdateBlock, IUpdateBlock { [JsonProperty("heading_1")] - public TextContentUpdate Heading_1 { get; set; } + public Info Heading_1 { get; set; } + + public class Info + { + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } + } } } diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingThreeeUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingThreeeUpdateBlock.cs index 2f413e35..574ea0f0 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingThreeeUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingThreeeUpdateBlock.cs @@ -1,10 +1,17 @@ -using Newtonsoft.Json; +using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class HeadingThreeeUpdateBlock : UpdateBlock, IUpdateBlock { [JsonProperty("heading_3")] - public TextContentUpdate Heading_3 { get; set; } + public Info Heading_3 { get; set; } + + public class Info + { + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } + } } } diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingTwoUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingTwoUpdateBlock.cs index 9b314a03..0269a0ce 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingTwoUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingTwoUpdateBlock.cs @@ -1,10 +1,17 @@ -using Newtonsoft.Json; +using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class HeadingTwoUpdateBlock : UpdateBlock, IUpdateBlock { [JsonProperty("heading_2")] - public TextContentUpdate Heading_2 { get; set; } + public Info Heading_2 { get; set; } + + public class Info + { + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } + } } } diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/NumberedListItemUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/NumberedListItemUpdateBlock.cs index 03e6f20b..c27363d3 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/NumberedListItemUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/NumberedListItemUpdateBlock.cs @@ -1,10 +1,17 @@ -using Newtonsoft.Json; +using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class NumberedListItemUpdateBlock : UpdateBlock, IUpdateBlock { [JsonProperty("numbered_list_item")] - public TextContentUpdate NumberedListItem { get; set; } + public Info NumberedListItem { get; set; } + + public class Info + { + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } + } } } diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ParagraphUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ParagraphUpdateBlock.cs index 43fca06e..2e49c64a 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ParagraphUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ParagraphUpdateBlock.cs @@ -1,10 +1,17 @@ -using Newtonsoft.Json; +using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class ParagraphUpdateBlock : UpdateBlock, IUpdateBlock { [JsonProperty("paragraph")] - public TextContentUpdate Paragraph { get; set; } + public Info Paragraph { get; set; } + + public class Info + { + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } + } } } diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/QuoteUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/QuoteUpdateBlock.cs index 9d0405f0..fdfd189c 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/QuoteUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/QuoteUpdateBlock.cs @@ -10,8 +10,8 @@ public class QuoteUpdateBlock : UpdateBlock, IUpdateBlock public class Info { - [JsonProperty("text")] - public IEnumerable Text { get; set; } + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } } } } diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/SyncedBlockUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/SyncedBlockUpdateBlock.cs index 97f393fe..9cb234d8 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/SyncedBlockUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/SyncedBlockUpdateBlock.cs @@ -5,9 +5,9 @@ namespace Notion.Client public class SyncedBlockUpdateBlock : UpdateBlock, IUpdateBlock { [JsonProperty("synced_block")] - public Data SyncedBlock { get; set; } + public Info SyncedBlock { get; set; } - public class Data + public class Info { [JsonProperty("synced_from")] public SyncedFromBlockId SyncedFrom { get; set; } diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TableOfContentsUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TableOfContentsUpdateBlock.cs index 9e742597..36eee182 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TableOfContentsUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TableOfContentsUpdateBlock.cs @@ -7,15 +7,15 @@ public class TableOfContentsUpdateBlock : IUpdateBlock public bool Archived { get; set; } [JsonProperty("table_of_contents")] - public Data TableOfContents { get; set; } + public Info TableOfContents { get; set; } - public class Data + public class Info { } public TableOfContentsUpdateBlock() { - TableOfContents = new Data(); + TableOfContents = new Info(); } } } diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TemplateUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TemplateUpdateBlock.cs index 032cb335..62457971 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TemplateUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TemplateUpdateBlock.cs @@ -6,12 +6,12 @@ namespace Notion.Client public class TemplateUpdateBlock : UpdateBlock, IUpdateBlock { [JsonProperty("template")] - public Data Template { get; set; } + public Info Template { get; set; } - public class Data + public class Info { - [JsonProperty("text")] - public IEnumerable Text { get; set; } + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } } } } diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TextContentUpdate.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TextContentUpdate.cs deleted file mode 100644 index b0388162..00000000 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TextContentUpdate.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; -using Newtonsoft.Json; - -namespace Notion.Client -{ - public class TextContentUpdate - { - [JsonProperty("text")] - public IEnumerable Text { get; set; } - } -} diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToDoUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToDoUpdateBlock.cs index e5b5cd5b..f1accfc8 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToDoUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToDoUpdateBlock.cs @@ -10,8 +10,8 @@ public class ToDoUpdateBlock : UpdateBlock, IUpdateBlock public class Info { - [JsonProperty("text")] - public IEnumerable Text { get; set; } + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } [JsonProperty("checked")] public bool IsChecked { get; set; } diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToggleUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToggleUpdateBlock.cs index 89b71ac9..b87834d1 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToggleUpdateBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToggleUpdateBlock.cs @@ -1,10 +1,17 @@ -using Newtonsoft.Json; +using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class ToggleUpdateBlock : UpdateBlock, IUpdateBlock { [JsonProperty("toggle")] - public TextContentUpdate Toggle { get; set; } + public Info Toggle { get; set; } + + public class Info + { + [JsonProperty("rich_text")] + public IEnumerable RichText { get; set; } + } } } diff --git a/Test/Notion.IntegrationTests/IBlocksClientTests.cs b/Test/Notion.IntegrationTests/IBlocksClientTests.cs index c1e94e4e..eabef5b4 100644 --- a/Test/Notion.IntegrationTests/IBlocksClientTests.cs +++ b/Test/Notion.IntegrationTests/IBlocksClientTests.cs @@ -230,7 +230,7 @@ private static IEnumerable BlockData() } }, new BookmarkUpdateBlock { - Bookmark = new BookmarkUpdateBlock.Data + Bookmark = new BookmarkUpdateBlock.Info { Url = "https://github.com/notion-dotnet/notion-sdk-net", Caption = new List @@ -260,7 +260,7 @@ private static IEnumerable BlockData() } }, new EquationUpdateBlock { - Equation = new EquationUpdateBlock.Data + Equation = new EquationUpdateBlock.Info { Expression = "e=mc^2" } @@ -337,7 +337,7 @@ private static IEnumerable BlockData() { Callout = new CalloutUpdateBlock.Info { - Text = new List + RichText = new List { new RichTextTextInput { @@ -379,7 +379,7 @@ private static IEnumerable BlockData() { Quote = new QuoteUpdateBlock.Info { - Text = new List + RichText = new List { new RichTextTextInput { @@ -440,7 +440,7 @@ private static IEnumerable BlockData() }, new EmbedUpdateBlock() { - Embed = new EmbedUpdateBlock.Data + Embed = new EmbedUpdateBlock.Info { Url = "https://www.iaspaper.net/wp-content/uploads/2017/09/TNEA-Online-Application.jpg" } @@ -483,9 +483,9 @@ private static IEnumerable BlockData() }, new TemplateUpdateBlock() { - Template = new TemplateUpdateBlock.Data + Template = new TemplateUpdateBlock.Info { - Text = new List + RichText = new List { new RichTextTextInput { diff --git a/Test/Notion.UnitTests/BlocksClientTests.cs b/Test/Notion.UnitTests/BlocksClientTests.cs index 8bfe218e..753e5464 100644 --- a/Test/Notion.UnitTests/BlocksClientTests.cs +++ b/Test/Notion.UnitTests/BlocksClientTests.cs @@ -168,7 +168,7 @@ public async Task UpdateAsync() { ToDo = new ToDoUpdateBlock.Info { - Text = new List() + RichText = new List() { new RichTextTextInput { From 5cb1c5dc4447286e092b73a5f6cf79407bcbbde0 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Mon, 11 Jul 2022 01:09:11 +0530 Subject: [PATCH 03/12] Fix text filter properties and rename files --- .../{Checkbox.cs => CheckboxFilter.cs} | 68 ++--- .../Models/Filters/{Date.cs => DateFilter.cs} | 246 +++++++++--------- .../Models/Filters/EmailFilter.cs | 34 +++ .../Filters/{Files.cs => FilesFilter.cs} | 73 +++--- .../Filters/{Formula.cs => FormulaFilter.cs} | 104 ++++---- .../{Multiselect.cs => MultiSelectFilter.cs} | 110 ++++---- .../Filters/{Number.cs => NumberFilter.cs} | 164 ++++++------ .../Filters/{People.cs => PeopleFilter.cs} | 106 ++++---- .../Models/Filters/PhoneNumberFilter.cs | 34 +++ .../{Relation.cs => RelationFilter.cs} | 106 ++++---- .../Filters/{Text.cs => RichTextFilter.cs} | 165 ++++++------ .../Filters/{Select.cs => SelectFilter.cs} | 106 ++++---- .../Models/Filters/TitleFilter.cs | 34 +++ Src/Notion.Client/Models/Filters/URLFilter.cs | 34 +++ Test/Notion.UnitTests/FilterTests.cs | 4 +- 15 files changed, 763 insertions(+), 625 deletions(-) rename Src/Notion.Client/Models/Filters/{Checkbox.cs => CheckboxFilter.cs} (96%) rename Src/Notion.Client/Models/Filters/{Date.cs => DateFilter.cs} (97%) create mode 100644 Src/Notion.Client/Models/Filters/EmailFilter.cs rename Src/Notion.Client/Models/Filters/{Files.cs => FilesFilter.cs} (95%) rename Src/Notion.Client/Models/Filters/{Formula.cs => FormulaFilter.cs} (96%) rename Src/Notion.Client/Models/Filters/{Multiselect.cs => MultiSelectFilter.cs} (96%) rename Src/Notion.Client/Models/Filters/{Number.cs => NumberFilter.cs} (96%) rename Src/Notion.Client/Models/Filters/{People.cs => PeopleFilter.cs} (96%) create mode 100644 Src/Notion.Client/Models/Filters/PhoneNumberFilter.cs rename Src/Notion.Client/Models/Filters/{Relation.cs => RelationFilter.cs} (96%) rename Src/Notion.Client/Models/Filters/{Text.cs => RichTextFilter.cs} (89%) rename Src/Notion.Client/Models/Filters/{Select.cs => SelectFilter.cs} (96%) create mode 100644 Src/Notion.Client/Models/Filters/TitleFilter.cs create mode 100644 Src/Notion.Client/Models/Filters/URLFilter.cs diff --git a/Src/Notion.Client/Models/Filters/Checkbox.cs b/Src/Notion.Client/Models/Filters/CheckboxFilter.cs similarity index 96% rename from Src/Notion.Client/Models/Filters/Checkbox.cs rename to Src/Notion.Client/Models/Filters/CheckboxFilter.cs index 1eb73e2e..f0c2b41d 100644 --- a/Src/Notion.Client/Models/Filters/Checkbox.cs +++ b/Src/Notion.Client/Models/Filters/CheckboxFilter.cs @@ -1,35 +1,35 @@ -using System; -using Newtonsoft.Json; - -namespace Notion.Client -{ - public class CheckboxFilter : SinglePropertyFilter - { - [JsonProperty("checkbox")] - public Condition Checkbox { get; set; } - - public CheckboxFilter( - string propertyName, - bool? equal = null, - bool? doesNotEqual = null) - { - Property = propertyName; - Checkbox = new Condition(equal: equal, doesNotEqual: doesNotEqual); - } - - public class Condition - { - [JsonProperty("equals")] - public bool? Equal { get; set; } - - [JsonProperty("does_not_equal")] - public bool? DoesNotEqual { get; set; } - - public Condition(Nullable equal = null, Nullable doesNotEqual = null) - { - Equal = equal; - DoesNotEqual = doesNotEqual; - } - } - } +using System; +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class CheckboxFilter : SinglePropertyFilter + { + [JsonProperty("checkbox")] + public Condition Checkbox { get; set; } + + public CheckboxFilter( + string propertyName, + bool? equal = null, + bool? doesNotEqual = null) + { + Property = propertyName; + Checkbox = new Condition(equal: equal, doesNotEqual: doesNotEqual); + } + + public class Condition + { + [JsonProperty("equals")] + public bool? Equal { get; set; } + + [JsonProperty("does_not_equal")] + public bool? DoesNotEqual { get; set; } + + public Condition(Nullable equal = null, Nullable doesNotEqual = null) + { + Equal = equal; + DoesNotEqual = doesNotEqual; + } + } + } } diff --git a/Src/Notion.Client/Models/Filters/Date.cs b/Src/Notion.Client/Models/Filters/DateFilter.cs similarity index 97% rename from Src/Notion.Client/Models/Filters/Date.cs rename to Src/Notion.Client/Models/Filters/DateFilter.cs index 44b29fb9..a472ff49 100644 --- a/Src/Notion.Client/Models/Filters/Date.cs +++ b/Src/Notion.Client/Models/Filters/DateFilter.cs @@ -1,124 +1,124 @@ -using System; -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; - -namespace Notion.Client -{ - public class DateFilter : SinglePropertyFilter - { - [JsonProperty("date")] - public Condition Date { get; set; } - - public DateFilter( - string propertyName, - DateTime? equal = null, - DateTime? before = null, - DateTime? after = null, - DateTime? onOrBefore = null, - DateTime? onOrAfter = null, - Dictionary pastWeek = null, - Dictionary pastMonth = null, - Dictionary pastYear = null, - Dictionary nextWeek = null, - Dictionary nextMonth = null, - Dictionary nextYear = null, - bool? isEmpty = null, - bool? isNotEmpty = null) - { - Property = propertyName; - Date = new Condition( - equal: equal, - before: before, - after: after, - onOrBefore: onOrBefore, - onOrAfter: onOrAfter, - pastWeek: pastWeek, - pastMonth: pastMonth, - pastYear: pastYear, - nextWeek: nextWeek, - nextMonth: nextMonth, - nextYear: nextYear, - isEmpty: isEmpty, - isNotEmpty: isNotEmpty - ); - } - - public class Condition - { - [JsonProperty("equals")] - [JsonConverter(typeof(IsoDateTimeConverter))] - public DateTime? Equal { get; set; } - - [JsonProperty("before")] - [JsonConverter(typeof(IsoDateTimeConverter))] - public DateTime? Before { get; set; } - - [JsonProperty("after")] - [JsonConverter(typeof(IsoDateTimeConverter))] - public DateTime? After { get; set; } - - [JsonProperty("on_or_before")] - [JsonConverter(typeof(IsoDateTimeConverter))] - public DateTime? OnOrBefore { get; set; } - - [JsonProperty("on_or_after")] - [JsonConverter(typeof(IsoDateTimeConverter))] - public DateTime? OnOrAfter { get; set; } - - [JsonProperty("past_week")] - public Dictionary PastWeek { get; set; } - - [JsonProperty("past_month")] - public Dictionary PastMonth { get; set; } - - [JsonProperty("past_year")] - public Dictionary PastYear { get; set; } - - [JsonProperty("next_week")] - public Dictionary NextWeek { get; set; } - - [JsonProperty("next_month")] - public Dictionary NextMonth { get; set; } - - [JsonProperty("next_year")] - public Dictionary NextYear { get; set; } - - [JsonProperty("is_empty")] - public bool? IsEmpty { get; set; } - - [JsonProperty("is_not_empty")] - public bool? IsNotEmpty { get; set; } - - public Condition( - DateTime? equal = null, - DateTime? before = null, - DateTime? after = null, - DateTime? onOrBefore = null, - DateTime? onOrAfter = null, - Dictionary pastWeek = null, - Dictionary pastMonth = null, - Dictionary pastYear = null, - Dictionary nextWeek = null, - Dictionary nextMonth = null, - Dictionary nextYear = null, - bool? isEmpty = null, - bool? isNotEmpty = null) - { - Equal = equal; - Before = before; - After = after; - OnOrBefore = onOrBefore; - OnOrAfter = onOrAfter; - PastWeek = pastWeek; - PastMonth = pastMonth; - PastYear = pastYear; - NextWeek = nextWeek; - NextMonth = nextMonth; - NextYear = nextYear; - IsEmpty = isEmpty; - IsNotEmpty = isNotEmpty; - } - } - } +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Notion.Client +{ + public class DateFilter : SinglePropertyFilter + { + [JsonProperty("date")] + public Condition Date { get; set; } + + public DateFilter( + string propertyName, + DateTime? equal = null, + DateTime? before = null, + DateTime? after = null, + DateTime? onOrBefore = null, + DateTime? onOrAfter = null, + Dictionary pastWeek = null, + Dictionary pastMonth = null, + Dictionary pastYear = null, + Dictionary nextWeek = null, + Dictionary nextMonth = null, + Dictionary nextYear = null, + bool? isEmpty = null, + bool? isNotEmpty = null) + { + Property = propertyName; + Date = new Condition( + equal: equal, + before: before, + after: after, + onOrBefore: onOrBefore, + onOrAfter: onOrAfter, + pastWeek: pastWeek, + pastMonth: pastMonth, + pastYear: pastYear, + nextWeek: nextWeek, + nextMonth: nextMonth, + nextYear: nextYear, + isEmpty: isEmpty, + isNotEmpty: isNotEmpty + ); + } + + public class Condition + { + [JsonProperty("equals")] + [JsonConverter(typeof(IsoDateTimeConverter))] + public DateTime? Equal { get; set; } + + [JsonProperty("before")] + [JsonConverter(typeof(IsoDateTimeConverter))] + public DateTime? Before { get; set; } + + [JsonProperty("after")] + [JsonConverter(typeof(IsoDateTimeConverter))] + public DateTime? After { get; set; } + + [JsonProperty("on_or_before")] + [JsonConverter(typeof(IsoDateTimeConverter))] + public DateTime? OnOrBefore { get; set; } + + [JsonProperty("on_or_after")] + [JsonConverter(typeof(IsoDateTimeConverter))] + public DateTime? OnOrAfter { get; set; } + + [JsonProperty("past_week")] + public Dictionary PastWeek { get; set; } + + [JsonProperty("past_month")] + public Dictionary PastMonth { get; set; } + + [JsonProperty("past_year")] + public Dictionary PastYear { get; set; } + + [JsonProperty("next_week")] + public Dictionary NextWeek { get; set; } + + [JsonProperty("next_month")] + public Dictionary NextMonth { get; set; } + + [JsonProperty("next_year")] + public Dictionary NextYear { get; set; } + + [JsonProperty("is_empty")] + public bool? IsEmpty { get; set; } + + [JsonProperty("is_not_empty")] + public bool? IsNotEmpty { get; set; } + + public Condition( + DateTime? equal = null, + DateTime? before = null, + DateTime? after = null, + DateTime? onOrBefore = null, + DateTime? onOrAfter = null, + Dictionary pastWeek = null, + Dictionary pastMonth = null, + Dictionary pastYear = null, + Dictionary nextWeek = null, + Dictionary nextMonth = null, + Dictionary nextYear = null, + bool? isEmpty = null, + bool? isNotEmpty = null) + { + Equal = equal; + Before = before; + After = after; + OnOrBefore = onOrBefore; + OnOrAfter = onOrAfter; + PastWeek = pastWeek; + PastMonth = pastMonth; + PastYear = pastYear; + NextWeek = nextWeek; + NextMonth = nextMonth; + NextYear = nextYear; + IsEmpty = isEmpty; + IsNotEmpty = isNotEmpty; + } + } + } } diff --git a/Src/Notion.Client/Models/Filters/EmailFilter.cs b/Src/Notion.Client/Models/Filters/EmailFilter.cs new file mode 100644 index 00000000..ff5feda9 --- /dev/null +++ b/Src/Notion.Client/Models/Filters/EmailFilter.cs @@ -0,0 +1,34 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class EmailFilter : SinglePropertyFilter + { + [JsonProperty("email")] + public TextFilter.Condition Email { get; set; } + + public EmailFilter( + string propertyName, + string equal = null, + string doesNotEqual = null, + string contains = null, + string doesNotContain = null, + string startsWith = null, + string endsWith = null, + bool? isEmpty = null, + bool? isNotEmpty = null) + { + Property = propertyName; + Email = new TextFilter.Condition( + equal: equal, + doesNotEqual: doesNotEqual, + contains: contains, + doesNotContain: doesNotContain, + startsWith: startsWith, + endsWith: endsWith, + isEmpty: isEmpty, + isNotEmpty: isNotEmpty + ); + } + } +} diff --git a/Src/Notion.Client/Models/Filters/Files.cs b/Src/Notion.Client/Models/Filters/FilesFilter.cs similarity index 95% rename from Src/Notion.Client/Models/Filters/Files.cs rename to Src/Notion.Client/Models/Filters/FilesFilter.cs index e20f863d..a3dca061 100644 --- a/Src/Notion.Client/Models/Filters/Files.cs +++ b/Src/Notion.Client/Models/Filters/FilesFilter.cs @@ -1,37 +1,36 @@ -using Newtonsoft.Json; - -namespace Notion.Client -{ - - public class FilesFilter : SinglePropertyFilter - { - [JsonProperty("files")] - public Condition Files { get; set; } - - public FilesFilter( - string propertyName, - bool? isEmpty = null, - bool? isNotEmpty = null) - { - Property = propertyName; - Files = new Condition(isEmpty: isEmpty, isNotEmpty: isNotEmpty); - } - - public class Condition - { - [JsonProperty("is_empty")] - public bool? IsEmpty { get; set; } - - [JsonProperty("is_not_empty")] - public bool? IsNotEmpty { get; set; } - - public Condition( - bool? isEmpty = null, - bool? isNotEmpty = null) - { - IsEmpty = isEmpty; - IsNotEmpty = isNotEmpty; - } - } - } -} +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class FilesFilter : SinglePropertyFilter + { + [JsonProperty("files")] + public Condition Files { get; set; } + + public FilesFilter( + string propertyName, + bool? isEmpty = null, + bool? isNotEmpty = null) + { + Property = propertyName; + Files = new Condition(isEmpty: isEmpty, isNotEmpty: isNotEmpty); + } + + public class Condition + { + [JsonProperty("is_empty")] + public bool? IsEmpty { get; set; } + + [JsonProperty("is_not_empty")] + public bool? IsNotEmpty { get; set; } + + public Condition( + bool? isEmpty = null, + bool? isNotEmpty = null) + { + IsEmpty = isEmpty; + IsNotEmpty = isNotEmpty; + } + } + } +} diff --git a/Src/Notion.Client/Models/Filters/Formula.cs b/Src/Notion.Client/Models/Filters/FormulaFilter.cs similarity index 96% rename from Src/Notion.Client/Models/Filters/Formula.cs rename to Src/Notion.Client/Models/Filters/FormulaFilter.cs index 82b58cc8..9e6fdc19 100644 --- a/Src/Notion.Client/Models/Filters/Formula.cs +++ b/Src/Notion.Client/Models/Filters/FormulaFilter.cs @@ -1,53 +1,53 @@ -using Newtonsoft.Json; - -namespace Notion.Client -{ - public class FormulaFilter : SinglePropertyFilter - { - [JsonProperty("formula")] - public Condition Formula { get; set; } - - public FormulaFilter( - string propertyName, - TextFilter.Condition text = null, - CheckboxFilter.Condition checkbox = null, - NumberFilter.Condition number = null, - DateFilter.Condition date = null) - { - Property = propertyName; - Formula = new Condition( - text: text, - checkbox: checkbox, - number: number, - date: date - ); - } - - public class Condition - { - [JsonProperty("text")] - public TextFilter.Condition Text { get; set; } - - [JsonProperty("checkbox")] - public CheckboxFilter.Condition Checkbox { get; set; } - - [JsonProperty("number")] - public NumberFilter.Condition Number { get; set; } - - [JsonProperty("date")] - public DateFilter.Condition Date { get; set; } - - public Condition( - TextFilter.Condition text = null, - CheckboxFilter.Condition checkbox = null, - NumberFilter.Condition number = null, - DateFilter.Condition date = null) - { - Text = text; - Checkbox = checkbox; - Number = number; - Date = date; - } - } - } +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class FormulaFilter : SinglePropertyFilter + { + [JsonProperty("formula")] + public Condition Formula { get; set; } + + public FormulaFilter( + string propertyName, + TextFilter.Condition text = null, + CheckboxFilter.Condition checkbox = null, + NumberFilter.Condition number = null, + DateFilter.Condition date = null) + { + Property = propertyName; + Formula = new Condition( + text: text, + checkbox: checkbox, + number: number, + date: date + ); + } + + public class Condition + { + [JsonProperty("text")] + public TextFilter.Condition Text { get; set; } + + [JsonProperty("checkbox")] + public CheckboxFilter.Condition Checkbox { get; set; } + + [JsonProperty("number")] + public NumberFilter.Condition Number { get; set; } + + [JsonProperty("date")] + public DateFilter.Condition Date { get; set; } + + public Condition( + TextFilter.Condition text = null, + CheckboxFilter.Condition checkbox = null, + NumberFilter.Condition number = null, + DateFilter.Condition date = null) + { + Text = text; + Checkbox = checkbox; + Number = number; + Date = date; + } + } + } } diff --git a/Src/Notion.Client/Models/Filters/Multiselect.cs b/Src/Notion.Client/Models/Filters/MultiSelectFilter.cs similarity index 96% rename from Src/Notion.Client/Models/Filters/Multiselect.cs rename to Src/Notion.Client/Models/Filters/MultiSelectFilter.cs index bf69d110..69615b3d 100644 --- a/Src/Notion.Client/Models/Filters/Multiselect.cs +++ b/Src/Notion.Client/Models/Filters/MultiSelectFilter.cs @@ -1,55 +1,55 @@ -using Newtonsoft.Json; - -namespace Notion.Client -{ - public class MultiSelectFilter : SinglePropertyFilter - { - [JsonProperty("multi_select")] - public Condition MultiSelect { get; set; } - - public MultiSelectFilter( - string propertyName, - string contains = null, - string doesNotContain = null, - bool? isEmpty = null, - bool? isNotEmpty = null) - { - Property = propertyName; - MultiSelect = new Condition( - contains: contains, - doesNotContain: doesNotContain, - isEmpty: isEmpty, - isNotEmpty: isNotEmpty - ); - } - - - public class Condition - { - [JsonProperty("contains")] - public string Contains { get; set; } - - [JsonProperty("does_not_contain")] - public string DoesNotContain { get; set; } - - [JsonProperty("is_empty")] - public bool? IsEmpty { get; set; } - - [JsonProperty("is_not_empty")] - public bool? IsNotEmpty { get; set; } - - public Condition( - string contains = null, - string doesNotContain = null, - bool? isEmpty = null, - bool? isNotEmpty = null) - { - Contains = contains; - DoesNotContain = doesNotContain; - IsEmpty = isEmpty; - IsNotEmpty = isNotEmpty; - } - } - - } -} +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class MultiSelectFilter : SinglePropertyFilter + { + [JsonProperty("multi_select")] + public Condition MultiSelect { get; set; } + + public MultiSelectFilter( + string propertyName, + string contains = null, + string doesNotContain = null, + bool? isEmpty = null, + bool? isNotEmpty = null) + { + Property = propertyName; + MultiSelect = new Condition( + contains: contains, + doesNotContain: doesNotContain, + isEmpty: isEmpty, + isNotEmpty: isNotEmpty + ); + } + + + public class Condition + { + [JsonProperty("contains")] + public string Contains { get; set; } + + [JsonProperty("does_not_contain")] + public string DoesNotContain { get; set; } + + [JsonProperty("is_empty")] + public bool? IsEmpty { get; set; } + + [JsonProperty("is_not_empty")] + public bool? IsNotEmpty { get; set; } + + public Condition( + string contains = null, + string doesNotContain = null, + bool? isEmpty = null, + bool? isNotEmpty = null) + { + Contains = contains; + DoesNotContain = doesNotContain; + IsEmpty = isEmpty; + IsNotEmpty = isNotEmpty; + } + } + + } +} diff --git a/Src/Notion.Client/Models/Filters/Number.cs b/Src/Notion.Client/Models/Filters/NumberFilter.cs similarity index 96% rename from Src/Notion.Client/Models/Filters/Number.cs rename to Src/Notion.Client/Models/Filters/NumberFilter.cs index 9282226a..58e0c38a 100644 --- a/Src/Notion.Client/Models/Filters/Number.cs +++ b/Src/Notion.Client/Models/Filters/NumberFilter.cs @@ -1,82 +1,82 @@ -using Newtonsoft.Json; - -namespace Notion.Client -{ - public class NumberFilter : SinglePropertyFilter - { - [JsonProperty("number")] - public Condition Number { get; set; } - - public NumberFilter( - string propertyName, - double? equal = null, - double? doesNotEqual = null, - double? greaterThan = null, - double? lessThan = null, - double? greaterThanOrEqualTo = null, - double? lessThanOrEqualTo = null, - bool? isEmpty = null, - bool? isNotEmpty = null) - { - Property = propertyName; - Number = new Condition( - equal: equal, - doesNotEqual: doesNotEqual, - greaterThan: greaterThan, - lessThan: lessThan, - greaterThanOrEqualTo: greaterThanOrEqualTo, - lessThanOrEqualTo: lessThanOrEqualTo, - isEmpty: isEmpty, - isNotEmpty: isNotEmpty - ); - } - - public class Condition - { - [JsonProperty("equals")] - public double? Equal { get; set; } - - [JsonProperty("does_not_equal")] - public double? DoesNotEqual { get; set; } - - [JsonProperty("greater_than")] - public double? GreaterThan { get; set; } - - [JsonProperty("less_than")] - public double? LessThan { get; set; } - - [JsonProperty("greater_than_or_equal_to")] - public double? GreaterThanOrEqualTo { get; set; } - - [JsonProperty("less_than_or_equal_to")] - public double? LessThanOrEqualTo { get; set; } - - [JsonProperty("is_empty")] - public bool? IsEmpty { get; set; } - - [JsonProperty("is_not_empty")] - public bool? IsNotEmpty { get; set; } - - public Condition( - double? equal = null, - double? doesNotEqual = null, - double? greaterThan = null, - double? lessThan = null, - double? greaterThanOrEqualTo = null, - double? lessThanOrEqualTo = null, - bool? isEmpty = null, - bool? isNotEmpty = null) - { - Equal = equal; - DoesNotEqual = doesNotEqual; - GreaterThan = greaterThan; - LessThan = lessThan; - GreaterThanOrEqualTo = greaterThanOrEqualTo; - LessThanOrEqualTo = lessThanOrEqualTo; - IsEmpty = isEmpty; - IsNotEmpty = isNotEmpty; - } - } - - } -} +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class NumberFilter : SinglePropertyFilter + { + [JsonProperty("number")] + public Condition Number { get; set; } + + public NumberFilter( + string propertyName, + double? equal = null, + double? doesNotEqual = null, + double? greaterThan = null, + double? lessThan = null, + double? greaterThanOrEqualTo = null, + double? lessThanOrEqualTo = null, + bool? isEmpty = null, + bool? isNotEmpty = null) + { + Property = propertyName; + Number = new Condition( + equal: equal, + doesNotEqual: doesNotEqual, + greaterThan: greaterThan, + lessThan: lessThan, + greaterThanOrEqualTo: greaterThanOrEqualTo, + lessThanOrEqualTo: lessThanOrEqualTo, + isEmpty: isEmpty, + isNotEmpty: isNotEmpty + ); + } + + public class Condition + { + [JsonProperty("equals")] + public double? Equal { get; set; } + + [JsonProperty("does_not_equal")] + public double? DoesNotEqual { get; set; } + + [JsonProperty("greater_than")] + public double? GreaterThan { get; set; } + + [JsonProperty("less_than")] + public double? LessThan { get; set; } + + [JsonProperty("greater_than_or_equal_to")] + public double? GreaterThanOrEqualTo { get; set; } + + [JsonProperty("less_than_or_equal_to")] + public double? LessThanOrEqualTo { get; set; } + + [JsonProperty("is_empty")] + public bool? IsEmpty { get; set; } + + [JsonProperty("is_not_empty")] + public bool? IsNotEmpty { get; set; } + + public Condition( + double? equal = null, + double? doesNotEqual = null, + double? greaterThan = null, + double? lessThan = null, + double? greaterThanOrEqualTo = null, + double? lessThanOrEqualTo = null, + bool? isEmpty = null, + bool? isNotEmpty = null) + { + Equal = equal; + DoesNotEqual = doesNotEqual; + GreaterThan = greaterThan; + LessThan = lessThan; + GreaterThanOrEqualTo = greaterThanOrEqualTo; + LessThanOrEqualTo = lessThanOrEqualTo; + IsEmpty = isEmpty; + IsNotEmpty = isNotEmpty; + } + } + + } +} diff --git a/Src/Notion.Client/Models/Filters/People.cs b/Src/Notion.Client/Models/Filters/PeopleFilter.cs similarity index 96% rename from Src/Notion.Client/Models/Filters/People.cs rename to Src/Notion.Client/Models/Filters/PeopleFilter.cs index 6138e3d2..cd77c186 100644 --- a/Src/Notion.Client/Models/Filters/People.cs +++ b/Src/Notion.Client/Models/Filters/PeopleFilter.cs @@ -1,53 +1,53 @@ -using Newtonsoft.Json; - -namespace Notion.Client -{ - public class PeopleFilter : SinglePropertyFilter - { - [JsonProperty("people")] - public Condition People { get; set; } - - public PeopleFilter( - string propertyName, - string contains = null, - string doesNotContain = null, - bool? isEmpty = null, - bool? isNotEmpty = null) - { - Property = propertyName; - People = new Condition( - contains: contains, - doesNotContain: doesNotContain, - isEmpty: isEmpty, - isNotEmpty: isNotEmpty - ); - } - - public class Condition - { - [JsonProperty("contains")] - public string Contains { get; set; } - - [JsonProperty("does_not_contain")] - public string DoesNotContain { get; set; } - - [JsonProperty("is_empty")] - public bool? IsEmpty { get; set; } - - [JsonProperty("is_not_empty")] - public bool? IsNotEmpty { get; set; } - - public Condition( - string contains = null, - string doesNotContain = null, - bool? isEmpty = null, - bool? isNotEmpty = null) - { - Contains = contains; - DoesNotContain = doesNotContain; - IsEmpty = isEmpty; - IsNotEmpty = isNotEmpty; - } - } - } -} +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class PeopleFilter : SinglePropertyFilter + { + [JsonProperty("people")] + public Condition People { get; set; } + + public PeopleFilter( + string propertyName, + string contains = null, + string doesNotContain = null, + bool? isEmpty = null, + bool? isNotEmpty = null) + { + Property = propertyName; + People = new Condition( + contains: contains, + doesNotContain: doesNotContain, + isEmpty: isEmpty, + isNotEmpty: isNotEmpty + ); + } + + public class Condition + { + [JsonProperty("contains")] + public string Contains { get; set; } + + [JsonProperty("does_not_contain")] + public string DoesNotContain { get; set; } + + [JsonProperty("is_empty")] + public bool? IsEmpty { get; set; } + + [JsonProperty("is_not_empty")] + public bool? IsNotEmpty { get; set; } + + public Condition( + string contains = null, + string doesNotContain = null, + bool? isEmpty = null, + bool? isNotEmpty = null) + { + Contains = contains; + DoesNotContain = doesNotContain; + IsEmpty = isEmpty; + IsNotEmpty = isNotEmpty; + } + } + } +} diff --git a/Src/Notion.Client/Models/Filters/PhoneNumberFilter.cs b/Src/Notion.Client/Models/Filters/PhoneNumberFilter.cs new file mode 100644 index 00000000..758a65db --- /dev/null +++ b/Src/Notion.Client/Models/Filters/PhoneNumberFilter.cs @@ -0,0 +1,34 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class PhoneNumberFilter : SinglePropertyFilter + { + [JsonProperty("phone_number")] + public TextFilter.Condition Text { get; set; } + + public PhoneNumberFilter( + string propertyName, + string equal = null, + string doesNotEqual = null, + string contains = null, + string doesNotContain = null, + string startsWith = null, + string endsWith = null, + bool? isEmpty = null, + bool? isNotEmpty = null) + { + Property = propertyName; + Text = new TextFilter.Condition( + equal: equal, + doesNotEqual: doesNotEqual, + contains: contains, + doesNotContain: doesNotContain, + startsWith: startsWith, + endsWith: endsWith, + isEmpty: isEmpty, + isNotEmpty: isNotEmpty + ); + } + } +} diff --git a/Src/Notion.Client/Models/Filters/Relation.cs b/Src/Notion.Client/Models/Filters/RelationFilter.cs similarity index 96% rename from Src/Notion.Client/Models/Filters/Relation.cs rename to Src/Notion.Client/Models/Filters/RelationFilter.cs index 26f7214a..e7eef130 100644 --- a/Src/Notion.Client/Models/Filters/Relation.cs +++ b/Src/Notion.Client/Models/Filters/RelationFilter.cs @@ -1,53 +1,53 @@ -using Newtonsoft.Json; - -namespace Notion.Client -{ - public class RelationFilter : SinglePropertyFilter - { - [JsonProperty("relation")] - public Condition Relation { get; set; } - - public RelationFilter( - string propertyName, - string contains = null, - string doesNotContain = null, - bool? isEmpty = null, - bool? isNotEmpty = null) - { - Property = propertyName; - Relation = new Condition( - contains: contains, - doesNotContain: doesNotContain, - isEmpty: isEmpty, - isNotEmpty: isNotEmpty - ); - } - - public class Condition - { - [JsonProperty("contains")] - public string Contains { get; set; } - - [JsonProperty("does_not_contain")] - public string DoesNotContain { get; set; } - - [JsonProperty("is_empty")] - public bool? IsEmpty { get; set; } - - [JsonProperty("is_not_empty")] - public bool? IsNotEmpty { get; set; } - - public Condition( - string contains = null, - string doesNotContain = null, - bool? isEmpty = null, - bool? isNotEmpty = null) - { - Contains = contains; - DoesNotContain = doesNotContain; - IsEmpty = isEmpty; - IsNotEmpty = isNotEmpty; - } - } - } -} +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class RelationFilter : SinglePropertyFilter + { + [JsonProperty("relation")] + public Condition Relation { get; set; } + + public RelationFilter( + string propertyName, + string contains = null, + string doesNotContain = null, + bool? isEmpty = null, + bool? isNotEmpty = null) + { + Property = propertyName; + Relation = new Condition( + contains: contains, + doesNotContain: doesNotContain, + isEmpty: isEmpty, + isNotEmpty: isNotEmpty + ); + } + + public class Condition + { + [JsonProperty("contains")] + public string Contains { get; set; } + + [JsonProperty("does_not_contain")] + public string DoesNotContain { get; set; } + + [JsonProperty("is_empty")] + public bool? IsEmpty { get; set; } + + [JsonProperty("is_not_empty")] + public bool? IsNotEmpty { get; set; } + + public Condition( + string contains = null, + string doesNotContain = null, + bool? isEmpty = null, + bool? isNotEmpty = null) + { + Contains = contains; + DoesNotContain = doesNotContain; + IsEmpty = isEmpty; + IsNotEmpty = isNotEmpty; + } + } + } +} diff --git a/Src/Notion.Client/Models/Filters/Text.cs b/Src/Notion.Client/Models/Filters/RichTextFilter.cs similarity index 89% rename from Src/Notion.Client/Models/Filters/Text.cs rename to Src/Notion.Client/Models/Filters/RichTextFilter.cs index 3446e854..84128fcb 100644 --- a/Src/Notion.Client/Models/Filters/Text.cs +++ b/Src/Notion.Client/Models/Filters/RichTextFilter.cs @@ -1,81 +1,84 @@ -using Newtonsoft.Json; - -namespace Notion.Client -{ - public class TextFilter : SinglePropertyFilter - { - [JsonProperty("text")] - public Condition Text { get; set; } - - public TextFilter( - string propertyName, - string equal = null, - string doesNotEqual = null, - string contains = null, - string doesNotContain = null, - string startsWith = null, - string endsWith = null, - bool? isEmpty = null, - bool? isNotEmpty = null) - { - Property = propertyName; - Text = new Condition( - equal: equal, - doesNotEqual: doesNotEqual, - contains: contains, - doesNotContain: doesNotContain, - startsWith: startsWith, - endsWith: endsWith, - isEmpty: isEmpty, - isNotEmpty: isNotEmpty - ); - } - - public class Condition - { - [JsonProperty("equals")] - public string Equal { get; set; } - - [JsonProperty("does_not_equal")] - public string DoesNotEqual { get; set; } - - [JsonProperty("contains")] - public string Contains { get; set; } - - [JsonProperty("does_not_contain")] - public string DoesNotContain { get; set; } - - [JsonProperty("starts_with")] - public string StartsWith { get; set; } - - [JsonProperty("ends_with")] - public string EndsWith { get; set; } - - [JsonProperty("is_empty")] - public bool? IsEmpty { get; set; } - - [JsonProperty("is_not_empty")] - public bool? IsNotEmpty { get; set; } - - public Condition( - string equal = null, - string doesNotEqual = null, - string contains = null, - string doesNotContain = null, - string startsWith = null, - string endsWith = null, - bool? isEmpty = null, - bool? isNotEmpty = null) - { - Equal = equal; - DoesNotEqual = doesNotEqual; - Contains = contains; - DoesNotContain = doesNotContain; - StartsWith = startsWith; - EndsWith = endsWith; - IsEmpty = isEmpty; - IsNotEmpty = isNotEmpty; - } - } - } -} +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class RichTextFilter : SinglePropertyFilter + { + [JsonProperty("rich_text")] + public TextFilter.Condition RichText { get; set; } + + public RichTextFilter( + string propertyName, + string equal = null, + string doesNotEqual = null, + string contains = null, + string doesNotContain = null, + string startsWith = null, + string endsWith = null, + bool? isEmpty = null, + bool? isNotEmpty = null) + { + Property = propertyName; + RichText = new TextFilter.Condition( + equal: equal, + doesNotEqual: doesNotEqual, + contains: contains, + doesNotContain: doesNotContain, + startsWith: startsWith, + endsWith: endsWith, + isEmpty: isEmpty, + isNotEmpty: isNotEmpty + ); + } + } + + public static class TextFilter + { + public class Condition + { + [JsonProperty("equals")] + public string Equal { get; set; } + + [JsonProperty("does_not_equal")] + public string DoesNotEqual { get; set; } + + [JsonProperty("contains")] + public string Contains { get; set; } + + [JsonProperty("does_not_contain")] + public string DoesNotContain { get; set; } + + [JsonProperty("starts_with")] + public string StartsWith { get; set; } + + [JsonProperty("ends_with")] + public string EndsWith { get; set; } + + [JsonProperty("is_empty")] + public bool? IsEmpty { get; set; } + + [JsonProperty("is_not_empty")] + public bool? IsNotEmpty { get; set; } + + public Condition( + string equal = null, + string doesNotEqual = null, + string contains = null, + string doesNotContain = null, + string startsWith = null, + string endsWith = null, + bool? isEmpty = null, + bool? isNotEmpty = null) + { + Equal = equal; + DoesNotEqual = doesNotEqual; + Contains = contains; + DoesNotContain = doesNotContain; + StartsWith = startsWith; + EndsWith = endsWith; + IsEmpty = isEmpty; + IsNotEmpty = isNotEmpty; + } + } + } +} diff --git a/Src/Notion.Client/Models/Filters/Select.cs b/Src/Notion.Client/Models/Filters/SelectFilter.cs similarity index 96% rename from Src/Notion.Client/Models/Filters/Select.cs rename to Src/Notion.Client/Models/Filters/SelectFilter.cs index bf246be2..a8d22cf7 100644 --- a/Src/Notion.Client/Models/Filters/Select.cs +++ b/Src/Notion.Client/Models/Filters/SelectFilter.cs @@ -1,53 +1,53 @@ -using Newtonsoft.Json; - -namespace Notion.Client -{ - public class SelectFilter : SinglePropertyFilter - { - [JsonProperty("select")] - public Condition Select { get; set; } - - public SelectFilter( - string propertyName, - string equal = null, - string doesNotEqual = null, - bool? isEmpty = null, - bool? isNotEmpty = null) - { - Property = propertyName; - Select = new Condition( - equal: equal, - doesNotEqual: doesNotEqual, - isEmpty: isEmpty, - isNotEmpty: isNotEmpty - ); - } - - public class Condition - { - [JsonProperty("equals")] - public string Equal { get; set; } - - [JsonProperty("does_not_equal")] - public string DoesNotEqual { get; set; } - - [JsonProperty("is_empty")] - public bool? IsEmpty { get; set; } - - [JsonProperty("is_not_empty")] - public bool? IsNotEmpty { get; set; } - - public Condition( - string equal = null, - string doesNotEqual = null, - bool? isEmpty = null, - bool? isNotEmpty = null) - { - Equal = equal; - DoesNotEqual = doesNotEqual; - IsEmpty = isEmpty; - IsNotEmpty = isNotEmpty; - } - } - } -} +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class SelectFilter : SinglePropertyFilter + { + [JsonProperty("select")] + public Condition Select { get; set; } + + public SelectFilter( + string propertyName, + string equal = null, + string doesNotEqual = null, + bool? isEmpty = null, + bool? isNotEmpty = null) + { + Property = propertyName; + Select = new Condition( + equal: equal, + doesNotEqual: doesNotEqual, + isEmpty: isEmpty, + isNotEmpty: isNotEmpty + ); + } + + public class Condition + { + [JsonProperty("equals")] + public string Equal { get; set; } + + [JsonProperty("does_not_equal")] + public string DoesNotEqual { get; set; } + + [JsonProperty("is_empty")] + public bool? IsEmpty { get; set; } + + [JsonProperty("is_not_empty")] + public bool? IsNotEmpty { get; set; } + + public Condition( + string equal = null, + string doesNotEqual = null, + bool? isEmpty = null, + bool? isNotEmpty = null) + { + Equal = equal; + DoesNotEqual = doesNotEqual; + IsEmpty = isEmpty; + IsNotEmpty = isNotEmpty; + } + } + } +} diff --git a/Src/Notion.Client/Models/Filters/TitleFilter.cs b/Src/Notion.Client/Models/Filters/TitleFilter.cs new file mode 100644 index 00000000..7c21bb33 --- /dev/null +++ b/Src/Notion.Client/Models/Filters/TitleFilter.cs @@ -0,0 +1,34 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class TitleFilter : SinglePropertyFilter + { + [JsonProperty("title")] + public TextFilter.Condition Title { get; set; } + + public TitleFilter( + string propertyName, + string equal = null, + string doesNotEqual = null, + string contains = null, + string doesNotContain = null, + string startsWith = null, + string endsWith = null, + bool? isEmpty = null, + bool? isNotEmpty = null) + { + Property = propertyName; + Title = new TextFilter.Condition( + equal: equal, + doesNotEqual: doesNotEqual, + contains: contains, + doesNotContain: doesNotContain, + startsWith: startsWith, + endsWith: endsWith, + isEmpty: isEmpty, + isNotEmpty: isNotEmpty + ); + } + } +} diff --git a/Src/Notion.Client/Models/Filters/URLFilter.cs b/Src/Notion.Client/Models/Filters/URLFilter.cs new file mode 100644 index 00000000..b6a1fe6b --- /dev/null +++ b/Src/Notion.Client/Models/Filters/URLFilter.cs @@ -0,0 +1,34 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class URLFilter : SinglePropertyFilter + { + [JsonProperty("url")] + public TextFilter.Condition URL { get; set; } + + public URLFilter( + string propertyName, + string equal = null, + string doesNotEqual = null, + string contains = null, + string doesNotContain = null, + string startsWith = null, + string endsWith = null, + bool? isEmpty = null, + bool? isNotEmpty = null) + { + Property = propertyName; + URL = new TextFilter.Condition( + equal: equal, + doesNotEqual: doesNotEqual, + contains: contains, + doesNotContain: doesNotContain, + startsWith: startsWith, + endsWith: endsWith, + isEmpty: isEmpty, + isNotEmpty: isNotEmpty + ); + } + } +} diff --git a/Test/Notion.UnitTests/FilterTests.cs b/Test/Notion.UnitTests/FilterTests.cs index 38a0921b..87f317eb 100644 --- a/Test/Notion.UnitTests/FilterTests.cs +++ b/Test/Notion.UnitTests/FilterTests.cs @@ -122,9 +122,9 @@ public void PeopleFilter() } [Fact] - public void TextFilterTest() + public void RichTextFilterTest() { - var filter = new TextFilter("Some property", doesNotEqual: "Example text"); + var filter = new RichTextFilter("Some property", doesNotEqual: "Example text"); Assert.Equal( "{\"text\":{\"does_not_equal\":\"Example text\"},\"property\":\"Some property\"}", SerializeFilter(filter) From f9ddfff781b4b840adac5117da728590b81b370e Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Mon, 11 Jul 2022 01:46:03 +0530 Subject: [PATCH 04/12] add rollup property filter --- .../Models/Filters/CheckboxFilter.cs | 2 +- .../Models/Filters/DateFilter.cs | 2 +- .../Models/Filters/FilesFilter.cs | 2 +- .../Models/Filters/MultiSelectFilter.cs | 2 +- .../Models/Filters/NumberFilter.cs | 2 +- .../Models/Filters/PeopleFilter.cs | 2 +- .../Models/Filters/RelationFilter.cs | 2 +- .../Models/Filters/RichTextFilter.cs | 2 +- .../Rollup/IRollupSubPropertyFilter.cs | 6 ++ .../Models/Filters/Rollup/RollupFilter.cs | 60 +++++++++++++++++++ .../Models/Filters/SelectFilter.cs | 2 +- 11 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 Src/Notion.Client/Models/Filters/Rollup/IRollupSubPropertyFilter.cs create mode 100644 Src/Notion.Client/Models/Filters/Rollup/RollupFilter.cs diff --git a/Src/Notion.Client/Models/Filters/CheckboxFilter.cs b/Src/Notion.Client/Models/Filters/CheckboxFilter.cs index f0c2b41d..da144aec 100644 --- a/Src/Notion.Client/Models/Filters/CheckboxFilter.cs +++ b/Src/Notion.Client/Models/Filters/CheckboxFilter.cs @@ -3,7 +3,7 @@ namespace Notion.Client { - public class CheckboxFilter : SinglePropertyFilter + public class CheckboxFilter : SinglePropertyFilter, IRollupSubPropertyFilter { [JsonProperty("checkbox")] public Condition Checkbox { get; set; } diff --git a/Src/Notion.Client/Models/Filters/DateFilter.cs b/Src/Notion.Client/Models/Filters/DateFilter.cs index a472ff49..51b38dc2 100644 --- a/Src/Notion.Client/Models/Filters/DateFilter.cs +++ b/Src/Notion.Client/Models/Filters/DateFilter.cs @@ -5,7 +5,7 @@ namespace Notion.Client { - public class DateFilter : SinglePropertyFilter + public class DateFilter : SinglePropertyFilter, IRollupSubPropertyFilter { [JsonProperty("date")] public Condition Date { get; set; } diff --git a/Src/Notion.Client/Models/Filters/FilesFilter.cs b/Src/Notion.Client/Models/Filters/FilesFilter.cs index a3dca061..a32d4d7b 100644 --- a/Src/Notion.Client/Models/Filters/FilesFilter.cs +++ b/Src/Notion.Client/Models/Filters/FilesFilter.cs @@ -2,7 +2,7 @@ namespace Notion.Client { - public class FilesFilter : SinglePropertyFilter + public class FilesFilter : SinglePropertyFilter, IRollupSubPropertyFilter { [JsonProperty("files")] public Condition Files { get; set; } diff --git a/Src/Notion.Client/Models/Filters/MultiSelectFilter.cs b/Src/Notion.Client/Models/Filters/MultiSelectFilter.cs index 69615b3d..14aec6d5 100644 --- a/Src/Notion.Client/Models/Filters/MultiSelectFilter.cs +++ b/Src/Notion.Client/Models/Filters/MultiSelectFilter.cs @@ -2,7 +2,7 @@ namespace Notion.Client { - public class MultiSelectFilter : SinglePropertyFilter + public class MultiSelectFilter : SinglePropertyFilter, IRollupSubPropertyFilter { [JsonProperty("multi_select")] public Condition MultiSelect { get; set; } diff --git a/Src/Notion.Client/Models/Filters/NumberFilter.cs b/Src/Notion.Client/Models/Filters/NumberFilter.cs index 58e0c38a..4895d3e8 100644 --- a/Src/Notion.Client/Models/Filters/NumberFilter.cs +++ b/Src/Notion.Client/Models/Filters/NumberFilter.cs @@ -2,7 +2,7 @@ namespace Notion.Client { - public class NumberFilter : SinglePropertyFilter + public class NumberFilter : SinglePropertyFilter, IRollupSubPropertyFilter { [JsonProperty("number")] public Condition Number { get; set; } diff --git a/Src/Notion.Client/Models/Filters/PeopleFilter.cs b/Src/Notion.Client/Models/Filters/PeopleFilter.cs index cd77c186..af1067c4 100644 --- a/Src/Notion.Client/Models/Filters/PeopleFilter.cs +++ b/Src/Notion.Client/Models/Filters/PeopleFilter.cs @@ -2,7 +2,7 @@ namespace Notion.Client { - public class PeopleFilter : SinglePropertyFilter + public class PeopleFilter : SinglePropertyFilter, IRollupSubPropertyFilter { [JsonProperty("people")] public Condition People { get; set; } diff --git a/Src/Notion.Client/Models/Filters/RelationFilter.cs b/Src/Notion.Client/Models/Filters/RelationFilter.cs index e7eef130..b7e2924d 100644 --- a/Src/Notion.Client/Models/Filters/RelationFilter.cs +++ b/Src/Notion.Client/Models/Filters/RelationFilter.cs @@ -2,7 +2,7 @@ namespace Notion.Client { - public class RelationFilter : SinglePropertyFilter + public class RelationFilter : SinglePropertyFilter, IRollupSubPropertyFilter { [JsonProperty("relation")] public Condition Relation { get; set; } diff --git a/Src/Notion.Client/Models/Filters/RichTextFilter.cs b/Src/Notion.Client/Models/Filters/RichTextFilter.cs index 84128fcb..90bae02e 100644 --- a/Src/Notion.Client/Models/Filters/RichTextFilter.cs +++ b/Src/Notion.Client/Models/Filters/RichTextFilter.cs @@ -2,7 +2,7 @@ namespace Notion.Client { - public class RichTextFilter : SinglePropertyFilter + public class RichTextFilter : SinglePropertyFilter, IRollupSubPropertyFilter { [JsonProperty("rich_text")] public TextFilter.Condition RichText { get; set; } diff --git a/Src/Notion.Client/Models/Filters/Rollup/IRollupSubPropertyFilter.cs b/Src/Notion.Client/Models/Filters/Rollup/IRollupSubPropertyFilter.cs new file mode 100644 index 00000000..b9c850c5 --- /dev/null +++ b/Src/Notion.Client/Models/Filters/Rollup/IRollupSubPropertyFilter.cs @@ -0,0 +1,6 @@ +namespace Notion.Client +{ + public interface IRollupSubPropertyFilter + { + } +} diff --git a/Src/Notion.Client/Models/Filters/Rollup/RollupFilter.cs b/Src/Notion.Client/Models/Filters/Rollup/RollupFilter.cs new file mode 100644 index 00000000..41cb759e --- /dev/null +++ b/Src/Notion.Client/Models/Filters/Rollup/RollupFilter.cs @@ -0,0 +1,60 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class RollupFilter : SinglePropertyFilter + { + [JsonProperty("rollup")] + public Condition Rollup { get; set; } + + public RollupFilter( + string propertyName + , IRollupSubPropertyFilter any = null + , IRollupSubPropertyFilter none = null + , IRollupSubPropertyFilter every = null + , DateFilter.Condition date = null + , NumberFilter.Condition number = null) + { + Property = propertyName; + Rollup = new Condition( + any, + none, + every, + date, + number + ); + } + + public class Condition + { + public Condition( + IRollupSubPropertyFilter any = null + , IRollupSubPropertyFilter none = null + , IRollupSubPropertyFilter every = null + , DateFilter.Condition date = null + , NumberFilter.Condition number = null) + { + Any = any; + None = none; + Every = every; + Date = date; + Number = number; + } + + [JsonProperty("any")] + public IRollupSubPropertyFilter Any { get; set; } + + [JsonProperty("none")] + public IRollupSubPropertyFilter None { get; set; } + + [JsonProperty("every")] + public IRollupSubPropertyFilter Every { get; set; } + + [JsonProperty("date")] + public DateFilter.Condition Date { get; set; } + + [JsonProperty("number")] + public NumberFilter.Condition Number { get; set; } + } + } +} diff --git a/Src/Notion.Client/Models/Filters/SelectFilter.cs b/Src/Notion.Client/Models/Filters/SelectFilter.cs index a8d22cf7..6f0887a4 100644 --- a/Src/Notion.Client/Models/Filters/SelectFilter.cs +++ b/Src/Notion.Client/Models/Filters/SelectFilter.cs @@ -2,7 +2,7 @@ namespace Notion.Client { - public class SelectFilter : SinglePropertyFilter + public class SelectFilter : SinglePropertyFilter, IRollupSubPropertyFilter { [JsonProperty("select")] public Condition Select { get; set; } From 4ecab195bd7c3e458edbe4745e85ca1dc1904598 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Mon, 11 Jul 2022 02:08:50 +0530 Subject: [PATCH 05/12] =?UTF-8?q?fix=20breaking=20test=20cases=20=E2=9C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Test/Notion.UnitTests/FilterTests.cs | 2 +- .../data/blocks/AppendBlockChildrenResponse.json | 4 ++-- .../data/blocks/RetrieveBlockChildrenResponse.json | 10 +++++----- .../data/blocks/RetrieveBlockResponse.json | 2 +- .../data/blocks/UpdateBlockResponse.json | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Test/Notion.UnitTests/FilterTests.cs b/Test/Notion.UnitTests/FilterTests.cs index 87f317eb..5b4650a5 100644 --- a/Test/Notion.UnitTests/FilterTests.cs +++ b/Test/Notion.UnitTests/FilterTests.cs @@ -126,7 +126,7 @@ public void RichTextFilterTest() { var filter = new RichTextFilter("Some property", doesNotEqual: "Example text"); Assert.Equal( - "{\"text\":{\"does_not_equal\":\"Example text\"},\"property\":\"Some property\"}", + "{\"rich_text\":{\"does_not_equal\":\"Example text\"},\"property\":\"Some property\"}", SerializeFilter(filter) ); } diff --git a/Test/Notion.UnitTests/data/blocks/AppendBlockChildrenResponse.json b/Test/Notion.UnitTests/data/blocks/AppendBlockChildrenResponse.json index 7cba0666..32612405 100644 --- a/Test/Notion.UnitTests/data/blocks/AppendBlockChildrenResponse.json +++ b/Test/Notion.UnitTests/data/blocks/AppendBlockChildrenResponse.json @@ -9,7 +9,7 @@ "has_children": false, "type": "heading_2", "heading_2": { - "text": [ + "rich_text": [ { "type": "text", "text": { @@ -38,7 +38,7 @@ "has_children": false, "type": "paragraph", "paragraph": { - "text": [ + "rich_text": [ { "type": "text", "text": { diff --git a/Test/Notion.UnitTests/data/blocks/RetrieveBlockChildrenResponse.json b/Test/Notion.UnitTests/data/blocks/RetrieveBlockChildrenResponse.json index fe30ff6b..649185e7 100644 --- a/Test/Notion.UnitTests/data/blocks/RetrieveBlockChildrenResponse.json +++ b/Test/Notion.UnitTests/data/blocks/RetrieveBlockChildrenResponse.json @@ -10,7 +10,7 @@ "archived": false, "type": "paragraph", "paragraph": { - "text": [] + "rich_text": [] } }, { @@ -22,7 +22,7 @@ "archived": false, "type": "heading_2", "heading_2": { - "text": [ + "rich_text": [ { "type": "text", "text": { @@ -52,7 +52,7 @@ "archived": false, "type": "heading_2", "heading_2": { - "text": [ + "rich_text": [ { "type": "text", "text": { @@ -82,7 +82,7 @@ "archived": false, "type": "paragraph", "paragraph": { - "text": [] + "rich_text": [] } }, { @@ -118,7 +118,7 @@ "archived": false, "type": "paragraph", "paragraph": { - "text": [] + "rich_text": [] } }, { diff --git a/Test/Notion.UnitTests/data/blocks/RetrieveBlockResponse.json b/Test/Notion.UnitTests/data/blocks/RetrieveBlockResponse.json index 201a2a96..9c7deabe 100644 --- a/Test/Notion.UnitTests/data/blocks/RetrieveBlockResponse.json +++ b/Test/Notion.UnitTests/data/blocks/RetrieveBlockResponse.json @@ -6,7 +6,7 @@ "has_children": false, "type": "to_do", "to_do": { - "text": [ + "rich_text": [ { "type": "text", "text": { diff --git a/Test/Notion.UnitTests/data/blocks/UpdateBlockResponse.json b/Test/Notion.UnitTests/data/blocks/UpdateBlockResponse.json index c9fb6a9a..497aba34 100644 --- a/Test/Notion.UnitTests/data/blocks/UpdateBlockResponse.json +++ b/Test/Notion.UnitTests/data/blocks/UpdateBlockResponse.json @@ -6,7 +6,7 @@ "has_children": false, "type": "to_do", "to_do": { - "text": [ + "rich_text": [ { "type": "text", "text": { From 6d8a3452942dd65f47393cecbf231c762ce13a9e Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Mon, 11 Jul 2022 02:23:40 +0530 Subject: [PATCH 06/12] Rename Text prop to String in formula property filter --- Src/Notion.Client/Models/Filters/FormulaFilter.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Src/Notion.Client/Models/Filters/FormulaFilter.cs b/Src/Notion.Client/Models/Filters/FormulaFilter.cs index 9e6fdc19..eee9fc52 100644 --- a/Src/Notion.Client/Models/Filters/FormulaFilter.cs +++ b/Src/Notion.Client/Models/Filters/FormulaFilter.cs @@ -9,14 +9,14 @@ public class FormulaFilter : SinglePropertyFilter public FormulaFilter( string propertyName, - TextFilter.Condition text = null, + TextFilter.Condition @string = null, CheckboxFilter.Condition checkbox = null, NumberFilter.Condition number = null, DateFilter.Condition date = null) { Property = propertyName; Formula = new Condition( - text: text, + @string: @string, checkbox: checkbox, number: number, date: date @@ -25,8 +25,8 @@ public FormulaFilter( public class Condition { - [JsonProperty("text")] - public TextFilter.Condition Text { get; set; } + [JsonProperty("string")] + public TextFilter.Condition String { get; set; } [JsonProperty("checkbox")] public CheckboxFilter.Condition Checkbox { get; set; } @@ -38,12 +38,12 @@ public class Condition public DateFilter.Condition Date { get; set; } public Condition( - TextFilter.Condition text = null, + TextFilter.Condition @string = null, CheckboxFilter.Condition checkbox = null, NumberFilter.Condition number = null, DateFilter.Condition date = null) { - Text = text; + String = @string; Checkbox = checkbox; Number = number; Date = date; From 3c252dd1c22dfaede06fad4940a202dce45d271d Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Mon, 11 Jul 2022 04:05:00 +0530 Subject: [PATCH 07/12] Add support for id, next_url & property_item prop * cleanup unused item --- .../Models/PropertyItems/IPropertyItemObject.cs | 9 +++++++++ .../Models/PropertyItems/ListPropertyItem.cs | 11 ++++++++--- .../Models/PropertyItems/RollupPropertyItem.cs | 12 ------------ .../Models/PropertyItems/SimplePropertyItem.cs | 4 ++++ 4 files changed, 21 insertions(+), 15 deletions(-) delete mode 100644 Src/Notion.Client/Models/PropertyItems/RollupPropertyItem.cs diff --git a/Src/Notion.Client/Models/PropertyItems/IPropertyItemObject.cs b/Src/Notion.Client/Models/PropertyItems/IPropertyItemObject.cs index e6eb91c2..5ebc7730 100644 --- a/Src/Notion.Client/Models/PropertyItems/IPropertyItemObject.cs +++ b/Src/Notion.Client/Models/PropertyItems/IPropertyItemObject.cs @@ -13,5 +13,14 @@ public interface IPropertyItemObject [JsonProperty("type")] string Type { get; } + + [JsonProperty("id")] + string Id { get; } + + /// + /// Only present in paginated property values with another page of results. If present, the url the user can request to get the next page of results. + /// + [JsonProperty("next_url")] + string NextURL { get; } } } diff --git a/Src/Notion.Client/Models/PropertyItems/ListPropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/ListPropertyItem.cs index 3ca83d81..f539fcd6 100644 --- a/Src/Notion.Client/Models/PropertyItems/ListPropertyItem.cs +++ b/Src/Notion.Client/Models/PropertyItems/ListPropertyItem.cs @@ -4,14 +4,16 @@ namespace Notion.Client { - [JsonConverter(typeof(JsonSubtypes), "type")] - [JsonSubtypes.KnownSubType(typeof(RollupPropertyItem), "rollup")] - [JsonSubtypes.FallBackSubType(typeof(ListPropertyItem))] public class ListPropertyItem : IPropertyItemObject { public string Object => "list"; + public virtual string Type { get; set; } + public string Id { get; set; } + + public string NextURL { get; set; } + [JsonProperty("results")] public IEnumerable Results { get; set; } @@ -20,5 +22,8 @@ public class ListPropertyItem : IPropertyItemObject [JsonProperty("next_cursor")] public string NextCursor { get; set; } + + [JsonProperty("property_item")] + public SimplePropertyItem PropertyItem { get; set; } } } diff --git a/Src/Notion.Client/Models/PropertyItems/RollupPropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/RollupPropertyItem.cs deleted file mode 100644 index 6e6e53cd..00000000 --- a/Src/Notion.Client/Models/PropertyItems/RollupPropertyItem.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Newtonsoft.Json; - -namespace Notion.Client -{ - public class RollupPropertyItem : ListPropertyItem - { - public override string Type => "rollup"; - - [JsonProperty("rollup")] - public RollupValue Rollup { get; set; } - } -} diff --git a/Src/Notion.Client/Models/PropertyItems/SimplePropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/SimplePropertyItem.cs index 6cc1f52b..da753319 100644 --- a/Src/Notion.Client/Models/PropertyItems/SimplePropertyItem.cs +++ b/Src/Notion.Client/Models/PropertyItems/SimplePropertyItem.cs @@ -27,5 +27,9 @@ public abstract class SimplePropertyItem : IPropertyItemObject public string Object => "property_item"; public abstract string Type { get; } + + public string Id { get; set; } + + public string NextURL { get; set; } } } From f83606e3c7c26bae1e97698145e460cd4b9356f6 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Wed, 13 Jul 2022 16:12:57 +0530 Subject: [PATCH 08/12] Removed list database endpoint --- .../Api/Databases/DatabasesClient.cs | 18 +----------- .../Api/Databases/IDatabasesClient.cs | 11 +------- Test/Notion.UnitTests/DatabasesClientTests.cs | 28 ------------------- 3 files changed, 2 insertions(+), 55 deletions(-) diff --git a/Src/Notion.Client/Api/Databases/DatabasesClient.cs b/Src/Notion.Client/Api/Databases/DatabasesClient.cs index ee546aef..2ab17a8b 100644 --- a/Src/Notion.Client/Api/Databases/DatabasesClient.cs +++ b/Src/Notion.Client/Api/Databases/DatabasesClient.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; +using System.Threading.Tasks; using static Notion.Client.ApiEndpoints; namespace Notion.Client @@ -19,20 +17,6 @@ public async Task RetrieveAsync(string databaseId) return await _client.GetAsync(DatabasesApiUrls.Retrieve(databaseId)); } - [Obsolete("This endpoint is no longer recommended, use Search instead. This endpoint will only return explicitly shared pages, while search will also return child pages within explicitly shared pages. This endpoint's results cannot be filtered, while search can be used to match on page title.", false)] - public async Task> ListAsync(DatabasesListParameters databasesListParameters = null) - { - var databasesListQueryParmaters = (IDatabasesListQueryParmaters)databasesListParameters; - - var queryParams = new Dictionary() - { - { "start_cursor", databasesListQueryParmaters?.StartCursor }, - { "page_size", databasesListQueryParmaters?.PageSize?.ToString() } - }; - - return await _client.GetAsync>(DatabasesApiUrls.List(), queryParams); - } - public async Task> QueryAsync(string databaseId, DatabasesQueryParameters databasesQueryParameters) { var body = (IDatabaseQueryBodyParameters)databasesQueryParameters; diff --git a/Src/Notion.Client/Api/Databases/IDatabasesClient.cs b/Src/Notion.Client/Api/Databases/IDatabasesClient.cs index c339e4da..2b2c2746 100644 --- a/Src/Notion.Client/Api/Databases/IDatabasesClient.cs +++ b/Src/Notion.Client/Api/Databases/IDatabasesClient.cs @@ -1,5 +1,4 @@ -using System; -using System.Threading.Tasks; +using System.Threading.Tasks; namespace Notion.Client { @@ -8,14 +7,6 @@ public interface IDatabasesClient Task RetrieveAsync(string databaseId); Task> QueryAsync(string databaseId, DatabasesQueryParameters databasesQueryParameters); - /// - /// List all Databases shared with the authenticated integration. - /// - /// database list request parameters. - /// PaginatedList of databases. - [Obsolete("This endpoint is no longer recommended, use Search instead. This endpoint will only return explicitly shared pages, while search will also return child pages within explicitly shared pages. This endpoint's results cannot be filtered, while search can be used to match on page title.", false)] - Task> ListAsync(DatabasesListParameters databasesListParameters = null); - /// /// Creates a database as a subpage in the specified parent page, with the specified properties schema. /// diff --git a/Test/Notion.UnitTests/DatabasesClientTests.cs b/Test/Notion.UnitTests/DatabasesClientTests.cs index 8462b42d..b87fdd5e 100644 --- a/Test/Notion.UnitTests/DatabasesClientTests.cs +++ b/Test/Notion.UnitTests/DatabasesClientTests.cs @@ -18,34 +18,6 @@ public DatabasesClientTests() _client = new DatabasesClient(new RestClient(ClientOptions)); } - [Fact] - [Obsolete] - public async Task ListDatabasesAsync() - { - var path = ApiEndpoints.DatabasesApiUrls.List(); - var jsonData = await File.ReadAllTextAsync("data/databases/DatabasesListResponse.json"); - - Server.Given(CreateGetRequestBuilder(path)) - .RespondWith( - Response.Create() - .WithStatusCode(200) - .WithBody(jsonData) - ); - - var databases = await _client.ListAsync(); - - databases.Results.Should().HaveCount(3); - - foreach (var database in databases.Results) - { - database.Parent.Should().BeAssignableTo(); - foreach (var property in database.Properties) - { - property.Key.Should().Be(property.Value.Name); - } - } - } - [Fact] public async Task QueryAsync() { From 1172c4f8870b87f6fad5ff8e32f424f740457fb9 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Wed, 13 Jul 2022 16:16:30 +0530 Subject: [PATCH 09/12] =?UTF-8?q?updated=20document=20=F0=9F=93=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 - docs/README.md | 1 - 2 files changed, 2 deletions(-) diff --git a/README.md b/README.md index 29cc826b..7e552e88 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,6 @@ var complexFiler = new CompoundFilter( - [x] Create a database - [x] Update database - [x] Retrieve a database - - [x] List databases (Deprecated: use Search API instead) - [x] Pages - [x] Retrieve a page - [x] Create a page diff --git a/docs/README.md b/docs/README.md index 5ece487d..14a21997 100644 --- a/docs/README.md +++ b/docs/README.md @@ -80,7 +80,6 @@ var complexFiler = new CompoundFilter( - [x] Create a database - [x] Update database - [x] Retrieve a database - - [x] List databases (Deprecated: use Search API instead) - [x] Pages - [x] Retrieve a page - [x] Create a page From 59f6d11859d7d5b306a67845863ee2b18395ca45 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 16 Jul 2022 21:39:55 +0530 Subject: [PATCH 10/12] Set default Notion-Version to 2022-02-22 --- Src/Notion.Client/Constants.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/Notion.Client/Constants.cs b/Src/Notion.Client/Constants.cs index 5844bd6e..579e3db4 100644 --- a/Src/Notion.Client/Constants.cs +++ b/Src/Notion.Client/Constants.cs @@ -6,6 +6,6 @@ namespace Notion.Client internal class Constants { internal static string BASE_URL = "https://api.notion.com/"; - internal static string DEFAULT_NOTION_VERSION = "2021-08-16"; + internal static string DEFAULT_NOTION_VERSION = "2022-02-22"; } } From 85a8a6fa2f388431793e5d5088fd7a1a0f241b00 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 16 Jul 2022 21:41:22 +0530 Subject: [PATCH 11/12] =?UTF-8?q?Update=20readme=20to=20show=20default=20n?= =?UTF-8?q?otion-version=20by=20NuGet=20package=20version=20=F0=9F=93=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 ++++++--- docs/README.md | 7 ++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7e552e88..c3cf6c95 100644 --- a/README.md +++ b/README.md @@ -41,9 +41,12 @@ Provides the following packages: dotnet add package Notion.Net ``` -> Note: From Nuget 2.0.0 notion client sdk default sets the Notion-Version header to 2021-08-16. - - +> Note: default Notion-Version used by NuGet package versions +> | Package version | Notion-Version | +> | --- | --- | +> | 3.0.0+ | 2022-02-22 | +> | 2.0.0+ | 2021-08-16 | +> | 1.0.0+ | 2021-05-13 | ## Usage diff --git a/docs/README.md b/docs/README.md index 14a21997..a662d6f3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -10,7 +10,12 @@ A simple and easy to use client for the [Notion API](https://developers.notion.c dotnet add package Notion.Net ``` -> Note: From Nuget 2.0.0 notion client sdk default sets the Notion-Version header to 2021-08-16. +> Note: default Notion-Version used by NuGet package versions +> | Package version | Notion-Version | +> | --- | --- | +> | 3.0.0+ | 2022-02-22 | +> | 2.0.0+ | 2021-08-16 | +> | 1.0.0+ | 2021-05-13 | ## Usage From 01b5ed55869017ffc9c3c0faf354087a910ceb6a Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 16 Jul 2022 22:52:47 +0530 Subject: [PATCH 12/12] set version prefix to 3.0.0 --- Src/Notion.Client/Notion.Client.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/Notion.Client/Notion.Client.csproj b/Src/Notion.Client/Notion.Client.csproj index c1b237d1..541e191b 100644 --- a/Src/Notion.Client/Notion.Client.csproj +++ b/Src/Notion.Client/Notion.Client.csproj @@ -1,7 +1,7 @@  - 2.2.3-preview + 3.0.0-preview netstandard2.0 7.3