Skip to content

Add separate request model for blocks api #401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Notion.Client
{
public class BlockAppendChildrenRequest : IBlockAppendChildrenBodyParameters, IBlockAppendChildrenPathParameters
{
public IEnumerable<IBlock> Children { get; set; }
public IEnumerable<IBlockObjectRequest> Children { get; set; }

public string After { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

namespace Notion.Client
{
// TODO: need an input version of Block
public interface IBlockAppendChildrenBodyParameters
{
[JsonProperty("children")]
IEnumerable<IBlock> Children { get; set; }
IEnumerable<IBlockObjectRequest> Children { get; set; }

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

internal class BlockAppendChildrenBodyParameters : IBlockAppendChildrenBodyParameters
{
public IEnumerable<IBlock> Children { get; set; }
public IEnumerable<IBlockObjectRequest> Children { get; set; }

public string After { get; set; }

Expand Down
12 changes: 12 additions & 0 deletions Src/Notion.Client/Models/Blocks/Request/AudioBlockRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Newtonsoft.Json;

namespace Notion.Client
{
public class AudioBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
{
[JsonProperty("audio")]
public FileObject Audio { get; set; }

public override BlockType Type => BlockType.Audio;
}
}
28 changes: 28 additions & 0 deletions Src/Notion.Client/Models/Blocks/Request/BlockObjectRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;

namespace Notion.Client
{
public abstract class BlockObjectRequest : IBlockObjectRequest
{
public ObjectType Object => ObjectType.Block;

public string Id { get; set; }

public virtual BlockType Type { get; set; }

public DateTime CreatedTime { get; set; }

public DateTime LastEditedTime { get; set; }

public virtual bool HasChildren { get; set; }

public PartialUser CreatedBy { get; set; }

public PartialUser LastEditedBy { get; set; }

/// <summary>
/// Information about the block's parent.
/// </summary>
public IBlockParent Parent { get; set; }
}
}
22 changes: 22 additions & 0 deletions Src/Notion.Client/Models/Blocks/Request/BookmarkBlockRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Notion.Client
{
public class BookmarkBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
{
[JsonProperty("bookmark")]
public Info Bookmark { get; set; }

public override BlockType Type => BlockType.Bookmark;

public class Info
{
[JsonProperty("url")]
public string Url { get; set; }

[JsonProperty("caption")]
public IEnumerable<RichTextBase> Caption { get; set; }
}
}
}
16 changes: 16 additions & 0 deletions Src/Notion.Client/Models/Blocks/Request/BreadcrumbBlockRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Newtonsoft.Json;

namespace Notion.Client
{
public class BreadcrumbBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
{
[JsonProperty("breadcrumb")]
public Data Breadcrumb { get; set; }

public override BlockType Type => BlockType.Breadcrumb;

public class Data
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Notion.Client
{
public class BulletedListItemBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
{
[JsonProperty("bulleted_list_item")]
public Info BulletedListItem { get; set; }

public override BlockType Type => BlockType.BulletedListItem;

public class Info
{
[JsonProperty("rich_text")]
public IEnumerable<RichTextBase> RichText { get; set; }

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color? Color { get; set; }

[JsonProperty("children")]
public IEnumerable<INonColumnBlockRequest> Children { get; set; }
}
}
}
30 changes: 30 additions & 0 deletions Src/Notion.Client/Models/Blocks/Request/CalloutBlockRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Notion.Client
{
public class CalloutBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
{
[JsonProperty("callout")]
public Info Callout { get; set; }

public override BlockType Type => BlockType.Callout;

public class Info
{
[JsonProperty("rich_text")]
public IEnumerable<RichTextBase> RichText { get; set; }

[JsonProperty("icon")]
public IPageIcon Icon { get; set; }

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color? Color { get; set; }

[JsonProperty("children")]
public IEnumerable<INonColumnBlockRequest> Children { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Newtonsoft.Json;

namespace Notion.Client
{
public class ChildDatabaseBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
{
[JsonProperty("child_database")]
public Info ChildDatabase { get; set; }

public override BlockType Type => BlockType.ChildDatabase;

public class Info
{
[JsonProperty("title")]
public string Title { get; set; }
}
}
}
18 changes: 18 additions & 0 deletions Src/Notion.Client/Models/Blocks/Request/ChildPageBlockRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Newtonsoft.Json;

namespace Notion.Client
{
public class ChildPageBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
{
[JsonProperty("child_page")]
public Info ChildPage { get; set; }

public override BlockType Type => BlockType.ChildPage;

public class Info
{
[JsonProperty("title")]
public string Title { get; set; }
}
}
}
25 changes: 25 additions & 0 deletions Src/Notion.Client/Models/Blocks/Request/CodeBlockRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Notion.Client
{
public class CodeBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
{
[JsonProperty("code")]
public Info Code { get; set; }

public override BlockType Type => BlockType.Code;

public class Info
{
[JsonProperty("rich_text")]
public IEnumerable<RichTextBase> RichText { get; set; }

[JsonProperty("language")]
public string Language { get; set; }

[JsonProperty("caption")]
public IEnumerable<RichTextBase> Caption { get; set; }
}
}
}
19 changes: 19 additions & 0 deletions Src/Notion.Client/Models/Blocks/Request/ColumnBlockRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Notion.Client
{
public class ColumnBlockRequest : BlockObjectRequest
{
public override BlockType Type => BlockType.Column;

[JsonProperty("column")]
public Info Column { get; set; }

public class Info
{
[JsonProperty("children")]
public IEnumerable<IColumnChildrenBlockRequest> Children { get; set; }
}
}
}
19 changes: 19 additions & 0 deletions Src/Notion.Client/Models/Blocks/Request/ColumnListBlockRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Notion.Client
{
public class ColumnListBlockRequest : BlockObjectRequest, INonColumnBlockRequest
{
[JsonProperty("column_list")]
public Info ColumnList { get; set; }

public override BlockType Type => BlockType.ColumnList;

public class Info
{
[JsonProperty("children")]
public IEnumerable<ColumnBlockRequest> Children { get; set; }
}
}
}
16 changes: 16 additions & 0 deletions Src/Notion.Client/Models/Blocks/Request/DividerBlockRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Newtonsoft.Json;

namespace Notion.Client
{
public class DividerBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
{
[JsonProperty("divider")]
public Data Divider { get; set; }

public override BlockType Type => BlockType.Divider;

public class Data
{
}
}
}
22 changes: 22 additions & 0 deletions Src/Notion.Client/Models/Blocks/Request/EmbedBlockRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Notion.Client
{
public class EmbedBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
{
[JsonProperty("embed")]
public Info Embed { get; set; }

public override BlockType Type => BlockType.Embed;

public class Info
{
[JsonProperty("url")]
public string Url { get; set; }

[JsonProperty("caption")]
public IEnumerable<RichTextBase> Caption { get; set; }
}
}
}
18 changes: 18 additions & 0 deletions Src/Notion.Client/Models/Blocks/Request/EquationBlockRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Newtonsoft.Json;

namespace Notion.Client
{
public class EquationBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
{
[JsonProperty("equation")]
public Info Equation { get; set; }

public override BlockType Type => BlockType.Equation;

public class Info
{
[JsonProperty("expression")]
public string Expression { get; set; }
}
}
}
12 changes: 12 additions & 0 deletions Src/Notion.Client/Models/Blocks/Request/FileBlockRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Newtonsoft.Json;

namespace Notion.Client
{
public class FileBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
{
[JsonProperty("file")]
public FileObject File { get; set; }

public override BlockType Type => BlockType.File;
}
}
29 changes: 29 additions & 0 deletions Src/Notion.Client/Models/Blocks/Request/HeadingOneBlockRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Notion.Client
{
public class HeadingOneBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
{
[JsonProperty("heading_1")]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public Info Heading_1 { get; set; }

public override BlockType Type => BlockType.Heading_1;

public class Info
{
[JsonProperty("rich_text")]
public IEnumerable<RichTextBase> RichText { get; set; }

[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color? Color { get; set; }

[JsonProperty("is_toggleable")]
public bool IsToggleable { get; set; }
}
}
}
Loading