Skip to content

Update parent field for Page, Database and Block object #297

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
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add block as parent for page and database
  • Loading branch information
KoditkarVedant committed Aug 20, 2022
commit 1eff75231fe419f4b36aa00b189861b464ef949c
1 change: 1 addition & 0 deletions Src/Notion.Client/Models/Database/IDatabaseParent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Notion.Client
[JsonConverter(typeof(JsonSubtypes), "type")]
[JsonSubtypes.KnownSubType(typeof(PageParent), ParentType.PageId)]
[JsonSubtypes.KnownSubType(typeof(WorkspaceParent), ParentType.Workspace)]
[JsonSubtypes.KnownSubType(typeof(BlockParent), ParentType.BlockId)]
public interface IDatabaseParent : IParent
{
}
Expand Down
1 change: 1 addition & 0 deletions Src/Notion.Client/Models/Page/IPageParent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Notion.Client
[JsonSubtypes.KnownSubType(typeof(DatabaseParent), ParentType.DatabaseId)]
[JsonSubtypes.KnownSubType(typeof(PageParent), ParentType.PageId)]
[JsonSubtypes.KnownSubType(typeof(WorkspaceParent), ParentType.Workspace)]
[JsonSubtypes.KnownSubType(typeof(BlockParent), ParentType.BlockId)]
public interface IPageParent : IParent
{
}
Expand Down
18 changes: 18 additions & 0 deletions Src/Notion.Client/Models/Parents/BlockParent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Newtonsoft.Json;

namespace Notion.Client
{
public class BlockParent : IPageParent, IDatabaseParent
{
/// <summary>
/// Always has a value "block_id"
/// </summary>
public ParentType Type { get; set; }

/// <summary>
/// The ID of the block that the element belongs to.
/// </summary>
[JsonProperty("block_id")]
public string BlockId { get; set; }
}
}
5 changes: 4 additions & 1 deletion Src/Notion.Client/Models/Parents/ParentType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public enum ParentType
PageId,

[EnumMember(Value = "workspace")]
Workspace
Workspace,

[EnumMember(Value = "block_id")]
BlockId,
}
}