Skip to content

Commit b545bd8

Browse files
code refactor ♻️
1 parent 2d5f81e commit b545bd8

File tree

5 files changed

+31
-32
lines changed

5 files changed

+31
-32
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Collections.Generic;
2+
3+
namespace Notion.Client
4+
{
5+
// TODO: need an input version of Block
6+
public interface IBlocksAppendChildrenBodyParameters
7+
{
8+
IEnumerable<BlockBase> Children { get; set; }
9+
}
10+
11+
public class BlocksAppendChildrenParameters : IBlocksAppendChildrenBodyParameters
12+
{
13+
public IEnumerable<BlockBase> Children { get; set; }
14+
}
15+
}

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

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Notion.Client
77
{
88
public interface IBlocksClient
99
{
10-
Task<PaginatedList<BlockBase>> RetrieveChildrenAsync(string blockId, BlockRetrieveChildrenParameters parameters = null);
10+
Task<PaginatedList<BlockBase>> RetrieveChildrenAsync(string blockId, BlocksRetrieveChildrenParameters parameters = null);
1111
Task<BlockBase> AppendChildrenAsync(string blockId, BlocksAppendChildrenParameters parameters = null);
1212
}
1313

@@ -20,7 +20,7 @@ public BlocksClient(IRestClient client)
2020
_client = client;
2121
}
2222

23-
public async Task<PaginatedList<BlockBase>> RetrieveChildrenAsync(string blockId, BlockRetrieveChildrenParameters parameters = null)
23+
public async Task<PaginatedList<BlockBase>> RetrieveChildrenAsync(string blockId, BlocksRetrieveChildrenParameters parameters = null)
2424
{
2525
if (string.IsNullOrWhiteSpace(blockId))
2626
{
@@ -29,7 +29,7 @@ public async Task<PaginatedList<BlockBase>> RetrieveChildrenAsync(string blockId
2929

3030
var url = BlocksApiUrls.RetrieveChildren(blockId);
3131

32-
var queryParameters = (IBlockRetrieveChildrenQueryParameters)parameters;
32+
var queryParameters = (IBlocksRetrieveChildrenQueryParameters)parameters;
3333

3434
var queryParams = new Dictionary<string, string>()
3535
{
@@ -54,30 +54,4 @@ public async Task<BlockBase> AppendChildrenAsync(string blockId, BlocksAppendChi
5454
return await _client.PatchAsync<BlockBase>(url, body);
5555
}
5656
}
57-
58-
public interface IBlockRetrieveChildrenQueryParameters : IPaginationParameters
59-
{
60-
}
61-
62-
public interface IBlockRetrieveChildrenParameters : IBlockRetrieveChildrenQueryParameters
63-
{
64-
}
65-
66-
public class BlockRetrieveChildrenParameters : IBlockRetrieveChildrenParameters
67-
{
68-
public string StartCursor { get; set; }
69-
public string PageSize { get; set; }
70-
}
71-
72-
73-
// TODO: need an input version of Block
74-
public interface IBlocksAppendChildrenBodyParameters
75-
{
76-
IEnumerable<BlockBase> Children { get; set; }
77-
}
78-
79-
public class BlocksAppendChildrenParameters : IBlocksAppendChildrenBodyParameters
80-
{
81-
public IEnumerable<BlockBase> Children { get; set; }
82-
}
8357
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Notion.Client
2+
{
3+
public interface IBlocksRetrieveChildrenQueryParameters : IPaginationParameters
4+
{
5+
}
6+
7+
public class BlocksRetrieveChildrenParameters : IBlocksRetrieveChildrenQueryParameters
8+
{
9+
public string StartCursor { get; set; }
10+
public string PageSize { get; set; }
11+
}
12+
}

Src/Notion.Client/Models/Block.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public class BlockBase
3535

3636
[JsonProperty("has_children")]
3737
public virtual bool HasChildren { get; set; }
38-
3938
}
4039

4140
public class ParagraphBlock : BlockBase
@@ -160,7 +159,6 @@ public class ChildPageBlock : BlockBase
160159
{
161160
public override BlockType Type => BlockType.ChildPage;
162161

163-
164162
[JsonProperty("child_page")]
165163
public ChildPageClass ChildPage { get; set; }
166164

Test/Notion.UnitTests/BlocksClientTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public async Task RetrieveBlockChildren()
2424
{
2525
string blockId = "3c357473-a281-49a4-88c0-10d2b245a589";
2626

27-
var children = await _client.RetrieveChildrenAsync(blockId, new BlockRetrieveChildrenParameters());
27+
var children = await _client.RetrieveChildrenAsync(blockId, new BlocksRetrieveChildrenParameters());
2828

2929
Assert.NotNull(children);
3030
}

0 commit comments

Comments
 (0)