Skip to content

Commit 5e0882b

Browse files
authored
Merge pull request #401 from notion-dotnet/chore/219-add-separate-request-model-for-blocks-api
Add separate request model for blocks api
2 parents 484e365 + f5f69be commit 5e0882b

39 files changed

+793
-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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
4+
{
5+
public class AudioBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
6+
{
7+
[JsonProperty("audio")]
8+
public FileObject Audio { get; set; }
9+
10+
public override BlockType Type => BlockType.Audio;
11+
}
12+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
3+
namespace Notion.Client
4+
{
5+
public abstract class BlockObjectRequest : IBlockObjectRequest
6+
{
7+
public ObjectType Object => ObjectType.Block;
8+
9+
public string Id { get; set; }
10+
11+
public virtual BlockType Type { get; set; }
12+
13+
public DateTime CreatedTime { get; set; }
14+
15+
public DateTime LastEditedTime { get; set; }
16+
17+
public virtual bool HasChildren { get; set; }
18+
19+
public PartialUser CreatedBy { get; set; }
20+
21+
public PartialUser LastEditedBy { get; set; }
22+
23+
/// <summary>
24+
/// Information about the block's parent.
25+
/// </summary>
26+
public IBlockParent Parent { get; set; }
27+
}
28+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System.Collections.Generic;
2+
using Newtonsoft.Json;
3+
4+
namespace Notion.Client
5+
{
6+
public class BookmarkBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
7+
{
8+
[JsonProperty("bookmark")]
9+
public Info Bookmark { get; set; }
10+
11+
public override BlockType Type => BlockType.Bookmark;
12+
13+
public class Info
14+
{
15+
[JsonProperty("url")]
16+
public string Url { get; set; }
17+
18+
[JsonProperty("caption")]
19+
public IEnumerable<RichTextBase> Caption { get; set; }
20+
}
21+
}
22+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
4+
{
5+
public class BreadcrumbBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
6+
{
7+
[JsonProperty("breadcrumb")]
8+
public Data Breadcrumb { get; set; }
9+
10+
public override BlockType Type => BlockType.Breadcrumb;
11+
12+
public class Data
13+
{
14+
}
15+
}
16+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Collections.Generic;
2+
using Newtonsoft.Json;
3+
using Newtonsoft.Json.Converters;
4+
5+
namespace Notion.Client
6+
{
7+
public class BulletedListItemBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
8+
{
9+
[JsonProperty("bulleted_list_item")]
10+
public Info BulletedListItem { get; set; }
11+
12+
public override BlockType Type => BlockType.BulletedListItem;
13+
14+
public class Info
15+
{
16+
[JsonProperty("rich_text")]
17+
public IEnumerable<RichTextBase> RichText { get; set; }
18+
19+
[JsonProperty("color")]
20+
[JsonConverter(typeof(StringEnumConverter))]
21+
public Color? Color { get; set; }
22+
23+
[JsonProperty("children")]
24+
public IEnumerable<INonColumnBlockRequest> Children { get; set; }
25+
}
26+
}
27+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Collections.Generic;
2+
using Newtonsoft.Json;
3+
using Newtonsoft.Json.Converters;
4+
5+
namespace Notion.Client
6+
{
7+
public class CalloutBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
8+
{
9+
[JsonProperty("callout")]
10+
public Info Callout { get; set; }
11+
12+
public override BlockType Type => BlockType.Callout;
13+
14+
public class Info
15+
{
16+
[JsonProperty("rich_text")]
17+
public IEnumerable<RichTextBase> RichText { get; set; }
18+
19+
[JsonProperty("icon")]
20+
public IPageIcon Icon { get; set; }
21+
22+
[JsonProperty("color")]
23+
[JsonConverter(typeof(StringEnumConverter))]
24+
public Color? Color { get; set; }
25+
26+
[JsonProperty("children")]
27+
public IEnumerable<INonColumnBlockRequest> Children { get; set; }
28+
}
29+
}
30+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
4+
{
5+
public class ChildDatabaseBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
6+
{
7+
[JsonProperty("child_database")]
8+
public Info ChildDatabase { get; set; }
9+
10+
public override BlockType Type => BlockType.ChildDatabase;
11+
12+
public class Info
13+
{
14+
[JsonProperty("title")]
15+
public string Title { get; set; }
16+
}
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
4+
{
5+
public class ChildPageBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
6+
{
7+
[JsonProperty("child_page")]
8+
public Info ChildPage { get; set; }
9+
10+
public override BlockType Type => BlockType.ChildPage;
11+
12+
public class Info
13+
{
14+
[JsonProperty("title")]
15+
public string Title { get; set; }
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)