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 ;
23
34namespace Notion . Client
45{
6+ [ JsonConverter ( typeof ( JsonSubtypes ) , "type" ) ]
7+ [ JsonSubtypes . KnownSubType ( typeof ( EmojiObject ) , "emoji" ) ]
8+ [ JsonSubtypes . KnownSubType ( typeof ( FileObject ) , "file" ) ]
9+ [ JsonSubtypes . KnownSubType ( typeof ( FileObject ) , "external" ) ]
510 public interface IPageIcon
611 {
712 [ JsonProperty ( "type" ) ]
Original file line number Diff line number Diff line change @@ -119,6 +119,9 @@ public async Task RetrieveDatabaseAsync()
119119 {
120120 property . Key . Should ( ) . Be ( property . Value . Name ) ;
121121 }
122+
123+ HelperAsserts . IPageIconAsserts ( database . Icon ) ;
124+ HelperAsserts . FileObjectAsserts ( database . Cover ) ;
122125 }
123126
124127 [ 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 2222 "href" : null
2323 }
2424 ],
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" ,
2536 "properties" : {
2637 "Tags" : {
2738 "id" : " YG~h" ,
You can’t perform that action at this time.
0 commit comments