Skip to content

Commit f5f69be

Browse files
Use IBlockObjectRequest in Block Append Children api
1 parent 8d574d6 commit f5f69be

File tree

4 files changed

+41
-39
lines changed

4 files changed

+41
-39
lines changed

Src/Notion.Client/Api/Blocks/AppendChildren/Request/BlockAppendChildrenRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace Notion.Client
44
{
55
public class BlockAppendChildrenRequest : IBlockAppendChildrenBodyParameters, IBlockAppendChildrenPathParameters
66
{
7-
public IEnumerable<IBlock> Children { get; set; }
7+
public IEnumerable<IBlockObjectRequest> Children { get; set; }
88

99
public string After { get; set; }
1010

Src/Notion.Client/Api/Blocks/AppendChildren/Request/IBlockAppendChildrenBodyParameters.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33

44
namespace Notion.Client
55
{
6-
// TODO: need an input version of Block
76
public interface IBlockAppendChildrenBodyParameters
87
{
98
[JsonProperty("children")]
10-
IEnumerable<IBlock> Children { get; set; }
9+
IEnumerable<IBlockObjectRequest> Children { get; set; }
1110

1211
/// <summary>
1312
/// The ID of the existing block that the new block should be appended after.
@@ -18,7 +17,7 @@ public interface IBlockAppendChildrenBodyParameters
1817

1918
internal class BlockAppendChildrenBodyParameters : IBlockAppendChildrenBodyParameters
2019
{
21-
public IEnumerable<IBlock> Children { get; set; }
20+
public IEnumerable<IBlockObjectRequest> Children { get; set; }
2221

2322
public string After { get; set; }
2423

Test/Notion.IntegrationTests/BlocksClientTests.cs

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ public async Task AppendChildrenAsync_AppendsBlocksGivenBlocks()
3333
new BlockAppendChildrenRequest
3434
{
3535
BlockId = _page.Id,
36-
Children = new List<IBlock>
36+
Children = new List<IBlockObjectRequest>
3737
{
38-
new BreadcrumbBlock { Breadcrumb = new BreadcrumbBlock.Data() },
39-
new DividerBlock { Divider = new DividerBlock.Data() },
40-
new TableOfContentsBlock { TableOfContents = new TableOfContentsBlock.Data() },
41-
new CalloutBlock
38+
new BreadcrumbBlockRequest { Breadcrumb = new BreadcrumbBlockRequest.Data() },
39+
new DividerBlockRequest { Divider = new DividerBlockRequest.Data() },
40+
new TableOfContentsBlockRequest { TableOfContents = new TableOfContentsBlockRequest.Data() },
41+
new CalloutBlockRequest
4242
{
43-
Callout = new CalloutBlock.Info
43+
Callout = new CalloutBlockRequest.Info
4444
{
4545
RichText = new List<RichTextBaseInput>
4646
{
@@ -62,7 +62,10 @@ public async Task UpdateBlockAsync_UpdatesGivenBlock()
6262
new BlockAppendChildrenRequest
6363
{
6464
BlockId = _page.Id,
65-
Children = new List<IBlock> { new BreadcrumbBlock { Breadcrumb = new BreadcrumbBlock.Data() } }
65+
Children = new List<IBlockObjectRequest>
66+
{
67+
new BreadcrumbBlockRequest { Breadcrumb = new BreadcrumbBlockRequest.Data() }
68+
}
6669
}
6770
);
6871

@@ -82,10 +85,10 @@ public async Task DeleteAsync_DeleteBlockWithGivenId()
8285
new BlockAppendChildrenRequest
8386
{
8487
BlockId = _page.Id,
85-
Children = new List<IBlock>
88+
Children = new List<IBlockObjectRequest>
8689
{
87-
new DividerBlock { Divider = new DividerBlock.Data() },
88-
new TableOfContentsBlock { TableOfContents = new TableOfContentsBlock.Data() }
90+
new DividerBlockRequest { Divider = new DividerBlockRequest.Data() },
91+
new TableOfContentsBlockRequest { TableOfContents = new TableOfContentsBlockRequest.Data() }
8992
}
9093
}
9194
);
@@ -96,13 +99,13 @@ public async Task DeleteAsync_DeleteBlockWithGivenId()
9699
[Theory]
97100
[MemberData(nameof(BlockData))]
98101
public async Task UpdateAsync_UpdatesGivenBlock(
99-
IBlock block, IUpdateBlock updateBlock, Action<IBlock, INotionClient> assert)
102+
IBlockObjectRequest block, IUpdateBlock updateBlock, Action<IBlock, INotionClient> assert)
100103
{
101104
var blocks = await Client.Blocks.AppendChildrenAsync(
102105
new BlockAppendChildrenRequest
103106
{
104107
BlockId = _page.Id,
105-
Children = new List<IBlock> { block }
108+
Children = new List<IBlockObjectRequest> { block }
106109
}
107110
);
108111

@@ -125,9 +128,9 @@ private static IEnumerable<object[]> BlockData()
125128
{
126129
new object[]
127130
{
128-
new BookmarkBlock
131+
new BookmarkBlockRequest
129132
{
130-
Bookmark = new BookmarkBlock.Info
133+
Bookmark = new BookmarkBlockRequest.Info
131134
{
132135
Url = "https://developers.notion.com/reference/rich-text",
133136
Caption = new List<RichTextBase>
@@ -156,7 +159,7 @@ private static IEnumerable<object[]> BlockData()
156159
},
157160
new object[]
158161
{
159-
new EquationBlock { Equation = new EquationBlock.Info { Expression = "e=mc^3" } },
162+
new EquationBlockRequest { Equation = new EquationBlockRequest.Info { Expression = "e=mc^3" } },
160163
new EquationUpdateBlock { Equation = new EquationUpdateBlock.Info { Expression = "e=mc^2" } },
161164
new Action<IBlock, INotionClient>((block, _) =>
162165
{
@@ -166,7 +169,7 @@ private static IEnumerable<object[]> BlockData()
166169
},
167170
new object[]
168171
{
169-
new DividerBlock { Divider = new DividerBlock.Data() }, new DividerUpdateBlock(),
172+
new DividerBlockRequest { Divider = new DividerBlockRequest.Data() }, new DividerUpdateBlock(),
170173
new Action<IBlock, INotionClient>((block, client) =>
171174
{
172175
Assert.NotNull(block);
@@ -175,7 +178,7 @@ private static IEnumerable<object[]> BlockData()
175178
},
176179
new object[]
177180
{
178-
new AudioBlock
181+
new AudioBlockRequest
179182
{
180183
Audio = new ExternalFile
181184
{
@@ -206,7 +209,7 @@ private static IEnumerable<object[]> BlockData()
206209
},
207210
new object[]
208211
{
209-
new TableOfContentsBlock { TableOfContents = new TableOfContentsBlock.Data() },
212+
new TableOfContentsBlockRequest { TableOfContents = new TableOfContentsBlockRequest.Data() },
210213
new TableOfContentsUpdateBlock(), new Action<IBlock, INotionClient>((block, client) =>
211214
{
212215
Assert.NotNull(block);
@@ -215,9 +218,9 @@ private static IEnumerable<object[]> BlockData()
215218
},
216219
new object[]
217220
{
218-
new CalloutBlock
221+
new CalloutBlockRequest
219222
{
220-
Callout = new CalloutBlock.Info
223+
Callout = new CalloutBlockRequest.Info
221224
{
222225
RichText = new List<RichTextBaseInput>
223226
{
@@ -245,9 +248,9 @@ private static IEnumerable<object[]> BlockData()
245248
},
246249
new object[]
247250
{
248-
new QuoteBlock
251+
new QuoteBlockRequest
249252
{
250-
Quote = new QuoteBlock.Info
253+
Quote = new QuoteBlockRequest.Info
251254
{
252255
RichText = new List<RichTextBaseInput>
253256
{
@@ -275,7 +278,7 @@ private static IEnumerable<object[]> BlockData()
275278
},
276279
new object[]
277280
{
278-
new ImageBlock
281+
new ImageBlockRequest
279282
{
280283
Image = new ExternalFile
281284
{
@@ -308,9 +311,9 @@ private static IEnumerable<object[]> BlockData()
308311
},
309312
new object[]
310313
{
311-
new EmbedBlock
314+
new EmbedBlockRequest
312315
{
313-
Embed = new EmbedBlock.Info
316+
Embed = new EmbedBlockRequest.Info
314317
{
315318
Url = "https://zephoria.com/wp-content/uploads/2014/08/online-community.jpg"
316319
}
@@ -333,7 +336,7 @@ private static IEnumerable<object[]> BlockData()
333336
},
334337
new object[]
335338
{
336-
new LinkToPageBlock
339+
new LinkToPageBlockRequest
337340
{
338341
LinkToPage = new PageParent
339342
{
@@ -359,16 +362,16 @@ private static IEnumerable<object[]> BlockData()
359362
},
360363
new object[]
361364
{
362-
new TableBlock
365+
new TableBlockRequest
363366
{
364-
Table = new TableBlock.Info
367+
Table = new TableBlockRequest.Info
365368
{
366369
TableWidth = 1,
367370
Children = new[]
368371
{
369-
new TableRowBlock
372+
new TableRowBlockRequest
370373
{
371-
TableRow = new TableRowBlock.Info
374+
TableRow = new TableRowBlockRequest.Info
372375
{
373376
Cells = new[]
374377
{

Test/Notion.UnitTests/BlocksClientTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,21 @@ public async Task AppendBlockChildren()
6363
var request = new BlockAppendChildrenRequest
6464
{
6565
BlockId = blockId,
66-
Children = new List<IBlock>
66+
Children = new List<IBlockObjectRequest>
6767
{
68-
new HeadingTwoBlock
68+
new HeadingTwoBlockRequest
6969
{
70-
Heading_2 = new HeadingTwoBlock.Info
70+
Heading_2 = new HeadingTwoBlockRequest.Info
7171
{
7272
RichText = new List<RichTextBase>
7373
{
7474
new RichTextText { Text = new Text { Content = "Lacinato kale" } }
7575
}
7676
}
7777
},
78-
new ParagraphBlock
78+
new ParagraphBlockRequest
7979
{
80-
Paragraph = new ParagraphBlock.Info
80+
Paragraph = new ParagraphBlockRequest.Info
8181
{
8282
RichText = new List<RichTextBase>
8383
{

0 commit comments

Comments
 (0)