Skip to content

Commit 4089a9c

Browse files
Merge pull request #213 from notion-dotnet/195-add-support-for-updating-media-blocks
Add support for updating media blocks ❇️
2 parents 5cf7897 + 1fbf465 commit 4089a9c

File tree

5 files changed

+70
-0
lines changed

5 files changed

+70
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
4+
{
5+
public class FileUpdateBlock : UpdateBlock, IUpdateBlock
6+
{
7+
[JsonProperty("file")]
8+
public IFileObjectInput File { get; set; }
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
4+
{
5+
public class ImageUpdateBlock : UpdateBlock, IUpdateBlock
6+
{
7+
[JsonProperty("image")]
8+
public IFileObjectInput Image { get; set; }
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
4+
{
5+
public class PDFUpdateBlock : UpdateBlock, IUpdateBlock
6+
{
7+
[JsonProperty("pdf")]
8+
public IFileObjectInput PDF { get; set; }
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
4+
{
5+
public class VideoUpdateBlock : UpdateBlock, IUpdateBlock
6+
{
7+
[JsonProperty("video")]
8+
public IFileObjectInput Video { get; set; }
9+
}
10+
}

Test/Notion.IntegrationTests/IBlocksClientTests.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,36 @@ private static IEnumerable<object[]> BlockData()
398398

399399
Assert.Equal("Test 2", quoteBlock.Quote.Text.OfType<RichTextText>().First().Text.Content);
400400
})
401+
},
402+
new object[]
403+
{
404+
new ImageBlock() {
405+
Image = new ExternalFile
406+
{
407+
External = new ExternalFile.Info
408+
{
409+
Url = "https://zephoria.com/wp-content/uploads/2014/08/online-community.jpg"
410+
}
411+
}
412+
},
413+
new ImageUpdateBlock()
414+
{
415+
Image = new ExternalFileInput
416+
{
417+
External = new ExternalFileInput.Data
418+
{
419+
Url = "https://www.iaspaper.net/wp-content/uploads/2017/09/TNEA-Online-Application.jpg"
420+
}
421+
}
422+
},
423+
new Action<IBlock> (block =>
424+
{
425+
Assert.NotNull(block);
426+
var imageBlock = Assert.IsType<ImageBlock>(block);
427+
var imageFile = Assert.IsType<ExternalFile>(imageBlock.Image);
428+
429+
Assert.Equal("https://www.iaspaper.net/wp-content/uploads/2017/09/TNEA-Online-Application.jpg", imageFile.External.Url);
430+
})
401431
}
402432
};
403433
}

0 commit comments

Comments
 (0)