Skip to content

Removed 'archived' property and added 'in_trash' property. #417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Src/Notion.Client/Api/Blocks/IBlocksClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Task<AppendChildrenResponse> AppendChildrenAsync(
);

/// <summary>
/// Sets a Block object, including page blocks, to archived: true using the ID specified.
/// Moves a Block object, including page blocks, to the trash: true using the ID specified.
/// </summary>
/// <param name="blockId">Identifier for a Notion block</param>
Task DeleteAsync(string blockId, CancellationToken cancellationToken = default);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class BookmarkUpdateBlock : IUpdateBlock
[JsonProperty("bookmark")]
public Info Bookmark { get; set; }

public bool Archived { get; set; }
public bool InTrash { get; set; }

public class Info
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public BreadcrumbUpdateBlock()
[JsonProperty("breadcrumb")]
public Info Breadcrumb { get; set; }

public bool Archived { get; set; }
public bool InTrash { get; set; }

public class Info
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public DividerUpdateBlock()
[JsonProperty("divider")]
public Info Divider { get; set; }

public bool Archived { get; set; }
public bool InTrash { get; set; }

public class Info
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Notion.Client
{
public interface IUpdateBlock
{
[JsonProperty("archived")]
bool Archived { get; set; }
[JsonProperty("in_trash")]
bool InTrash { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public TableOfContentsUpdateBlock()
[JsonProperty("table_of_contents")]
public Info TableOfContents { get; set; }

public bool Archived { get; set; }
public bool InTrash { get; set; }

public class Info
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{
public abstract class UpdateBlock : IUpdateBlock
{
public bool Archived { get; set; }
public bool InTrash { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class DatabasesUpdateParameters : IDatabasesUpdateBodyParameters

public FileObject Cover { get; set; }

public bool Archived { get; set; }
public bool InTrash { get; set; }

public bool? IsInline { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public interface IDatabasesUpdateBodyParameters
[JsonProperty("cover")]
FileObject Cover { get; set; }

[JsonProperty("archived")]
bool Archived { get; set; }
[JsonProperty("in_trash")]
bool InTrash { get; set; }

[JsonProperty("is_inline")]
bool? IsInline { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace Notion.Client
{
public interface IPagesUpdateBodyParameters
{
[JsonProperty("archived")]
bool Archived { get; set; }
[JsonProperty("in_trash")]
bool InTrash { get; set; }

[JsonProperty("properties")]
IDictionary<string, PropertyValue> Properties { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public class PagesUpdateParameters : IPagesUpdateBodyParameters
[JsonProperty("cover")]
public FileObject Cover { get; set; }

[JsonProperty("archived")]
public bool Archived { get; set; }
[JsonProperty("in_trash")]
public bool InTrash { get; set; }

[JsonProperty("properties")]
public IDictionary<string, PropertyValue> Properties { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions Src/Notion.Client/Models/Blocks/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public abstract class Block : IBlock

public virtual bool HasChildren { get; set; }

public bool InTrash { get; set; }

public PartialUser CreatedBy { get; set; }

public PartialUser LastEditedBy { get; set; }
Expand Down
3 changes: 3 additions & 0 deletions Src/Notion.Client/Models/Blocks/IBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public interface IBlock : IObject, IObjectModificationData
[JsonProperty("has_children")]
bool HasChildren { get; set; }

[JsonProperty("in_trash")]
bool InTrash { get; set; }

[JsonProperty("parent")]
IBlockParent Parent { get; set; }
}
Expand Down
7 changes: 2 additions & 5 deletions Src/Notion.Client/Models/Database/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ public class Database : IObject, IObjectModificationData, IWikiDatabase
[JsonProperty("url")]
public string Url { get; set; }

/// <summary>
/// The archived status of the database.
/// </summary>
[JsonProperty("archived")]
public bool Archived { get; set; }
[JsonProperty("in_trash")]
public bool InTrash { get; set; }

[JsonProperty("is_inline")]
public bool IsInline { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions Src/Notion.Client/Models/Page/Page.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public class Page : IObject, IObjectModificationData, IWikiDatabase
public IPageParent Parent { get; set; }

/// <summary>
/// The archived status of the page.
/// Indicates whether the page is currently in the trash.
/// </summary>
[JsonProperty("archived")]
public bool IsArchived { get; set; }
[JsonProperty("in_trash")]
public bool InTrash { get; set; }

/// <summary>
/// Property values of this page.
Expand Down
2 changes: 1 addition & 1 deletion Test/Notion.IntegrationTests/BlocksClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task InitializeAsync()

public async Task DisposeAsync()
{
await Client.Pages.UpdateAsync(_page.Id, new PagesUpdateParameters { Archived = true });
await Client.Pages.UpdateAsync(_page.Id, new PagesUpdateParameters { InTrash = true });
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion Test/Notion.IntegrationTests/CommentsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public async Task InitializeAsync()

public async Task DisposeAsync()
{
await Client.Pages.UpdateAsync(_page.Id, new PagesUpdateParameters { Archived = true });
await Client.Pages.UpdateAsync(_page.Id, new PagesUpdateParameters { InTrash = true });
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion Test/Notion.IntegrationTests/DatabasesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public async Task InitializeAsync()

public async Task DisposeAsync()
{
await Client.Pages.UpdateAsync(_page.Id, new PagesUpdateParameters { Archived = true });
await Client.Pages.UpdateAsync(_page.Id, new PagesUpdateParameters { InTrash = true });
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion Test/Notion.IntegrationTests/PageClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public async Task InitializeAsync()

public async Task DisposeAsync()
{
await Client.Pages.UpdateAsync(_page.Id, new PagesUpdateParameters { Archived = true });
await Client.Pages.UpdateAsync(_page.Id, new PagesUpdateParameters { InTrash = true });
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion Test/Notion.IntegrationTests/PageWithPageParentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public async Task InitializeAsync()

public async Task DisposeAsync()
{
await Client.Pages.UpdateAsync(_page.Id, new PagesUpdateParameters { Archived = true });
await Client.Pages.UpdateAsync(_page.Id, new PagesUpdateParameters { InTrash = true });
}

[Fact]
Expand Down
1 change: 1 addition & 0 deletions Test/Notion.UnitTests/BlocksClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public async Task UpdateAsync()

block.Id.Should().Be(blockId);
block.HasChildren.Should().BeFalse();
block.InTrash.Should().BeFalse();
block.Type.Should().Be(BlockType.ToDo);

var todoBlock = (ToDoBlock)block;
Expand Down
2 changes: 1 addition & 1 deletion Test/Notion.UnitTests/Notion.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<None Update="data\databases\UpdateDatabaseResponse.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="data\pages\ArchivePageResponse.json">
<None Update="data\pages\TrashPageResponse.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="data\pages\CreatePageResponse.json">
Expand Down
14 changes: 7 additions & 7 deletions Test/Notion.UnitTests/PagesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task RetrieveAsync()
page.Id.Should().Be(pageId);
page.Parent.Type.Should().Be(ParentType.DatabaseId);
((DatabaseParent)page.Parent).DatabaseId.Should().Be("48f8fee9-cd79-4180-bc2f-ec0398253067");
page.IsArchived.Should().BeFalse();
page.InTrash.Should().BeFalse();
}

[Fact]
Expand Down Expand Up @@ -72,7 +72,7 @@ public async Task CreateAsync()
page.Url.Should().NotBeNullOrEmpty();
page.Properties.Should().HaveCount(1);
page.Properties.First().Key.Should().Be("Name");
page.IsArchived.Should().BeFalse();
page.InTrash.Should().BeFalse();
page.Parent.Should().NotBeNull();
((DatabaseParent)page.Parent).DatabaseId.Should().Be("3c357473-a281-49a4-88c0-10d2b245a589");
}
Expand Down Expand Up @@ -172,7 +172,7 @@ public async Task UpdatePageAsync()
var page = await _client.UpdateAsync(pageId, pagesUpdateParameters);

page.Id.Should().Be(pageId);
page.IsArchived.Should().BeFalse();
page.InTrash.Should().BeFalse();
page.Properties.Should().HaveCount(2);
var updatedProperty = page.Properties.First(x => x.Key == "In stock");

Expand All @@ -187,14 +187,14 @@ public async Task UpdatePageAsync()
}

[Fact]
public async Task ArchivePageAsync()
public async Task TrashPageAsync()
{
var pageId = "251d2b5f-268c-4de2-afe9-c71ff92ca95c";
var propertyId = "{>U;";

var path = ApiEndpoints.PagesApiUrls.UpdateProperties(pageId);

var jsonData = await File.ReadAllTextAsync("data/pages/ArchivePageResponse.json");
var jsonData = await File.ReadAllTextAsync("data/pages/TrashPageResponse.json");

Server.Given(CreatePatchRequestBuilder(path))
.RespondWith(
Expand All @@ -211,7 +211,7 @@ public async Task ArchivePageAsync()

var pagesUpdateParameters = new PagesUpdateParameters
{
Archived = true,
InTrash = true,
Properties = new Dictionary<string, PropertyValue>
{
{ "In stock", new CheckboxPropertyValue { Checkbox = true } }
Expand All @@ -221,7 +221,7 @@ public async Task ArchivePageAsync()
var page = await _client.UpdateAsync(pageId, pagesUpdateParameters);

page.Id.Should().Be(pageId);
page.IsArchived.Should().BeTrue();
page.InTrash.Should().BeTrue();
page.Properties.Should().HaveCount(2);
var updatedProperty = page.Properties.First(x => x.Key == "In stock");

Expand Down
2 changes: 1 addition & 1 deletion Test/Notion.UnitTests/SearchClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Task Search()
obj.Object.Should().Be(ObjectType.Page);

var page = (Page)obj;
page.IsArchived.Should().BeFalse();
page.InTrash.Should().BeFalse();
page.Properties.Should().HaveCount(1);
page.Parent.Should().BeAssignableTo<DatabaseParent>();
((DatabaseParent)page.Parent).DatabaseId.Should().Be("e6c6f8ff-c70e-4970-91ba-98f03e0d7fc6");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"created_time": "2021-03-16T16:31:00.000Z",
"last_edited_time": "2021-03-16T16:32:00.000Z",
"has_children": false,
"in_trash" : false,
"type": "heading_2",
"heading_2": {
"rich_text": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"created_time": "2021-05-29T16:22:00.000Z",
"last_edited_time": "2021-05-29T16:22:00.000Z",
"has_children": false,
"archived": false,
"in_trash": false,
"type": "paragraph",
"paragraph": {
"rich_text": []
Expand All @@ -19,7 +19,7 @@
"created_time": "2021-05-30T09:25:00.000Z",
"last_edited_time": "2021-05-30T09:25:00.000Z",
"has_children": false,
"archived": false,
"in_trash": false,
"type": "heading_2",
"heading_2": {
"rich_text": [
Expand Down Expand Up @@ -49,7 +49,7 @@
"created_time": "2021-05-30T09:36:00.000Z",
"last_edited_time": "2021-05-30T09:36:00.000Z",
"has_children": false,
"archived": false,
"in_trash": false,
"type": "heading_2",
"heading_2": {
"rich_text": [
Expand Down Expand Up @@ -79,7 +79,7 @@
"created_time": "2021-08-18T21:12:00.000Z",
"last_edited_time": "2021-08-18T21:12:00.000Z",
"has_children": false,
"archived": false,
"in_trash": false,
"type": "paragraph",
"paragraph": {
"rich_text": []
Expand All @@ -91,7 +91,7 @@
"created_time": "2021-08-18T23:00:00.000Z",
"last_edited_time": "2021-08-18T23:00:00.000Z",
"has_children": false,
"archived": false,
"in_trash": false,
"type": "child_page",
"child_page": {
"title": ""
Expand All @@ -103,7 +103,7 @@
"created_time": "2021-08-18T23:00:00.000Z",
"last_edited_time": "2021-08-18T23:00:00.000Z",
"has_children": false,
"archived": false,
"in_trash": false,
"type": "child_page",
"child_page": {
"title": ""
Expand All @@ -115,7 +115,7 @@
"created_time": "2021-09-09T05:22:00.000Z",
"last_edited_time": "2021-09-09T05:22:00.000Z",
"has_children": false,
"archived": false,
"in_trash": false,
"type": "paragraph",
"paragraph": {
"rich_text": []
Expand All @@ -127,7 +127,7 @@
"created_time": "2022-05-03T13:28:00.000Z",
"last_edited_time": "2022-05-03T13:29:00.000Z",
"has_children": false,
"archived": false,
"in_trash": false,
"type": "image",
"image": {
"caption": [
Expand Down Expand Up @@ -174,7 +174,7 @@
"id": "92e803ec-193c-4bcd-b28e-88365858d562"
},
"has_children": true,
"archived": false,
"in_trash": false,
"type": "synced_block",
"synced_block": {
"synced_from": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"created_time": "2021-03-16T16:31:00.000Z",
"last_edited_time": "2021-03-16T16:32:00.000Z",
"has_children": false,
"in_trash" : false,
"type": "to_do",
"to_do": {
"rich_text": [
Expand Down
1 change: 1 addition & 0 deletions Test/Notion.UnitTests/data/blocks/UpdateBlockResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"created_time": "2021-03-16T16:31:00.000Z",
"last_edited_time": "2021-03-16T16:32:00.000Z",
"has_children": false,
"in_trash" : false,
"type": "to_do",
"to_do": {
"rich_text": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
}
},
"url": "https://www.notion.so/668d797c76fa49349b05ad288df2d136",
"in_trash" : false,
"properties": {
"Tags": {
"id": "YG~h",
Expand Down
Loading
Loading