File tree Expand file tree Collapse file tree 8 files changed +79
-4
lines changed Expand file tree Collapse file tree 8 files changed +79
-4
lines changed Original file line number Diff line number Diff line change @@ -20,5 +20,10 @@ public static class BlocksApiUrls
2020 public static string RetrieveChildren ( string blockId ) => $ "/v1/blocks/{ blockId } /children";
2121 public static string AppendChildren ( string blockId ) => $ "/v1/blocks/{ blockId } /children";
2222 }
23+
24+ public static class PagesApiUrls
25+ {
26+ public static string Create ( ) => $ "/v1/pages";
27+ }
2328 }
2429}
Original file line number Diff line number Diff line change @@ -31,11 +31,11 @@ public async Task<PaginatedList<Database>> ListAsync(DatabasesListParameters dat
3131 return await _client . GetAsync < PaginatedList < Database > > ( DatabasesApiUrls . List ( ) , queryParams ) ;
3232 }
3333
34- public async Task < PaginatedList < Page > > QueryAsync ( string databaseId , DatabasesQueryParameters databasesQueryParameters )
34+ public async Task < PaginatedList < RetrievedPage > > QueryAsync ( string databaseId , DatabasesQueryParameters databasesQueryParameters )
3535 {
3636 var body = ( IDatabaseQueryBodyParameters ) databasesQueryParameters ;
3737
38- return await _client . PostAsync < PaginatedList < Page > > ( DatabasesApiUrls . Query ( databaseId ) , body ) ;
38+ return await _client . PostAsync < PaginatedList < RetrievedPage > > ( DatabasesApiUrls . Query ( databaseId ) , body ) ;
3939 }
4040 }
4141}
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ namespace Notion.Client
55 public interface IDatabasesClient
66 {
77 Task < Database > RetrieveAsync ( string databaseId ) ;
8- Task < PaginatedList < Page > > QueryAsync ( string databaseId , DatabasesQueryParameters databasesQueryParameters ) ;
8+ Task < PaginatedList < RetrievedPage > > QueryAsync ( string databaseId , DatabasesQueryParameters databasesQueryParameters ) ;
99 Task < PaginatedList < Database > > ListAsync ( DatabasesListParameters databasesListParameters = null ) ;
1010 }
1111}
Original file line number Diff line number Diff line change 1+ using System . Threading . Tasks ;
2+
3+ namespace Notion . Client
4+ {
5+ public interface IPagesClient
6+ {
7+ Task < RetrievedPage > CreateAsync ( CreatedPage page ) ;
8+ }
9+ }
Original file line number Diff line number Diff line change 1+ using System . Threading . Tasks ;
2+ using static Notion . Client . ApiEndpoints ;
3+
4+ namespace Notion . Client
5+ {
6+ public class PagesClient : IPagesClient
7+ {
8+ private readonly IRestClient _client ;
9+
10+ public PagesClient ( IRestClient client )
11+ {
12+ _client = client ;
13+ }
14+
15+ public async Task < RetrievedPage > CreateAsync ( CreatedPage page )
16+ {
17+ return await _client . PostAsync < RetrievedPage > ( PagesApiUrls . Create ( ) , page ) ;
18+ }
19+ }
20+
21+ }
Original file line number Diff line number Diff line change 1+ using System . Collections . Generic ;
2+ using System . Runtime . Serialization ;
3+
4+ namespace Notion . Client
5+ {
6+ [ DataContract ]
7+ public class CreatedPage
8+ {
9+ public CreatedPage ( Parent parent )
10+ {
11+ Parent = parent ;
12+ Properties = new Dictionary < string , PropertyValue > ( ) ;
13+ Children = new List < Block > ( ) ;
14+ }
15+
16+ [ DataMember ]
17+ private Parent Parent ;
18+
19+ [ DataMember ]
20+ private Dictionary < string , PropertyValue > Properties ;
21+
22+ [ DataMember ]
23+ private List < Block > Children ;
24+
25+ public CreatedPage AddProperty ( string nameOrId , PropertyValue value )
26+ {
27+ Properties [ nameOrId ] = value ;
28+ return this ;
29+ }
30+
31+ public CreatedPage AddPageContent ( Block block )
32+ {
33+ Children . Add ( block ) ;
34+ return this ;
35+ }
36+ }
37+ }
Original file line number Diff line number Diff line change 44
55namespace Notion . Client
66{
7- public class Page
7+ public class RetrievedPage
88 {
99 public string Object => "page" ;
1010 public string Id { get ; set ; }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ public interface INotionClient
44 {
55 IUsersClient Users { get ; }
66 IDatabasesClient Databases { get ; }
7+ IPagesClient Pages { get ; }
78 }
89
910 public class NotionClient : INotionClient
@@ -13,9 +14,11 @@ public NotionClient(ClientOptions options)
1314 var restClient = new RestClient ( options ) ;
1415 Users = new UsersClient ( restClient ) ;
1516 Databases = new DatabasesClient ( restClient ) ;
17+ Pages = new PagesClient ( restClient ) ;
1618 }
1719
1820 public IUsersClient Users { get ; }
1921 public IDatabasesClient Databases { get ; }
22+ public IPagesClient Pages { get ; }
2023 }
2124}
You can’t perform that action at this time.
0 commit comments