File tree Expand file tree Collapse file tree 10 files changed +119
-13
lines changed
DatabasesCreateParameters
DatabasesUpdateParameters Expand file tree Collapse file tree 10 files changed +119
-13
lines changed Original file line number Diff line number Diff line change 1
1
using System . Collections . Generic ;
2
+ using Newtonsoft . Json ;
2
3
3
4
namespace Notion . Client
4
5
{
5
6
public class DatabasesCreateParameters : IDatabasesCreateBodyParameters , IDatabasesCreateQueryParameters
6
7
{
8
+ [ JsonProperty ( "parent" ) ]
7
9
public ParentPageInput Parent { get ; set ; }
10
+
11
+ [ JsonProperty ( "properties" ) ]
8
12
public Dictionary < string , IPropertySchema > Properties { get ; set ; }
13
+
14
+ [ JsonProperty ( "title" ) ]
9
15
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 ; }
10
22
}
11
23
}
Original file line number Diff line number Diff line change 1
1
using System . Collections . Generic ;
2
+ using Newtonsoft . Json ;
2
3
3
4
namespace Notion . Client
4
5
{
5
6
public interface IDatabasesUpdateBodyParameters
6
7
{
8
+ [ JsonProperty ( "properties" ) ]
7
9
Dictionary < string , IUpdatePropertySchema > Properties { get ; set ; }
10
+
11
+ [ JsonProperty ( "title" ) ]
8
12
List < RichTextBaseInput > Title { get ; set ; }
13
+
14
+ [ JsonProperty ( "icon" ) ]
15
+ IPageIcon Icon { get ; set ; }
16
+
17
+ [ JsonProperty ( "cover" ) ]
18
+ FileObject Cover { get ; set ; }
9
19
}
10
20
11
21
public class DatabasesUpdateParameters : IDatabasesUpdateBodyParameters
12
22
{
13
23
public Dictionary < string , IUpdatePropertySchema > Properties { get ; set ; }
14
24
public List < RichTextBaseInput > Title { get ; set ; }
25
+ public IPageIcon Icon { get ; set ; }
26
+ public FileObject Cover { get ; set ; }
15
27
}
16
28
}
Original file line number Diff line number Diff line change 1
1
using System . Collections . Generic ;
2
+ using Newtonsoft . Json ;
2
3
3
4
namespace Notion . Client
4
5
{
5
8000
6
public class PagesUpdateParameters : IPagesUpdateBodyParameters
6
7
{
7
8
public bool Archived { get ; set ; }
9
+
8
10
public IDictionary < string , PropertyValue > Properties { get ; set ; }
11
+
12
+ [ JsonProperty ( "icon" ) ]
13
+ public IPageIcon Icon { get ; set ; }
14
+
15
+ [ JsonProperty ( "cover" ) ]
16
+ public FileObject Cover { get ; set ; }
9
17
}
10
18
}
Original file line number Diff line number Diff line change @@ -16,10 +16,19 @@ public class Database : IObject
16
16
[ JsonProperty ( "last_edited_time" ) ]
17
17
public DateTime LastEditedTime { get ; set ; }
18
18
19
+ [ JsonProperty ( "title" ) ]
19
20
public List < RichTextBase > Title { get ; set ; }
20
21
22
+ [ JsonProperty ( "properties" ) ]
21
23
public Dictionary < string , Property > Properties { get ; set ; }
22
24
25
+ [ JsonProperty ( "parent" ) ]
23
26
public IDatabaseParent Parent { get ; set ; }
27
+
28
+ [ JsonProperty ( "icon" ) ]
29
+ public IPageIcon Icon { get ; set ; }
30
+
31
+ [ JsonProperty ( "cover" ) ]
32
+ public FileObject Cover { get ; set ; }
24
33
}
25
34
}
Original file line number Diff line number Diff line change
1
+ using Newtonsoft . Json ;
2
+
3
+ namespace Notion . Client
4
+ {
5
+ public class EmojiObject : IPageIcon
6
+ {
7
+ [ JsonProperty ( "type" ) ]
8
+ public string Type { get ; set ; }
9
+
10
+ [ JsonProperty ( "emoji" ) ]
11
+ public string Emoji { get ; set ; }
12
+ }
13
+ }
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using JsonSubTypes ;
3
+ using Newtonsoft . Json ;
4
+ using Newtonsoft . Json . Converters ;
5
+
6
+ namespace Notion . Client
7
+ {
8
+ [ JsonConverter ( typeof ( JsonSubtypes ) , "type" ) ]
9
+ [ JsonSubtypes . KnownSubType ( typeof ( UploadedFile ) , "file" ) ]
10
+ [ JsonSubtypes . KnownSubType ( typeof ( ExternalFile ) , "external" ) ]
11
+ public abstract class FileObject : IPageIcon
12
+ {
13
+ [ JsonProperty ( "type" ) ]
14
+ [ JsonConverter ( typeof ( StringEnumConverter ) ) ]
15
+ public virtual string Type { get ; set ; }
16
+
17
+ [ JsonProperty ( "url" ) ]
18
+ public string Url { get ; set ; }
19
+ }
20
+
21
+ public class UploadedFile : FileObject
22
+ {
23
+ public override string Type => "file" ;
24
+
25
+ [ JsonProperty ( "expiry_time" ) ]
26
+ public DateTime ExpiryTime { get ; set ; }
27
+ }
28
+
29
+ public class ExternalFile : FileObject
30
+ {
31
+ public override string Type => "external" ;
32
+ }
33
+ }
Original file line number Diff line number Diff line change
1
+ using Newtonsoft . Json ;
2
+
3
+ namespace Notion . Client
4
+ {
5
+ public interface IPageIcon
6
+ {
7
+ [ JsonProperty ( "type" ) ]
8
+ string Type { get ; set ; }
9
+ }
10
+ }
Original file line number Diff line number Diff line change 1
1
using System . Collections . Generic ;
2
+ using Newtonsoft . Json ;
2
3
3
4
namespace Notion . Client
4
5
{
5
6
public class NewPage
6
7
{
7
- /// <summary>
8
- /// Constructor without arguments: added for class initializations using class literals.
9
- /// </summary>
10
- public NewPage ( )
11
- {
12
- Properties = new Dictionary < string , PropertyValue > ( ) ;
13
- Children = new List < Block > ( ) ;
14
- }
15
-
16
8
/// <summary>
17
9
/// Constructor that adds required <c>Parent</c> property. Used when you don't want to
18
10
/// assign properties in separate operations.
@@ -24,12 +16,21 @@ public NewPage(IPageParent parent)
24
16
Children = new List < Block > ( ) ;
25
17
}
26
18
19
+ [ JsonProperty ( "parent" ) ]
27
20
public IPageParent Parent { get ; set ; }
28
21
22
+ [ JsonProperty ( "properties" ) ]
29
23
public Dictionary < string , PropertyValue > Properties { get ; set ; }
30
24
25
+ [ JsonProperty ( "children" ) ]
31
26
public List < Block > Children { get ; set ; }
32
27
28
+ [ JsonProperty ( "icon" ) ]
29
+ public IPageIcon Icon { get ; set ; }
30
+
31
+ [ JsonProperty ( "cover" ) ]
32
+ public FileObject Cover { get ; set ; }
33
+
33
34
public NewPage AddProperty ( string nameOrId , PropertyValue value )
34
35
{
35
36
Properties [ nameOrId ] = value ;
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ public class Page : IObject
10
10
11
11
public string Id { get ; set ; }
12
12
13
+ [ JsonProperty ( "parent" ) ]
13
14
public IPageParent Parent { get ; set ; }
14
15
15
16
[ JsonProperty ( "created_time" ) ]
@@ -21,8 +22,16 @@ public class Page : IObject
21
22
[ JsonProperty ( "archived" ) ]
22
23
public bool IsArchived { get ; set ; }
23
24
25
+ [ JsonProperty ( "properties" ) ]
24
26
public IDictionary < string , PropertyValue > Properties { get ; set ; }
25
27
28
+ [ JsonProperty ( "url" ) ]
26
29
public string Url { get ; set ; }
30
+
31
+ [ JsonProperty ( "icon" ) ]
32
+ public IPageIcon Icon { get ; set ; }
33
+
34
+ [ JsonProperty ( "cover" ) ]
35
+ public FileObject Cover { get ; set ; }
27
36
}
28
37
}
Original file line number Diff line number Diff line change @@ -56,11 +56,10 @@ public async Task CreateAsync()
56
56
. WithBody ( jsonData )
57
57
) ;
58
58
59
- var newPage = new NewPage ( ) ;
60
- newPage . Parent = new PageParent
59
+ var newPage = new NewPage ( new PageParent
61
60
{
62
61
PageId = "3c357473-a281-49a4-88c0-10d2b245a589"
63
- } ;
62
+ } ) ;
64
63
65
64
newPage . AddProperty ( "Name" , new TitlePropertyValue ( )
66
65
{
@@ -210,7 +209,7 @@ public async Task CreateAsync_Throws_ArgumentNullException_When_Parameter_Is_Nul
210
209
[ Fact ]
211
210
public async Task CreateAsync_Throws_ArgumentNullException_When_Parent_Is_Missing ( )
212
211
{
213
- var newPage = new NewPage ( ) ;
212
+ var newPage = new NewPage ( null ) ;
214
213
215
214
Func < Task > act = async ( ) => await _client . CreateAsync ( newPage ) ;
216
215
You can’t perform that action at this time.
0 commit comments