File tree Expand file tree Collapse file tree 8 files changed +91
-0
lines changed
Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks
Test/Notion.IntegrationTests Expand file tree Collapse file tree 8 files changed +91
-0
lines changed Original file line number Diff line number Diff line change 1+ using Newtonsoft . Json ;
2+
3+ namespace Notion . Client
4+ {
5+ public class AudioUpdateBlock : UpdateBlock , IUpdateBlock
6+ {
7+ [ JsonProperty ( "audio" ) ]
8+ public IFileObjectInput Audio { get ; set ; }
9+ }
10+ }
Original file line number Diff line number Diff line change 1+ using Newtonsoft . Json ;
2+
3+ namespace Notion . Client
4+ {
5+ public class AudioBlock : Block
6+ {
7+ public override BlockType Type => BlockType . Audio ;
8+
9+ [ JsonProperty ( "audio" ) ]
10+ public FileObject Audio { get ; set ; }
11+ }
12+ }
Original file line number Diff line number Diff line change 55namespace Notion . Client
66{
77 [ JsonConverter ( typeof ( JsonSubtypes ) , "type" ) ]
8+ [ JsonSubtypes . KnownSubType ( typeof ( AudioBlock ) , BlockType . Audio ) ]
89 [ JsonSubtypes . KnownSubType ( typeof ( BookmarkBlock ) , BlockType . Bookmark ) ]
910 [ JsonSubtypes . KnownSubType ( typeof ( BulletedListItemBlock ) , BlockType . BulletedListItem ) ]
1011 [ JsonSubtypes . KnownSubType ( typeof ( ChildPageBlock ) , BlockType . ChildPage ) ]
Original file line number Diff line number Diff line change @@ -64,6 +64,9 @@ public enum BlockType
6464 [ EnumMember ( Value = "divider" ) ]
6565 Divider ,
6666
67+ [ EnumMember ( Value = "audio" ) ]
68+ Audio ,
69+
6770 [ EnumMember ( Value = "unsupported" ) ]
6871 Unsupported
6972 }
Original file line number Diff line number Diff line change 1+ using Newtonsoft . Json ;
2+
3+ namespace Notion . Client
4+ {
5+ public class ExternalFileInput : IFileObjectInput
6+ {
7+ [ JsonProperty ( "external" ) ]
8+ public Data External { get ; set ; }
9+
10+ public class Data
11+ {
12+ [ JsonProperty ( "url" ) ]
13+ public string Url { get ; set ; }
14+ }
15+ }
16+ }
Original file line number Diff line number Diff line change 1+ namespace Notion . Client
2+ {
3+ public interface IFileObjectInput
4+ {
5+ }
6+ }
Original file line number Diff line number Diff line change 1+ using System ;
2+ using Newtonsoft . Json ;
3+
4+ namespace Notion . Client
5+ {
6+ public class UploadedFileInput : IFileObjectInput
7+ {
8+ [ JsonProperty ( "file" ) ]
9+ public Data File { get ; set ; }
10+
11+ public class Data
12+ {
13+ [ JsonProperty ( "url" ) ]
14+ public string Url { get ; set ; }
15+
16+ [ JsonProperty ( "expiry_time" ) ]
17+ public DateTime ExpiryTime { get ; set ; }
18+ }
19+ }
20+ }
Original file line number Diff line number Diff line change @@ -268,6 +268,29 @@ private static IEnumerable<object[]> BlockData()
268268 Assert . NotNull ( block ) ;
269269 Assert . IsType < DividerBlock > ( block ) ;
270270 } )
271+ } ,
272+ new object [ ] {
273+ new AudioBlock {
274+ Audio = new ExternalFile {
275+ External = new ExternalFile . Info {
276+ Url = "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3"
277+ }
278+ }
279+ } ,
280+ new AudioUpdateBlock {
281+ Audio = new ExternalFileInput {
282+ External = new ExternalFileInput . Data {
283+ Url = "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-3.mp3"
284+ }
285+ }
286+ } ,
287+ new Action < Block > ( ( block ) => {
288+ block . Should ( ) . NotBeNull ( ) ;
289+
290+ block . Should ( ) . BeOfType < AudioBlock > ( ) . Subject
291+ . Audio . Should ( ) . BeOfType < ExternalFile > ( ) . Subject
292+ . External . Url . Should ( ) . Be ( "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-3.mp3" ) ;
293+ } )
271294 }
272295 } ;
273296 }
You can’t perform that action at this time.
0 commit comments