From abe9927f7005c4a55a72dd78235753983eab626a Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Fri, 17 Sep 2021 22:55:28 +0530 Subject: [PATCH 01/32] =?UTF-8?q?Change=20default=20notion=20version=20to?= =?UTF-8?q?=202021-08-16=20=F0=9F=92=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 b2a413b4..5844bd6e 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-05-13"; + internal static string DEFAULT_NOTION_VERSION = "2021-08-16"; } } From 6bb013da540f4b25a1732f9a084e47288fa22dff Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Fri, 17 Sep 2021 22:58:32 +0530 Subject: [PATCH 02/32] =?UTF-8?q?Append=20Block=20Children=20returns=20a?= =?UTF-8?q?=20list=20of=20blocks=20=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Notion.Client/Api/Blocks/BlocksClient.cs | 4 +- Src/Notion.Client/Api/Blocks/IBlocksClient.cs | 9 +- Test/Notion.UnitTests/BlocksClientTests.cs | 29 ++-- .../blocks/AppendBlockChildrenResponse.json | 128 +++++++++++------- 4 files changed, 113 insertions(+), 57 deletions(-) diff --git a/Src/Notion.Client/Api/Blocks/BlocksClient.cs b/Src/Notion.Client/Api/Blocks/BlocksClient.cs index 79f7da4d..19d07474 100644 --- a/Src/Notion.Client/Api/Blocks/BlocksClient.cs +++ b/Src/Notion.Client/Api/Blocks/BlocksClient.cs @@ -34,7 +34,7 @@ public async Task> RetrieveChildrenAsync(string blockId, Bl return await _client.GetAsync>(url, queryParams); } - public async Task AppendChildrenAsync(string blockId, BlocksAppendChildrenParameters parameters = null) + public async Task> AppendChildrenAsync(string blockId, BlocksAppendChildrenParameters parameters = null) { if (string.IsNullOrWhiteSpace(blockId)) { @@ -45,7 +45,7 @@ public async Task AppendChildrenAsync(string blockId, BlocksAppendChildre var body = (IBlocksAppendChildrenBodyParameters)parameters; - return await _client.PatchAsync(url, body); + return await _client.PatchAsync>(url, body); } public async Task RetrieveAsync(string blockId) diff --git a/Src/Notion.Client/Api/Blocks/IBlocksClient.cs b/Src/Notion.Client/Api/Blocks/IBlocksClient.cs index 9d555c0c..917f8f95 100644 --- a/Src/Notion.Client/Api/Blocks/IBlocksClient.cs +++ b/Src/Notion.Client/Api/Blocks/IBlocksClient.cs @@ -20,6 +20,13 @@ public interface IBlocksClient Task UpdateAsync(string blockId, IUpdateBlock updateBlock); Task> RetrieveChildrenAsync(string blockId, BlocksRetrieveChildrenParameters parameters = null); - Task AppendChildrenAsync(string blockId, BlocksAppendChildrenParameters parameters = null); + + /// + /// Creates and appends new children blocks to the parent block_id specified. + /// + /// Identifier for a block + /// + /// A paginated list of newly created first level children block objects. + Task> AppendChildrenAsync(string blockId, BlocksAppendChildrenParameters parameters = null); } } diff --git a/Test/Notion.UnitTests/BlocksClientTests.cs b/Test/Notion.UnitTests/BlocksClientTests.cs index 5fd7dac6..cb1b0f99 100644 --- a/Test/Notion.UnitTests/BlocksClientTests.cs +++ b/Test/Notion.UnitTests/BlocksClientTests.cs @@ -101,14 +101,27 @@ public async Task AppendBlockChildren() }; // Act - var block = await _client.AppendChildrenAsync(blockId, parameters); - - // Assert - block.Type.Should().Be(BlockType.Paragraph); - var paragraphBlock = (ParagraphBlock)block; - var text = paragraphBlock.Paragraph.Text.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"); + var blocksResult = await _client.AppendChildrenAsync(blockId, parameters); + + // Assert + var blocks = blocksResult.Results; + blocks.Should().SatisfyRespectively( + block => + { + block.Type.Should().Be(BlockType.Heading_2); + var headingBlock = (HeadingTwoBlock)block; + var text = headingBlock.Heading_2.Text.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(); + 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"); + } + ); } [Fact] diff --git a/Test/Notion.UnitTests/data/blocks/AppendBlockChildrenResponse.json b/Test/Notion.UnitTests/data/blocks/AppendBlockChildrenResponse.json index af682930..7cba0666 100644 --- a/Test/Notion.UnitTests/data/blocks/AppendBlockChildrenResponse.json +++ b/Test/Notion.UnitTests/data/blocks/AppendBlockChildrenResponse.json @@ -1,50 +1,86 @@ { - "object": "block", - "id": "7face6fd-3ef4-4b38-b1dc-c5044988eec0", - "created_time": "2021-03-16T16:34:00.000Z", - "last_edited_time": "2021-03-16T16:36:00.000Z", - "has_children": false, - "type": "paragraph", - "paragraph": { - "text": [ - { - "type": "text", - "text": { - "content": "Lacinato kale", - "link": { - "url": "https://en.wikipedia.org/wiki/Lacinato_kale" + "object": "list", + "results": [ + { + "object": "block", + "id": "9bc30ad4-9373-46a5-84ab-0a7845ee52e6", + "created_time": "2021-03-16T16:31:00.000Z", + "last_edited_time": "2021-03-16T16:32:00.000Z", + "has_children": false, + "type": "heading_2", + "heading_2": { + "text": [ + { + "type": "text", + "text": { + "content": "Lacinato kale", + "link": null + }, + "annotations": { + "bold": false, + "italic": false, + "strikethrough": false, + "underline": false, + "code": false, + "color": "default" + }, + "plain_text": "Lacinato kale", + "href": null } - }, - "annotations": { - "bold": false, - "italic": false, - "strikethrough": false, - "underline": false, - "code": false, - "color": "default" - }, - "plain_text": "Lacinato kale", - "href": "https://en.wikipedia.org/wiki/Lacinato_kale" - }, - { - "type": "text", - "text": { - "content": "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.", - "link": { - "url": "https://en.wikipedia.org/wiki/Lacinato_kale" + ] + } + }, + { + "object": "block", + "id": "7face6fd-3ef4-4b38-b1dc-c5044988eec0", + "created_time": "2021-03-16T16:34:00.000Z", + "last_edited_time": "2021-03-16T16:36:00.000Z", + "has_children": false, + "type": "paragraph", + "paragraph": { + "text": [ + { + "type": "text", + "text": { + "content": "Lacinato kale", + "link": { + "url": "https://en.wikipedia.org/wiki/Lacinato_kale" + } + }, + "annotations": { + "bold": false, + "italic": false, + "strikethrough": false, + "underline": false, + "code": false, + "color": "default" + }, + "plain_text": "Lacinato kale", + "href": "https://en.wikipedia.org/wiki/Lacinato_kale" + }, + { + "type": "text", + "text": { + "content": "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.", + "link": { + "url": "https://en.wikipedia.org/wiki/Lacinato_kale" + } + }, + "annotations": { + "bold": false, + "italic": false, + "strikethrough": false, + "underline": false, + "code": false, + "color": "default" + }, + "plain_text": "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.", + "href": "https://en.wikipedia.org/wiki/Lacinato_kale" } - }, - "annotations": { - "bold": false, - "italic": false, - "strikethrough": false, - "underline": false, - "code": false, - "color": "default" - }, - "plain_text": "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.", - "href": "https://en.wikipedia.org/wiki/Lacinato_kale" + ] } - ] - } -} + } + ], + "next_cursor": null, + "has_more": false +} \ No newline at end of file From ae08ad87d924b23967635c29ba481abb63a2aed0 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Wed, 29 Sep 2021 02:25:41 +0530 Subject: [PATCH 03/32] =?UTF-8?q?Add=20Relation=20property=20when=20creati?= =?UTF-8?q?ng=20database=20=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PropertySchema/RelationPropertySchema.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RelationPropertySchema.cs diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RelationPropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RelationPropertySchema.cs new file mode 100644 index 00000000..2d74b08c --- /dev/null +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RelationPropertySchema.cs @@ -0,0 +1,11 @@ +using System; +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class RelationPropertySchema : IPropertySchema + { + [JsonProperty("database_id")] + public Guid DatabaseId { get; set; } + } +} From f369abdb1633659340ce033b00ee72e41743f96b Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Wed, 29 Sep 2021 02:25:53 +0530 Subject: [PATCH 04/32] =?UTF-8?q?Add=20Relation=20property=20when=20updati?= =?UTF-8?q?ng=20database=20=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RelationUpdatePropertySchema.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RelationUpdatePropertySchema.cs diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RelationUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RelationUpdatePropertySchema.cs new file mode 100644 index 00000000..32895cc3 --- /dev/null +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RelationUpdatePropertySchema.cs @@ -0,0 +1,23 @@ +using System; +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class RelationUpdatePropertySchema : IUpdatePropertySchema + { + [JsonProperty("relation")] + public RelationInfo Relation { get; set; } + + public class RelationInfo + { + [JsonProperty("database_id")] + public Guid DatabaseId { get; set; } + + [JsonProperty("synced_property_id")] + public string SynchedPropertyId { get; set; } + + [JsonProperty("synced_property_name")] + public string SynchedPropertyName { get; set; } + } + } +} From 8ec5b911932b64ee4cdfae6d2b051bbd5c258e51 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Wed, 29 Sep 2021 02:27:19 +0530 Subject: [PATCH 05/32] =?UTF-8?q?Add=20rollup=20property=20when=20creating?= =?UTF-8?q?=20database=20=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RollupConfigPropertySchema.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RollupConfigPropertySchema.cs diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RollupConfigPropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RollupConfigPropertySchema.cs new file mode 100644 index 00000000..0a4227b3 --- /dev/null +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RollupConfigPropertySchema.cs @@ -0,0 +1,24 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Notion.Client +{ + public class RollupConfigPropertySchema : IPropertySchema + { + [JsonProperty("relation_property_name")] + public string RelationPropertyName { get; set; } + + [JsonProperty("relation_property_id")] + public string RelationPropertyId { get; set; } + + [JsonProperty("rollup_property_name")] + public string RollupPropertyName { get; set; } + + [JsonProperty("rollup_property_id")] + public string RollupPropertyId { get; set; } + + [JsonProperty("function")] + [JsonConverter(typeof(StringEnumConverter))] + public Function Function { get; set; } + } +} From 32119c6f5611810908d946eaf9fb6cd696a46bdb Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Fri, 1 Oct 2021 21:08:42 +0530 Subject: [PATCH 06/32] Fix relation property schema --- .../PropertySchema/RelationPropertySchema.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RelationPropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RelationPropertySchema.cs index 2d74b08c..bee17690 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RelationPropertySchema.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RelationPropertySchema.cs @@ -1,11 +1,23 @@ -using System; +using System; using Newtonsoft.Json; namespace Notion.Client { public class RelationPropertySchema : IPropertySchema { - [JsonProperty("database_id")] - public Guid DatabaseId { get; set; } + [JsonProperty("relation")] + public RelationInfo Relation { get; set; } + + public class RelationInfo + { + [JsonProperty("database_id")] + public Guid DatabaseId { get; set; } + + [JsonProperty("synced_property_id")] + public string SynchedPropertyId { get; set; } + + [JsonProperty("synced_property_name")] + public string SynchedPropertyName { get; set; } + } } } From e6589755b09d29f9c92fa92d7c6aeca56279259f Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Fri, 1 Oct 2021 22:04:39 +0530 Subject: [PATCH 07/32] Add rollup property when updating database --- .../RollupConfigUpdatePropertySchema.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RollupConfigUpdatePropertySchema.cs diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RollupConfigUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RollupConfigUpdatePropertySchema.cs new file mode 100644 index 00000000..8d3395f6 --- /dev/null +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RollupConfigUpdatePropertySchema.cs @@ -0,0 +1,24 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Notion.Client +{ + public class RollupConfigUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema + { + [JsonProperty("relation_property_name")] + public string RelationPropertyName { get; set; } + + [JsonProperty("relation_property_id")] + public string RelationPropertyId { get; set; } + + [JsonProperty("rollup_property_name")] + public string RollupPropertyName { get; set; } + + [JsonProperty("rollup_property_id")] + public string RollupPropertyId { get; set; } + + [JsonProperty("function")] + [JsonConverter(typeof(StringEnumConverter))] + public Function Function { get; set; } + } +} From 5678e97323b92d6bb513a624107fd899cc20f91b Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Fri, 1 Oct 2021 22:06:42 +0530 Subject: [PATCH 08/32] Inherit UpdatePropertySchema abstract class --- .../PropertySchema/RelationUpdatePropertySchema.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RelationUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RelationUpdatePropertySchema.cs index 32895cc3..a101b8a2 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RelationUpdatePropertySchema.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RelationUpdatePropertySchema.cs @@ -3,7 +3,7 @@ namespace Notion.Client { - public class RelationUpdatePropertySchema : IUpdatePropertySchema + public class RelationUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema { [JsonProperty("relation")] public RelationInfo Relation { get; set; } From 79a70ac3cbfa5d8394027a6ac75bc9e6bf1347c7 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Fri, 1 Oct 2021 22:33:42 +0530 Subject: [PATCH 09/32] =?UTF-8?q?Update=20rest=20client=20to=20send=20dele?= =?UTF-8?q?te=20request=20=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Notion.Client/RestClient/IRestClient.cs | 7 +++++++ Src/Notion.Client/RestClient/RestClient.cs | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/Src/Notion.Client/RestClient/IRestClient.cs b/Src/Notion.Client/RestClient/IRestClient.cs index 9aa41173..792840b6 100644 --- a/Src/Notion.Client/RestClient/IRestClient.cs +++ b/Src/Notion.Client/RestClient/IRestClient.cs @@ -29,5 +29,12 @@ Task PatchAsync( IDictionary headers = null, JsonSerializerSettings serializerSettings = null, CancellationToken cancellationToken = default); + + Task DeleteAsync( + string uri, + IDictionary queryParams = null, + IDictionary headers = null, + JsonSerializerSettings serializerSettings = null, + CancellationToken cancellationToken = default); } } diff --git a/Src/Notion.Client/RestClient/RestClient.cs b/Src/Notion.Client/RestClient/RestClient.cs index 91428218..abc4491c 100644 --- a/Src/Notion.Client/RestClient/RestClient.cs +++ b/Src/Notion.Client/RestClient/RestClient.cs @@ -144,6 +144,11 @@ void AttachContent(HttpRequestMessage httpRequest) return await response.ParseStreamAsync(serializerSettings); } + public async Task DeleteAsync(string uri, IDictionary queryParams = null, IDictionary headers = null, JsonSerializerSettings serializerSettings = null, CancellationToken cancellationToken = default) + { + await SendAsync(uri, HttpMethod.Delete, queryParams, headers, null, cancellationToken); + } + private HttpClient EnsureHttpClient() { if (_httpClient == null) From 55d842a9dd089a838407aa41a3f0b288c12f7a9e Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Fri, 1 Oct 2021 22:34:26 +0530 Subject: [PATCH 10/32] =?UTF-8?q?Add=20support=20to=20delete=20block=20api?= =?UTF-8?q?=20=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Notion.Client/Api/ApiEndpoints.cs | 8 ++++++++ Src/Notion.Client/Api/Blocks/BlocksClient.cs | 12 ++++++++++++ Src/Notion.Client/Api/Blocks/IBlocksClient.cs | 6 ++++++ 3 files changed, 26 insertions(+) diff --git a/Src/Notion.Client/Api/ApiEndpoints.cs b/Src/Notion.Client/Api/ApiEndpoints.cs index e2fa13cf..8e68e22b 100644 --- a/Src/Notion.Client/Api/ApiEndpoints.cs +++ b/Src/Notion.Client/Api/ApiEndpoints.cs @@ -21,6 +21,14 @@ public static class BlocksApiUrls { public static string Retrieve(string blockId) => $"/v1/blocks/{blockId}"; public static string Update(string blockId) => $"/v1/blocks/{blockId}"; + + /// + /// Get the for deleting a block. + /// + /// Identifier for a Notion block + /// Returns a for deleting a block. + public static string Delete(string blockId) => $"/v1/blocks/{blockId}"; + public static string RetrieveChildren(string blockId) => $"/v1/blocks/{blockId}/children"; public static string AppendChildren(string blockId) => $"/v1/blocks/{blockId}/children"; } diff --git a/Src/Notion.Client/Api/Blocks/BlocksClient.cs b/Src/Notion.Client/Api/Blocks/BlocksClient.cs index 19d07474..4c038cc5 100644 --- a/Src/Notion.Client/Api/Blocks/BlocksClient.cs +++ b/Src/Notion.Client/Api/Blocks/BlocksClient.cs @@ -71,5 +71,17 @@ public async Task UpdateAsync(string blockId, IUpdateBlock updateBlock) return await _client.PatchAsync(url, updateBlock); } + + public async Task DeleteAsync(string blockId) + { + if (string.IsNullOrWhiteSpace(blockId)) + { + throw new ArgumentNullException(nameof(blockId)); + } + + var url = BlocksApiUrls.Delete(blockId); + + await _client.DeleteAsync(url); + } } } diff --git a/Src/Notion.Client/Api/Blocks/IBlocksClient.cs b/Src/Notion.Client/Api/Blocks/IBlocksClient.cs index 917f8f95..4c088803 100644 --- a/Src/Notion.Client/Api/Blocks/IBlocksClient.cs +++ b/Src/Notion.Client/Api/Blocks/IBlocksClient.cs @@ -28,5 +28,11 @@ public interface IBlocksClient /// /// A paginated list of newly created first level children block objects. Task> AppendChildrenAsync(string blockId, BlocksAppendChildrenParameters parameters = null); + + /// + /// Sets a Block object, including page blocks, to archived: true using the ID specified. + /// + /// Identifier for a Notion block + Task DeleteAsync(string blockId); } } From 3680e07574cf1cf38ca4d5a8a971a5c605c44a09 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 00:49:50 +0530 Subject: [PATCH 11/32] Add support for additional block types * Code * ChildDatabase * Embed * Image * Video * File * PDF * Bookmark * Equation --- Src/Notion.Client/Models/Blocks/BlockType.cs | 27 ++++++++++ .../Models/Blocks/BookmarkBlock.cs | 18 +++++++ .../Models/Blocks/ChildDatabaseBlock.cs | 18 +++++++ Src/Notion.Client/Models/Blocks/CodeBlock.cs | 22 ++++++++ Src/Notion.Client/Models/Blocks/EmbedBlock.cs | 18 +++++++ .../Models/Blocks/EquationBlock.cs | 18 +++++++ Src/Notion.Client/Models/Blocks/FileBlock.cs | 12 +++++ Src/Notion.Client/Models/Blocks/ImageBlock.cs | 51 +++++++++++++++++++ Src/Notion.Client/Models/Blocks/PDFBlock.cs | 12 +++++ Src/Notion.Client/Models/Blocks/VideoBlock.cs | 12 +++++ 10 files changed, 208 insertions(+) create mode 100644 Src/Notion.Client/Models/Blocks/BookmarkBlock.cs create mode 100644 Src/Notion.Client/Models/Blocks/ChildDatabaseBlock.cs create mode 100644 Src/Notion.Client/Models/Blocks/CodeBlock.cs create mode 100644 Src/Notion.Client/Models/Blocks/EmbedBlock.cs create mode 100644 Src/Notion.Client/Models/Blocks/EquationBlock.cs create mode 100644 Src/Notion.Client/Models/Blocks/FileBlock.cs create mode 100644 Src/Notion.Client/Models/Blocks/ImageBlock.cs create mode 100644 Src/Notion.Client/Models/Blocks/PDFBlock.cs create mode 100644 Src/Notion.Client/Models/Blocks/VideoBlock.cs diff --git a/Src/Notion.Client/Models/Blocks/BlockType.cs b/Src/Notion.Client/Models/Blocks/BlockType.cs index 24c07566..1c37f205 100644 --- a/Src/Notion.Client/Models/Blocks/BlockType.cs +++ b/Src/Notion.Client/Models/Blocks/BlockType.cs @@ -31,6 +31,33 @@ public enum BlockType [EnumMember(Value = "child_page")] ChildPage, + [EnumMember(Value = "code")] + Code, + + [EnumMember(Value = "child_database")] + ChildDatabase, + + [EnumMember(Value = "embed")] + Embed, + + [EnumMember(Value = "image")] + Image, + + [EnumMember(Value = "video")] + Video, + + [EnumMember(Value = "file")] + File, + + [EnumMember(Value = "pdf")] + PDF, + + [EnumMember(Value = "bookmark")] + Bookmark, + + [EnumMember(Value = "equation")] + Equation, + [EnumMember(Value = "unsupported")] Unsupported } diff --git a/Src/Notion.Client/Models/Blocks/BookmarkBlock.cs b/Src/Notion.Client/Models/Blocks/BookmarkBlock.cs new file mode 100644 index 00000000..f4df3a90 --- /dev/null +++ b/Src/Notion.Client/Models/Blocks/BookmarkBlock.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class BookmarkBlock : Block + { + public override BlockType Type => BlockType.Bookmark; + + [JsonProperty("bookmark")] + public Info Bookmark { get; set; } + + public class Info + { + [JsonProperty("url")] + public string Url { get; set; } + } + } +} diff --git a/Src/Notion.Client/Models/Blocks/ChildDatabaseBlock.cs b/Src/Notion.Client/Models/Blocks/ChildDatabaseBlock.cs new file mode 100644 index 00000000..eb4577b7 --- /dev/null +++ b/Src/Notion.Client/Models/Blocks/ChildDatabaseBlock.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class ChildDatabaseBlock : Block + { + public override BlockType Type => BlockType.ChildDatabase; + + [JsonProperty("child_database")] + public Info ChildDatabase { get; set; } + + public class Info + { + [JsonProperty("title")] + public string Title { get; set; } + } + } +} diff --git a/Src/Notion.Client/Models/Blocks/CodeBlock.cs b/Src/Notion.Client/Models/Blocks/CodeBlock.cs new file mode 100644 index 00000000..58ac5d6a --- /dev/null +++ b/Src/Notion.Client/Models/Blocks/CodeBlock.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class CodeBlock : Block + { + public override BlockType Type => BlockType.Code; + + [JsonProperty("code")] + public Info Code { get; set; } + + public class Info + { + [JsonProperty("text")] + public IEnumerable Text { get; set; } + + [JsonProperty("language")] + public string Language { get; set; } + } + } +} diff --git a/Src/Notion.Client/Models/Blocks/EmbedBlock.cs b/Src/Notion.Client/Models/Blocks/EmbedBlock.cs new file mode 100644 index 00000000..5b3f715f --- /dev/null +++ b/Src/Notion.Client/Models/Blocks/EmbedBlock.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class EmbedBlock : Block + { + public override BlockType Type => BlockType.Embed; + + [JsonProperty("embed")] + public Info Embed { get; set; } + + public class Info + { + [JsonProperty("url")] + public string Url { get; set; } + } + } +} diff --git a/Src/Notion.Client/Models/Blocks/EquationBlock.cs b/Src/Notion.Client/Models/Blocks/EquationBlock.cs new file mode 100644 index 00000000..79585539 --- /dev/null +++ b/Src/Notion.Client/Models/Blocks/EquationBlock.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class EquationBlock : Block + { + public override BlockType Type => BlockType.Equation; + + [JsonProperty("equation")] + public Info Equation { get; set; } + + public class Info + { + [JsonProperty("expression")] + public string Expression { get; set; } + } + } +} diff --git a/Src/Notion.Client/Models/Blocks/FileBlock.cs b/Src/Notion.Client/Models/Blocks/FileBlock.cs new file mode 100644 index 00000000..c06533ed --- /dev/null +++ b/Src/Notion.Client/Models/Blocks/FileBlock.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class FileBlock : Block + { + public override BlockType Type => BlockType.File; + + [JsonProperty("file")] + public FileObject File { get; set; } + } +} diff --git a/Src/Notion.Client/Models/Blocks/ImageBlock.cs b/Src/Notion.Client/Models/Blocks/ImageBlock.cs new file mode 100644 index 00000000..dad712f8 --- /dev/null +++ b/Src/Notion.Client/Models/Blocks/ImageBlock.cs @@ -0,0 +1,51 @@ +using System; +using System.Runtime.Serialization; +using JsonSubTypes; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Notion.Client +{ + public class ImageBlock : Block + { + public override BlockType Type => BlockType.Image; + + [JsonProperty("image")] + public FileObject Image { get; set; } + } + + public enum FileType + { + [EnumMember(Value = "external")] + External, + + [EnumMember(Value = "file")] + File + } + + [JsonConverter(typeof(JsonSubtypes), "type")] + [JsonSubtypes.KnownSubType(typeof(UploadedFile), FileType.File)] + [JsonSubtypes.KnownSubType(typeof(ExternalFile), FileType.External)] + public abstract class FileObject + { + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public virtual FileType Type { get; set; } + + [JsonProperty("url")] + public string Url { get; set; } + } + + public class UploadedFile : FileObject + { + public override FileType Type => FileType.File; + + [JsonProperty("expiry_time")] + public DateTime ExpiryTime { get; set; } + } + + public class ExternalFile : FileObject + { + public override FileType Type => FileType.External; + } +} diff --git a/Src/Notion.Client/Models/Blocks/PDFBlock.cs b/Src/Notion.Client/Models/Blocks/PDFBlock.cs new file mode 100644 index 00000000..84a3a29f --- /dev/null +++ b/Src/Notion.Client/Models/Blocks/PDFBlock.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class PDFBlock : Block + { + public override BlockType Type => BlockType.PDF; + + [JsonProperty("pdf")] + public FileObject PDF { get; set; } + } +} diff --git a/Src/Notion.Client/Models/Blocks/VideoBlock.cs b/Src/Notion.Client/Models/Blocks/VideoBlock.cs new file mode 100644 index 00000000..49a1a697 --- /dev/null +++ b/Src/Notion.Client/Models/Blocks/VideoBlock.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class VideoBlock : Block + { + public override BlockType Type => BlockType.Video; + + [JsonProperty("video")] + public FileObject Video { get; set; } + } +} From c2c72b0b0b823a0e4b1f955cfae0af301f8a90c2 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 01:03:54 +0530 Subject: [PATCH 12/32] =?UTF-8?q?Run=20linter=20=F0=9F=9A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PropertySchema/RollupConfigPropertySchema.cs | 2 +- .../PropertySchema/RelationUpdatePropertySchema.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RollupConfigPropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RollupConfigPropertySchema.cs index 0a4227b3..e4065344 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RollupConfigPropertySchema.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RollupConfigPropertySchema.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using Newtonsoft.Json.Converters; namespace Notion.Client diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RelationUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RelationUpdatePropertySchema.cs index a101b8a2..2091df91 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RelationUpdatePropertySchema.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RelationUpdatePropertySchema.cs @@ -1,4 +1,4 @@ -using System; +using System; using Newtonsoft.Json; namespace Notion.Client From a7bb81daafe3dc79852d399b451292919f14ba1f Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 01:53:20 +0530 Subject: [PATCH 13/32] Add icon & cover image support for page object --- .../RequestParams/PagesUpdateParameters.cs | 8 +++++ Src/Notion.Client/Models/EmojiObject.cs | 13 ++++++++ Src/Notion.Client/Models/FileObject.cs | 33 +++++++++++++++++++ Src/Notion.Client/Models/Page/IPageIcon.cs | 10 ++++++ Src/Notion.Client/Models/Page/NewPage.cs | 7 ++++ Src/Notion.Client/Models/Page/Page.cs | 6 ++++ 6 files changed, 77 insertions(+) create mode 100644 Src/Notion.Client/Models/EmojiObject.cs create mode 100644 Src/Notion.Client/Models/FileObject.cs create mode 100644 Src/Notion.Client/Models/Page/IPageIcon.cs diff --git a/Src/Notion.Client/Api/Pages/RequestParams/PagesUpdateParameters.cs b/Src/Notion.Client/Api/Pages/RequestParams/PagesUpdateParameters.cs index db35d093..4e45cff6 100644 --- a/Src/Notion.Client/Api/Pages/RequestParams/PagesUpdateParameters.cs +++ b/Src/Notion.Client/Api/Pages/RequestParams/PagesUpdateParameters.cs @@ -1,10 +1,18 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class PagesUpdateParameters : IPagesUpdateBodyParameters { public bool Archived { get; set; } + public IDictionary Properties { get; set; } + + [JsonProperty("icon")] + public IPageIcon Icon { get; set; } + + [JsonProperty("cover")] + public FileObject Cover { get; set; } } } diff --git a/Src/Notion.Client/Models/EmojiObject.cs b/Src/Notion.Client/Models/EmojiObject.cs new file mode 100644 index 00000000..95c67b61 --- /dev/null +++ b/Src/Notion.Client/Models/EmojiObject.cs @@ -0,0 +1,13 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class EmojiObject : IPageIcon + { + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("emoji")] + public string Emoji { get; set; } + } +} diff --git a/Src/Notion.Client/Models/FileObject.cs b/Src/Notion.Client/Models/FileObject.cs new file mode 100644 index 00000000..30919d53 --- /dev/null +++ b/Src/Notion.Client/Models/FileObject.cs @@ -0,0 +1,33 @@ +using System; +using JsonSubTypes; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Notion.Client +{ + [JsonConverter(typeof(JsonSubtypes), "type")] + [JsonSubtypes.KnownSubType(typeof(UploadedFile), "file")] + [JsonSubtypes.KnownSubType(typeof(ExternalFile), "external")] + public abstract class FileObject : IPageIcon + { + [JsonProperty("type")] + [JsonConverter(typeof(StringEnumConverter))] + public virtual string Type { get; set; } + + [JsonProperty("url")] + public string Url { get; set; } + } + + public class UploadedFile : FileObject + { + public override string Type => "file"; + + [JsonProperty("expiry_time")] + public DateTime ExpiryTime { get; set; } + } + + public class ExternalFile : FileObject + { + public override string Type => "external"; + } +} diff --git a/Src/Notion.Client/Models/Page/IPageIcon.cs b/Src/Notion.Client/Models/Page/IPageIcon.cs new file mode 100644 index 00000000..c85b3a4c --- /dev/null +++ b/Src/Notion.Client/Models/Page/IPageIcon.cs @@ -0,0 +1,10 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public interface IPageIcon + { + [JsonProperty("type")] + string Type { get; set; } + } +} diff --git a/Src/Notion.Client/Models/Page/NewPage.cs b/Src/Notion.Client/Models/Page/NewPage.cs index 57cca85f..a46725bb 100644 --- a/Src/Notion.Client/Models/Page/NewPage.cs +++ b/Src/Notion.Client/Models/Page/NewPage.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { @@ -30,6 +31,12 @@ public NewPage(IPageParent parent) public List Children { get; set; } + [JsonProperty("icon")] + public IPageIcon Icon { get; set; } + + [JsonProperty("cover")] + public FileObject Cover { get; set; } + public NewPage AddProperty(string nameOrId, PropertyValue value) { Properties[nameOrId] = value; diff --git a/Src/Notion.Client/Models/Page/Page.cs b/Src/Notion.Client/Models/Page/Page.cs index e318f0af..fe6d2b5e 100644 --- a/Src/Notion.Client/Models/Page/Page.cs +++ b/Src/Notion.Client/Models/Page/Page.cs @@ -24,5 +24,11 @@ public class Page : IObject public IDictionary Properties { get; set; } public string Url { get; set; } + + [JsonProperty("icon")] + public IPageIcon Icon { get; set; } + + [JsonProperty("cover")] + public FileObject Cover { get; set; } } } From 347aec0db07b755d825270277c67064c677f1111 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 01:55:03 +0530 Subject: [PATCH 14/32] Remove NewPage default constructor & updated tests --- Src/Notion.Client/Models/Page/NewPage.cs | 9 --------- Test/Notion.UnitTests/PagesClientTests.cs | 7 +++---- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/Src/Notion.Client/Models/Page/NewPage.cs b/Src/Notion.Client/Models/Page/NewPage.cs index a46725bb..0ba6185c 100644 --- a/Src/Notion.Client/Models/Page/NewPage.cs +++ b/Src/Notion.Client/Models/Page/NewPage.cs @@ -5,15 +5,6 @@ namespace Notion.Client { public class NewPage { - /// - /// Constructor without arguments: added for class initializations using class literals. - /// - public NewPage() - { - Properties = new Dictionary(); - Children = new List(); - } - /// /// Constructor that adds required Parent property. Used when you don't want to /// assign properties in separate operations. diff --git a/Test/Notion.UnitTests/PagesClientTests.cs b/Test/Notion.UnitTests/PagesClientTests.cs index 1e00e59d..00185905 100644 --- a/Test/Notion.UnitTests/PagesClientTests.cs +++ b/Test/Notion.UnitTests/PagesClientTests.cs @@ -56,11 +56,10 @@ public async Task CreateAsync() .WithBody(jsonData) ); - var newPage = new NewPage(); - newPage.Parent = new PageParent + var newPage = new NewPage(new PageParent { PageId = "3c357473-a281-49a4-88c0-10d2b245a589" - }; + }); newPage.AddProperty("Name", new TitlePropertyValue() { @@ -210,7 +209,7 @@ public async Task CreateAsync_Throws_ArgumentNullException_When_Parameter_Is_Nul [Fact] public async Task CreateAsync_Throws_ArgumentNullException_When_Parent_Is_Missing() { - var newPage = new NewPage(); + var newPage = new NewPage(null); Func act = async () => await _client.CreateAsync(newPage); From ae2ada5b05ab8038ee491bb69140dc4d4c255647 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 02:02:53 +0530 Subject: [PATCH 15/32] Add icon & cover image support for database object --- .../DatabasesCreateParameters.cs | 7 +++++++ .../DatabasesUpdateParameters.cs | 9 +++++++++ Src/Notion.Client/Models/Database/Database.cs | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/DatabasesCreateParameters.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/DatabasesCreateParameters.cs index 58ec990a..12542120 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/DatabasesCreateParameters.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/DatabasesCreateParameters.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { @@ -7,5 +8,11 @@ public class DatabasesCreateParameters : IDatabasesCreateBodyParameters, IDataba public ParentPageInput Parent { get; set; } public Dictionary Properties { get; set; } public List Title { get; set; } + + [JsonProperty("icon")] + public IPageIcon Icon { get; set; } + + [JsonProperty("cover")] + public FileObject Cover { get; set; } } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/DatabasesUpdateParameters.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/DatabasesUpdateParameters.cs index aa8e7a56..85da2006 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/DatabasesUpdateParameters.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/DatabasesUpdateParameters.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { @@ -6,11 +7,19 @@ public interface IDatabasesUpdateBodyParameters { Dictionary Properties { get; set; } List Title { get; set; } + + [JsonProperty("icon")] + IPageIcon Icon { get; set; } + + [JsonProperty("cover")] + FileObject Cover { get; set; } } public class DatabasesUpdateParameters : IDatabasesUpdateBodyParameters { public Dictionary Properties { get; set; } public List Title { get; set; } + public IPageIcon Icon { get; set; } + public FileObject Cover { get; set; } } } diff --git a/Src/Notion.Client/Models/Database/Database.cs b/Src/Notion.Client/Models/Database/Database.cs index 7f906bf3..13d18af2 100644 --- a/Src/Notion.Client/Models/Database/Database.cs +++ b/Src/Notion.Client/Models/Database/Database.cs @@ -21,5 +21,11 @@ public class Database : IObject public Dictionary Properties { get; set; } public IDatabaseParent Parent { get; set; } + + [JsonProperty("icon")] + public IPageIcon Icon { get; set; } + + [JsonProperty("cover")] + public FileObject Cover { get; set; } } } From 3eafdf566ef20336d7f4948668cbf504e6a13e50 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 02:08:51 +0530 Subject: [PATCH 16/32] Add JsonProperty attribute --- .../DatabasesCreateParameters/DatabasesCreateParameters.cs | 5 +++++ .../DatabasesUpdateParameters/DatabasesUpdateParameters.cs | 3 +++ Src/Notion.Client/Models/Database/Database.cs | 3 +++ Src/Notion.Client/Models/Page/NewPage.cs | 3 +++ Src/Notion.Client/Models/Page/Page.cs | 3 +++ 5 files changed, 17 insertions(+) diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/DatabasesCreateParameters.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/DatabasesCreateParameters.cs index 12542120..79a984f9 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/DatabasesCreateParameters.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/DatabasesCreateParameters.cs @@ -5,8 +5,13 @@ namespace Notion.Client { public class DatabasesCreateParameters : IDatabasesCreateBodyParameters, IDatabasesCreateQueryParameters { + [JsonProperty("parent")] public ParentPageInput Parent { get; set; } + + [JsonProperty("properties")] public Dictionary Properties { get; set; } + + [JsonProperty("title")] public List Title { get; set; } [JsonProperty("icon")] diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/DatabasesUpdateParameters.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/DatabasesUpdateParameters.cs index 85da2006..ff2e129e 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/DatabasesUpdateParameters.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/DatabasesUpdateParameters.cs @@ -5,7 +5,10 @@ namespace Notion.Client { public interface IDatabasesUpdateBodyParameters { + [JsonProperty("properties")] Dictionary Properties { get; set; } + + [JsonProperty("title")] List Title { get; set; } [JsonProperty("icon")] diff --git a/Src/Notion.Client/Models/Database/Database.cs b/Src/Notion.Client/Models/Database/Database.cs index 13d18af2..ff008a90 100644 --- a/Src/Notion.Client/Models/Database/Database.cs +++ b/Src/Notion.Client/Models/Database/Database.cs @@ -16,10 +16,13 @@ public class Database : IObject [JsonProperty("last_edited_time")] public DateTime LastEditedTime { get; set; } + [JsonProperty("title")] public List Title { get; set; } + [JsonProperty("properties")] public Dictionary Properties { get; set; } + [JsonProperty("parent")] public IDatabaseParent Parent { get; set; } [JsonProperty("icon")] diff --git a/Src/Notion.Client/Models/Page/NewPage.cs b/Src/Notion.Client/Models/Page/NewPage.cs index 0ba6185c..0194bae5 100644 --- a/Src/Notion.Client/Models/Page/NewPage.cs +++ b/Src/Notion.Client/Models/Page/NewPage.cs @@ -16,10 +16,13 @@ public NewPage(IPageParent parent) Children = new List(); } + [JsonProperty("parent")] public IPageParent Parent { get; set; } + [JsonProperty("properties")] public Dictionary Properties { get; set; } + [JsonProperty("children")] public List Children { get; set; } [JsonProperty("icon")] diff --git a/Src/Notion.Client/Models/Page/Page.cs b/Src/Notion.Client/Models/Page/Page.cs index fe6d2b5e..e6b4921c 100644 --- a/Src/Notion.Client/Models/Page/Page.cs +++ b/Src/Notion.Client/Models/Page/Page.cs @@ -10,6 +10,7 @@ public class Page : IObject public string Id { get; set; } + [JsonProperty("parent")] public IPageParent Parent { get; set; } [JsonProperty("created_time")] @@ -21,8 +22,10 @@ public class Page : IObject [JsonProperty("archived")] public bool IsArchived { get; set; } + [JsonProperty("properties")] public IDictionary Properties { get; set; } + [JsonProperty("url")] public string Url { get; set; } [JsonProperty("icon")] From b9146178d5c8b96928f9c264cec414be29875b36 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 02:19:51 +0530 Subject: [PATCH 17/32] Add new block types as JsonSubTypes known subtype --- Src/Notion.Client/Models/Blocks/Block.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Src/Notion.Client/Models/Blocks/Block.cs b/Src/Notion.Client/Models/Blocks/Block.cs index 2018ff40..fa821cb1 100644 --- a/Src/Notion.Client/Models/Blocks/Block.cs +++ b/Src/Notion.Client/Models/Blocks/Block.cs @@ -5,15 +5,24 @@ namespace Notion.Client { [JsonConverter(typeof(JsonSubtypes), "type")] + [JsonSubtypes.KnownSubType(typeof(BookmarkBlock), BlockType.Bookmark)] [JsonSubtypes.KnownSubType(typeof(BulletedListItemBlock), BlockType.BulletedListItem)] [JsonSubtypes.KnownSubType(typeof(ChildPageBlock), BlockType.ChildPage)] + [JsonSubtypes.KnownSubType(typeof(ChildDatabaseBlock), BlockType.ChildDatabase)] + [JsonSubtypes.KnownSubType(typeof(CodeBlock), BlockType.Code)] + [JsonSubtypes.KnownSubType(typeof(EmbedBlock), BlockType.Embed)] + [JsonSubtypes.KnownSubType(typeof(EquationBlock), BlockType.Equation)] + [JsonSubtypes.KnownSubType(typeof(FileBlock), BlockType.File)] [JsonSubtypes.KnownSubType(typeof(HeadingOneBlock), BlockType.Heading_1)] [JsonSubtypes.KnownSubType(typeof(HeadingTwoBlock), BlockType.Heading_2)] [JsonSubtypes.KnownSubType(typeof(HeadingThreeeBlock), BlockType.Heading_3)] + [JsonSubtypes.KnownSubType(typeof(ImageBlock), BlockType.Image)] [JsonSubtypes.KnownSubType(typeof(NumberedListItemBlock), BlockType.NumberedListItem)] [JsonSubtypes.KnownSubType(typeof(ParagraphBlock), BlockType.Paragraph)] + [JsonSubtypes.KnownSubType(typeof(PDFBlock), BlockType.PDF)] [JsonSubtypes.KnownSubType(typeof(ToDoBlock), BlockType.ToDo)] [JsonSubtypes.KnownSubType(typeof(ToggleBlock), BlockType.Toggle)] + [JsonSubtypes.KnownSubType(typeof(VideoBlock), BlockType.Video)] [JsonSubtypes.KnownSubType(typeof(UnsupportedBlock), BlockType.Unsupported)] public class Block : IObject { From 36e0ec2787151e0db8867455e6c46e50cfd6c01e Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 02:24:21 +0530 Subject: [PATCH 18/32] =?UTF-8?q?Remove=20duplicate=20classes=20=E2=99=BB?= =?UTF-8?q?=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Notion.Client/Models/Blocks/ImageBlock.cs | 41 +------------------ 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/Src/Notion.Client/Models/Blocks/ImageBlock.cs b/Src/Notion.Client/Models/Blocks/ImageBlock.cs index dad712f8..cead4547 100644 --- a/Src/Notion.Client/Models/Blocks/ImageBlock.cs +++ b/Src/Notion.Client/Models/Blocks/ImageBlock.cs @@ -1,8 +1,4 @@ -using System; -using System.Runtime.Serialization; -using JsonSubTypes; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; +using Newtonsoft.Json; namespace Notion.Client { @@ -13,39 +9,4 @@ public class ImageBlock : Block [JsonProperty("image")] public FileObject Image { get; set; } } - - public enum FileType - { - [EnumMember(Value = "external")] - External, - - [EnumMember(Value = "file")] - File - } - - [JsonConverter(typeof(JsonSubtypes), "type")] - [JsonSubtypes.KnownSubType(typeof(UploadedFile), FileType.File)] - [JsonSubtypes.KnownSubType(typeof(ExternalFile), FileType.External)] - public abstract class FileObject - { - [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] - public virtual FileType Type { get; set; } - - [JsonProperty("url")] - public string Url { get; set; } - } - - public class UploadedFile : FileObject - { - public override FileType Type => FileType.File; - - [JsonProperty("expiry_time")] - public DateTime ExpiryTime { get; set; } - } - - public class ExternalFile : FileObject - { - public override FileType Type => FileType.External; - } } From 7ce88b8d1370825b1fe3c139e7a82f93105fb1e4 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 03:15:54 +0530 Subject: [PATCH 19/32] Remove StringEnumConverter --- Src/Notion.Client/Models/{ => File}/FileObject.cs | 2 -- 1 file changed, 2 deletions(-) rename Src/Notion.Client/Models/{ => File}/FileObject.cs (89%) diff --git a/Src/Notion.Client/Models/FileObject.cs b/Src/Notion.Client/Models/File/FileObject.cs similarity index 89% rename from Src/Notion.Client/Models/FileObject.cs rename to Src/Notion.Client/Models/File/FileObject.cs index 30919d53..57e26982 100644 --- a/Src/Notion.Client/Models/FileObject.cs +++ b/Src/Notion.Client/Models/File/FileObject.cs @@ -1,7 +1,6 @@ using System; using JsonSubTypes; using Newtonsoft.Json; -using Newtonsoft.Json.Converters; namespace Notion.Client { @@ -11,7 +10,6 @@ namespace Notion.Client public abstract class FileObject : IPageIcon { [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] public virtual string Type { get; set; } [JsonProperty("url")] From eab06d0cd9d251534002721d694889450cd38a9b Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 03:25:30 +0530 Subject: [PATCH 20/32] Update file page property schema --- .../Models/File/FileObjectWithName.cs | 49 +++++++++++++++++++ .../PropertyValue/FilesPropertyValue.cs | 7 +-- 2 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 Src/Notion.Client/Models/File/FileObjectWithName.cs diff --git a/Src/Notion.Client/Models/File/FileObjectWithName.cs b/Src/Notion.Client/Models/File/FileObjectWithName.cs new file mode 100644 index 00000000..6a7e0409 --- /dev/null +++ b/Src/Notion.Client/Models/File/FileObjectWithName.cs @@ -0,0 +1,49 @@ +using System; +using JsonSubTypes; +using Newtonsoft.Json; + +namespace Notion.Client +{ + [JsonConverter(typeof(JsonSubtypes), "type")] + [JsonSubtypes.KnownSubType(typeof(UploadedFileWithName), "file")] + [JsonSubtypes.KnownSubType(typeof(ExternalFileWithName), "external")] + public abstract class FileObjectWithName + { + [JsonProperty("type")] + public virtual string Type { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + } + + public class UploadedFileWithName : FileObjectWithName + { + public override string Type => "file"; + + [JsonProperty("file")] + public Info File { get; set; } + + public class Info + { + [JsonProperty("url")] + public string Url { get; set; } + + [JsonProperty("expiry_time")] + public DateTime ExpiryTime { get; set; } + } + } + + public class ExternalFileWithName : FileObjectWithName + { + public override string Type => "external"; + + [JsonProperty("external")] + public Info External { get; set; } + + public class Info + { + [JsonProperty("url")] + public string Url { get; set; } + } + } +} diff --git a/Src/Notion.Client/Models/PropertyValue/FilesPropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/FilesPropertyValue.cs index bd144643..5eef91f6 100644 --- a/Src/Notion.Client/Models/PropertyValue/FilesPropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/FilesPropertyValue.cs @@ -6,11 +6,6 @@ public class FilesPropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.Files; - public List Files { get; set; } - } - - public class FileValue - { - public string Name { get; set; } + public List Files { get; set; } } } From 0f77ce697c8c8b15f2b2abf84febc150de956cf9 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 03:33:05 +0530 Subject: [PATCH 21/32] =?UTF-8?q?Fix=20FileObject=20structure=20?= =?UTF-8?q?=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Notion.Client/Models/FileObject.cs | 27 +++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Src/Notion.Client/Models/FileObject.cs b/Src/Notion.Client/Models/FileObject.cs index 30919d53..6d8b346c 100644 --- a/Src/Notion.Client/Models/FileObject.cs +++ b/Src/Notion.Client/Models/FileObject.cs @@ -1,7 +1,6 @@ using System; using JsonSubTypes; using Newtonsoft.Json; -using Newtonsoft.Json.Converters; namespace Notion.Client { @@ -11,23 +10,37 @@ namespace Notion.Client public abstract class FileObject : IPageIcon { [JsonProperty("type")] - [JsonConverter(typeof(StringEnumConverter))] public virtual string Type { get; set; } - - [JsonProperty("url")] - public string Url { get; set; } } public class UploadedFile : FileObject { public override string Type => "file"; - [JsonProperty("expiry_time")] - public DateTime ExpiryTime { get; set; } + [JsonProperty("file")] + public Info File { get; set; } + + public class Info + { + [JsonProperty("url")] + public string Url { get; set; } + + [JsonProperty("expiry_time")] + public DateTime ExpiryTime { get; set; } + } } public class ExternalFile : FileObject { public override string Type => "external"; + + [JsonProperty("external")] + public Info External { get; set; } + + public class Info + { + [JsonProperty("url")] + public string Url { get; set; } + } } } From da39d0f45f035b988f83cfbaded3eb81d108587a Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 03:39:15 +0530 Subject: [PATCH 22/32] Keep a single class per a file --- Src/Notion.Client/Models/ExternalFile.cs | 18 +++++++++++++ Src/Notion.Client/Models/FileObject.cs | 34 +----------------------- Src/Notion.Client/Models/UploadedFile.cs | 22 +++++++++++++++ 3 files changed, 41 insertions(+), 33 deletions(-) create mode 100644 Src/Notion.Client/Models/ExternalFile.cs create mode 100644 Src/Notion.Client/Models/UploadedFile.cs diff --git a/Src/Notion.Client/Models/ExternalFile.cs b/Src/Notion.Client/Models/ExternalFile.cs new file mode 100644 index 00000000..7b8770fd --- /dev/null +++ b/Src/Notion.Client/Models/ExternalFile.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class ExternalFile : FileObject + { + public override string Type => "external"; + + [JsonProperty("external")] + public Info External { get; set; } + + public class Info + { + [JsonProperty("url")] + public string Url { get; set; } + } + } +} diff --git a/Src/Notion.Client/Models/FileObject.cs b/Src/Notion.Client/Models/FileObject.cs index 6d8b346c..88c701ae 100644 --- a/Src/Notion.Client/Models/FileObject.cs +++ b/Src/Notion.Client/Models/FileObject.cs @@ -1,5 +1,4 @@ -using System; -using JsonSubTypes; +using JsonSubTypes; using Newtonsoft.Json; namespace Notion.Client @@ -12,35 +11,4 @@ public abstract class FileObject : IPageIcon [JsonProperty("type")] public virtual string Type { get; set; } } - - public class UploadedFile : FileObject - { - public override string Type => "file"; - - [JsonProperty("file")] - public Info File { get; set; } - - public class Info - { - [JsonProperty("url")] - public string Url { get; set; } - - [JsonProperty("expiry_time")] - public DateTime ExpiryTime { get; set; } - } - } - - public class ExternalFile : FileObject - { - public override string Type => "external"; - - [JsonProperty("external")] - public Info External { get; set; } - - public class Info - { - [JsonProperty("url")] - public string Url { get; set; } - } - } } diff --git a/Src/Notion.Client/Models/UploadedFile.cs b/Src/Notion.Client/Models/UploadedFile.cs new file mode 100644 index 00000000..e476e487 --- /dev/null +++ b/Src/Notion.Client/Models/UploadedFile.cs @@ -0,0 +1,22 @@ +using System; +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class UploadedFile : FileObject + { + public override string Type => "file"; + + [JsonProperty("file")] + public Info File { get; set; } + + public class Info + { + [JsonProperty("url")] + public string Url { get; set; } + + [JsonProperty("expiry_time")] + public DateTime ExpiryTime { get; set; } + } + } +} From 6a1aa71f00987cd8f9cec463ac2f99ea62311b27 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 03:50:46 +0530 Subject: [PATCH 23/32] =?UTF-8?q?Move=20files=20in=20File=20directory=20?= =?UTF-8?q?=F0=9F=9A=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Notion.Client/Models/{ => File}/ExternalFile.cs | 0 Src/Notion.Client/Models/{ => File}/UploadedFile.cs | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename Src/Notion.Client/Models/{ => File}/ExternalFile.cs (100%) rename Src/Notion.Client/Models/{ => File}/UploadedFile.cs (100%) diff --git a/Src/Notion.Client/Models/ExternalFile.cs b/Src/Notion.Client/Models/File/ExternalFile.cs similarity index 100% rename from Src/Notion.Client/Models/ExternalFile.cs rename to Src/Notion.Client/Models/File/ExternalFile.cs diff --git a/Src/Notion.Client/Models/UploadedFile.cs b/Src/Notion.Client/Models/File/UploadedFile.cs similarity index 100% rename from Src/Notion.Client/Models/UploadedFile.cs rename to Src/Notion.Client/Models/File/UploadedFile.cs From 8be01eef9be9564f9a86c934b2143c15a28487dd Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 03:53:01 +0530 Subject: [PATCH 24/32] =?UTF-8?q?Move=20classes=20into=20separate=20files?= =?UTF-8?q?=20=F0=9F=9A=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Models/File/ExternalFileWithName.cs | 18 ++++++++++ .../Models/File/FileObjectWithName.cs | 34 +------------------ .../Models/File/UploadedFileWithName.cs | 22 ++++++++++++ 3 files changed, 41 insertions(+), 33 deletions(-) create mode 100644 Src/Notion.Client/Models/File/ExternalFileWithName.cs create mode 100644 Src/Notion.Client/Models/File/UploadedFileWithName.cs diff --git a/Src/Notion.Client/Models/File/ExternalFileWithName.cs b/Src/Notion.Client/Models/File/ExternalFileWithName.cs new file mode 100644 index 00000000..e06b0b63 --- /dev/null +++ b/Src/Notion.Client/Models/File/ExternalFileWithName.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class ExternalFileWithName : FileObjectWithName + { + public override string Type => "external"; + + [JsonProperty("external")] + public Info External { get; set; } + + public class Info + { + [JsonProperty("url")] + public string Url { get; set; } + } + } +} diff --git a/Src/Notion.Client/Models/File/FileObjectWithName.cs b/Src/Notion.Client/Models/File/FileObjectWithName.cs index 6a7e0409..a7381929 100644 --- a/Src/Notion.Client/Models/File/FileObjectWithName.cs +++ b/Src/Notion.Client/Models/File/FileObjectWithName.cs @@ -1,5 +1,4 @@ -using System; -using JsonSubTypes; +using JsonSubTypes; using Newtonsoft.Json; namespace Notion.Client @@ -15,35 +14,4 @@ public abstract class FileObjectWithName [JsonProperty("name")] public string Name { get; set; } } - - public class UploadedFileWithName : FileObjectWithName - { - public override string Type => "file"; - - [JsonProperty("file")] - public Info File { get; set; } - - public class Info - { - [JsonProperty("url")] - public string Url { get; set; } - - [JsonProperty("expiry_time")] - public DateTime ExpiryTime { get; set; } - } - } - - public class ExternalFileWithName : FileObjectWithName - { - public override string Type => "external"; - - [JsonProperty("external")] - public Info External { get; set; } - - public class Info - { - [JsonProperty("url")] - public string Url { get; set; } - } - } } diff --git a/Src/Notion.Client/Models/File/UploadedFileWithName.cs b/Src/Notion.Client/Models/File/UploadedFileWithName.cs new file mode 100644 index 00000000..e1510459 --- /dev/null +++ b/Src/Notion.Client/Models/File/UploadedFileWithName.cs @@ -0,0 +1,22 @@ +using System; +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class UploadedFileWithName : FileObjectWithName + { + public override string Type => "file"; + + [JsonProperty("file")] + public Info File { get; set; } + + public class Info + { + [JsonProperty("url")] + public string Url { get; set; } + + [JsonProperty("expiry_time")] + public DateTime ExpiryTime { get; set; } + } + } +} From 5563072853be3824fceef63fdd1842947abdda74 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 03:58:07 +0530 Subject: [PATCH 25/32] Add URL property to database object --- Src/Notion.Client/Models/Database/Database.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Src/Notion.Client/Models/Database/Database.cs b/Src/Notion.Client/Models/Database/Database.cs index ff008a90..6943048f 100644 --- a/Src/Notion.Client/Models/Database/Database.cs +++ b/Src/Notion.Client/Models/Database/Database.cs @@ -30,5 +30,11 @@ public class Database : IObject [JsonProperty("cover")] public FileObject Cover { get; set; } + + /// + /// The URL of the Notion database. + /// + [JsonProperty("url")] + public string Url { get; set; } } } From 807707c510ee15a8972a3353ad0d26a37f6cee72 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 05:18:17 +0530 Subject: [PATCH 26/32] Add JsonProperty attribute to request & response model --- .../UpdateBlocks/ParagraphBlock.cs | 5 ++- .../UpdateBlocks/TextContentUpdate.cs | 2 + .../UpdateBlocks/ToDoBlock.cs | 1 + .../UpdateBlocks/ToggleBlock.cs | 5 ++- .../IBlocksAppendChildrenBodyParameters.cs | 2 + .../IDatabasesCreateBodyParameters.cs | 6 +++ .../DatabasesCreateParameters/MentionInput.cs | 13 ++++++- .../PropertySchema/CheckboxPropertySchema.cs | 2 + .../PropertySchema/DatePropertySchema.cs | 2 + .../PropertySchema/EmailPropertySchema.cs | 2 + .../PropertySchema/FilePropertySchema.cs | 2 + .../PropertySchema/FormulaPropertySchema.cs | 5 ++- .../PropertySchema/NumberPropertySchema.cs | 5 ++- .../PropertySchema/PeoplePropertySchema.cs | 2 + .../PropertySchema/SelectOptionSchema.cs | 2 + .../PropertySchema/SelectPropertySchema.cs | 5 ++- .../PropertySchema/TitlePropertySchema.cs | 2 + .../PropertySchema/URLPropertyScheam.cs | 2 + .../RichTextEquationInput.cs | 6 ++- .../RichTextMentionInput.cs | 6 ++- .../RichTextTextInput.cs | 6 ++- .../FormulaUpdatePropertySchema.cs | 2 +- .../IDatabaseQueryBodyParameters.cs | 4 ++ .../Api/Databases/RequestParams/Sort.cs | 3 ++ .../IPagesUpdateBodyParameters.cs | 4 ++ .../RequestParams/PagesUpdateParameters.cs | 2 + .../Parameters/ISearchBodyParameters.cs | 9 ++++- .../Api/Search/Parameters/SearchSort.cs | 2 + Src/Notion.Client/Models/Blocks/Block.cs | 1 + .../Models/Blocks/BulletedListItemBlock.cs | 3 ++ .../Models/Blocks/ChildPageBlock.cs | 1 + .../Models/Blocks/HeadingOneBlock.cs | 1 + .../Models/Blocks/HeadingThreeeBlock.cs | 1 + .../Models/Blocks/HeadingTwoBlock.cs | 1 + .../Models/Blocks/NumberedListItemBlock.cs | 3 ++ .../Models/Blocks/ParagraphBlock.cs | 5 +++ Src/Notion.Client/Models/Blocks/ToDoBlock.cs | 2 + .../Models/Blocks/ToggleBlock.cs | 5 +++ .../Database/Properties/CheckboxProperty.cs | 3 ++ .../Database/Properties/DateProperty.cs | 3 ++ .../Database/Properties/EmailProperty.cs | 3 ++ .../Database/Properties/FilesProperty.cs | 3 ++ .../Database/Properties/FormulaProperty.cs | 6 ++- .../Database/Properties/NumberProperty.cs | 3 ++ .../Database/Properties/PeopleProperty.cs | 3 ++ .../Models/Database/Properties/Property.cs | 3 ++ .../Database/Properties/RelationProperty.cs | 2 + .../Database/Properties/RollupProperty.cs | 1 + .../Database/Properties/SelectProperty.cs | 14 +++++++ .../Database/Properties/TitleProperty.cs | 3 ++ .../Models/Database/Properties/UrlProperty.cs | 3 ++ .../Models/Database/RichText/RichTextBase.cs | 4 ++ .../Database/RichText/RichTextEquation.cs | 7 +++- .../Database/RichText/RichTextMention.cs | 16 +++++++- .../Models/Database/RichText/RichTextText.cs | 12 +++++- Src/Notion.Client/Models/Filters/Checkbox.cs | 1 + Src/Notion.Client/Models/Filters/Date.cs | 1 + Src/Notion.Client/Models/Filters/Files.cs | 1 + Src/Notion.Client/Models/Filters/Filter.cs | 5 +++ Src/Notion.Client/Models/Filters/Formula.cs | 12 +++++- .../Models/Filters/Multiselect.cs | 1 + Src/Notion.Client/Models/Filters/Number.cs | 1 + Src/Notion.Client/Models/Filters/People.cs | 2 + Src/Notion.Client/Models/Filters/Relation.cs | 2 + Src/Notion.Client/Models/Filters/Select.cs | 1 + Src/Notion.Client/Models/Filters/Text.cs | 2 + Src/Notion.Client/Models/IObject.cs | 2 + Src/Notion.Client/Models/Page/Page.cs | 30 +++++++++++++++ Src/Notion.Client/Models/PaginatedList.cs | 2 + .../Models/Parents/DatabaseParent.cs | 6 +++ .../Models/Parents/PageParent.cs | 9 ++++- .../Models/Parents/WorkspaceParent.cs | 3 ++ .../PropertyValue/CheckboxPropertyValue.cs | 8 +++- .../PropertyValue/CreatedByPropertyValue.cs | 6 +++ .../PropertyValue/CreatedTimePropertyValue.cs | 6 +++ .../Models/PropertyValue/DatePropertyValue.cs | 21 ++++++++++ .../PropertyValue/EmailPropertyValue.cs | 11 +++++- .../PropertyValue/FilesPropertyValue.cs | 8 ++++ .../PropertyValue/FormulaPropertyValue.cs | 38 ++++++++++++++++++- .../LastEditedByPropertyValue.cs | 6 +++ .../LastEditedTimePropertyValue.cs | 6 +++ .../PropertyValue/MultiSelectPropertyValue.cs | 6 +++ .../PropertyValue/NumberPropertyValue.cs | 12 +++++- .../PropertyValue/PeoplePropertyValue.cs | 9 +++++ .../PropertyValue/PhoneNumberPropertyValue.cs | 6 +++ .../Models/PropertyValue/PropertyValue.cs | 7 ++++ .../Models/PropertyValue/PropertyValueType.cs | 3 ++ .../PropertyValue/RelationPropertyValue.cs | 5 +++ .../PropertyValue/RichTextPropertyValue.cs | 6 +++ .../PropertyValue/RollupPropertyValue.cs | 26 ++++++++++++- .../PropertyValue/SelectPropertyValue.cs | 9 ++++- .../PropertyValue/TitlePropertyValue.cs | 9 +++++ .../Models/PropertyValue/UrlPropertyValue.cs | 11 +++++- Src/Notion.Client/Models/User.cs | 8 ++++ 94 files changed, 505 insertions(+), 24 deletions(-) diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ParagraphBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ParagraphBlock.cs index 42d103e6..209c7ea4 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ParagraphBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ParagraphBlock.cs @@ -1,7 +1,10 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { public class ParagraphUpdateBlock : IUpdateBlock { + [JsonProperty("paragraph")] public TextContentUpdate Paragraph { 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 index b78f8fbf..b0388162 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TextContentUpdate.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TextContentUpdate.cs @@ -1,9 +1,11 @@ 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/ToDoBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToDoBlock.cs index 43b24863..6a58ed12 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToDoBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToDoBlock.cs @@ -10,6 +10,7 @@ public class ToDoUpdateBlock : IUpdateBlock public class Info { + [JsonProperty("text")] public IEnumerable Text { get; set; } [JsonProperty("checked")] diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToggleBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToggleBlock.cs index e7027add..b714c916 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToggleBlock.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToggleBlock.cs @@ -1,7 +1,10 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { public class ToggleUpdateBlock : IUpdateBlock { + [JsonProperty("toggle")] public TextContentUpdate Toggle { get; set; } } } diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/IBlocksAppendChildrenBodyParameters.cs b/Src/Notion.Client/Api/Blocks/RequestParams/IBlocksAppendChildrenBodyParameters.cs index f024eba9..33b0ca0f 100644 --- a/Src/Notion.Client/Api/Blocks/RequestParams/IBlocksAppendChildrenBodyParameters.cs +++ b/Src/Notion.Client/Api/Blocks/RequestParams/IBlocksAppendChildrenBodyParameters.cs @@ -1,10 +1,12 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { // TODO: need an input version of Block public interface IBlocksAppendChildrenBodyParameters { + [JsonProperty("children")] IEnumerable Children { get; set; } } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/IDatabasesCreateBodyParameters.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/IDatabasesCreateBodyParameters.cs index 0218a49a..b0f97061 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/IDatabasesCreateBodyParameters.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/IDatabasesCreateBodyParameters.cs @@ -1,11 +1,17 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public interface IDatabasesCreateBodyParameters { + [JsonProperty("parent")] ParentPageInput Parent { get; set; } + + [JsonProperty("properties")] Dictionary Properties { get; set; } + + [JsonProperty("title")] List Title { get; set; } } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/MentionInput.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/MentionInput.cs index 1324e518..83d1e699 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/MentionInput.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/MentionInput.cs @@ -1,11 +1,22 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { public class MentionInput { + [JsonProperty("type")] public string Type { get; set; } + + [JsonProperty("user")] public Person User { get; set; } + + [JsonProperty("page")] public ObjectId Page { get; set; } + + [JsonProperty("database")] public ObjectId Database { get; set; } + + [JsonProperty("date")] public DatePropertyValue Date { get; set; } } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/CheckboxPropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/CheckboxPropertySchema.cs index c6fd7335..fb955a3e 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/CheckboxPropertySchema.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/CheckboxPropertySchema.cs @@ -1,9 +1,11 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class CheckboxPropertySchema : IPropertySchema { + [JsonProperty("checkbox")] public Dictionary Checkbox { get; set; } } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/DatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/DatePropertySchema.cs index 8042a2d2..1dc37c20 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/DatePropertySchema.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/DatePropertySchema.cs @@ -1,9 +1,11 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class DatePropertySchema : IPropertySchema { + [JsonProperty("date")] public Dictionary Date { get; set; } } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/EmailPropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/EmailPropertySchema.cs index dac130f5..6a680c2b 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/EmailPropertySchema.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/EmailPropertySchema.cs @@ -1,9 +1,11 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class EmailPropertySchema : IPropertySchema { + [JsonProperty("email")] public Dictionary Email { get; set; } } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/FilePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/FilePropertySchema.cs index 2347a67e..4591a3fc 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/FilePropertySchema.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/FilePropertySchema.cs @@ -1,9 +1,11 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class FilePropertySchema : IPropertySchema { + [JsonProperty("files")] public Dictionary Files { get; set; } } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/FormulaPropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/FormulaPropertySchema.cs index e1802d38..97e7cb33 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/FormulaPropertySchema.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/FormulaPropertySchema.cs @@ -1,7 +1,10 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { public class FormulaPropertySchema : IPropertySchema { + [JsonProperty("formula")] public Formula Formula { get; set; } } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/NumberPropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/NumberPropertySchema.cs index 9d5d652f..dbb7fa28 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/NumberPropertySchema.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/NumberPropertySchema.cs @@ -1,7 +1,10 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { public class NumberPropertySchema : IPropertySchema { + [JsonProperty("number")] public Number Number { get; set; } } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/PeoplePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/PeoplePropertySchema.cs index cc3a8409..5293746c 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/PeoplePropertySchema.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/PeoplePropertySchema.cs @@ -1,9 +1,11 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class PeoplePropertySchema : IPropertySchema { + [JsonProperty("people")] public Dictionary People { get; set; } } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/SelectOptionSchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/SelectOptionSchema.cs index b58d7626..c31aef9f 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/SelectOptionSchema.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/SelectOptionSchema.cs @@ -5,8 +5,10 @@ namespace Notion.Client { public class SelectOptionSchema { + [JsonProperty("name")] public string Name { get; set; } + [JsonProperty("color")] [JsonConverter(typeof(StringEnumConverter))] public Color Color { get; set; } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/SelectPropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/SelectPropertySchema.cs index a582fe71..6e764bf3 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/SelectPropertySchema.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/SelectPropertySchema.cs @@ -1,7 +1,10 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { public class SelectPropertySchema : IPropertySchema { + [JsonProperty("select")] public OptionWrapper Select { get; set; } } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/TitlePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/TitlePropertySchema.cs index 2c64db1f..b7fb2f72 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/TitlePropertySchema.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/TitlePropertySchema.cs @@ -1,9 +1,11 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class TitlePropertySchema : IPropertySchema { + [JsonProperty("title")] public Dictionary Title { get; set; } } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/URLPropertyScheam.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/URLPropertyScheam.cs index fdaa5d90..468244d8 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/URLPropertyScheam.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/URLPropertyScheam.cs @@ -1,9 +1,11 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class URLPropertyScheam : IPropertySchema { + [JsonProperty("url")] public Dictionary Url { get; set; } } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/RichTextEquationInput.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/RichTextEquationInput.cs index 4ca358a1..f86dd803 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/RichTextEquationInput.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/RichTextEquationInput.cs @@ -1,8 +1,12 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { public class RichTextEquationInput : RichTextBaseInput { public override RichTextType Type => RichTextType.Equation; + + [JsonProperty("equation")] public Equation Equation { get; set; } } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/RichTextMentionInput.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/RichTextMentionInput.cs index 0b83f8d6..3e9c914d 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/RichTextMentionInput.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/RichTextMentionInput.cs @@ -1,8 +1,12 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { public class RichTextMentionInput : RichTextBaseInput { public override RichTextType Type => RichTextType.Mention; + + [JsonProperty("mention")] public MentionInput Mention { get; set; } } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/RichTextTextInput.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/RichTextTextInput.cs index 1a54ee30..9f73157f 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/RichTextTextInput.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/RichTextTextInput.cs @@ -1,8 +1,12 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { public class RichTextTextInput : RichTextBaseInput { public override RichTextType Type => RichTextType.Text; + + [JsonProperty("text")] public Text Text { get; set; } } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/FormulaUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/FormulaUpdatePropertySchema.cs index f9084144..158a42bb 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/FormulaUpdatePropertySchema.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/FormulaUpdatePropertySchema.cs @@ -4,7 +4,7 @@ namespace Notion.Client { public class FormulaUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema { - [JsonProperty("checkbox")] + [JsonProperty("formula")] public Formula Formula { get; set; } } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/IDatabaseQueryBodyParameters.cs b/Src/Notion.Client/Api/Databases/RequestParams/IDatabaseQueryBodyParameters.cs index a48faa87..4ac46860 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/IDatabaseQueryBodyParameters.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/IDatabaseQueryBodyParameters.cs @@ -1,10 +1,14 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public interface IDatabaseQueryBodyParameters : IPaginationParameters { + [JsonProperty("filter")] Filter Filter { get; set; } + + [JsonProperty("sorts")] List Sorts { get; set; } } } diff --git a/Src/Notion.Client/Api/Databases/RequestParams/Sort.cs b/Src/Notion.Client/Api/Databases/RequestParams/Sort.cs index d8ccc878..f0afc72d 100644 --- a/Src/Notion.Client/Api/Databases/RequestParams/Sort.cs +++ b/Src/Notion.Client/Api/Databases/RequestParams/Sort.cs @@ -5,11 +5,14 @@ namespace Notion.Client { public class Sort { + [JsonProperty("property")] public string Property { get; set; } + [JsonProperty("timestamp")] [JsonConverter(typeof(StringEnumConverter))] public Timestamp Timestamp { get; set; } + [JsonProperty("direction")] [JsonConverter(typeof(StringEnumConverter))] public Direction Direction { get; set; } } diff --git a/Src/Notion.Client/Api/Pages/RequestParams/IPagesUpdateBodyParameters.cs b/Src/Notion.Client/Api/Pages/RequestParams/IPagesUpdateBodyParameters.cs index 12a8cc12..b37dd1fd 100644 --- a/Src/Notion.Client/Api/Pages/RequestParams/IPagesUpdateBodyParameters.cs +++ b/Src/Notion.Client/Api/Pages/RequestParams/IPagesUpdateBodyParameters.cs @@ -1,10 +1,14 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public interface IPagesUpdateBodyParameters { + [JsonProperty("archived")] bool Archived { get; set; } + + [JsonProperty("properties")] IDictionary Properties { get; set; } } } diff --git a/Src/Notion.Client/Api/Pages/RequestParams/PagesUpdateParameters.cs b/Src/Notion.Client/Api/Pages/RequestParams/PagesUpdateParameters.cs index 4e45cff6..40f06b12 100644 --- a/Src/Notion.Client/Api/Pages/RequestParams/PagesUpdateParameters.cs +++ b/Src/Notion.Client/Api/Pages/RequestParams/PagesUpdateParameters.cs @@ -5,8 +5,10 @@ namespace Notion.Client { public class PagesUpdateParameters : IPagesUpdateBodyParameters { + [JsonProperty("archived")] public bool Archived { get; set; } + [JsonProperty("properties")] public IDictionary Properties { get; set; } [JsonProperty("icon")] diff --git a/Src/Notion.Client/Api/Search/Parameters/ISearchBodyParameters.cs b/Src/Notion.Client/Api/Search/Parameters/ISearchBodyParameters.cs index 2f66aa48..18965000 100644 --- a/Src/Notion.Client/Api/Search/Parameters/ISearchBodyParameters.cs +++ b/Src/Notion.Client/Api/Search/Parameters/ISearchBodyParameters.cs @@ -1,9 +1,16 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { public interface ISearchBodyParameters : IPaginationParameters { + [JsonProperty("query")] string Query { get; set; } + + [JsonProperty("sort")] SearchSort Sort { get; set; } + + [JsonProperty("filter")] SearchFilter Filter { get; set; } } } diff --git a/Src/Notion.Client/Api/Search/Parameters/SearchSort.cs b/Src/Notion.Client/Api/Search/Parameters/SearchSort.cs index 5cc4bbfd..fed3f205 100644 --- a/Src/Notion.Client/Api/Search/Parameters/SearchSort.cs +++ b/Src/Notion.Client/Api/Search/Parameters/SearchSort.cs @@ -5,9 +5,11 @@ namespace Notion.Client { public class SearchSort { + [JsonProperty("direction")] [JsonConverter(typeof(StringEnumConverter))] public SearchDirection Direction { get; set; } + [JsonProperty("timestamp")] public string Timestamp { get; set; } } } diff --git a/Src/Notion.Client/Models/Blocks/Block.cs b/Src/Notion.Client/Models/Blocks/Block.cs index fa821cb1..60f68bf0 100644 --- a/Src/Notion.Client/Models/Blocks/Block.cs +++ b/Src/Notion.Client/Models/Blocks/Block.cs @@ -29,6 +29,7 @@ public class Block : IObject public ObjectType Object => ObjectType.Block; public string Id { get; set; } + [JsonProperty("type")] [JsonConverter(typeof(StringEnumConverter))] public virtual BlockType Type { get; set; } diff --git a/Src/Notion.Client/Models/Blocks/BulletedListItemBlock.cs b/Src/Notion.Client/Models/Blocks/BulletedListItemBlock.cs index 83f31c83..c787da86 100644 --- a/Src/Notion.Client/Models/Blocks/BulletedListItemBlock.cs +++ b/Src/Notion.Client/Models/Blocks/BulletedListItemBlock.cs @@ -12,7 +12,10 @@ public class BulletedListItemBlock : Block public class Info { + [JsonProperty("text")] public IEnumerable Text { get; set; } + + [JsonProperty("children")] public IEnumerable Children { get; set; } } } diff --git a/Src/Notion.Client/Models/Blocks/ChildPageBlock.cs b/Src/Notion.Client/Models/Blocks/ChildPageBlock.cs index 66a9489d..9fdc4b7b 100644 --- a/Src/Notion.Client/Models/Blocks/ChildPageBlock.cs +++ b/Src/Notion.Client/Models/Blocks/ChildPageBlock.cs @@ -11,6 +11,7 @@ public class ChildPageBlock : Block public class Info { + [JsonProperty("title")] public string Title { get; set; } } } diff --git a/Src/Notion.Client/Models/Blocks/HeadingOneBlock.cs b/Src/Notion.Client/Models/Blocks/HeadingOneBlock.cs index 7cab0370..2105cefe 100644 --- a/Src/Notion.Client/Models/Blocks/HeadingOneBlock.cs +++ b/Src/Notion.Client/Models/Blocks/HeadingOneBlock.cs @@ -14,6 +14,7 @@ public class HeadingOneBlock : Block public class Info { + [JsonProperty("text")] public IEnumerable Text { get; set; } } } diff --git a/Src/Notion.Client/Models/Blocks/HeadingThreeeBlock.cs b/Src/Notion.Client/Models/Blocks/HeadingThreeeBlock.cs index d64b57fa..4f1ca0a0 100644 --- a/Src/Notion.Client/Models/Blocks/HeadingThreeeBlock.cs +++ b/Src/Notion.Client/Models/Blocks/HeadingThreeeBlock.cs @@ -14,6 +14,7 @@ public class HeadingThreeeBlock : Block public class Info { + [JsonProperty("text")] public IEnumerable Text { get; set; } } } diff --git a/Src/Notion.Client/Models/Blocks/HeadingTwoBlock.cs b/Src/Notion.Client/Models/Blocks/HeadingTwoBlock.cs index 88835f3c..5b07e758 100644 --- a/Src/Notion.Client/Models/Blocks/HeadingTwoBlock.cs +++ b/Src/Notion.Client/Models/Blocks/HeadingTwoBlock.cs @@ -14,6 +14,7 @@ public class HeadingTwoBlock : Block public class Info { + [JsonProperty("text")] public IEnumerable Text { get; set; } } } diff --git a/Src/Notion.Client/Models/Blocks/NumberedListItemBlock.cs b/Src/Notion.Client/Models/Blocks/NumberedListItemBlock.cs index 27fc29fd..3d233af3 100644 --- a/Src/Notion.Client/Models/Blocks/NumberedListItemBlock.cs +++ b/Src/Notion.Client/Models/Blocks/NumberedListItemBlock.cs @@ -12,7 +12,10 @@ public class NumberedListItemBlock : Block public class Info { + [JsonProperty("text")] public IEnumerable Text { 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 96b4c239..ebce97a7 100644 --- a/Src/Notion.Client/Models/Blocks/ParagraphBlock.cs +++ b/Src/Notion.Client/Models/Blocks/ParagraphBlock.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { @@ -6,11 +7,15 @@ public class ParagraphBlock : Block { public override BlockType Type => BlockType.Paragraph; + [JsonProperty("paragraph")] public Info Paragraph { get; set; } public class Info { + [JsonProperty("text")] public IEnumerable Text { 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 aeff42f2..da6518a2 100644 --- a/Src/Notion.Client/Models/Blocks/ToDoBlock.cs +++ b/Src/Notion.Client/Models/Blocks/ToDoBlock.cs @@ -12,11 +12,13 @@ public class ToDoBlock : Block public class Info { + [JsonProperty("text")] public IEnumerable Text { get; set; } [JsonProperty("checked")] public bool IsChecked { get; set; } + [JsonProperty("children")] public IEnumerable Children { get; set; } } } diff --git a/Src/Notion.Client/Models/Blocks/ToggleBlock.cs b/Src/Notion.Client/Models/Blocks/ToggleBlock.cs index 6fc6f3df..3da4d6d7 100644 --- a/Src/Notion.Client/Models/Blocks/ToggleBlock.cs +++ b/Src/Notion.Client/Models/Blocks/ToggleBlock.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { @@ -6,11 +7,15 @@ public class ToggleBlock : Block { public override BlockType Type => BlockType.Toggle; + [JsonProperty("toggle")] public Info Toggle { get; set; } public class Info { + [JsonProperty("text")] public IEnumerable Text { get; set; } + + [JsonProperty("children")] public IEnumerable Children { get; set; } } } diff --git a/Src/Notion.Client/Models/Database/Properties/CheckboxProperty.cs b/Src/Notion.Client/Models/Database/Properties/CheckboxProperty.cs index ff0e450b..146e6401 100644 --- a/Src/Notion.Client/Models/Database/Properties/CheckboxProperty.cs +++ b/Src/Notion.Client/Models/Database/Properties/CheckboxProperty.cs @@ -1,10 +1,13 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class CheckboxProperty : Property { public override PropertyType Type => PropertyType.Checkbox; + + [JsonProperty("checkbox")] public Dictionary Checkbox { get; set; } } } diff --git a/Src/Notion.Client/Models/Database/Properties/DateProperty.cs b/Src/Notion.Client/Models/Database/Properties/DateProperty.cs index 942f56c9..03e79c97 100644 --- a/Src/Notion.Client/Models/Database/Properties/DateProperty.cs +++ b/Src/Notion.Client/Models/Database/Properties/DateProperty.cs @@ -1,10 +1,13 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class DateProperty : Property { public override PropertyType Type => PropertyType.Date; + + [JsonProperty("date")] public Dictionary Date { get; set; } } } diff --git a/Src/Notion.Client/Models/Database/Properties/EmailProperty.cs b/Src/Notion.Client/Models/Database/Properties/EmailProperty.cs index 7c8b596c..defde555 100644 --- a/Src/Notion.Client/Models/Database/Properties/EmailProperty.cs +++ b/Src/Notion.Client/Models/Database/Properties/EmailProperty.cs @@ -1,10 +1,13 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class EmailProperty : Property { public override PropertyType Type => PropertyType.Email; + + [JsonProperty("email")] public Dictionary Email { get; set; } } } diff --git a/Src/Notion.Client/Models/Database/Properties/FilesProperty.cs b/Src/Notion.Client/Models/Database/Properties/FilesProperty.cs index f52277c9..48ae3475 100644 --- a/Src/Notion.Client/Models/Database/Properties/FilesProperty.cs +++ b/Src/Notion.Client/Models/Database/Properties/FilesProperty.cs @@ -1,10 +1,13 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class FilesProperty : Property { public override PropertyType Type => PropertyType.Files; + + [JsonProperty("files")] public Dictionary Files { get; set; } } } diff --git a/Src/Notion.Client/Models/Database/Properties/FormulaProperty.cs b/Src/Notion.Client/Models/Database/Properties/FormulaProperty.cs index 184f9be0..82e4a240 100644 --- a/Src/Notion.Client/Models/Database/Properties/FormulaProperty.cs +++ b/Src/Notion.Client/Models/Database/Properties/FormulaProperty.cs @@ -1,14 +1,18 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { public class FormulaProperty : Property { public override PropertyType Type => PropertyType.Formula; + [JsonProperty("formula")] public Formula Formula { get; set; } } public class Formula { + [JsonProperty("expression")] public string Expression { get; set; } } } diff --git a/Src/Notion.Client/Models/Database/Properties/NumberProperty.cs b/Src/Notion.Client/Models/Database/Properties/NumberProperty.cs index 1905b2f0..a00d7d9b 100644 --- a/Src/Notion.Client/Models/Database/Properties/NumberProperty.cs +++ b/Src/Notion.Client/Models/Database/Properties/NumberProperty.cs @@ -7,11 +7,14 @@ namespace Notion.Client public class NumberProperty : Property { public override PropertyType Type => PropertyType.Number; + + [JsonProperty("number")] public Number Number { get; set; } } public class Number { + [JsonProperty("format")] [JsonConverter(typeof(StringEnumConverter))] public NumberFormat Format { get; set; } } diff --git a/Src/Notion.Client/Models/Database/Properties/PeopleProperty.cs b/Src/Notion.Client/Models/Database/Properties/PeopleProperty.cs index 002ee200..c21d2fbd 100644 --- a/Src/Notion.Client/Models/Database/Properties/PeopleProperty.cs +++ b/Src/Notion.Client/Models/Database/Properties/PeopleProperty.cs @@ -1,10 +1,13 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class PeopleProperty : Property { public override PropertyType Type => PropertyType.People; + + [JsonProperty("people")] public Dictionary People { get; set; } } } diff --git a/Src/Notion.Client/Models/Database/Properties/Property.cs b/Src/Notion.Client/Models/Database/Properties/Property.cs index 3201cc39..30ecd151 100644 --- a/Src/Notion.Client/Models/Database/Properties/Property.cs +++ b/Src/Notion.Client/Models/Database/Properties/Property.cs @@ -26,11 +26,14 @@ namespace Notion.Client [JsonSubtypes.KnownSubType(typeof(UrlProperty), PropertyType.Url)] public class Property { + [JsonProperty("id")] public string Id { get; set; } + [JsonProperty("type")] [JsonConverter(typeof(StringEnumConverter))] public virtual PropertyType Type { get; set; } + [JsonProperty("name")] public string Name { get; set; } } } diff --git a/Src/Notion.Client/Models/Database/Properties/RelationProperty.cs b/Src/Notion.Client/Models/Database/Properties/RelationProperty.cs index 0c595369..8c55bc80 100644 --- a/Src/Notion.Client/Models/Database/Properties/RelationProperty.cs +++ b/Src/Notion.Client/Models/Database/Properties/RelationProperty.cs @@ -6,6 +6,8 @@ public class RelationProperty : Property { public override PropertyType Type => PropertyType.Relation; + + [JsonProperty("relation")] public Relation Relation { get; set; } } diff --git a/Src/Notion.Client/Models/Database/Properties/RollupProperty.cs b/Src/Notion.Client/Models/Database/Properties/RollupProperty.cs index b323e55c..fa0c4b92 100644 --- a/Src/Notion.Client/Models/Database/Properties/RollupProperty.cs +++ b/Src/Notion.Client/Models/Database/Properties/RollupProperty.cs @@ -8,6 +8,7 @@ public class RollupProperty : Property { public override PropertyType Type => PropertyType.Rollup; + [JsonProperty("rollup")] public Rollup Rollup { get; set; } } diff --git a/Src/Notion.Client/Models/Database/Properties/SelectProperty.cs b/Src/Notion.Client/Models/Database/Properties/SelectProperty.cs index 23d60afc..6d678ae2 100644 --- a/Src/Notion.Client/Models/Database/Properties/SelectProperty.cs +++ b/Src/Notion.Client/Models/Database/Properties/SelectProperty.cs @@ -13,14 +13,28 @@ public class SelectProperty : Property public class OptionWrapper { + [JsonProperty("options")] public List Options { get; set; } } public class SelectOption { + /// + /// Name of the option as it appears in Notion. + /// + [JsonProperty("name")] public string Name { get; set; } + + /// + /// ID of the option. + /// + [JsonProperty("id")] public string Id { get; set; } + /// + /// Color of the option. Possible values are: "default", "gray", "brown", "red", "orange", "yellow", "green", "blue", "purple", "pink". Defaults to "default". + /// + [JsonProperty("color")] [JsonConverter(typeof(StringEnumConverter))] public Color Color { get; set; } } diff --git a/Src/Notion.Client/Models/Database/Properties/TitleProperty.cs b/Src/Notion.Client/Models/Database/Properties/TitleProperty.cs index afa4f5e2..2268d0ad 100644 --- a/Src/Notion.Client/Models/Database/Properties/TitleProperty.cs +++ b/Src/Notion.Client/Models/Database/Properties/TitleProperty.cs @@ -1,10 +1,13 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class TitleProperty : Property { public override PropertyType Type => PropertyType.Title; + + [JsonProperty("title")] public Dictionary Title { get; set; } } } diff --git a/Src/Notion.Client/Models/Database/Properties/UrlProperty.cs b/Src/Notion.Client/Models/Database/Properties/UrlProperty.cs index 8cade5ef..451ef911 100644 --- a/Src/Notion.Client/Models/Database/Properties/UrlProperty.cs +++ b/Src/Notion.Client/Models/Database/Properties/UrlProperty.cs @@ -1,10 +1,13 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { public class UrlProperty : Property { public override PropertyType Type => PropertyType.Url; + + [JsonProperty("url")] public Dictionary Url { get; set; } } } diff --git a/Src/Notion.Client/Models/Database/RichText/RichTextBase.cs b/Src/Notion.Client/Models/Database/RichText/RichTextBase.cs index dd7d6e0a..1c9a7610 100644 --- a/Src/Notion.Client/Models/Database/RichText/RichTextBase.cs +++ b/Src/Notion.Client/Models/Database/RichText/RichTextBase.cs @@ -13,10 +13,13 @@ public class RichTextBase [JsonProperty("plain_text")] public string PlainText { get; set; } + [JsonProperty("href")] public string Href { get; set; } + [JsonProperty("annotations")] public Annotations Annotations { get; set; } + [JsonProperty("type")] [JsonConverter(typeof(StringEnumConverter))] public virtual RichTextType Type { get; set; } } @@ -38,6 +41,7 @@ public class Annotations [JsonProperty("code")] public bool IsCode { get; set; } + [JsonProperty("color")] // color: Color | BackgroundColor public string Color { get; set; } } diff --git a/Src/Notion.Client/Models/Database/RichText/RichTextEquation.cs b/Src/Notion.Client/Models/Database/RichText/RichTextEquation.cs index 76c7a0df..05412cac 100644 --- a/Src/Notion.Client/Models/Database/RichText/RichTextEquation.cs +++ b/Src/Notion.Client/Models/Database/RichText/RichTextEquation.cs @@ -1,13 +1,18 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { public class RichTextEquation : RichTextBase { public override RichTextType Type => RichTextType.Equation; + + [JsonProperty("equation")] public Equation Equation { get; set; } } public class Equation { + [JsonProperty("expression")] public string Expression { get; set; } } } diff --git a/Src/Notion.Client/Models/Database/RichText/RichTextMention.cs b/Src/Notion.Client/Models/Database/RichText/RichTextMention.cs index 5c6fbe79..02f6beb0 100644 --- a/Src/Notion.Client/Models/Database/RichText/RichTextMention.cs +++ b/Src/Notion.Client/Models/Database/RichText/RichTextMention.cs @@ -1,22 +1,36 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { public class RichTextMention : RichTextBase { public override RichTextType Type => RichTextType.Mention; + + [JsonProperty("mention")] public Mention Mention { get; set; } } public class Mention { + [JsonProperty("type")] public string Type { get; set; } + + [JsonProperty("user")] public User User { get; set; } + + [JsonProperty("page")] public ObjectId Page { get; set; } + + [JsonProperty("database")] public ObjectId Database { get; set; } + + [JsonProperty("date")] public DatePropertyValue Date { get; set; } } public class ObjectId { + [JsonProperty("id")] public string Id { get; set; } } } diff --git a/Src/Notion.Client/Models/Database/RichText/RichTextText.cs b/Src/Notion.Client/Models/Database/RichText/RichTextText.cs index 2d2c7b31..52982061 100644 --- a/Src/Notion.Client/Models/Database/RichText/RichTextText.cs +++ b/Src/Notion.Client/Models/Database/RichText/RichTextText.cs @@ -1,20 +1,30 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { public class RichTextText : RichTextBase { public override RichTextType Type => RichTextType.Text; + + [JsonProperty("text")] public Text Text { get; set; } } public class Text { + [JsonProperty("content")] public string Content { get; set; } + + [JsonProperty("link")] public Link Link { get; set; } } public class Link { + [JsonProperty("type")] public string Type => "url"; + + [JsonProperty("url")] public string Url { get; set; } } } diff --git a/Src/Notion.Client/Models/Filters/Checkbox.cs b/Src/Notion.Client/Models/Filters/Checkbox.cs index 93107bfc..1eb73e2e 100644 --- a/Src/Notion.Client/Models/Filters/Checkbox.cs +++ b/Src/Notion.Client/Models/Filters/Checkbox.cs @@ -5,6 +5,7 @@ namespace Notion.Client { public class CheckboxFilter : SinglePropertyFilter { + [JsonProperty("checkbox")] public Condition Checkbox { get; set; } public CheckboxFilter( diff --git a/Src/Notion.Client/Models/Filters/Date.cs b/Src/Notion.Client/Models/Filters/Date.cs index c6a2d589..44b29fb9 100644 --- a/Src/Notion.Client/Models/Filters/Date.cs +++ b/Src/Notion.Client/Models/Filters/Date.cs @@ -7,6 +7,7 @@ namespace Notion.Client { public class DateFilter : SinglePropertyFilter { + [JsonProperty("date")] public Condition Date { get; set; } public DateFilter( diff --git a/Src/Notion.Client/Models/Filters/Files.cs b/Src/Notion.Client/Models/Filters/Files.cs index af86f915..e20f863d 100644 --- a/Src/Notion.Client/Models/Filters/Files.cs +++ b/Src/Notion.Client/Models/Filters/Files.cs @@ -5,6 +5,7 @@ namespace Notion.Client public class FilesFilter : SinglePropertyFilter { + [JsonProperty("files")] public Condition Files { get; set; } public FilesFilter( diff --git a/Src/Notion.Client/Models/Filters/Filter.cs b/Src/Notion.Client/Models/Filters/Filter.cs index d905d599..61f81f7e 100644 --- a/Src/Notion.Client/Models/Filters/Filter.cs +++ b/Src/Notion.Client/Models/Filters/Filter.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { @@ -9,12 +10,16 @@ public class Filter public class SinglePropertyFilter : Filter { + [JsonProperty("property")] public string Property { get; set; } } public class CompoundFilter : Filter { + [JsonProperty("or")] public List Or { get; set; } + + [JsonProperty("and")] public List And { get; set; } public CompoundFilter(List or = null, List and = null) diff --git a/Src/Notion.Client/Models/Filters/Formula.cs b/Src/Notion.Client/Models/Filters/Formula.cs index afab84d8..82b58cc8 100644 --- a/Src/Notion.Client/Models/Filters/Formula.cs +++ b/Src/Notion.Client/Models/Filters/Formula.cs @@ -1,7 +1,10 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { public class FormulaFilter : SinglePropertyFilter { + [JsonProperty("formula")] public Condition Formula { get; set; } public FormulaFilter( @@ -22,9 +25,16 @@ public FormulaFilter( 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( diff --git a/Src/Notion.Client/Models/Filters/Multiselect.cs b/Src/Notion.Client/Models/Filters/Multiselect.cs index 03ea62b0..bf69d110 100644 --- a/Src/Notion.Client/Models/Filters/Multiselect.cs +++ b/Src/Notion.Client/Models/Filters/Multiselect.cs @@ -26,6 +26,7 @@ public MultiSelectFilter( public class Condition { + [JsonProperty("contains")] public string Contains { get; set; } [JsonProperty("does_not_contain")] diff --git a/Src/Notion.Client/Models/Filters/Number.cs b/Src/Notion.Client/Models/Filters/Number.cs index 15b6158c..9282226a 100644 --- a/Src/Notion.Client/Models/Filters/Number.cs +++ b/Src/Notion.Client/Models/Filters/Number.cs @@ -4,6 +4,7 @@ namespace Notion.Client { public class NumberFilter : SinglePropertyFilter { + [JsonProperty("number")] public Condition Number { get; set; } public NumberFilter( diff --git a/Src/Notion.Client/Models/Filters/People.cs b/Src/Notion.Client/Models/Filters/People.cs index 8b2fcd23..6138e3d2 100644 --- a/Src/Notion.Client/Models/Filters/People.cs +++ b/Src/Notion.Client/Models/Filters/People.cs @@ -4,6 +4,7 @@ namespace Notion.Client { public class PeopleFilter : SinglePropertyFilter { + [JsonProperty("people")] public Condition People { get; set; } public PeopleFilter( @@ -24,6 +25,7 @@ public PeopleFilter( public class Condition { + [JsonProperty("contains")] public string Contains { get; set; } [JsonProperty("does_not_contain")] diff --git a/Src/Notion.Client/Models/Filters/Relation.cs b/Src/Notion.Client/Models/Filters/Relation.cs index 7d34bd7e..26f7214a 100644 --- a/Src/Notion.Client/Models/Filters/Relation.cs +++ b/Src/Notion.Client/Models/Filters/Relation.cs @@ -4,6 +4,7 @@ namespace Notion.Client { public class RelationFilter : SinglePropertyFilter { + [JsonProperty("relation")] public Condition Relation { get; set; } public RelationFilter( @@ -24,6 +25,7 @@ public RelationFilter( public class Condition { + [JsonProperty("contains")] public string Contains { get; set; } [JsonProperty("does_not_contain")] diff --git a/Src/Notion.Client/Models/Filters/Select.cs b/Src/Notion.Client/Models/Filters/Select.cs index b7f29f11..bf246be2 100644 --- a/Src/Notion.Client/Models/Filters/Select.cs +++ b/Src/Notion.Client/Models/Filters/Select.cs @@ -4,6 +4,7 @@ namespace Notion.Client { public class SelectFilter : SinglePropertyFilter { + [JsonProperty("select")] public Condition Select { get; set; } public SelectFilter( diff --git a/Src/Notion.Client/Models/Filters/Text.cs b/Src/Notion.Client/Models/Filters/Text.cs index 0b2d187f..3446e854 100644 --- a/Src/Notion.Client/Models/Filters/Text.cs +++ b/Src/Notion.Client/Models/Filters/Text.cs @@ -4,6 +4,7 @@ namespace Notion.Client { public class TextFilter : SinglePropertyFilter { + [JsonProperty("text")] public Condition Text { get; set; } public TextFilter( @@ -38,6 +39,7 @@ public class Condition [JsonProperty("does_not_equal")] public string DoesNotEqual { get; set; } + [JsonProperty("contains")] public string Contains { get; set; } [JsonProperty("does_not_contain")] diff --git a/Src/Notion.Client/Models/IObject.cs b/Src/Notion.Client/Models/IObject.cs index 73e4b90f..98f50f3f 100644 --- a/Src/Notion.Client/Models/IObject.cs +++ b/Src/Notion.Client/Models/IObject.cs @@ -11,8 +11,10 @@ namespace Notion.Client [JsonSubtypes.KnownSubType(typeof(User), ObjectType.User)] public interface IObject { + [JsonProperty("id")] string Id { get; set; } + [JsonProperty("object")] [JsonConverter(typeof(StringEnumConverter))] ObjectType Object { get; } } diff --git a/Src/Notion.Client/Models/Page/Page.cs b/Src/Notion.Client/Models/Page/Page.cs index e6b4921c..352f9d13 100644 --- a/Src/Notion.Client/Models/Page/Page.cs +++ b/Src/Notion.Client/Models/Page/Page.cs @@ -6,31 +6,61 @@ namespace Notion.Client { public class Page : IObject { + /// + /// Object type + /// public ObjectType Object => ObjectType.Page; + /// + /// Unique identifier of the page. + /// public string Id { get; set; } + /// + /// The parent of this page. Can be a database, page, or workspace. + /// [JsonProperty("parent")] public IPageParent Parent { get; set; } + /// + /// Date and time when this page was created. + /// [JsonProperty("created_time")] public DateTime CreatedTime { get; set; } + /// + /// Date and time when this page was updated. + /// [JsonProperty("last_edited_time")] public DateTime LastEditedTime { get; set; } + /// + /// The archived status of the page. + /// [JsonProperty("archived")] public bool IsArchived { get; set; } + /// + /// Property values of this page. + /// [JsonProperty("properties")] public IDictionary Properties { get; set; } + /// + /// The URL of the Notion page. + /// [JsonProperty("url")] public string Url { get; set; } + /// + /// Page icon. + /// [JsonProperty("icon")] public IPageIcon Icon { get; set; } + /// + /// Page cover image. + /// [JsonProperty("cover")] public FileObject Cover { get; set; } } diff --git a/Src/Notion.Client/Models/PaginatedList.cs b/Src/Notion.Client/Models/PaginatedList.cs index 05881b26..e126125a 100644 --- a/Src/Notion.Client/Models/PaginatedList.cs +++ b/Src/Notion.Client/Models/PaginatedList.cs @@ -14,8 +14,10 @@ public interface IPaginationParameters public class PaginatedList { + [JsonProperty("object")] public const string Object = "list"; + [JsonProperty("results")] public List Results { get; set; } [JsonProperty("has_more")] diff --git a/Src/Notion.Client/Models/Parents/DatabaseParent.cs b/Src/Notion.Client/Models/Parents/DatabaseParent.cs index 6c262b79..c3e028e7 100644 --- a/Src/Notion.Client/Models/Parents/DatabaseParent.cs +++ b/Src/Notion.Client/Models/Parents/DatabaseParent.cs @@ -4,8 +4,14 @@ namespace Notion.Client { public class DatabaseParent : IPageParent { + /// + /// Always "database_id" + /// public ParentType Type { get; set; } + /// + /// The ID of the database that this page belongs to. + /// [JsonProperty("database_id")] public string DatabaseId { get; set; } } diff --git a/Src/Notion.Client/Models/Parents/PageParent.cs b/Src/Notion.Client/Models/Parents/PageParent.cs index 6abd7263..ff185747 100644 --- a/Src/Notion.Client/Models/Parents/PageParent.cs +++ b/Src/Notion.Client/Models/Parents/PageParent.cs @@ -4,8 +4,15 @@ namespace Notion.Client { public class PageParent : IPageParent, IDatabaseParent { + /// + /// Always "page_id". + /// + public ParentType Type { get; set; } + + /// + /// The ID of the page that this page belongs to. + /// [JsonProperty("page_id")] public string PageId { get; set; } - public ParentType Type { get; set; } } } diff --git a/Src/Notion.Client/Models/Parents/WorkspaceParent.cs b/Src/Notion.Client/Models/Parents/WorkspaceParent.cs index c0f0f4cf..fc645b60 100644 --- a/Src/Notion.Client/Models/Parents/WorkspaceParent.cs +++ b/Src/Notion.Client/Models/Parents/WorkspaceParent.cs @@ -2,6 +2,9 @@ { public class WorkspaceParent : IPageParent, IDatabaseParent { + /// + /// Always "workspace". + /// public ParentType Type { get; set; } } } diff --git a/Src/Notion.Client/Models/PropertyValue/CheckboxPropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/CheckboxPropertyValue.cs index 3d9fb7fa..1f3fec50 100644 --- a/Src/Notion.Client/Models/PropertyValue/CheckboxPropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/CheckboxPropertyValue.cs @@ -1,9 +1,15 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { + /// + /// Checkbox property value objects contain a boolean within the checkbox property. + /// public class CheckboxPropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.Checkbox; + [JsonProperty("checkbox")] public bool Checkbox { get; set; } } } diff --git a/Src/Notion.Client/Models/PropertyValue/CreatedByPropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/CreatedByPropertyValue.cs index 8e78b564..17fa4ef4 100644 --- a/Src/Notion.Client/Models/PropertyValue/CreatedByPropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/CreatedByPropertyValue.cs @@ -2,10 +2,16 @@ namespace Notion.Client { + /// + /// Created by property value object + /// public class CreatedByPropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.CreatedBy; + /// + /// Describes the user who created this page. + /// [JsonProperty("created_by")] public User CreatedBy { get; set; } } diff --git a/Src/Notion.Client/Models/PropertyValue/CreatedTimePropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/CreatedTimePropertyValue.cs index 6885f1fe..0b20b2dc 100644 --- a/Src/Notion.Client/Models/PropertyValue/CreatedTimePropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/CreatedTimePropertyValue.cs @@ -2,10 +2,16 @@ namespace Notion.Client { + /// + /// Created time property value object. + /// public class CreatedTimePropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.CreatedTime; + /// + /// The date and time when this page was created. + /// [JsonProperty("created_time")] public string CreatedTime { get; set; } } diff --git a/Src/Notion.Client/Models/PropertyValue/DatePropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/DatePropertyValue.cs index 0fc98859..6182b197 100644 --- a/Src/Notion.Client/Models/PropertyValue/DatePropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/DatePropertyValue.cs @@ -1,16 +1,37 @@ using System; +using Newtonsoft.Json; namespace Notion.Client { + /// + /// Date property value object. + /// public class DatePropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.Date; + + /// + /// Date + /// + [JsonProperty("date")] public Date Date { get; set; } } + /// + /// Date value object. + /// public class Date { + /// + /// Start date with optional time. + /// + [JsonProperty("start")] public DateTime? Start { get; set; } + + /// + /// End date with optional time. + /// + [JsonProperty("end")] public DateTime? End { get; set; } } } diff --git a/Src/Notion.Client/Models/PropertyValue/EmailPropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/EmailPropertyValue.cs index 095f060c..1869fc85 100644 --- a/Src/Notion.Client/Models/PropertyValue/EmailPropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/EmailPropertyValue.cs @@ -1,9 +1,18 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { + /// + /// Email property value object. + /// public class EmailPropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.Email; + /// + /// Describes an email address. + /// + [JsonProperty("email")] public string Email { get; set; } } } diff --git a/Src/Notion.Client/Models/PropertyValue/FilesPropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/FilesPropertyValue.cs index bd144643..c712379f 100644 --- a/Src/Notion.Client/Models/PropertyValue/FilesPropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/FilesPropertyValue.cs @@ -1,11 +1,19 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { + /// + /// File property value object. + /// public class FilesPropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.Files; + /// + /// Array of File Object with name. + /// + [JsonProperty("files")] public List Files { get; set; } } diff --git a/Src/Notion.Client/Models/PropertyValue/FormulaPropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/FormulaPropertyValue.cs index 49ce4c53..e85fd5bd 100644 --- a/Src/Notion.Client/Models/PropertyValue/FormulaPropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/FormulaPropertyValue.cs @@ -1,18 +1,54 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { + /// + /// Formula property value object. + /// public class FormulaPropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.Formula; + /// + /// A formula described in the database's properties. + /// + [JsonProperty("formula")] public FormulaValue Formula { get; set; } } + /// + /// Formula value object. + /// public class FormulaValue { + /// + /// Formula value type + /// + [JsonProperty("type")] public string Type { get; set; } + + /// + /// String formula value. + /// + [JsonProperty("string")] public string String { get; set; } + + /// + /// Number formula value. + /// + [JsonProperty("number")] public double? Number { get; set; } + + /// + /// Boolean formula value. + /// + [JsonProperty("boolean")] public bool? Boolean { get; set; } + + /// + /// Date formula value + /// + [JsonProperty("date")] public Date Date { get; set; } } } diff --git a/Src/Notion.Client/Models/PropertyValue/LastEditedByPropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/LastEditedByPropertyValue.cs index 56e216a7..b5e26efc 100644 --- a/Src/Notion.Client/Models/PropertyValue/LastEditedByPropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/LastEditedByPropertyValue.cs @@ -2,10 +2,16 @@ namespace Notion.Client { + /// + /// Last edited by property value object. + /// public class LastEditedByPropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.LastEditedBy; + /// + /// Describes the user who last updated this page. + /// [JsonProperty("last_edited_by")] public User LastEditedBy { get; set; } } diff --git a/Src/Notion.Client/Models/PropertyValue/LastEditedTimePropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/LastEditedTimePropertyValue.cs index cdb192f5..785ac3bc 100644 --- a/Src/Notion.Client/Models/PropertyValue/LastEditedTimePropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/LastEditedTimePropertyValue.cs @@ -2,10 +2,16 @@ namespace Notion.Client { + /// + /// Last edited time property value object. + /// public class LastEditedTimePropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.LastEditedTime; + /// + /// The date and time when this page was last updated. + /// [JsonProperty("last_edited_time")] public string LastEditedTime { get; set; } } diff --git a/Src/Notion.Client/Models/PropertyValue/MultiSelectPropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/MultiSelectPropertyValue.cs index 71dc8327..a5ee4f0a 100644 --- a/Src/Notion.Client/Models/PropertyValue/MultiSelectPropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/MultiSelectPropertyValue.cs @@ -3,10 +3,16 @@ namespace Notion.Client { + /// + /// Multi-select property value object. + /// public class MultiSelectPropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.MultiSelect; + /// + /// An array of multi-select option values. + /// [JsonProperty("multi_select")] public List MultiSelect { get; set; } } diff --git a/Src/Notion.Client/Models/PropertyValue/NumberPropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/NumberPropertyValue.cs index 4f95dceb..863d5f1b 100644 --- a/Src/Notion.Client/Models/PropertyValue/NumberPropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/NumberPropertyValue.cs @@ -1,8 +1,18 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { + /// + /// Number formula property value object. + /// public class NumberPropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.Number; + + /// + /// Value of number + /// + [JsonProperty("number")] public double Number { get; set; } } } diff --git a/Src/Notion.Client/Models/PropertyValue/PeoplePropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/PeoplePropertyValue.cs index 734368d9..047d33ee 100644 --- a/Src/Notion.Client/Models/PropertyValue/PeoplePropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/PeoplePropertyValue.cs @@ -1,10 +1,19 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { + /// + /// People property value object. + /// public class PeoplePropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.People; + + /// + /// List of users. + /// + [JsonProperty("people")] public List People { get; set; } } } diff --git a/Src/Notion.Client/Models/PropertyValue/PhoneNumberPropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/PhoneNumberPropertyValue.cs index d4f4610c..be5e482e 100644 --- a/Src/Notion.Client/Models/PropertyValue/PhoneNumberPropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/PhoneNumberPropertyValue.cs @@ -2,10 +2,16 @@ namespace Notion.Client { + /// + /// Phone number property value object. + /// public class PhoneNumberPropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.PhoneNumber; + /// + /// Phone number value + /// [JsonProperty("phone_number")] public string PhoneNumber { get; set; } } diff --git a/Src/Notion.Client/Models/PropertyValue/PropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/PropertyValue.cs index 6c831746..c85ebbdc 100644 --- a/Src/Notion.Client/Models/PropertyValue/PropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/PropertyValue.cs @@ -4,6 +4,9 @@ namespace Notion.Client { + /// + /// An object describing the identifier, type, and value of a page property. + /// [JsonConverter(typeof(JsonSubtypes), "type")] [JsonSubtypes.KnownSubType(typeof(CheckboxPropertyValue), PropertyValueType.Checkbox)] [JsonSubtypes.KnownSubType(typeof(CreatedByPropertyValue), PropertyValueType.CreatedBy)] @@ -26,6 +29,10 @@ namespace Notion.Client [JsonSubtypes.KnownSubType(typeof(UrlPropertyValue), PropertyValueType.Url)] public class PropertyValue { + /// + /// Underlying identifier of the property. + /// + [JsonProperty("id")] public string Id { get; set; } [JsonConverter(typeof(StringEnumConverter))] diff --git a/Src/Notion.Client/Models/PropertyValue/PropertyValueType.cs b/Src/Notion.Client/Models/PropertyValue/PropertyValueType.cs index e34563df..4a4b8189 100644 --- a/Src/Notion.Client/Models/PropertyValue/PropertyValueType.cs +++ b/Src/Notion.Client/Models/PropertyValue/PropertyValueType.cs @@ -2,6 +2,9 @@ namespace Notion.Client { + /// + /// Types of Property Value + /// public enum PropertyValueType { [EnumMember(Value = null)] diff --git a/Src/Notion.Client/Models/PropertyValue/RelationPropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/RelationPropertyValue.cs index e6195a57..3d11a096 100644 --- a/Src/Notion.Client/Models/PropertyValue/RelationPropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/RelationPropertyValue.cs @@ -1,7 +1,11 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { + /// + /// Relation property value object. + /// public class RelationPropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.Relation; @@ -9,6 +13,7 @@ public class RelationPropertyValue : PropertyValue /// /// Array of page references /// + [JsonProperty("relation")] public List Relation { get; set; } } } diff --git a/Src/Notion.Client/Models/PropertyValue/RichTextPropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/RichTextPropertyValue.cs index ad9b48f3..028ed046 100644 --- a/Src/Notion.Client/Models/PropertyValue/RichTextPropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/RichTextPropertyValue.cs @@ -3,10 +3,16 @@ namespace Notion.Client { + /// + /// Rich Text property value object. + /// public class RichTextPropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.RichText; + /// + /// List of rich text objects + /// [JsonProperty("rich_text")] public List RichText { get; set; } } diff --git a/Src/Notion.Client/Models/PropertyValue/RollupPropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/RollupPropertyValue.cs index d5ef5f53..c6587226 100644 --- a/Src/Notion.Client/Models/PropertyValue/RollupPropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/RollupPropertyValue.cs @@ -1,23 +1,47 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { + /// + /// Rollup property value object. + /// public class RollupPropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.Rollup; + [JsonProperty("rollup")] public RollupValue Rollup { get; set; } } + /// + /// Object containing rollup type-specific data. + /// public class RollupValue { + /// + /// The type of rollup. Possible values are "number", "date", and "array". + /// + [JsonProperty("type")] public string Type { get; set; } + + /// + /// Number rollup property values contain a number + /// + [JsonProperty("number")] public double Number { get; set; } + + /// + /// Date rollup property values contain a date property value. + /// + [JsonProperty("date")] public DatePropertyValue Date { get; set; } /// - /// Array containing the propert value object will not contain value for Id field + /// Array rollup property values contain an array of element objects. + /// Array containing the property value object will not contain value for Id field /// + [JsonProperty("array")] public List Array { get; set; } } } diff --git a/Src/Notion.Client/Models/PropertyValue/SelectPropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/SelectPropertyValue.cs index d4140d3a..07b2a346 100644 --- a/Src/Notion.Client/Models/PropertyValue/SelectPropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/SelectPropertyValue.cs @@ -1,8 +1,15 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { + /// + /// Select property value object. + /// public class SelectPropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.Select; + + [JsonProperty("select")] public SelectOption Select { get; set; } } } diff --git a/Src/Notion.Client/Models/PropertyValue/TitlePropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/TitlePropertyValue.cs index 80e4aa8d..58b7842d 100644 --- a/Src/Notion.Client/Models/PropertyValue/TitlePropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/TitlePropertyValue.cs @@ -1,10 +1,19 @@ using System.Collections.Generic; +using Newtonsoft.Json; namespace Notion.Client { + /// + /// Title property value object. + /// public class TitlePropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.Title; + + /// + /// An array of rich text objects + /// + [JsonProperty("title")] public List Title { get; set; } } } diff --git a/Src/Notion.Client/Models/PropertyValue/UrlPropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/UrlPropertyValue.cs index cf69a78b..08b800e6 100644 --- a/Src/Notion.Client/Models/PropertyValue/UrlPropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/UrlPropertyValue.cs @@ -1,9 +1,18 @@ -namespace Notion.Client +using Newtonsoft.Json; + +namespace Notion.Client { + /// + /// URL property value object. + /// public class UrlPropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.Url; + /// + /// Describes a web address + /// + [JsonProperty("url")] public string Url { get; set; } } } diff --git a/Src/Notion.Client/Models/User.cs b/Src/Notion.Client/Models/User.cs index 032f1a88..ce39e822 100644 --- a/Src/Notion.Client/Models/User.cs +++ b/Src/Notion.Client/Models/User.cs @@ -6,18 +6,26 @@ public class User : IObject { public ObjectType Object => ObjectType.User; public string Id { get; set; } + + [JsonProperty("type")] public string Type { get; set; } + + [JsonProperty("name")] public string Name { get; set; } [JsonProperty("avatar_url")] public string AvatarUrl { get; set; } + [JsonProperty("person")] public Person Person { get; set; } + + [JsonProperty("bot")] public Bot Bot { get; set; } } public class Person { + [JsonProperty("email")] public string Email { get; set; } } From f95db70614dd765c976a9fc54d53e9a3e12f3b80 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 05:28:11 +0530 Subject: [PATCH 27/32] Add JsonProperty attribute --- Src/Notion.Client/Models/Database/Properties/RollupProperty.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Src/Notion.Client/Models/Database/Properties/RollupProperty.cs b/Src/Notion.Client/Models/Database/Properties/RollupProperty.cs index fa0c4b92..5176dd88 100644 --- a/Src/Notion.Client/Models/Database/Properties/RollupProperty.cs +++ b/Src/Notion.Client/Models/Database/Properties/RollupProperty.cs @@ -26,6 +26,7 @@ public class Rollup [JsonProperty("rollup_property_id")] public string RollupPropertyId { get; set; } + [JsonProperty("function")] [JsonConverter(typeof(StringEnumConverter))] public Function Function { get; set; } } From cdb757ab2b348058434d4772a0235e5717c84604 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 05:46:00 +0530 Subject: [PATCH 28/32] Set version to 2.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 c83dbe70..be7a595f 100644 --- a/Src/Notion.Client/Notion.Client.csproj +++ b/Src/Notion.Client/Notion.Client.csproj @@ -1,7 +1,7 @@  - 1.4.1-preview + 2.0.0-preview netstandard2.0 7.3 From 6b9a3da1f7c0323af7b6b3d05d0ca10232cb4181 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 05:50:26 +0530 Subject: [PATCH 29/32] =?UTF-8?q?Update=20readme=20files=20=F0=9F=93=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++++- docs/README.md | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9520d4c3..4595f480 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,10 @@ 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. + + + ## Usage > Before getting started, you need to [create an integration](https://www.notion.com/my-integrations) and find the token. You can learn more about authorization [here](https://developers.notion.com/docs/authorization). @@ -116,4 +120,3 @@ var complexFiler = new CompoundFilter( ## Contribution Guideline Hello! Thank you for choosing to help contribute to this open source library. There are many ways you can contribute and help is always welcome. You can read the detailed [Contribution Guideline](https://github.com/notion-dotnet/notion-sdk-net/blob/main/CONTRIBUTING.md) defined here - we will continue to improve it. - diff --git a/docs/README.md b/docs/README.md index b25583b8..494f31d1 100644 --- a/docs/README.md +++ b/docs/README.md @@ -10,6 +10,8 @@ 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. + ## Usage > Before getting started, you need to [create an integration](https://www.notion.com/my-integrations) and find the token. You can learn more about authorization [here](https://developers.notion.com/docs/authorization). From 7ec3c2019e4516e0afeb78e59455b39e25edc117 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 05:53:55 +0530 Subject: [PATCH 30/32] Update supported endpoints list in Readme --- README.md | 6 ++++-- docs/README.md | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4595f480..09e8acf2 100644 --- a/README.md +++ b/README.md @@ -97,12 +97,13 @@ var complexFiler = new CompoundFilter( ``` ## Supported Endpoints + - [x] Databases - - [x] Retrieve a database - [x] Query a database - - [x] List databases - [x] Create a database - [x] Update database + - [x] Retrieve a database + - [x] List databases - [x] Pages - [x] Retrieve a page - [x] Create a page @@ -112,6 +113,7 @@ var complexFiler = new CompoundFilter( - [x] Update a block - [x] Retrieve block children - [x] Append block children + - [x] Delete a block - [x] Users - [x] Retrieve a User - [x] List all users diff --git a/docs/README.md b/docs/README.md index 494f31d1..954accdc 100644 --- a/docs/README.md +++ b/docs/README.md @@ -66,11 +66,11 @@ var complexFiler = new CompoundFilter( ## Supported Endpoints - [x] Databases - - [x] Retrieve a database - [x] Query a database - - [x] List databases - [x] Create a database - [x] Update database + - [x] Retrieve a database + - [x] List databases - [x] Pages - [x] Retrieve a page - [x] Create a page @@ -80,6 +80,7 @@ var complexFiler = new CompoundFilter( - [x] Update a block - [x] Retrieve block children - [x] Append block children + - [x] Delete a block - [x] Users - [x] Retrieve a User - [x] List all users From c35d522b464e72f6ce1b517745a95b901275090e Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 06:03:43 +0530 Subject: [PATCH 31/32] =?UTF-8?q?Mark=20database=20list=20endpoint=20obsol?= =?UTF-8?q?ete=20with=20warning=20=F0=9F=97=91=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Notion.Client/Api/Databases/DatabasesClient.cs | 4 +++- Src/Notion.Client/Api/Databases/IDatabasesClient.cs | 10 +++++++++- Test/Notion.UnitTests/DatabasesClientTests.cs | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Src/Notion.Client/Api/Databases/DatabasesClient.cs b/Src/Notion.Client/Api/Databases/DatabasesClient.cs index 7f12bb62..ee546aef 100644 --- a/Src/Notion.Client/Api/Databases/DatabasesClient.cs +++ b/Src/Notion.Client/Api/Databases/DatabasesClient.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Threading.Tasks; using static Notion.Client.ApiEndpoints; @@ -18,6 +19,7 @@ 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; diff --git a/Src/Notion.Client/Api/Databases/IDatabasesClient.cs b/Src/Notion.Client/Api/Databases/IDatabasesClient.cs index e6f591cb..c339e4da 100644 --- a/Src/Notion.Client/Api/Databases/IDatabasesClient.cs +++ b/Src/Notion.Client/Api/Databases/IDatabasesClient.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; namespace Notion.Client { @@ -6,6 +7,13 @@ 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); /// diff --git a/Test/Notion.UnitTests/DatabasesClientTests.cs b/Test/Notion.UnitTests/DatabasesClientTests.cs index d6b66316..37c02d30 100644 --- a/Test/Notion.UnitTests/DatabasesClientTests.cs +++ b/Test/Notion.UnitTests/DatabasesClientTests.cs @@ -19,6 +19,7 @@ public DatabasesClientTests() } [Fact] + [Obsolete] public async Task ListDatabasesAsync() { var path = ApiEndpoints.DatabasesApiUrls.List(); From 2a96fc5776079ed97bd2886159dd46f126ac0873 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 2 Oct 2021 06:07:14 +0530 Subject: [PATCH 32/32] Update readme with deprecated api details --- README.md | 2 +- docs/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 09e8acf2..900a2451 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ var complexFiler = new CompoundFilter( - [x] Create a database - [x] Update database - [x] Retrieve a database - - [x] List databases + - [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 954accdc..4088b54b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -70,7 +70,7 @@ var complexFiler = new CompoundFilter( - [x] Create a database - [x] Update database - [x] Retrieve a database - - [x] List databases + - [x] List databases (Deprecated: use Search API instead) - [x] Pages - [x] Retrieve a page - [x] Create a page