Skip to content

Commit 70e7d23

Browse files
Revert AppendBlockChildren api should return PaginatedList of blocks
1 parent ad0532d commit 70e7d23

File tree

4 files changed

+56
-105
lines changed

4 files changed

+56
-105
lines changed

Src/Notion.Client/Api/Blocks/BlocksClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public async Task<PaginatedList<Block>> RetrieveChildrenAsync(string blockId, Bl
3434
return await _client.GetAsync<PaginatedList<Block>>(url, queryParams);
3535
}
3636

37-
public async Task<PaginatedList<Block>> AppendChildrenAsync(string blockId, BlocksAppendChildrenParameters parameters = null)
37+
public async Task<Block> AppendChildrenAsync(string blockId, BlocksAppendChildrenParameters parameters = null)
3838
{
3939
if (string.IsNullOrWhiteSpace(blockId))
4040
{
@@ -45,7 +45,7 @@ public async Task<PaginatedList<Block>> AppendChildrenAsync(string blockId, Bloc
4545

4646
var body = (IBlocksAppendChildrenBodyParameters)parameters;
4747

48-
return await _client.PatchAsync<PaginatedList<Block>>(url, body);
48+
return await _client.PatchAsync<Block>(url, body);
4949
}
5050

5151
public async Task<Block> RetrieveAsync(string blockId)

Src/Notion.Client/Api/Blocks/IBlocksClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ public interface IBlocksClient
2020
Task<Block> UpdateAsync(string blockId, IUpdateBlock updateBlock);
2121

2222
Task<PaginatedList<Block>> RetrieveChildrenAsync(string blockId, BlocksRetrieveChildrenParameters parameters = null);
23-
Task<PaginatedList<Block>> AppendChildrenAsync(string blockId, BlocksAppendChildrenParameters parameters = null);
23+
Task<Block> AppendChildrenAsync(string blockId, BlocksAppendChildrenParameters parameters = null);
2424
}
2525
}

Test/Notion.UnitTests/BlocksClientTests.cs

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -101,27 +101,14 @@ public async Task AppendBlockChildren()
101101
};
102102

103103
// Act
104-
var blocksResult = await _client.AppendChildrenAsync(blockId, parameters);
105-
106-
// Assert
107-
var blocks = blocksResult.Results;
108-
blocks.Should().SatisfyRespectively(
109-
block =>
110-
{
111-
block.Type.Should().Be(BlockType.Heading_2);
112-
var headingBlock = (HeadingTwoBlock)block;
113-
var text = headingBlock.Heading_2.Text.OfType<RichTextText>().FirstOrDefault();
114-
text.Text.Content.Should().Be("Lacinato kale");
115-
},
116-
block =>
117-
{
118-
block.Type.Should().Be(BlockType.Paragraph);
119-
var paragraphBlock = (ParagraphBlock)block;
120-
var text = paragraphBlock.Paragraph.Text.OfType<RichTextText>().LastOrDefault();
121-
text.Text.Content.Should().Be("Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm.");
122-
text.Text.Link.Url.Should().Be("https://en.wikipedia.org/wiki/Lacinato_kale");
123-
}
124-
);
104+
var block = await _client.AppendChildrenAsync(blockId, parameters);
105+
106+
// Assert
107+
block.Type.Should().Be(BlockType.Paragraph);
108+
var paragraphBlock = (ParagraphBlock)block;
109+
var text = paragraphBlock.Paragraph.Text.OfType<RichTextText>().LastOrDefault();
110+
text.Text.Content.Should().Be("Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm.");
111+
text.Text.Link.Url.Should().Be("https://en.wikipedia.org/wiki/Lacinato_kale");
125112
}
126113

