Skip to content

Commit 8d574d6

Browse files
Add Block object request models
1 parent 484e365 commit 8d574d6

35 files changed

+752
-0
lines changed
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+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Collections.Generic;
2+
using Newtonsoft.Json;
3+
4+
namespace Notion.Client
5+
{
6+
public class CodeBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
7+
{
8+
[JsonProperty("code")]
9+
public Info Code { get; set; }
10+
11+
public override BlockType Type => BlockType.Code;
12+
13+
public class Info
14+
{
15+
[JsonProperty("rich_text")]
16+
public IEnumerable<RichTextBase> RichText { get; set; }
17+
18+
[JsonProperty("language")]
19+
public string Language { get; set; }
20+
21+
[JsonProperty("caption")]
22+
public IEnumerable<RichTextBase> Caption { get; set; }
23+
}
24+
}
25+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Collections.Generic;
2+
using Newtonsoft.Json;
3+
4+
namespace Notion.Client
5+
{
6+
public class ColumnBlockRequest : BlockObjectRequest
7+
{
8+
public override BlockType Type => BlockType.Column;
9+
10+
[JsonProperty("column")]
11+
public Info Column { get; set; }
12+
13+
public class Info
14+
{
15+
[JsonProperty("children")]
16+
public IEnumerable<IColumnChildrenBlockRequest> Children { get; set; }
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)