8000 Merge branch 'main' into 258-update-page-object-only-has-property-id · notion-dotnet/notion-sdk-net@42368c5 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 42368c5

Browse files
Merge branch 'main' into 258-update-page-object-only-has-property-id
2 parents df37322 + 3e54645 commit 42368c5

File tree

9 files changed

+50
-3
lines changed

9 files changed

+50
-3
lines changed

Src/Notion.Client/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ namespace Notion.Client
66
internal class Constants
77
{
88
internal static string BASE_URL = "https://api.notion.com/";
9-
internal static string DEFAULT_NOTION_VERSION = "2022-02-22";
9+
internal static string DEFAULT_NOTION_VERSION = "2022-06-28";
1010
}
1111
}

Src/Notion.Client/Models/Blocks/Block.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using Notion.Client.Models.Blocks;
23

34
namespace Notion.Client
45
{
@@ -19,5 +20,10 @@ public abstract class Block : IBlock
1920
public PartialUser CreatedBy { get; set; }
2021

2122
public PartialUser LastEditedBy { get; set; }
23+
24+
/// <summary>
25+
/// Information about the block's parent.
26+
/// </summary>
27+
public IBlockParent Parent { get; set; }
2228
}
2329
}

Src/Notion.Client/Models/Blocks/IBlock.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using JsonSubTypes;
22
using Newtonsoft.Json;
33
using Newtonsoft.Json.Converters;
4+
using Notion.Client.Models.Blocks;
45

56
namespace Notion.Client
67
{
@@ -44,5 +45,8 @@ public interface IBlock : IObject, IObjectModificationData
4445

4546
[JsonProperty("has_children")]
4647
bool HasChildren { get; set; }
48+
49+
[JsonProperty("parent")]
50+
IBlockParent Parent { get; set; }
4751
}
4852
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using JsonSubTypes;
2+
using Newtonsoft.Json;
3+
4+
namespace Notion.Client.Models.Blocks
5+
{
6+
[JsonConverter(typeof(JsonSubtypes), "type")]
7+
[JsonSubtypes.KnownSubType(typeof(DatabaseParent), ParentType.DatabaseId)]
8+
[JsonSubtypes.KnownSubType(typeof(PageParent), ParentType.PageId)]
9+
[JsonSubtypes.KnownSubType(typeof(WorkspaceParent), ParentType.Workspace)]
10+
[JsonSubtypes.KnownSubType(typeof(BlockParent), ParentType.BlockId)]
11+
public interface IBlockParent
12+
{
13+
}
14+
}

Src/Notion.Client/Models/Database/IDatabaseParent.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace Notion.Client
66
[JsonConverter(typeof(JsonSubtypes), "type")]
77
[JsonSubtypes.KnownSubType(typeof(PageParent), ParentType.PageId)]
88
[JsonSubtypes.KnownSubType(typeof(WorkspaceParent), ParentType.Workspace)]
9+
[JsonSubtypes.KnownSubType(typeof(BlockParent), ParentType.BlockId)]
910
public interface IDatabaseParent : IParent
1011
{
1112
}

Src/Notion.Client/Models/Page/IPageParent.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace Notion.Client
77
[JsonSubtypes.KnownSubType(typeof(DatabaseParent), ParentType.DatabaseId)]
88
[JsonSubtypes.KnownSubType(typeof(PageParent), ParentType.PageId)]
99
[JsonSubtypes.KnownSubType(typeof(WorkspaceParent), ParentType.Workspace)]
10+
[JsonSubtypes.KnownSubType(typeof(BlockParent), ParentType.BlockId)]
1011
public interface IPageParent : IParent
1112
{
1213
}
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 BlockParent : IPageParent, IDatabaseParent
6+
{
7+
/// <summary>
8+
/// Always has a value "block_id"
9+
/// </summary>
10+
public ParentType Type { get; set; }
11+
12+
/// <summary>
13+
/// The ID of the block that the element belongs to.
14+
/// </summary>
15+
[JsonProperty("block_id")]
16+
public string BlockId { get; set; }
17+
}
18+
}

Src/Notion.Client/Models/Parents/ParentType.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ public enum ParentType
1414
PageId,
1515

1616
[EnumMember(Value = "workspace")]
17-
Workspace
17+
Workspace,
18+
19+
[EnumMember(Value = "block_id")]
20+
BlockId,
1821
}
1922
}

Src/Notion.Client/Notion.Client.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<VersionPrefix>3.1.0-preview</VersionPrefix>
4+
<VersionPrefix>4.0.0-preview</VersionPrefix>
55
<TargetFramework>netstandard2.0</TargetFramework>
66
<LangVersion>7.3</LangVersion>
77

0 commit comments

Comments
 (0)
0