Skip to content

Commit 50f9916

Browse files
committed
✨ UpdatePagePropertiesAsync added to Pages client
1 parent 605fc23 commit 50f9916

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

Src/Notion.Client/Api/ApiEndpoints.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public static class BlocksApiUrls
2424
public static class PagesApiUrls
2525
{
2626
public static string Create() => $"/v1/pages";
27+
public static string UpdatePageProperties(string pageId) => $"/v1/pages/{pageId}";
2728
}
2829
}
2930
}
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
using System.Threading.Tasks;
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
23

34
namespace Notion.Client
45
{
56
public interface IPagesClient
67
{
78
Task<RetrievedPage> CreateAsync(CreatedPage page);
9+
Task<RetrievedPage> UpdatePagePropertiesAsync(
10+
string pageId,
11+
IDictionary<string, PropertyValue> updatedProperties
12+
);
13+
814
}
915
}

Src/Notion.Client/Api/Pages/PagesClient.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Threading.Tasks;
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
23
using static Notion.Client.ApiEndpoints;
34

45
namespace Notion.Client
@@ -16,6 +17,20 @@ public async Task<RetrievedPage> CreateAsync(CreatedPage page)
1617
{
1718
return await _client.PostAsync<RetrievedPage>(PagesApiUrls.Create(), page);
1819
}
19-
}
2020

21+
public async Task<RetrievedPage> UpdatePagePropertiesAsync(
22+
string pageId,
23+
IDictionary<string, PropertyValue> updatedProperties)
24+
{
25+
var url = PagesApiUrls.UpdatePageProperties(pageId);
26+
var body = new PageUpdatePropertiesParameters { Properties = updatedProperties };
27+
28+
return await _client.PatchAsync<RetrievedPage>(url, body);
29+
}
30+
31+
private class PageUpdatePropertiesParameters
32+
{
33+
public IDictionary<string, PropertyValue> Properties { get; set; }
34+
}
35+
}
2136
}

0 commit comments

Comments
 (0)