Content-Length: 645346 | pFad | http://github.com/notion-dotnet/notion-sdk-net/commit/8a02230043435e002c311e085dce91ff7a434910

AB Merge pull request #418 from kosaku-hayashi/issue-416-support-button-… · notion-dotnet/notion-sdk-net@8a02230 · GitHub
Skip to content

Commit 8a02230

Browse files
Merge pull request #418 from kosaku-hayashi/issue-416-support-button-property
Added support for button properties.
2 parents 6fc72b0 + f0f595b commit 8a02230

12 files changed

+66
-1
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using Newtonsoft.Json;
5+
using System.Threading.Tasks;
6+
7+
namespace Notion.Client
8+
{
9+
public class ButtonProperty : Property
10+
{
11+
public override PropertyType Type => PropertyType.Button;
12+
13+
[JsonProperty("button")]
14+
public Dictionary<string,object> Button { get; set; }
15+
}
16+
}

Src/Notion.Client/Models/Database/Properties/Property.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace Notion.Client
2626
[JsonSubtypes.KnownSubTypeAttribute(typeof(TitleProperty), PropertyType.Title)]
2727
[JsonSubtypes.KnownSubTypeAttribute(typeof(UrlProperty), PropertyType.Url)]
2828
[JsonSubtypes.KnownSubTypeAttribute(typeof(UniqueIdProperty), PropertyType.UniqueId)]
29+
[JsonSubtypes.KnownSubTypeAttribute(typeof(ButtonProperty), PropertyType.Button)]
2930
public class Property
3031
{
3132
[JsonProperty("id")]

Src/Notion.Client/Models/Database/Properties/PropertyType.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,8 @@ public enum PropertyType
7171

7272
[EnumMember(Value = "unique_id")]
7373
UniqueId,
74+
75+
[EnumMember(Value = "button")]
76+
Button,
7477
}
7578
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using Newtonsoft.Json;
5+
6+
namespace Notion.Client
7+
{
8+
public class ButtonPropertyValue : PropertyValue
9+
{
10+
public override PropertyValueType Type => PropertyValueType.Button;
11+
12+
[JsonProperty("button")]
13+
public ButtonValue Button { get; set; }
14+
15+
public class ButtonValue { }
16+
}
17+
}

Src/Notion.Client/Models/PropertyValue/PropertyValue.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ namespace Notion.Client
3030
[JsonSubtypes.KnownSubTypeAttribute(typeof(TitlePropertyValue), PropertyValueType.Title)]
3131
[JsonSubtypes.KnownSubTypeAttribute(typeof(UrlPropertyValue), PropertyValueType.Url)]
3232
[JsonSubtypes.KnownSubTypeAttribute(typeof(UniqueIdPropertyValue), PropertyValueType.UniqueId)]
33+
[JsonSubtypes.KnownSubTypeAttribute(typeof(ButtonPropertyValue), PropertyValueType.Button)]
3334
[JsonSubtypes.KnownSubTypeAttribute(typeof(VerificationPropertyValue), PropertyValueType.Verification)]
3435
[SuppressMessage("ReSharper", "UnusedMember.Global")]
3536
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]

Src/Notion.Client/Models/PropertyValue/PropertyValueType.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,8 @@ public enum PropertyValueType
7777

7878
[EnumMember(Value = "verification")]
7979
Verification,
80+
81+
[EnumMember(Value = "button")]
82+
Button,
8083
}
8184
}

Test/Notion.UnitTests/PagesClientTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public async Task TrashPageAsync()
222222

223223
page.Id.Should().Be(pageId);
224224
page.InTrash.Should().BeTrue();
225-
page.Properties.Should().HaveCount(2);
225+
page.Properties.Should().HaveCount(3);
226226
var updatedProperty = page.Properties.First(x => x.Key == "In stock");
227227

228228
var checkboxPropertyValue = (CheckboxPropertyItem)await _client.RetrievePagePropertyItemAsync(

Test/Notion.UnitTests/PropertyTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class PropertyTests
2727
[InlineData(typeof(TitleProperty), PropertyType.Title)]
2828
[InlineData(typeof(UrlProperty), PropertyType.Url)]
2929
[InlineData(typeof(UniqueIdProperty), PropertyType.UniqueId)]
30+
[InlineData(typeof(ButtonProperty),PropertyType.Button)]
3031
public void TestPropertyType(Type type, PropertyType expectedPropertyType)
3132
{
3233
var typeInstance = (Property)Activator.CreateInstance(type);
@@ -56,6 +57,7 @@ public void TestPropertyType(Type type, PropertyType expectedPropertyType)
5657
[InlineData(typeof(TitleProperty), "title")]
5758
[InlineData(typeof(UrlProperty), "url")]
5859
[InlineData(typeof(UniqueIdProperty), "unique_id")]
60+
[InlineData(typeof(ButtonProperty), "button")]
5961
public void TestPropertyTypeText(Type type, string expectedPropertyType)
6062
{
6163
var typeInstance = (Property)Activator.CreateInstance(type);

Test/Notion.UnitTests/data/databases/DatabaseRetrieveResponse.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@
9090
}
9191
}
9292
},
93+
"SimpleButton": {
94+
"id":"_ri%7C",
95+
"name":"SimpleButton",
96+
"type":"button",
97+
"button": {}
98+
},
9399
"Name": {
94100
"id": "title",
95101
"name": "Name",

Test/Notion.UnitTests/data/databases/DatabasesListResponse.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@
8181
}
8282
}
8383
},
84+
"SimpleButton": {
85+
"id":"_ri%7C",
86+
"name":"SimpleButton",
87+
"type":"button",
88+
"button": {}
89+
},
8490
"Name": {
8591
"id": "title",
8692
"name": "Name",

Test/Notion.UnitTests/data/databases/DatabasesQueryResponse.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
"id": "{>U;",
4646
"type": "checkbox",
4747
"checkbox": false
48+
},
49+
"Add Page Button": {
50+
"id":"_ri%7C",
51+
"type":"button",
52+
"button": {}
4853
}
4954
}
5055
}

Test/Notion.UnitTests/data/pages/TrashPageResponse.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
"type": "checkbox",
1212
"checkbox": true
1313
},
14+
"Add Page Button": {
15+
"id":"_ri%7C",
16+
"type":"button",
17+
"button": {}
18+
},
1419
"Name": {
1520
"id": "title",
1621
"type": "title",

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/notion-dotnet/notion-sdk-net/commit/8a02230043435e002c311e085dce91ff7a434910

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy