Skip to content

Commit e51fce1

Browse files
Merge pull request #156 from notion-dotnet/2.0.0
Merge 2.0.0 release 🎉
2 parents 079dc2f + 0b43508 commit e51fce1

File tree

135 files changed

+1161
-109
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+1161
-109
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ Provides the following packages:
4141
dotnet add package Notion.Net
4242
```
4343

44+
> Note: From Nuget 2.0.0 notion client sdk default sets the Notion-Version header to 2021-08-16.
45+
46+
47+
4448
## Usage
4549

4650
> 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).
@@ -93,12 +97,13 @@ var complexFiler = new CompoundFilter(
9397
```
9498

9599
## Supported Endpoints
100+
96101
- [x] Databases
97-
- [x] Retrieve a database
98102
- [x] Query a database
99-
- [x] List databases
100103
- [x] Create a database
101104
- [x] Update database
105+
- [x] Retrieve a database
106+
- [x] List databases (Deprecated: use Search API instead)
102107
- [x] Pages
103108
- [x] Retrieve a page
104109
- [x] Create a page
@@ -108,6 +113,7 @@ var complexFiler = new CompoundFilter(
108113
- [x] Update a block
109114
- [x] Retrieve block children
110115
- [x] Append block children
116+
- [x] Delete a block
111117
- [x] Users
112118
- [x] Retrieve a User
113119
- [x] List all users
@@ -116,4 +122,3 @@ var complexFiler = new CompoundFilter(
116122
## Contribution Guideline
117123

118124
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.
119-

Src/Notion.Client/Api/ApiEndpoints.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ public static class BlocksApiUrls
2121
{
2222
public static string Retrieve(string blockId) => $"/v1/blocks/{blockId}";
2323
public static string Update(string blockId) => $"/v1/blocks/{blockId}";
24+
25+
/// <summary>
26+
/// Get the <see cref="uri string"/> for deleting a block.
27+
/// </summary>
28+
/// <param name="blockId">Identifier for a Notion block</param>
29+
/// <returns>Returns a <see cref="uri string"/> for deleting a block.</returns>
30+
public static string Delete(string blockId) => $"/v1/blocks/{blockId}";
31+
2432
public static string RetrieveChildren(string blockId) => $"/v1/blocks/{blockId}/children";
2533
public static string AppendChildren(string blockId) => $"/v1/blocks/{blockId}/children";
2634
}

Src/Notion.Client/Api/Blocks/BlocksClient.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public async Task<PaginatedList<Block>> RetrieveChildrenAsync(string blockId, Bl
3434
return await _client.GetAsync<PaginatedList<Block>>(url, queryParams);
3535
}
3636

37-
public async Task<Block> AppendChildrenAsync(string blockId, BlocksAppendChildrenParameters parameters = null)
37+
public async Task<PaginatedList<Block>> AppendChildrenAsync(string blockId, BlocksAppendChildrenParameters parameters = null)
3838
{
3939
if (string.IsNullOrWhiteSpace(blockId))
4040
{
@@ -45,7 +45,7 @@ public async Task<Block> AppendChildrenAsync(string blockId, BlocksAppendChildre
4545

4646
var body = (IBlocksAppendChildrenBodyParameters)parameters;
4747

48-
return await _client.PatchAsync<Block>(url, body);
48+
return await _client.PatchAsync<PaginatedList<Block>>(url, body);
4949
}
5050

5151
public async Task<Block> RetrieveAsync(string blockId)
@@ -71,5 +71,17 @@ public async Task<Block> UpdateAsync(string blockId, IUpdateBlock updateBlock)
7171

7272
return await _client.PatchAsync<Block>(url, updateBlock);
7373
}
74+
75+
public async Task DeleteAsync(string blockId)
76+
{
77+
if (string.IsNullOrWhiteSpace(blockId))
78+
{
79+
throw new ArgumentNullException(nameof(blockId));
80+
}
81+
82+
var url = BlocksApiUrls.Delete(blockId);
83+
84+
await _client.DeleteAsync(url);
85+
}
7486
}
7587
}

Src/Notion.Client/Api/Blocks/IBlocksClient.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ public interface IBlocksClient
2020
Task<Block> UpdateAsync(string blockId, IUpdateBlock updateBlock);
2121

2222
Task<PaginatedList<Block>> RetrieveChildrenAsync(string blockId, BlocksRetrieveChildrenParameters parameters = null);
23-
Task<Block> AppendChildrenAsync(string blockId, BlocksAppendChildrenParameters parameters = null);
23+
24+
/// <summary>
25+
/// Creates and appends new children blocks to the parent block_id specified.
26+
/// </summary>
27+
/// <param name="blockId">Identifier for a block</param>
28+
/// <param name="parameters"></param>
29+
/// <returns>A paginated list of newly created first level children block objects.</returns>
30+
Task<PaginatedList<Block>> AppendChildrenAsync(string blockId, BlocksAppendChildrenParameters parameters = null);
31+
32+
/// <summary>
33+
/// Sets a Block object, including page blocks, to archived: true using the ID specified.
34+
/// </summary>
35+
/// <param name="blockId">Identifier for a Notion block</param>
36+
Task DeleteAsync(string blockId);
2437
}
2538
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
namespace Notion.Client
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
24
{
35
public class ParagraphUpdateBlock : IUpdateBlock
46
{
7+
[JsonProperty("paragraph")]
58
public TextContentUpdate Paragraph { get; set; }
69
}
710
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System.Collections.Generic;
2+
using Newtonsoft.Json;
23

34
namespace Notion.Client
45
{
56
public class TextContentUpdate
67
{
8+
[JsonProperty("text")]
79
public IEnumerable<RichTextBaseInput> Text { get; set; }
810
}
911
}

Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToDoBlock.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class ToDoUpdateBlock : IUpdateBlock
1010

1111
public class Info
1212
{
13+
[JsonProperty("text")]
1314
public IEnumerable<RichTextBaseInput> Text { get; set; }
1415

1516
[JsonProperty("checked")]
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
namespace Notion.Client
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
24
{
35
public class ToggleUpdateBlock : IUpdateBlock
46
{
7+
[JsonProperty("toggle")]
58
public TextContentUpdate Toggle { get; set; }
69
}
710
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using System.Collections.Generic;
2+
using Newtonsoft.Json;
23

34
namespace Notion.Client
45
{
56
// TODO: need an input version of Block
67
public interface IBlocksAppendChildrenBodyParameters
78
{
9+
[JsonProperty("children")]
810
IEnumerable<Block> Children { get; set; }
911
}
1012
}

Src/Notion.Client/Api/Databases/DatabasesClient.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.Threading.Tasks;
34
using static Notion.Client.ApiEndpoints;
45

@@ -18,6 +19,7 @@ public async Task<Database> RetrieveAsync(string databaseId)
1819
return await _client.GetAsync<Database>(DatabasesApiUrls.Retrieve(databaseId));
1920
}
2021

22+
[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)]
2123
public async Task<PaginatedList<Database>> ListAsync(DatabasesListParameters databasesListParameters = null)
2224
{
2325
var databasesListQueryParmaters = (IDatabasesListQueryParmaters)databasesListParameters;

Src/Notion.Client/Api/Databases/IDatabasesClient.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
using System.Threading.Tasks;
1+
using System;
2+
using System.Threading.Tasks;
23

34
namespace Notion.Client
45
{
56
public interface IDatabasesClient
67
{
78
Task<Database> RetrieveAsync(string databaseId);
89
Task<PaginatedList<Page>> QueryAsync(string databaseId, DatabasesQueryParameters databasesQueryParameters);
10+
11+
/// <summary>
12+
/// List all Databases shared with the authenticated integration.
13+
/// </summary>
14+
/// <param name="databasesListParameters">database list request parameters.</param>
15+
/// <returns>PaginatedList of databases.</returns>
16+
[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)]
917
Task<PaginatedList<Database>> ListAsync(DatabasesListParameters databasesListParameters = null);
1018

1119
/// <summary>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
using System.Collections.Generic;
2+
using Newtonsoft.Json;
23

34
namespace Notion.Client
45
{
56
public class DatabasesCreateParameters : IDatabasesCreateBodyParameters, IDatabasesCreateQueryParameters
67
{
8+
[JsonProperty("parent")]
79
public ParentPageInput Parent { get; set; }
10+
11+
[JsonProperty("properties")]
812
public Dictionary<string, IPropertySchema> Properties { get; set; }
13+
14+
[JsonProperty("title")]
915
public List<RichTextBaseInput> Title { get; set; }
16+
17+
[JsonProperty("icon")]
18+
public IPageIcon Icon { get; set; }
19+
20+
[JsonProperty("cover")]
21+
public FileObject Cover { get; set; }
1022
}
1123
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
using System.Collections.Generic;
2+
using Newtonsoft.Json;
23

34
namespace Notion.Client
45
{
56
public interface IDatabasesCreateBodyParameters
67
{
8+
[JsonProperty("parent")]
79
ParentPageInput Parent { get; set; }
10+
11+
[JsonProperty("properties")]
812
Dictionary<string, IPropertySchema> Properties { get; set; }
13+
14+
[JsonProperty("title")]
915
List<RichTextBaseInput> Title { get; set; }
1016
}
1117
}
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
namespace Notion.Client
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
24
{
35
public class MentionInput
46
{
7+
[JsonProperty("type")]
58
public string Type { get; set; }
9+
10+
[JsonProperty("user")]
611
public Person User { get; set; }
12+
13+
[JsonProperty("page")]
714
public ObjectId Page { get; set; }
15+
16+
[JsonProperty("database")]
817
public ObjectId Database { get; set; }
18+
19+
[JsonProperty("date")]
920
public DatePropertyValue Date { get; set; }
1021
}
1122
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System.Collections.Generic;
2+
using Newtonsoft.Json;
23

34
namespace Notion.Client
45
{
56
public class CheckboxPropertySchema : IPropertySchema
67
{
8+
[JsonProperty("checkbox")]
79
public Dictionary<string, object> Checkbox { get; set; }
810
}
911
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System.Collections.Generic;
2+
using Newtonsoft.Json;
23

34
namespace Notion.Client
45
{
56
public class DatePropertySchema : IPropertySchema
67
{
8+
[JsonProperty("date")]
79
public Dictionary<string, object> Date { get; set; }
810
}
911
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System.Collections.Generic;
2+
using Newtonsoft.Json;
23

34
namespace Notion.Client
45
{
56
public class EmailPropertySchema : IPropertySchema
67
{
8+
[JsonProperty("email")]
79
public Dictionary<string, object> Email { get; set; }
810
}
911
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System.Collections.Generic;
2+
using Newtonsoft.Json;
23

34
namespace Notion.Client
45
{
56
public class FilePropertySchema : IPropertySchema
67
{
8+
[JsonProperty("files")]
79
public Dictionary<string, object> Files { get; set; }
810
}
911
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
namespace Notion.Client
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
24
{
35
public class FormulaPropertySchema : IPropertySchema
46
{
7+
[JsonProperty("formula")]
58
public Formula Formula { get; set; }
69
}
710
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
namespace Notion.Client
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
24
{
35
public class NumberPropertySchema : IPropertySchema
46
{
7+
[JsonProperty("number")]
58
public Number Number { get; set; }
69
}
710
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System.Collections.Generic;
2+
using Newtonsoft.Json;
23

34
namespace Notion.Client
45
{
56
public class PeoplePropertySchema : IPropertySchema
67
{
8+
[JsonProperty("people")]
79
public Dictionary<string, object> People { get; set; }
810
}
911
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using Newtonsoft.Json;
3+
4+
namespace Notion.Client
5+
{
6+
public class RelationPropertySchema : IPropertySchema
7+
{
8+
[JsonProperty("relation")]
9+
public RelationInfo Relation { get; set; }
10+
11+
public class RelationInfo
12+
{
13+
[JsonProperty("database_id")]
14+
public Guid DatabaseId { get; set; }
15+
16+
[JsonProperty("synced_property_id")]
17+
public string SynchedPropertyId { get; set; }
18+
19+
[JsonProperty("synced_property_name")]
20+
public string SynchedPropertyName { get; set; }
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)