127114
[Fact]
Lines changed: 45 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,50 @@
11
{
2-
"object": "list",
3-
"results": [
4-
{
5-
"object": "block",
6-
"id": "9bc30ad4-9373-46a5-84ab-0a7845ee52e6",
7-
"created_time": "2021-03-16T16:31:00.000Z",
8-
"last_edited_time": "2021-03-16T16:32:00.000Z",
9-
"has_children": false,
10-
"type": "heading_2",
11-
"heading_2": {
12-
"text": [
13-
{
14-
"type": "text",
15-
"text": {
16-
"content": "Lacinato kale",
17-
"link": null
18-
},
19-
"annotations": {
20-
"bold": false,
21-
"italic": false,
22-
"strikethrough": false,
23-
"underline": false,
24-
"code": false,
25-
"color": "default"
26-
},
27-
"plain_text": "Lacinato kale",
28-
"href": null
2+
"object": "block",
3+
"id": "7face6fd-3ef4-4b38-b1dc-c5044988eec0",
4+
"created_time": "2021-03-16T16:34:00.000Z",
5+
"last_edited_time": "2021-03-16T16:36:00.000Z",
6+
"has_children": false,
7+
"type": "paragraph",
8+
"paragraph": {
9+
"text": [
10+
{
11+
"type": "text",
12+
"text": {
13+
"content": "Lacinato kale",
14+
"link": {
15+
"url": "https://en.wikipedia.org/wiki/Lacinato_kale"
2916
}
30-
]
31-
}
32-
},
33-
{
34-
"object": "block",
35-
"id": "7face6fd-3ef4-4b38-b1dc-c5044988eec0",
36-
"created_time": "2021-03-16T16:34:00.000Z",
37-
"last_edited_time": "2021-03-16T16:36:00.000Z",
38-
"has_children": false,
39-
"type": "paragraph",
40-
"paragraph": {
41-
"text": [
42-
{
43-
"type": "text",
44-
"text": {
45-
"content": "Lacinato kale",
46-
"link": {
47-
"url": "https://en.wikipedia.org/wiki/Lacinato_kale"
48-
}
49-
},
50-
"annotations": {
51-
"bold": false,
52-
"italic": false,
53-
"strikethrough": false,
54-
"underline": false,
55-
"code": false,
56-
"color": "default"
57-
},
58-
"plain_text": "Lacinato kale",
59-
"href": "https://en.wikipedia.org/wiki/Lacinato_kale"
60-
},
61-
{
62-
"type": "text",
63-
"text": {
64-
"content": "Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm.",
65-
"link": {
66-
"url": "https://en.wikipedia.org/wiki/Lacinato_kale"
67-
}
68-
},
69-
"annotations": {
70-
"bold": false,
71-
"italic": false,
72-
"strikethrough": false,
73-
"underline": false,
74-
"code": false,
75-
"color": "default"
76-
},
77-
"plain_text": "Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm.",
78-
"href": "https://en.wikipedia.org/wiki/Lacinato_kale"
17+
},
18+
"annotations": {
19+
"bold": false,
20+
"italic": false,
21+
"strikethrough": false,
22+
"underline": false,
23+
"code": false,
24+
"color": "default"
25+
},
26+
"plain_text": "Lacinato kale",
27+
"href": "https://en.wikipedia.org/wiki/Lacinato_kale"
28+
},
29+
{
30+
"type": "text",
31+
"text": {
32+
"content": "Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm.",
33+
"link": {
34+
"url": "https://en.wikipedia.org/wiki/Lacinato_kale"
7935
}
80-
]
36+
},
37+
"annotations": {
38+
"bold": false,
39+
"italic": false,
40+
"strikethrough": false,
41+
"underline": false,
42+
"code": false,
43+
"color": "default"
44+
},
45+
"plain_text": "Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm.",
46+
"href": "https://en.wikipedia.org/wiki/Lacinato_kale"
8147
}
82-
}
83-
],
84-
"next_cursor": null,
85-
"has_more": false
48+
]
49+
}
8650
}

0 commit comments

Comments
 (0)