Skip to content

Commit

Permalink
Merge pull request #276 from notion-dotnet/notion-version-2022-02-22
Browse files Browse the repository at this point in the history
Support Notion-Version 2022-02-22 💖
  • Loading branch information
KoditkarVedant authored Jul 17, 2022
2 parents 07d09c4 + c9d5103 commit f7d5449
Show file tree
Hide file tree
Showing 66 changed files with 1,018 additions and 817 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ Provides the following packages:
dotnet add package Notion.Net
```

> Note: From Nuget 2.0.0 notion client sdk default sets the Notion-Version header to 2021-08-16.

> Note: default Notion-Version used by NuGet package versions
> | Package version | Notion-Version |
> | --- | --- |
> | 3.0.0+ | 2022-02-22 |
> | 2.0.0+ | 2021-08-16 |
> | 1.0.0+ | 2021-05-13 |
## Usage

Expand Down Expand Up @@ -113,7 +116,6 @@ var complexFiler = new CompoundFilter(
- [x] Create a database
- [x] Update database
- [x] Retrieve a database
- [x] List databases (Deprecated: use Search API instead)
- [x] Pages
- [x] Retrieve a page
- [x] Create a page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public class BookmarkUpdateBlock : IUpdateBlock
public bool Archived { get; set; }

[JsonProperty("bookmark")]
public Data Bookmark { get; set; }
public Info Bookmark { get; set; }

public class Data
public class Info
{
[JsonProperty("url")]
public string Url { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ public class BreadcrumbUpdateBlock : IUpdateBlock
public bool Archived { get; set; }

[JsonProperty("breadcrumb")]
public Data Breadcrumb { get; set; }
public Info Breadcrumb { get; set; }

public class Data
public class Info
{
}

public BreadcrumbUpdateBlock()
{
Breadcrumb = new Data();
Breadcrumb = new Info();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Notion.Client
{
public class BulletedListItemUpdateBlock : UpdateBlock, IUpdateBlock
{
[JsonProperty("bulleted_list_item")]
public TextContentUpdate BulletedListItem { get; set; }
public Info BulletedListItem { get; set; }

public class Info
{
[JsonProperty("rich_text")]
public IEnumerable<RichTextBaseInput> RichText { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public class CalloutUpdateBlock : UpdateBlock, IUpdateBlock

public class Info
{
[JsonProperty("text")]
public IEnumerable<RichTextBaseInput> Text { get; set; }
[JsonProperty("rich_text")]
public IEnumerable<RichTextBaseInput> RichText { get; set; }

[JsonProperty("icon")]
public IPageIcon Icon { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public class CodeUpdateBlock : UpdateBlock, IUpdateBlock

public class Info
{
[JsonProperty("text")]
public IEnumerable<RichTextBase> Text { get; set; }
[JsonProperty("rich_text")]
public IEnumerable<RichTextBase> RichText { get; set; }

[JsonProperty("language")]
public string Language { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ public class DividerUpdateBlock : IUpdateBlock
public bool Archived { get; set; }

[JsonProperty("divider")]
public Data Divider { get; set; }
public Info Divider { get; set; }

public class Data
public class Info
{
}

public DividerUpdateBlock()
{
Divider = new Data();
Divider = new Info();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace Notion.Client
public class EmbedUpdateBlock : UpdateBlock, IUpdateBlock
{
[JsonProperty("embed")]
public Data Embed { get; set; }
public Info Embed { get; set; }

public class Data
public class Info
{
[JsonProperty("url")]
public string Url { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace Notion.Client
public class EquationUpdateBlock : UpdateBlock, IUpdateBlock
{
[JsonProperty("equation")]
public Data Equation { get; set; }
public Info Equation { get; set; }

public class Data
public class Info
{
[JsonProperty("expression")]
public string Expression { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Notion.Client
{
public class HeadingOneUpdateBlock : UpdateBlock, IUpdateBlock
{
[JsonProperty("heading_1")]
public TextContentUpdate Heading_1 { get; set; }
public Info Heading_1 { get; set; }

public class Info
{
[JsonProperty("rich_text")]
public IEnumerable<RichTextBaseInput> RichText { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Notion.Client
{
public class HeadingThreeeUpdateBlock : UpdateBlock, IUpdateBlock
{
[JsonProperty("heading_3")]
public TextContentUpdate Heading_3 { get; set; }
public Info Heading_3 { get; set; }

public class Info
{
[JsonProperty("rich_text")]
public IEnumerable<RichTextBaseInput> RichText { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Notion.Client
{
public class HeadingTwoUpdateBlock : UpdateBlock, IUpdateBlock
{
[JsonProperty("heading_2")]
public TextContentUpdate Heading_2 { get; set; }
public Info Heading_2 { get; set; }

public class Info
{
[JsonProperty("rich_text")]
public IEnumerable<RichTextBaseInput> RichText { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Notion.Client
{
public class NumberedListItemUpdateBlock : UpdateBlock, IUpdateBlock
{
[JsonProperty("numbered_list_item")]
public TextContentUpdate NumberedListItem { get; set; }
public Info NumberedListItem { get; set; }

public class Info
{
[JsonProperty("rich_text")]
public IEnumerable<RichTextBaseInput> RichText { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Notion.Client
{
public class ParagraphUpdateBlock : UpdateBlock, IUpdateBlock
{
[JsonProperty("paragraph")]
public TextContentUpdate Paragraph { get; set; }
public Info Paragraph { get; set; }

public class Info
{
[JsonProperty("rich_text")]
public IEnumerable<RichTextBaseInput> RichText { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public class QuoteUpdateBlock : UpdateBlock, IUpdateBlock

public class Info
{
[JsonProperty("text")]
public IEnumerable<RichTextBaseInput> Text { get; set; }
[JsonProperty("rich_text")]
public IEnumerable<RichTextBaseInput> RichText { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace Notion.Client
public class SyncedBlockUpdateBlock : UpdateBlock, IUpdateBlock
{
[JsonProperty("synced_block")]
public Data SyncedBlock { get; set; }
public Info SyncedBlock { get; set; }

public class Data
public class Info
{
[JsonProperty("synced_from")]
public SyncedFromBlockId SyncedFrom { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ public class TableOfContentsUpdateBlock : IUpdateBlock
public bool Archived { get; set; }

[JsonProperty("table_of_contents")]
public Data TableOfContents { get; set; }
public Info TableOfContents { get; set; }

public class Data
public class Info
{
}

public TableOfContentsUpdateBlock()
{
TableOfContents = new Data();
TableOfContents = new Info();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ namespace Notion.Client
public class TemplateUpdateBlock : UpdateBlock, IUpdateBlock
{
[JsonProperty("template")]
public Data Template { get; set; }
public Info Template { get; set; }

public class Data
public class Info
{
[JsonProperty("text")]
public IEnumerable<RichTextBaseInput> Text { get; set; }
[JsonProperty("rich_text")]
public IEnumerable<RichTextBaseInput> RichText { get; set; }
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public class ToDoUpdateBlock : UpdateBlock, IUpdateBlock

public class Info
{
[JsonProperty("text")]
public IEnumerable<RichTextBaseInput> Text { get; set; }
[JsonProperty("rich_text")]
public IEnumerable<RichTextBaseInput> RichText { get; set; }

[JsonProperty("checked")]
public bool IsChecked { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Notion.Client
{
public class ToggleUpdateBlock : UpdateBlock, IUpdateBlock
{
[JsonProperty("toggle")]
public TextContentUpdate Toggle { get; set; }
public Info Toggle { get; set; }

public class Info
{
[JsonProperty("rich_text")]
public IEnumerable<RichTextBaseInput> RichText { get; set; }
}
}
}
18 changes: 1 addition & 17 deletions Src/Notion.Client/Api/Databases/DatabasesClient.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Threading.Tasks;
using static Notion.Client.ApiEndpoints;

namespace Notion.Client
Expand All @@ -19,20 +17,6 @@ public async Task<Database> RetrieveAsync(string databaseId)
return await _client.GetAsync<Database>(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<PaginatedList<Database>> ListAsync(DatabasesListParameters databasesListParameters = null)
{
var databasesListQueryParmaters = (IDatabasesListQueryParmaters)databasesListParameters;

var queryParams = new Dictionary<string, string>()
{
{ "start_cursor", databasesListQueryParmaters?.StartCursor },
{ "page_size", databasesListQueryParmaters?.PageSize?.ToString() }
};

return await _client.GetAsync<PaginatedList<Database>>(DatabasesApiUrls.List(), queryParams);
}

public async Task<PaginatedList<Page>> QueryAsync(string databaseId, DatabasesQueryParameters databasesQueryParameters)
{
var body = (IDatabaseQueryBodyParameters)databasesQueryParameters;
Expand Down
11 changes: 1 addition & 10 deletions Src/Notion.Client/Api/Databases/IDatabasesClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Threading.Tasks;
using System.Threading.Tasks;

namespace Notion.Client
{
Expand All @@ -8,14 +7,6 @@ public interface IDatabasesClient
Task<Database> RetrieveAsync(string databaseId);
Task<PaginatedList<Page>> QueryAsync(string databaseId, DatabasesQueryParameters databasesQueryParameters);

/// <summary>
/// List all Databases shared with the authenticated integration.
/// </summary>
/// <param name="databasesListParameters">database list request parameters.</param>
/// <returns>PaginatedList of databases.</returns>
[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<PaginatedList<Database>> ListAsync(DatabasesListParameters databasesListParameters = null);

/// <summary>
/// Creates a database as a subpage in the specified parent page, with the specified properties schema.
/// </summary>
Expand Down
Loading

0 comments on commit f7d5449

Please sign in to comment.