Skip to content

Commit f93ceb6

Browse files
Merge branch 'main' into 415-make-date-property-value-use-datetimeoffset
2 parents 54f5fd3 + 172570c commit f93ceb6

File tree

14 files changed

+72
-1
lines changed

14 files changed

+72
-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
}

Src/Notion.Client/Models/File/FileObject.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ public abstract class FileObject : IPageIcon
1212
[JsonProperty("caption")]
1313
public IEnumerable<RichTextBase> Caption { get; set; }
1414

15+
[JsonProperty("name")]
16+
public string Name { get; set; }
17+
1518
[JsonProperty("type")]
1619
public virtual string Type { get; set; }
1720
}
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
}

Src/Notion.Client/NotionAPIErrorCode.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public enum NotionAPIErrorCode
4242
[EnumMember(Value = "internal_server_error")]
4343
InternalServerError,
4444

45+
[EnumMember(Value = "bad_gateway")]
46+
BadGateway,
47+
4548
[EnumMember(Value = "service_unavailable")]
4649
ServiceUnavailable,
4750

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);

0 commit comments

Comments
 (0)