diff --git a/README.md b/README.md index 39368ff1..8e12bbd8 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,7 @@ var complexFiler = new CompoundFilter( - [x] Retrieve a page - [x] Create a page - [x] Update page + - [x] Retrieve page property item - [x] Blocks - [x] Retrieve a block - [x] Update a block diff --git a/Src/Notion.Client/Api/ApiEndpoints.cs b/Src/Notion.Client/Api/ApiEndpoints.cs index 7884123c..f9a9549b 100644 --- a/Src/Notion.Client/Api/ApiEndpoints.cs +++ b/Src/Notion.Client/Api/ApiEndpoints.cs @@ -47,6 +47,14 @@ public static class PagesApiUrls public static string Retrieve(string pageId) => $"/v1/pages/{pageId}"; public static string Update(string pageId) => $"/v1/pages/{pageId}"; public static string UpdateProperties(string pageId) => $"/v1/pages/{pageId}"; + + /// + /// Get the for retrieve page property item + /// + /// Identifier for a Notion Page + /// Identifier for a Notion Property + /// + public static string RetrievePropertyItem(string pageId, string propertyId) => $"/v1/pages/{pageId}/properties/{propertyId}"; } public static class SearchApiUrls diff --git a/Src/Notion.Client/Api/Pages/IPagesClient.cs b/Src/Notion.Client/Api/Pages/IPagesClient.cs index 711af28f..b4fc728f 100644 --- a/Src/Notion.Client/Api/Pages/IPagesClient.cs +++ b/Src/Notion.Client/Api/Pages/IPagesClient.cs @@ -31,5 +31,12 @@ IDictionary updatedProperties /// /// Updated page. Task UpdateAsync(string pageId, PagesUpdateParameters pagesUpdateParameters); + + /// + /// Retrieves a property_item object for a given pageId and propertyId. Depending on the property type, the object returned will either be a value or a paginated list of property item values. + /// + /// sdf sd + /// + Task RetrievePagePropertyItem(RetrievePropertyItemParameters retrievePropertyItemParameters); } } diff --git a/Src/Notion.Client/Api/Pages/PagesClient.cs b/Src/Notion.Client/Api/Pages/PagesClient.cs index 9f1f4c3a..5bce1904 100644 --- a/Src/Notion.Client/Api/Pages/PagesClient.cs +++ b/Src/Notion.Client/Api/Pages/PagesClient.cs @@ -51,6 +51,22 @@ public async Task RetrieveAsync(string pageId) return await _client.GetAsync(url); } + public async Task RetrievePagePropertyItem(RetrievePropertyItemParameters retrievePropertyItemParameters) + { + var pathParameters = (IRetrievePropertyItemPathParameters)retrievePropertyItemParameters; + var queryParameters = (IRetrievePropertyQueryParameters)retrievePropertyItemParameters; + + var url = PagesApiUrls.RetrievePropertyItem(pathParameters.PageId, pathParameters.PropertyId); + + var queryParams = new Dictionary() + { + { "start_cursor", queryParameters?.StartCursor }, + { "page_size", queryParameters?.PageSize?.ToString() } + }; + + return await _client.GetAsync(url, queryParams); + } + public async Task UpdateAsync(string pageId, PagesUpdateParameters pagesUpdateParameters) { var url = PagesApiUrls.Update(pageId); diff --git a/Src/Notion.Client/Api/Pages/RequestParams/RetrievePropertyItemParameters/IRetrievePropertyItemPathParameters.cs b/Src/Notion.Client/Api/Pages/RequestParams/RetrievePropertyItemParameters/IRetrievePropertyItemPathParameters.cs new file mode 100644 index 00000000..ea61a4b3 --- /dev/null +++ b/Src/Notion.Client/Api/Pages/RequestParams/RetrievePropertyItemParameters/IRetrievePropertyItemPathParameters.cs @@ -0,0 +1,13 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public interface IRetrievePropertyItemPathParameters + { + [JsonProperty("page_id")] + string PageId { get; set; } + + [JsonProperty("property_id")] + string PropertyId { get; set; } + } +} diff --git a/Src/Notion.Client/Api/Pages/RequestParams/RetrievePropertyItemParameters/IRetrievePropertyQueryParameters.cs b/Src/Notion.Client/Api/Pages/RequestParams/RetrievePropertyItemParameters/IRetrievePropertyQueryParameters.cs new file mode 100644 index 00000000..c6a1bbeb --- /dev/null +++ b/Src/Notion.Client/Api/Pages/RequestParams/RetrievePropertyItemParameters/IRetrievePropertyQueryParameters.cs @@ -0,0 +1,6 @@ +namespace Notion.Client +{ + public interface IRetrievePropertyQueryParameters : IPaginationParameters + { + } +} diff --git a/Src/Notion.Client/Api/Pages/RequestParams/RetrievePropertyItemParameters/RetrievePropertyItemParameters.cs b/Src/Notion.Client/Api/Pages/RequestParams/RetrievePropertyItemParameters/RetrievePropertyItemParameters.cs new file mode 100644 index 00000000..29fc0e6c --- /dev/null +++ b/Src/Notion.Client/Api/Pages/RequestParams/RetrievePropertyItemParameters/RetrievePropertyItemParameters.cs @@ -0,0 +1,13 @@ +namespace Notion.Client +{ + public class RetrievePropertyItemParameters : IRetrievePropertyItemPathParameters, IRetrievePropertyQueryParameters + { + public string PageId { get; set; } + + public string PropertyId { get; set; } + + public string StartCursor { get; set; } + + public int? PageSize { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/CheckboxPropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/CheckboxPropertyItem.cs new file mode 100644 index 00000000..89e4ea6a --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/CheckboxPropertyItem.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class CheckboxPropertyItem : SimplePropertyItem + { + public override string Type => "checkbox"; + + [JsonProperty("checkbox")] + public bool Checkbox { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/CreatedByPropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/CreatedByPropertyItem.cs new file mode 100644 index 00000000..eeb8851b --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/CreatedByPropertyItem.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class CreatedByPropertyItem : SimplePropertyItem + { + public override string Type => "created_by"; + + [JsonProperty("created_by")] + public User CreatedBy { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/CreatedTimePropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/CreatedTimePropertyItem.cs new file mode 100644 index 00000000..4dcd3ada --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/CreatedTimePropertyItem.cs @@ -0,0 +1,13 @@ +using System; +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class CreatedTimePropertyItem : SimplePropertyItem + { + public override string Type => "created_time"; + + [JsonProperty("created_time")] + public DateTime CreatedTime { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/DatePropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/DatePropertyItem.cs new file mode 100644 index 00000000..534e3a4e --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/DatePropertyItem.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class DatePropertyItem : SimplePropertyItem + { + public override string Type => "date"; + + [JsonProperty("date")] + public Date Date { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/EmailPropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/EmailPropertyItem.cs new file mode 100644 index 00000000..2f4edc81 --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/EmailPropertyItem.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class EmailPropertyItem : SimplePropertyItem + { + public override string Type => "email"; + + [JsonProperty("email")] + public string Email { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/FilesPropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/FilesPropertyItem.cs new file mode 100644 index 00000000..41ffd075 --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/FilesPropertyItem.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class FilesPropertyItem : SimplePropertyItem + { + public override string Type => "files"; + + [JsonProperty("files")] + public IEnumerable Files { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/FormulaPropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/FormulaPropertyItem.cs new file mode 100644 index 00000000..393f6775 --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/FormulaPropertyItem.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class FormulaPropertyItem : SimplePropertyItem + { + public override string Type => "formula"; + + [JsonProperty("formula")] + public FormulaValue Formula { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/IPropertyItemObject.cs b/Src/Notion.Client/Models/PropertyItems/IPropertyItemObject.cs new file mode 100644 index 00000000..e6eb91c2 --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/IPropertyItemObject.cs @@ -0,0 +1,17 @@ +using JsonSubTypes; +using Newtonsoft.Json; + +namespace Notion.Client +{ + [JsonConverter(typeof(JsonSubtypes), "object")] + [JsonSubtypes.KnownSubType(typeof(SimplePropertyItem), "property_item")] + [JsonSubtypes.KnownSubType(typeof(ListPropertyItem), "list")] + public interface IPropertyItemObject + { + [JsonProperty("object")] + string Object { get; } + + [JsonProperty("type")] + string Type { get; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/LastEditedByPropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/LastEditedByPropertyItem.cs new file mode 100644 index 00000000..885a1729 --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/LastEditedByPropertyItem.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class LastEditedByPropertyItem : SimplePropertyItem + { + public override string Type => "last_edited_by"; + + [JsonProperty("last_edited_by")] + public User LastEditedBy { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/LastEditedTimePropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/LastEditedTimePropertyItem.cs new file mode 100644 index 00000000..63ec805d --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/LastEditedTimePropertyItem.cs @@ -0,0 +1,13 @@ +using System; +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class LastEditedTimePropertyItem : SimplePropertyItem + { + public override string Type => "last_edited_time"; + + [JsonProperty("last_edited_time")] + public DateTime LastEditedTime { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/ListPropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/ListPropertyItem.cs new file mode 100644 index 00000000..3ca83d81 --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/ListPropertyItem.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using JsonSubTypes; +using Newtonsoft.Json; + +namespace Notion.Client +{ + [JsonConverter(typeof(JsonSubtypes), "type")] + [JsonSubtypes.KnownSubType(typeof(RollupPropertyItem), "rollup")] + [JsonSubtypes.FallBackSubType(typeof(ListPropertyItem))] + public class ListPropertyItem : IPropertyItemObject + { + public string Object => "list"; + public virtual string Type { get; set; } + + [JsonProperty("results")] + public IEnumerable Results { get; set; } + + [JsonProperty("has_more")] + public bool HasMore { get; set; } + + [JsonProperty("next_cursor")] + public string NextCursor { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/MultiSelectPropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/MultiSelectPropertyItem.cs new file mode 100644 index 00000000..6bfe1a75 --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/MultiSelectPropertyItem.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class MultiSelectPropertyItem : SimplePropertyItem + { + public override string Type => "multi_select"; + + [JsonProperty("multi_select")] + public IEnumerable MultiSelect { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/NumberPropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/NumberPropertyItem.cs new file mode 100644 index 00000000..144fc627 --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/NumberPropertyItem.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class NumberPropertyItem : SimplePropertyItem + { + public override string Type => "number"; + + [JsonProperty("number")] + public Number Number { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/PeoplePropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/PeoplePropertyItem.cs new file mode 100644 index 00000000..b77c1020 --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/PeoplePropertyItem.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class PeoplePropertyItem : SimplePropertyItem + { + public override string Type => "people"; + + [JsonProperty("people")] + public User People { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/PhoneNumberPropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/PhoneNumberPropertyItem.cs new file mode 100644 index 00000000..ec64b37d --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/PhoneNumberPropertyItem.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class PhoneNumberPropertyItem : SimplePropertyItem + { + public override string Type => "phone_number"; + + [JsonProperty("phone_number")] + public string PhoneNumber { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/RelationPropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/RelationPropertyItem.cs new file mode 100644 index 00000000..dd02f69d --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/RelationPropertyItem.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class RelationPropertyItem : SimplePropertyItem + { + public override string Type => "relation"; + + [JsonProperty("relation")] + public ObjectId Relation { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/RichTextPropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/RichTextPropertyItem.cs new file mode 100644 index 00000000..513b7300 --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/RichTextPropertyItem.cs @@ -0,0 +1,9 @@ +namespace Notion.Client +{ + public class RichTextPropertyItem : SimplePropertyItem + { + public override string Type => "rich_text"; + + public RichTextBase RichText { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/RollupPropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/RollupPropertyItem.cs new file mode 100644 index 00000000..6e6e53cd --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/RollupPropertyItem.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class RollupPropertyItem : ListPropertyItem + { + public override string Type => "rollup"; + + [JsonProperty("rollup")] + public RollupValue Rollup { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/SelectPropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/SelectPropertyItem.cs new file mode 100644 index 00000000..8e9afcd2 --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/SelectPropertyItem.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class SelectPropertyItem : SimplePropertyItem + { + public override string Type => "select"; + + [JsonProperty("select")] + public SelectOption Select { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/SimplePropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/SimplePropertyItem.cs new file mode 100644 index 00000000..6cc1f52b --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/SimplePropertyItem.cs @@ -0,0 +1,31 @@ +using JsonSubTypes; +using Newtonsoft.Json; + +namespace Notion.Client +{ + [JsonConverter(typeof(JsonSubtypes), "type")] + [JsonSubtypes.KnownSubType(typeof(NumberPropertyItem), "number")] + [JsonSubtypes.KnownSubType(typeof(UrlPropertyItem), "url")] + [JsonSubtypes.KnownSubType(typeof(SelectPropertyItem), "select")] + [JsonSubtypes.KnownSubType(typeof(MultiSelectPropertyItem), "multi_select")] + [JsonSubtypes.KnownSubType(typeof(DatePropertyItem), "date")] + [JsonSubtypes.KnownSubType(typeof(EmailPropertyItem), "email")] + [JsonSubtypes.KnownSubType(typeof(PhoneNumberPropertyItem), "phone_number")] + [JsonSubtypes.KnownSubType(typeof(CheckboxPropertyItem), "checkbox")] + [JsonSubtypes.KnownSubType(typeof(FilesPropertyItem), "files")] + [JsonSubtypes.KnownSubType(typeof(CreatedByPropertyItem), "created_by")] + [JsonSubtypes.KnownSubType(typeof(CreatedTimePropertyItem), "created_time")] + [JsonSubtypes.KnownSubType(typeof(LastEditedByPropertyItem), "last_edited_by")] + [JsonSubtypes.KnownSubType(typeof(LastEditedTimePropertyItem), "last_edited_time")] + [JsonSubtypes.KnownSubType(typeof(FormulaPropertyItem), "formula")] + [JsonSubtypes.KnownSubType(typeof(TitlePropertyItem), "title")] + [JsonSubtypes.KnownSubType(typeof(RichTextPropertyItem), "rich_text")] + [JsonSubtypes.KnownSubType(typeof(PeoplePropertyItem), "people")] + [JsonSubtypes.KnownSubType(typeof(RelationPropertyItem), "relation")] + public abstract class SimplePropertyItem : IPropertyItemObject + { + public string Object => "property_item"; + + public abstract string Type { get; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/TitlePropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/TitlePropertyItem.cs new file mode 100644 index 00000000..3cd45ee4 --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/TitlePropertyItem.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class TitlePropertyItem : SimplePropertyItem + { + public override string Type => "title"; + + [JsonProperty("title")] + public RichTextBase Title { get; set; } + } +} diff --git a/Src/Notion.Client/Models/PropertyItems/UrlPropertyItem.cs b/Src/Notion.Client/Models/PropertyItems/UrlPropertyItem.cs new file mode 100644 index 00000000..b0c6ccc2 --- /dev/null +++ b/Src/Notion.Client/Models/PropertyItems/UrlPropertyItem.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class UrlPropertyItem : SimplePropertyItem + { + public override string Type => "url"; + + [JsonProperty("url")] + public string Url { get; set; } + } +} diff --git a/Test/Notion.IntegrationTests/IPageClientTests.cs b/Test/Notion.IntegrationTests/IPageClientTests.cs index 6a8259be..ae1e317b 100644 --- a/Test/Notion.IntegrationTests/IPageClientTests.cs +++ b/Test/Notion.IntegrationTests/IPageClientTests.cs @@ -10,16 +10,21 @@ namespace Notion.IntegrationTests { public class IPageClientTests { - [Fact] - public async Task CreateAsync_CreatesANewPage() + private readonly INotionClient _client; + + public IPageClientTests() { var options = new ClientOptions { AuthToken = Environment.GetEnvironmentVariable("NOTION_AUTH_TOKEN") }; - IPagesClient _client = new PagesClient(new RestClient(options)); + _client = NotionClientFactory.Create(options); + } + [Fact] + public async Task CreateAsync_CreatesANewPage() + { PagesCreateParameters pagesCreateParameters = PagesCreateParametersBuilder.Create(new DatabaseParentInput { DatabaseId = "f86f2262-0751-40f2-8f63-e3f7a3c39fcb" @@ -28,18 +33,18 @@ public async Task CreateAsync_CreatesANewPage() { Title = new List { - new RichTextText - { - Text = new Text - { - Content = "Test Page Title" - } - } + new RichTextText + { + Text = new Text + { + Content = "Test Page Title" + } + } } }) .Build(); - var page = await _client.CreateAsync(pagesCreateParameters); + var page = await _client.Pages.CreateAsync(pagesCreateParameters); page.Should().NotBeNull(); page.Parent.Should().BeOfType().Which @@ -49,7 +54,7 @@ public async Task CreateAsync_CreatesANewPage() page.Properties["Name"].Should().BeOfType().Which .Title.First().PlainText.Should().Be("Test Page Title"); - await _client.UpdateAsync(page.Id, new PagesUpdateParameters + await _client.Pages.UpdateAsync(page.Id, new PagesUpdateParameters { Archived = true }); @@ -58,13 +63,6 @@ public async Task CreateAsync_CreatesANewPage() [Fact] public async Task Bug_unable_to_create_page_with_select_property() { - var options = new ClientOptions - { - AuthToken = Environment.GetEnvironmentVariable("NOTION_AUTH_TOKEN") - }; - - INotionClient _client = NotionClientFactory.Create(options); - PagesCreateParameters pagesCreateParameters = PagesCreateParametersBuilder.Create(new DatabaseParentInput { DatabaseId = "f86f2262-0751-40f2-8f63-e3f7a3c39fcb" @@ -73,13 +71,13 @@ public async Task Bug_unable_to_create_page_with_select_property() { Title = new List { - new RichTextText - { - Text = new Text - { - Content = "Test Page Title" - } - } + new RichTextText + { + Text = new Text + { + Content = "Test Page Title" + } + } } }) .AddProperty("TestSelect", new SelectPropertyValue @@ -106,5 +104,56 @@ public async Task Bug_unable_to_create_page_with_select_property() Archived = true }); } + + [Fact] + public async Task Test_RetrievePagePropertyItemAsync() + { + PagesCreateParameters pagesCreateParameters = PagesCreateParametersBuilder.Create(new DatabaseParentInput + { + DatabaseId = "f86f2262-0751-40f2-8f63-e3f7a3c39fcb" + }) + .AddProperty("Name", new TitlePropertyValue + { + Title = new List + { + new RichTextText + { + Text = new Text + { + Content = "Test Page Title" + } + } + } + }) + .Build(); + + var page = await _client.Pages.CreateAsync(pagesCreateParameters); + + var property = await _client.Pages.RetrievePagePropertyItem(new RetrievePropertyItemParameters + { + PageId = page.Id, + PropertyId = "title" + }); + + property.Should().NotBeNull(); + property.Should().BeOfType(); + + var listProperty = (ListPropertyItem)property; + + listProperty.Type.Should().BeNull(); + listProperty.Results.Should().SatisfyRespectively(p => + { + p.Should().BeOfType(); + var titleProperty = (TitlePropertyItem)p; + + titleProperty.Title.PlainText.Should().Be("Test Page Title"); + }); + + // cleanup + await _client.Pages.UpdateAsync(page.Id, new PagesUpdateParameters + { + Archived = true + }); + } } } diff --git a/docs/README.md b/docs/README.md index 5f32406e..5ece487d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -85,6 +85,7 @@ var complexFiler = new CompoundFilter( - [x] Retrieve a page - [x] Create a page - [x] Update page + - [x] Retrieve page property item - [x] Blocks - [x] Retrieve a block - [x] Update a block