File tree Expand file tree Collapse file tree 4 files changed +61
-1
lines changed
Src/Notion.Client/Models/Page Expand file tree Collapse file tree 4 files changed +61
-1
lines changed Original file line number Diff line number Diff line change 1
- using Newtonsoft . Json ;
1
+ using JsonSubTypes ;
2
+ using Newtonsoft . Json ;
2
3
3
4
namespace Notion . Client
4
5
{
6
+ [ JsonConverter ( typeof ( JsonSubtypes ) , "type" ) ]
7
+ [ JsonSubtypes . KnownSubType ( typeof ( EmojiObject ) , "emoji" ) ]
8
+ [ JsonSubtypes . KnownSubType ( typeof ( FileObject ) , "file" ) ]
9
+ [ JsonSubtypes . KnownSubType ( typeof ( FileObject ) , "external" ) ]
5
10
public interface IPageIcon
6
11
{
7
12
[ JsonProperty ( "type" ) ]
Original file line number Diff line number Diff line change @@ -119,6 +119,9 @@ public async Task RetrieveDatabaseAsync()
119
119
{
120
120
property . Key . Should ( ) . Be ( property . Value . Name ) ;
121
121
}
122
+
123
+ HelperAsserts . IPageIconAsserts ( database . Icon ) ;
124
+ HelperAsserts . FileObjectAsserts ( database . Cover ) ;
122
125
}
123
126
124
127
[ Fact ]
Original file line number Diff line number Diff line change
1
+ using FluentAssertions ;
2
+ using Notion . Client ;
3
+
4
+ namespace Notion . UnitTests
5
+ {
6
+ public static class HelperAsserts
7
+ {
8
+ public static void IPageIconAsserts ( IPageIcon icon )
9
+ {
10
+ icon . Should ( ) . NotBeNull ( ) ;
11
+
12
+ switch ( icon )
13
+ {
14
+ case EmojiObject emoji :
15
+ emoji . Emoji . Should ( ) . NotBeNull ( ) ;
16
+ break ;
17
+ case FileObject fileObject :
18
+ FileObjectAsserts ( fileObject ) ;
19
+ break ;
20
+ }
21
+ }
22
+
23
+ public static void FileObjectAsserts ( FileObject fileObject )
24
+ {
25
+ fileObject . Should ( ) . NotBeNull ( ) ;
26
+
27
+ switch ( fileObject )
28
+ {
29
+ case UploadedFile uploadedFile :
30
+ uploadedFile . File . Should ( ) . NotBeNull ( ) ;
31
+ uploadedFile . File . Url . Should ( ) . NotBeNull ( ) ;
32
+ uploadedFile . File . ExpiryTime . Should ( ) . NotBeSameDateAs ( default ) ;
33
+ break ;
34
+ case ExternalFile externalFile :
35
+ externalFile . External . Should ( ) . NotBeNull ( ) ;
36
+ externalFile . External . Url . Should ( ) . NotBeNull ( ) ;
37
+ break ;
38
+ }
39
+ }
40
+ }
41
+ }
Original file line number Diff line number Diff line change 22
22
"href" : null
23
23
}
24
24
],
25
+ "icon" : {
26
+ "type" : " emoji" ,
27
+ "emoji" : " 🎉"
28
+ },
29
+ "cover" : {
30
+ "type" : " external" ,
31
+ "external" : {
32
+ "url" : " https://website.domain/images/image.png"
33
+ }
34
+ },
35
+ "url" : " https://www.notion.so/668d797c76fa49349b05ad288df2d136" ,
25
36
"properties" : {
26
37
"Tags" : {
27
38
"id" : " YG~h" ,
You can’t perform that action at this time.
0 commit comments