Skip to content

Commit 75cbf61

Browse files
update page properties to only return property id
1 parent b5cdc1e commit 75cbf61

File tree

4 files changed

+44
-6
lines changed

4 files changed

+44
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class Page : IObject, IObjectModificationData
4444
/// Property values of this page.
4545
/// </summary>
4646
[JsonProperty("properties")]
47-
public IDictionary<string, PropertyValue> Properties { get; set; }
47+
public IDictionary<string, PagePropertyOnId> Properties { get; set; }
4848

4949
/// <summary>
5050
/// The URL of the Notion page.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
4+
{
5+
public class PagePropertyOnId
6+
{
7+
[JsonProperty("id")]
8+
public string Id { get; set; }
9+
}
10+
}

Test/Notion.UnitTests/DatabasesClientTests.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ namespace Notion.UnitTests
1212
public class DatabasesClientTests : ApiTestBase
1313
{
1414
private readonly IDatabasesClient _client;
15-
15+
private readonly IPagesClient _pagesClient;
1616
public DatabasesClientTests()
1717
{
1818
_client = new DatabasesClient(new RestClient(ClientOptions));
19+
_pagesClient = new PagesClient(new RestClient(ClientOptions));
1920
}
2021

2122
[Fact]
@@ -463,7 +464,13 @@ public async Task Fix123_QueryAsync_DateFormulaValue_Returns_Null()
463464
page.Parent.Should().BeAssignableTo<IPageParent>();
464465
page.Object.Should().Be(ObjectType.Page);
465466

466-
var formulaPropertyValue = (FormulaPropertyValue)page.Properties["FormulaProp"];
467+
var formulaPropertyValue = (FormulaPropertyValue)await _pagesClient.RetrievePagePropertyItem(new RetrievePropertyItemParameters
468+
{
469+
PageId = page.Id,
470+
PropertyId = page.Properties["FormulaProp"].Id
471+
});
472+
473+
//var formulaPropertyValue = (FormulaPropertyValue)page.Properties["FormulaProp"];
467474
formulaPropertyValue.Formula.Date.Start.Should().Be(DateTime.Parse("2021-06-28"));
468475
formulaPropertyValue.Formula.Date.End.Should().BeNull();
469476
}

Test/Notion.UnitTests/PagesClientTests.cs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,14 @@ public async Task UpdatePropertiesAsync()
109109
page.Id.Should().Be(pageId);
110110
page.Properties.Should().HaveCount(2);
111111
var updatedProperty = page.Properties.First(x => x.Key == "In stock");
112-
((CheckboxPropertyValue)updatedProperty.Value).Checkbox.Should().BeTrue();
112+
113+
var checkboxPropertyValue = (CheckboxPropertyValue)await _client.RetrievePagePropertyItem(new RetrievePropertyItemParameters
114+
{
115+
PageId = page.Id,
116+
PropertyId = updatedProperty.Value.Id
117+
});
118+
119+
checkboxPropertyValue.Checkbox.Should().BeTrue();
113120
}
114121

115122
[Fact]
@@ -160,7 +167,14 @@ public async Task UpdatePageAsync()
160167
page.IsArchived.Should().BeFalse();
161168
page.Properties.Should().HaveCount(2);
162169
var updatedProperty = page.Properties.First(x => x.Key == "In stock");
163-
((CheckboxPropertyValue)updatedProperty.Value).Checkbox.Should().BeTrue();
170+
171+
var checkboxPropertyValue = (CheckboxPropertyValue)await _client.RetrievePagePropertyItem(new RetrievePropertyItemParameters
172+
{
173+
PageId = page.Id,
174+
PropertyId = updatedProperty.Value.Id
175+
});
176+
177+
checkboxPropertyValue.Checkbox.Should().BeTrue();
164178
}
165179

166180
[Fact]
@@ -193,7 +207,14 @@ public async Task ArchivePageAsync()
193207
page.IsArchived.Should().BeTrue();
194208
page.Properties.Should().HaveCount(2);
195209
var updatedProperty = page.Properties.First(x => x.Key == "In stock");
196-
((CheckboxPropertyValue)updatedProperty.Value).Checkbox.Should().BeTrue();
210+
211+
var checkboxPropertyValue = (CheckboxPropertyValue)await _client.RetrievePagePropertyItem(new RetrievePropertyItemParameters
212+
{
213+
PageId = page.Id,
214+
PropertyId = updatedProperty.Value.Id
215+
});
216+
217+
checkboxPropertyValue.Checkbox.Should().BeTrue();
197218
}
198219

199220
[Fact]

0 commit comments

Comments
 (0)