diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
new file mode 100644
index 00000000..92211a4f
--- /dev/null
+++ b/.config/dotnet-tools.json
@@ -0,0 +1,12 @@
+{
+ "version": 1,
+ "isRoot": true,
+ "tools": {
+ "jetbrains.resharper.globaltools": {
+ "version": "2022.2.3",
+ "commands": [
+ "jb"
+ ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/.editorconfig b/.editorconfig
index f8d20ed2..1745f593 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,11 +1,52 @@
+root = true
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
-root = true
# Don't use tabs for indentation.
[*]
indent_style = space
+
+[*.cs]
+
+# ReSharper properties
+
+# Blank lines
+resharper_blank_lines_after_control_transfer_statements = 1
+resharper_blank_lines_after_multiline_statements = 1
+resharper_blank_lines_around_single_line_auto_property = 1
+resharper_blank_lines_around_single_line_local_method = 1
+resharper_blank_lines_around_single_line_property = 1
+resharper_blank_lines_before_block_statements = 1
+resharper_blank_lines_before_control_transfer_statements = 1
+resharper_blank_lines_before_multiline_statements = 1
+resharper_blank_lines_before_single_line_comment = 1
+
+# Baces
+resharper_braces_for_for = required
+resharper_braces_for_foreach = required
+resharper_braces_for_ifelse = required
+resharper_braces_for_while = required
+resharper_braces_redundant = false
+resharper_indent_nested_fixed_stmt = true
+resharper_indent_nested_foreach_stmt = true
+resharper_indent_nested_for_stmt = true
+resharper_indent_nested_lock_stmt = true
+resharper_indent_nested_usings_stmt = true
+resharper_indent_nested_while_stmt = true
+resharper_max_enum_members_on_line = 1
+
+resharper_csharp_force_attribute_style=separate
+resharper_csharp_method_or_operator_body=expression_body
+resharper_csharp_max_enum_members_on_line=1
+resharper_csharp_place_attribute_on_same_line=false
+resharper_csharp_wrap_object_and_collection_initializer_style=chop_always
+resharper_csharp_use_heuristics_for_body_style=true
+
+resharper_csharp_max_initializer_elements_on_line=0
+
+# Standard properties
+insert_final_newline = true
# (Please don't specify an indent_size here; that has too many unintended consequences.)
# Code files
@@ -39,7 +80,7 @@ indent_size = 2
[*.{cs,vb}]
# IDE0055: Fix formatting
-dotnet_diagnostic.IDE0055.severity = warning
+dotnet_diagnostic.ide0055.severity = warning
# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true
@@ -102,7 +143,7 @@ dotnet_naming_symbols.static_fields.applicable_kinds = field
dotnet_naming_symbols.static_fields.required_modifiers = static
dotnet_naming_style.static_field_style.capitalization = camel_case
-dotnet_naming_style.static_field_style.required_prefix = s_
+dotnet_naming_style.static_field_style.required_prefix = _
# Instance fields are camelCase and start with _
dotnet_naming_rule.instance_fields_should_be_camel_case.severity = suggestion
@@ -143,23 +184,23 @@ dotnet_naming_symbols.all_members.applicable_kinds = *
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
# error RS2008: Enable analyzer release tracking for the analyzer project containing rule '{0}'
-dotnet_diagnostic.RS2008.severity = none
+dotnet_diagnostic.rs2008.severity = none
# IDE0073: File header
# dotnet_diagnostic.IDE0073.severity = warning
# file_header_template =
# IDE0035: Remove unreachable code
-dotnet_diagnostic.IDE0035.severity = warning
+dotnet_diagnostic.ide0035.severity = warning
# IDE0036: Order modifiers
-dotnet_diagnostic.IDE0036.severity = warning
+dotnet_diagnostic.ide0036.severity = warning
# IDE0043: Format string contains invalid placeholder
-dotnet_diagnostic.IDE0043.severity = warning
+dotnet_diagnostic.ide0043.severity = warning
# IDE0044: Make field readonly
-dotnet_diagnostic.IDE0044.severity = warning
+dotnet_diagnostic.ide0044.severity = warning
# RS0016: Only enable if API files are present
dotnet_public_api_analyzer.require_api_files = true
@@ -236,39 +277,39 @@ csharp_preserve_single_line_statements = true
[src/CodeStyle/**.{cs,vb}]
# warning RS0005: Do not use generic CodeAction.Create to create CodeAction
-dotnet_diagnostic.RS0005.severity = none
+dotnet_diagnostic.rs0005.severity = none
[src/{Analyzers,CodeStyle,Features,Workspaces,EditorFeatures,VisualStudio}/**/*.{cs,vb}]
# IDE0011: Add braces
csharp_prefer_braces = when_multiline:warning
# NOTE: We need the below severity entry for Add Braces due to https://github.com/dotnet/roslyn/issues/44201
-dotnet_diagnostic.IDE0011.severity = warning
+dotnet_diagnostic.ide0011.severity = warning
# IDE0040: Add accessibility modifiers
-dotnet_diagnostic.IDE0040.severity = warning
+dotnet_diagnostic.ide0040.severity = warning
# CONSIDER: Are IDE0051 and IDE0052 too noisy to be warnings for IDE editing scenarios? Should they be made build-only warnings?
# IDE0051: Remove unused private member
-dotnet_diagnostic.IDE0051.severity = warning
+dotnet_diagnostic.ide0051.severity = warning
# IDE0052: Remove unread private member
-dotnet_diagnostic.IDE0052.severity = warning
+dotnet_diagnostic.ide0052.severity = warning
# IDE0059: Unnecessary assignment to a value
-dotnet_diagnostic.IDE0059.severity = warning
+dotnet_diagnostic.ide0059.severity = warning
# IDE0060: Remove unused parameter
-dotnet_diagnostic.IDE0060.severity = warning
+dotnet_diagnostic.ide0060.severity = warning
# CA1012: Abstract types should not have public constructors
-dotnet_diagnostic.CA1012.severity = warning
+dotnet_diagnostic.ca1012.severity = warning
# CA1822: Make member static
-dotnet_diagnostic.CA1822.severity = warning
+dotnet_diagnostic.ca1822.severity = warning
# Prefer "var" everywhere
-dotnet_diagnostic.IDE0007.severity = warning
+dotnet_diagnostic.ide0007.severity = warning
csharp_style_var_for_built_in_types = true:warning
csharp_style_var_when_type_is_apparent = true:warning
csharp_style_var_elsewhere = true:warning
@@ -277,4 +318,18 @@ csharp_style_var_elsewhere = true:warning
# CA1822: Make member static
# Not enforced as a build 'warning' for 'VisualStudio' layer due to large number of false positives from https://github.com/dotnet/roslyn-analyzers/issues/3857 and https://github.com/dotnet/roslyn-analyzers/issues/3858
# Additionally, there is a risk of accidentally breaking an internal API that partners rely on though IVT.
-dotnet_diagnostic.CA1822.severity = suggestion
\ No newline at end of file
+dotnet_diagnostic.ca1822.severity = suggestion
+
+[*.{appxmanifest,asax,ascx,aspx,axaml,axml,build,config,cs,cshtml,csproj,css,dbml,discomap,dtd,htm,html,js,json,jsproj,jsx,lsproj,master,njsproj,nuspec,paml,proj,props,proto,razor,resjson,resw,resx,skin,StyleCop,targets,tasks,ts,tsx,vb,vbproj,xaml,xamlx,xml,xoml,xsd}]
+indent_style = space
+indent_size = 4
+tab_width = 4
+
+[*.cs]
+# IDE0130: Namespace does not match folder structure
+dotnet_style_namespace_match_folder = false
+
+# IDE0130: Namespace does not match folder structure
+dotnet_diagnostic.IDE0130.severity = silent
+
+resharper_check_namespace_highlighting=none
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 00000000..331a95d5
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,14 @@
+# To get started with Dependabot version updates, you'll need to specify which
+# package ecosystems to update and where the package manifests are located.
+# Please see the documentation for all configuration options:
+# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
+
+version: 2
+updates:
+ - package-ecosystem: "nuget" # See documentation for possible values
+ directory: "/" # Location of package manifests
+ schedule:
+ interval: "weekly"
+ open-pull-requests-limit: 10
+ commit-message:
+ prefix: "deps"
diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml
new file mode 100644
index 00000000..f42ffd37
--- /dev/null
+++ b/.github/release-drafter.yml
@@ -0,0 +1,16 @@
+categories:
+ - title: '🚀 Features'
+ labels:
+ - 'feature'
+ - 'enhancement'
+ - title: '🐛 Bug Fixes'
+ labels:
+ - 'fix'
+ - 'bugfix'
+ - 'bug'
+ - title: '🧰 Maintenance'
+ label: 'chore'
+template: |
+ ## Changes
+
+ $CHANGES
\ No newline at end of file
diff --git a/.github/scripts/check.sh b/.github/scripts/check.sh
new file mode 100644
index 00000000..3006888a
--- /dev/null
+++ b/.github/scripts/check.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+dotnet jb inspectcode Notion.sln -f="Text" --no-build --include="**.cs" -o=".lint/CodeWarningResults.txt"
+
+totalLines=$(file .lint/CodeWarningResults.txt | nl | wc -l)
+
+if [[ "$totalLines" -gt 1 ]]; then
+ echo "There are few linter warnings - please fix them before running the pipeline"
+ cat .lint/CodeWarningResults.txt
+ exit 1
+fi
diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml
index c69148e8..35959b57 100644
--- a/.github/workflows/ci-build.yml
+++ b/.github/workflows/ci-build.yml
@@ -21,15 +21,15 @@ jobs:
- name: Restore dependencies
run: dotnet restore
- # Format the output of dotnet format
- - name: Add dotnet-format problem matcher
- uses: xt0rted/dotnet-format-problem-matcher@v1
-
# Install dotnet format as a global tool
- - name: Install dotnet format
+ - name: Install dotnet tools
+ run: dotnet tool restore
+
+ - name: Run Linter
run: |
- dotnet tool install --global dotnet-format
- dotnet format --verify-no-changes --verbosity diagnostic
+ sudo chmod +x ./.github/scripts/check.sh
+ ./.github/scripts/check.sh
+ shell: bash
- name: Build
run: dotnet build --no-restore
diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml
new file mode 100644
index 00000000..55a63c2c
--- /dev/null
+++ b/.github/workflows/greetings.yml
@@ -0,0 +1,23 @@
+name: Greetings
+
+on: [pull_request_target, issues]
+
+jobs:
+ greet-first-time-contributors:
+ name: Greet First-Time Contributors
+ runs-on: ubuntu-latest
+ permissions:
+ issues: write
+ pull-requests: write
+
+ steps:
+ - name: Send greeting to first-time contributors
+ uses: actions/first-interaction@v1
+ with:
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
+ issue-message: >
+ 👋 Hi there! Thanks for opening your first issue in this repository.
+ We appreciate your contribution. A maintainer will take a look soon.
+ pr-message: >
+ 🎉 Thanks for your first pull request!
+ The team will review it shortly. We’re excited to have you contribute!
diff --git a/.github/workflows/publish-code.yml b/.github/workflows/publish-code.yml
index ef76a197..2073a733 100644
--- a/.github/workflows/publish-code.yml
+++ b/.github/workflows/publish-code.yml
@@ -36,7 +36,7 @@ jobs:
dotnet pack --no-restore --no-build -o PackOutputs -c Release -p:Version=${{ github.event.release.tag_name }} -p:PackageReleaseNotes="See https://github.com/notion-dotnet/notion-sdk-net/releases/tag/${{ github.event.release.tag_name }}" -p:PackageReadmeFile=README.md
- name: Upload artifacts
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
with:
name: Notion.Net
path: PackOutputs/*
@@ -45,7 +45,7 @@ jobs:
run: dotnet nuget push PackOutputs/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }}
- name: Upload Nuget packages as release artifacts
- uses: actions/github-script@v2
+ uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml
new file mode 100644
index 00000000..4eed5a56
--- /dev/null
+++ b/.github/workflows/release-drafter.yml
@@ -0,0 +1,41 @@
+name: Release Drafter
+
+on:
+ push:
+ # branches to consider in the event; optional, defaults to all
+ branches:
+ - main
+ # pull_request event is required only for autolabeler
+ pull_request:
+ # Only following types are handled by the action, but one can default to all as well
+ types: [opened, reopened, synchronize]
+ # pull_request_target event is required for autolabeler to support PRs from forks
+ pull_request_target:
+ types: [opened, reopened, synchronize]
+
+permissions:
+ contents: read
+
+jobs:
+ update_release_draft:
+ permissions:
+ # write permission is required to create a github release
+ contents: write
+ # write permission is required for autolabeler
+ # otherwise, read permission is required at least
+ pull-requests: write
+ runs-on: ubuntu-latest
+ steps:
+ # (Optional) GitHub Enterprise requires GHE_HOST variable set
+ #- name: Set GHE_HOST
+ # run: |
+ # echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV
+
+ # Drafts your next Release notes as Pull Requests are merged into "master"
+ - uses: release-drafter/release-drafter@v5.21.1
+ # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
+ # with:
+ # config-name: my-config.yml
+ # disable-autolabeler: true
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
\ No newline at end of file
diff --git a/.github/workflows/test-publish-code.yml b/.github/workflows/test-publish-code.yml
index e90afd73..ce6974e6 100644
--- a/.github/workflows/test-publish-code.yml
+++ b/.github/workflows/test-publish-code.yml
@@ -45,7 +45,7 @@ jobs:
ls -l PackOutputs/
- name: Upload artifacts
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
with:
name: Notion.Net
path: PackOutputs/*
diff --git a/.gitignore b/.gitignore
index dfcfd56f..5072687a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -348,3 +348,11 @@ MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
+
+# Resharper linter
+.lint/
+
+# Rider
+.idea/
+
+.DS_Store
diff --git a/Notion.sln.DotSettings b/Notion.sln.DotSettings
new file mode 100644
index 00000000..833f39db
--- /dev/null
+++ b/Notion.sln.DotSettings
@@ -0,0 +1,5 @@
+
+ PDF
+ API
+ JSON
+ URL
diff --git a/README.md b/README.md
index 10893f28..d74a4cc6 100644
--- a/README.md
+++ b/README.md
@@ -14,9 +14,6 @@
[](https://github.com/notion-dotnet/notion-sdk-net/actions/workflows/publish-code.yml)
[](https://github.com/notion-dotnet/notion-sdk-net/actions/workflows/codeql-analysis.yml)
-[](https://lgtm.com/projects/g/notion-dotnet/notion-sdk-net/alerts/?mode=list)
-[](https://lgtm.com/projects/g/notion-dotnet/notion-sdk-net/alerts/?mode=list)
-
[]()
[]()
[]()
@@ -44,6 +41,7 @@ dotnet add package Notion.Net
**Note:** default Notion-Version used by NuGet package versions
| Package version | Notion-Version |
| --- | --- |
+| 4.0.0-preview-1.8.21.2022 | 2022-06-28 |
| 3.0.0+ | 2022-02-22 |
| 2.0.0+ | 2021-08-16 |
| 1.0.0+ | 2021-05-13 |
@@ -127,6 +125,9 @@ var complexFiler = new CompoundFilter(
- [x] Retrieve block children
- [x] Append block children
- [x] Delete a block
+- [x] Comments
+ - [x] Retrieve comments
+ - [x] Create comment
- [x] Users
- [x] Retrieve a User
- [x] List all users
diff --git a/Src/Notion.Client/Api/ApiEndpoints.cs b/Src/Notion.Client/Api/ApiEndpoints.cs
index f9a9549b..86d703b3 100644
--- a/Src/Notion.Client/Api/ApiEndpoints.cs
+++ b/Src/Notion.Client/Api/ApiEndpoints.cs
@@ -1,65 +1,141 @@
-using System;
-
-namespace Notion.Client
+namespace Notion.Client
{
public static class ApiEndpoints
{
public static class DatabasesApiUrls
{
- public static string Retrieve(string databaseId) => $"/v1/databases/{databaseId}";
- public static string List() => "/v1/databases";
- public static string Query(string databaseId) => $"/v1/databases/{databaseId}/query";
public static string Create => "/v1/databases";
- public static string Update(string databaseId) => $"/v1/databases/{databaseId}";
+
+ public static string Retrieve(string databaseId)
+ {
+ return $"/v1/databases/{databaseId}";
+ }
+
+ public static string Query(string databaseId)
+ {
+ return $"/v1/databases/{databaseId}/query";
+ }
+
+ public static string Update(string databaseId)
+ {
+ return $"/v1/databases/{databaseId}";
+ }
}
public static class UsersApiUrls
{
- public static string Retrieve(string userId) => $"/v1/users/{userId}";
- public static string List() => "/v1/users";
+ public static string Retrieve(string userId)
+ {
+ return $"/v1/users/{userId}";
+ }
+
+ public static string List()
+ {
+ return "/v1/users";
+ }
///
- /// Get the for retrieve your token's bot user.
+ /// Get the Uri for retrieve your token's bot user.
///
- /// Returns a retrieve your token's bot user.
- public static string Me() => "/v1/users/me";
+ /// Returns a Uri retrieve your token's bot user.
+ public static string Me()
+ {
+ return "/v1/users/me";
+ }
}
public static class BlocksApiUrls
{
- public static string Retrieve(string blockId) => $"/v1/blocks/{blockId}";
- public static string Update(string blockId) => $"/v1/blocks/{blockId}";
+ public static string Retrieve(string blockId)
+ {
+ return $"/v1/blocks/{blockId}";
+ }
+
+ public static string Update(string blockId)
+ {
+ return $"/v1/blocks/{blockId}";
+ }
///
- /// Get the for deleting a block.
+ /// Get the Uri for deleting a block.
///
/// Identifier for a Notion block
- /// Returns a for deleting a block.
- public static string Delete(string blockId) => $"/v1/blocks/{blockId}";
+ /// Returns a Uri for deleting a block.
+ public static string Delete(string blockId)
+ {
+ return $"/v1/blocks/{blockId}";
+ }
+
+ public static string RetrieveChildren(string blockId)
+ {
+ return $"/v1/blocks/{blockId}/children";
+ }
- public static string RetrieveChildren(string blockId) => $"/v1/blocks/{blockId}/children";
- public static string AppendChildren(string blockId) => $"/v1/blocks/{blockId}/children";
+ public static string AppendChildren(string blockId)
+ {
+ return $"/v1/blocks/{blockId}/children";
+ }
}
public static class PagesApiUrls
{
- public static string Create() => $"/v1/pages";
- 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}";
+ public static string Create()
+ {
+ return "/v1/pages";
+ }
+
+ public static string Retrieve(string pageId)
+ {
+ return $"/v1/pages/{pageId}";
+ }
+
+ public static string Update(string pageId)
+ {
+ return $"/v1/pages/{pageId}";
+ }
+
+ public static string UpdateProperties(string pageId)
+ {
+ return $"/v1/pages/{pageId}";
+ }
///
- /// Get the for retrieve page property item
+ /// Get the Uri 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}";
+ /// Returns a Uri for Retrieve page property item
+ public static string RetrievePropertyItem(string pageId, string propertyId)
+ {
+ return $"/v1/pages/{pageId}/properties/{propertyId}";
+ }
}
public static class SearchApiUrls
{
- public static string Search() => "/v1/search";
+ public static string Search()
+ {
+ return "/v1/search";
+ }
+ }
+
+ public static class CommentsApiUrls
+ {
+ public static string Retrieve()
+ {
+ return "/v1/comments";
+ }
+
+ public static string Create()
+ {
+ return "/v1/comments";
+ }
+ }
+
+ public static class AuthenticationUrls
+ {
+ public static string CreateToken() => "/v1/oauth/token";
+ public static string RevokeToken() => "/v1/oauth/revoke";
}
}
}
diff --git a/Src/Notion.Client/Api/Authentication/AuthenticationClient.cs b/Src/Notion.Client/Api/Authentication/AuthenticationClient.cs
new file mode 100644
index 00000000..ab141200
--- /dev/null
+++ b/Src/Notion.Client/Api/Authentication/AuthenticationClient.cs
@@ -0,0 +1,12 @@
+namespace Notion.Client
+{
+ public sealed partial class AuthenticationClient : IAuthenticationClient
+ {
+ private readonly IRestClient _client;
+
+ public AuthenticationClient(IRestClient restClient)
+ {
+ _client = restClient;
+ }
+ }
+}
diff --git a/Src/Notion.Client/Api/Authentication/CreateToken/AuthenticationClient.cs b/Src/Notion.Client/Api/Authentication/CreateToken/AuthenticationClient.cs
new file mode 100644
index 00000000..23632632
--- /dev/null
+++ b/Src/Notion.Client/Api/Authentication/CreateToken/AuthenticationClient.cs
@@ -0,0 +1,21 @@
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Notion.Client
+{
+ public sealed partial class AuthenticationClient
+ {
+ public async Task CreateTokenAsync(
+ CreateTokenRequest createTokenRequest,
+ CancellationToken cancellationToken = default)
+ {
+ var body = (ICreateTokenBodyParameters)createTokenRequest;
+
+ return await _client.PostAsync(
+ ApiEndpoints.AuthenticationUrls.CreateToken(),
+ body,
+ cancellationToken: cancellationToken
+ );
+ }
+ }
+}
diff --git a/Src/Notion.Client/Api/Authentication/CreateToken/Request/CreateTokenRequest.cs b/Src/Notion.Client/Api/Authentication/CreateToken/Request/CreateTokenRequest.cs
new file mode 100644
index 00000000..3fe8ffde
--- /dev/null
+++ b/Src/Notion.Client/Api/Authentication/CreateToken/Request/CreateTokenRequest.cs
@@ -0,0 +1,13 @@
+namespace Notion.Client
+{
+ public class CreateTokenRequest : ICreateTokenBodyParameters
+ {
+ public string GrantType => "authorization_code";
+
+ public string Code { get; set; }
+
+ public string RedirectUri { get; set; }
+
+ public ExternalAccount ExternalAccount { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Authentication/CreateToken/Request/ExternalAccount.cs b/Src/Notion.Client/Api/Authentication/CreateToken/Request/ExternalAccount.cs
new file mode 100644
index 00000000..432d709f
--- /dev/null
+++ b/Src/Notion.Client/Api/Authentication/CreateToken/Request/ExternalAccount.cs
@@ -0,0 +1,22 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ ///
+ /// External account info
+ ///
+ public class ExternalAccount
+ {
+ ///
+ /// External account key
+ ///
+ [JsonProperty("key")]
+ public string Key { get; set; }
+
+ ///
+ /// External account name
+ ///
+ [JsonProperty("name")]
+ public string Name { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Authentication/CreateToken/Request/ICreateTokenBodyParameters.cs b/Src/Notion.Client/Api/Authentication/CreateToken/Request/ICreateTokenBodyParameters.cs
new file mode 100644
index 00000000..e896e71a
--- /dev/null
+++ b/Src/Notion.Client/Api/Authentication/CreateToken/Request/ICreateTokenBodyParameters.cs
@@ -0,0 +1,35 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public interface ICreateTokenBodyParameters
+ {
+ ///
+ /// A constant string: "authorization_code".
+ ///
+ [JsonProperty("grant_type")]
+ string GrantType { get; }
+
+ ///
+ /// A unique random code that Notion generates to authenticate with your service,
+ /// generated when a user initiates the OAuth flow.
+ ///
+ [JsonProperty("code")]
+ string Code { get; set; }
+
+ ///
+ /// The "redirect_uri" that was provided in the OAuth Domain & URI section
+ /// of the integration's Authorization settings. Do not include this field if a
+ /// "redirect_uri" query param was not included in the Authorization URL
+ /// provided to users. In most cases, this field is required.
+ ///
+ [JsonProperty("redirect_uri")]
+ string RedirectUri { get; set; }
+
+ ///
+ /// External account details
+ ///
+ [JsonProperty("external_account")]
+ ExternalAccount ExternalAccount { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Authentication/CreateToken/Response/CreateTokenResponse.cs b/Src/Notion.Client/Api/Authentication/CreateToken/Response/CreateTokenResponse.cs
new file mode 100644
index 00000000..fbbe7a7a
--- /dev/null
+++ b/Src/Notion.Client/Api/Authentication/CreateToken/Response/CreateTokenResponse.cs
@@ -0,0 +1,31 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class CreateTokenResponse
+ {
+ [JsonProperty("access_token")]
+ public string AccessToken { get; set; }
+
+ [JsonProperty("token_type")]
+ public string TokenType { get; set; } = "bearer";
+
+ [JsonProperty("bot_id")]
+ public string BotId { get; set; }
+
+ [JsonProperty("duplicated_template_id")]
+ public string DuplicatedTemplateId { get; set; }
+
+ [JsonProperty("owner")]
+ public IBotOwner Owner { get; set; }
+
+ [JsonProperty("workspace_icon")]
+ public string WorkspaceIcon { get; set; }
+
+ [JsonProperty("workspace_id")]
+ public string WorkspaceId { get; set; }
+
+ [JsonProperty("workspace_name")]
+ public string WorkspaceName { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Authentication/IAuthenticationClient.cs b/Src/Notion.Client/Api/Authentication/IAuthenticationClient.cs
new file mode 100644
index 00000000..1973638f
--- /dev/null
+++ b/Src/Notion.Client/Api/Authentication/IAuthenticationClient.cs
@@ -0,0 +1,33 @@
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Notion.Client
+{
+ ///
+ /// Authentication client
+ ///
+ public interface IAuthenticationClient
+ {
+ ///
+ /// Creates an access token that a third-party service can use to authenticate with Notion.
+ ///
+ ///
+ ///
+ ///
+ Task CreateTokenAsync(
+ CreateTokenRequest createTokenRequest,
+ CancellationToken cancellationToken = default
+ );
+
+ ///
+ /// Revokes an access token.
+ ///
+ ///
+ ///
+ ///
+ Task RevokeTokenAsync(
+ RevokeTokenRequest revokeTokenRequest,
+ CancellationToken cancellationToken = default
+ );
+ }
+}
diff --git a/Src/Notion.Client/Api/Authentication/RevokeToken/AuthenticationClient.cs b/Src/Notion.Client/Api/Authentication/RevokeToken/AuthenticationClient.cs
new file mode 100644
index 00000000..c1f3ab9d
--- /dev/null
+++ b/Src/Notion.Client/Api/Authentication/RevokeToken/AuthenticationClient.cs
@@ -0,0 +1,21 @@
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Notion.Client
+{
+ public sealed partial class AuthenticationClient
+ {
+ public async Task RevokeTokenAsync(
+ RevokeTokenRequest revokeTokenRequest,
+ CancellationToken cancellationToken = default)
+ {
+ var body = (IRevokeTokenBodyParameters)revokeTokenRequest;
+
+ await _client.PostAsync(
+ ApiEndpoints.AuthenticationUrls.RevokeToken(),
+ body,
+ cancellationToken: cancellationToken
+ );
+ }
+ }
+}
diff --git a/Src/Notion.Client/Api/Authentication/RevokeToken/Request/IRevokeTokenBodyParameters.cs b/Src/Notion.Client/Api/Authentication/RevokeToken/Request/IRevokeTokenBodyParameters.cs
new file mode 100644
index 00000000..0a194516
--- /dev/null
+++ b/Src/Notion.Client/Api/Authentication/RevokeToken/Request/IRevokeTokenBodyParameters.cs
@@ -0,0 +1,13 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public interface IRevokeTokenBodyParameters
+ {
+ ///
+ /// The token to be revoked.
+ ///
+ [JsonProperty("token")]
+ string Token { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Authentication/RevokeToken/Request/RevokeTokenRequest.cs b/Src/Notion.Client/Api/Authentication/RevokeToken/Request/RevokeTokenRequest.cs
new file mode 100644
index 00000000..7e92ca01
--- /dev/null
+++ b/Src/Notion.Client/Api/Authentication/RevokeToken/Request/RevokeTokenRequest.cs
@@ -0,0 +1,7 @@
+namespace Notion.Client
+{
+ public class RevokeTokenRequest : IRevokeTokenBodyParameters
+ {
+ public string Token { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Authentication/RevokeToken/Response/RevokeTokenResponse.cs b/Src/Notion.Client/Api/Authentication/RevokeToken/Response/RevokeTokenResponse.cs
new file mode 100644
index 00000000..428dd287
--- /dev/null
+++ b/Src/Notion.Client/Api/Authentication/RevokeToken/Response/RevokeTokenResponse.cs
@@ -0,0 +1,6 @@
+namespace Notion.Client
+{
+ internal class RevokeTokenResponse
+ {
+ }
+}
diff --git a/Src/Notion.Client/Api/Blocks/AppendChildren/BlocksClient.cs b/Src/Notion.Client/Api/Blocks/AppendChildren/BlocksClient.cs
new file mode 100644
index 00000000..50ce3c61
--- /dev/null
+++ b/Src/Notion.Client/Api/Blocks/AppendChildren/BlocksClient.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Notion.Client
+{
+ public sealed partial class BlocksClient
+ {
+ public async Task AppendChildrenAsync(
+ BlockAppendChildrenRequest request,
+ CancellationToken cancellationToken = default)
+ {
+ if (string.IsNullOrWhiteSpace(request.BlockId))
+ {
+ throw new ArgumentNullException(nameof(request.BlockId));
+ }
+
+ var url = ApiEndpoints.BlocksApiUrls.AppendChildren(request.BlockId);
+
+ var body = new BlockAppendChildrenBodyParameters(request);
+
+ return await _client.PatchAsync(url, body, cancellationToken: cancellationToken);
+ }
+ }
+}
diff --git a/Src/Notion.Client/Api/Blocks/AppendChildren/Request/BlockAppendChildrenRequest.cs b/Src/Notion.Client/Api/Blocks/AppendChildren/Request/BlockAppendChildrenRequest.cs
new file mode 100644
index 00000000..8a5a9cde
--- /dev/null
+++ b/Src/Notion.Client/Api/Blocks/AppendChildren/Request/BlockAppendChildrenRequest.cs
@@ -0,0 +1,13 @@
+using System.Collections.Generic;
+
+namespace Notion.Client
+{
+ public class BlockAppendChildrenRequest : IBlockAppendChildrenBodyParameters, IBlockAppendChildrenPathParameters
+ {
+ public IEnumerable Children { get; set; }
+
+ public string After { get; set; }
+
+ public string BlockId { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Blocks/AppendChildren/Request/IBlockAppendChildrenBodyParameters.cs b/Src/Notion.Client/Api/Blocks/AppendChildren/Request/IBlockAppendChildrenBodyParameters.cs
new file mode 100644
index 00000000..ea6cef37
--- /dev/null
+++ b/Src/Notion.Client/Api/Blocks/AppendChildren/Request/IBlockAppendChildrenBodyParameters.cs
@@ -0,0 +1,30 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public interface IBlockAppendChildrenBodyParameters
+ {
+ [JsonProperty("children")]
+ IEnumerable Children { get; set; }
+
+ ///
+ /// The ID of the existing block that the new block should be appended after.
+ ///
+ [JsonProperty("after")]
+ public string After { get; set; }
+ }
+
+ internal class BlockAppendChildrenBodyParameters : IBlockAppendChildrenBodyParameters
+ {
+ public IEnumerable Children { get; set; }
+
+ public string After { get; set; }
+
+ public BlockAppendChildrenBodyParameters(BlockAppendChildrenRequest request)
+ {
+ Children = request.Children;
+ After = request.After;
+ }
+ }
+}
diff --git a/Src/Notion.Client/Api/Blocks/AppendChildren/Request/IBlockAppendChildrenPathParameters.cs b/Src/Notion.Client/Api/Blocks/AppendChildren/Request/IBlockAppendChildrenPathParameters.cs
new file mode 100644
index 00000000..350382f6
--- /dev/null
+++ b/Src/Notion.Client/Api/Blocks/AppendChildren/Request/IBlockAppendChildrenPathParameters.cs
@@ -0,0 +1,7 @@
+namespace Notion.Client
+{
+ public interface IBlockAppendChildrenPathParameters
+ {
+ public string BlockId { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Blocks/AppendChildren/Response/AppendChildrenResponse.cs b/Src/Notion.Client/Api/Blocks/AppendChildren/Response/AppendChildrenResponse.cs
new file mode 100644
index 00000000..88e04ad5
--- /dev/null
+++ b/Src/Notion.Client/Api/Blocks/AppendChildren/Response/AppendChildrenResponse.cs
@@ -0,0 +1,11 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class AppendChildrenResponse : PaginatedList
+ {
+ [JsonProperty("block")]
+ public Dictionary Block { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Blocks/BlocksClient.cs b/Src/Notion.Client/Api/Blocks/BlocksClient.cs
index cc06642e..92713a78 100644
--- a/Src/Notion.Client/Api/Blocks/BlocksClient.cs
+++ b/Src/Notion.Client/Api/Blocks/BlocksClient.cs
@@ -1,11 +1,12 @@
using System;
using System.Collections.Generic;
+using System.Threading;
using System.Threading.Tasks;
using static Notion.Client.ApiEndpoints;
namespace Notion.Client
{
- public class BlocksClient : IBlocksClient
+ public sealed partial class BlocksClient : IBlocksClient
{
private readonly IRestClient _client;
@@ -14,41 +15,7 @@ public BlocksClient(IRestClient client)
_client = client;
}
- public async Task> RetrieveChildrenAsync(string blockId, BlocksRetrieveChildrenParameters parameters = null)
- {
- if (string.IsNullOrWhiteSpace(blockId))
- {
- throw new ArgumentNullException(nameof(blockId));
- }
-
- var url = BlocksApiUrls.RetrieveChildren(blockId);
-
- var queryParameters = (IBlocksRetrieveChildrenQueryParameters)parameters;
-
- var queryParams = new Dictionary()
- {
- { "start_cursor", queryParameters?.StartCursor?.ToString() },
- { "page_size", queryParameters?.PageSize?.ToString() }
- };
-
- return await _client.GetAsync>(url, queryParams);
- }
-
- public async Task> AppendChildrenAsync(string blockId, BlocksAppendChildrenParameters parameters = null)
- {
- if (string.IsNullOrWhiteSpace(blockId))
- {
- throw new ArgumentNullException(nameof(blockId));
- }
-
- var url = BlocksApiUrls.AppendChildren(blockId);
-
- var body = (IBlocksAppendChildrenBodyParameters)parameters;
-
- return await _client.PatchAsync>(url, body);
- }
-
- public async Task RetrieveAsync(string blockId)
+ public async Task RetrieveAsync(string blockId, CancellationToken cancellationToken = default)
{
if (string.IsNullOrWhiteSpace(blockId))
{
@@ -57,10 +24,10 @@ public async Task RetrieveAsync(string blockId)
var url = BlocksApiUrls.Retrieve(blockId);
- return await _client.GetAsync(url);
+ return await _client.GetAsync(url, cancellationToken: cancellationToken);
}
- public async Task UpdateAsync(string blockId, IUpdateBlock updateBlock)
+ public async Task UpdateAsync(string blockId, IUpdateBlock updateBlock, CancellationToken cancellationToken = default)
{
if (string.IsNullOrWhiteSpace(blockId))
{
@@ -69,10 +36,10 @@ public async Task UpdateAsync(string blockId, IUpdateBlock updateBlock)
var url = BlocksApiUrls.Update(blockId);
- return await _client.PatchAsync(url, updateBlock);
+ return await _client.PatchAsync(url, updateBlock, cancellationToken: cancellationToken);
}
- public async Task DeleteAsync(string blockId)
+ public async Task DeleteAsync(string blockId, CancellationToken cancellationToken = default)
{
if (string.IsNullOrWhiteSpace(blockId))
{
@@ -81,7 +48,7 @@ public async Task DeleteAsync(string blockId)
var url = BlocksApiUrls.Delete(blockId);
- await _client.DeleteAsync(url);
+ await _client.DeleteAsync(url, cancellationToken: cancellationToken);
}
}
}
diff --git a/Src/Notion.Client/Api/Blocks/IBlocksClient.cs b/Src/Notion.Client/Api/Blocks/IBlocksClient.cs
index 90ebf073..c5a64e59 100644
--- a/Src/Notion.Client/Api/Blocks/IBlocksClient.cs
+++ b/Src/Notion.Client/Api/Blocks/IBlocksClient.cs
@@ -1,38 +1,55 @@
-using System.Threading.Tasks;
+using System.Threading;
+using System.Threading.Tasks;
namespace Notion.Client
{
public interface IBlocksClient
{
///
- /// Retrieves a Block object using the ID specified.
+ /// Retrieves a Block object using the ID specified.
///
///
/// Block
- Task RetrieveAsync(string blockId);
+ Task RetrieveAsync(string blockId, CancellationToken cancellationToken = default);
///
- /// Updates the content for the specified block_id based on the block type.
+ /// Updates the content for the specified block_id based on the block type.
///
///
///
/// Block
- Task UpdateAsync(string blockId, IUpdateBlock updateBlock);
+ Task UpdateAsync(string blockId, IUpdateBlock updateBlock,
+ CancellationToken cancellationToken = default);
- Task> RetrieveChildrenAsync(string blockId, BlocksRetrieveChildrenParameters parameters = null);
+ ///
+ /// Returns a paginated array of child block objects contained in the block using the ID specified.
+ ///
+ /// In order to receive a complete representation of a block, you may need to recursively retrieve the
+ /// block children of child blocks.
+ ///
+ ///
+ ///
+ ///
+ Task RetrieveChildrenAsync(
+ BlockRetrieveChildrenRequest request,
+ CancellationToken cancellationToken = default
+ );
///
- /// Creates and appends new children blocks to the parent block_id specified.
+ /// Creates and appends new children blocks to the parent block_id specified.
///
- /// Identifier for a block
- ///
+ ///
+ ///
/// A paginated list of newly created first level children block objects.
- Task> AppendChildrenAsync(string blockId, BlocksAppendChildrenParameters parameters = null);
+ Task AppendChildrenAsync(
+ BlockAppendChildrenRequest request,
+ CancellationToken cancellationToken = default
+ );
///
- /// 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.
///
/// Identifier for a Notion block
- Task DeleteAsync(string blockId);
+ Task DeleteAsync(string blockId, CancellationToken cancellationToken = default);
}
}
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksAppendChildrenParameters.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksAppendChildrenParameters.cs
deleted file mode 100644
index e78899bb..00000000
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksAppendChildrenParameters.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using System.Collections.Generic;
-
-namespace Notion.Client
-{
- public class BlocksAppendChildrenParameters : IBlocksAppendChildrenBodyParameters
- {
- public IEnumerable Children { get; set; }
- }
-}
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksRetrieveChildrenParameters.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksRetrieveChildrenParameters.cs
deleted file mode 100644
index ddc73a91..00000000
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksRetrieveChildrenParameters.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace Notion.Client
-{
- public class BlocksRetrieveChildrenParameters : IBlocksRetrieveChildrenQueryParameters
- {
- public string StartCursor { get; set; }
- public int? PageSize { get; set; }
- }
-}
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/AudioUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/AudioUpdateBlock.cs
index 8747ad63..0f4b1acb 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/AudioUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/AudioUpdateBlock.cs
@@ -1,9 +1,8 @@
-using System.Collections.Generic;
-using Newtonsoft.Json;
+using Newtonsoft.Json;
namespace Notion.Client
{
- public class AudioUpdateBlock : UpdateBlock, IUpdateBlock
+ public class AudioUpdateBlock : UpdateBlock
{
[JsonProperty("audio")]
public IFileObjectInput Audio { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BookmarkUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BookmarkUpdateBlock.cs
index c3333737..b147c587 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BookmarkUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BookmarkUpdateBlock.cs
@@ -5,11 +5,11 @@ namespace Notion.Client
{
public class BookmarkUpdateBlock : IUpdateBlock
{
- public bool Archived { get; set; }
-
[JsonProperty("bookmark")]
public Info Bookmark { get; set; }
+ public bool InTrash { get; set; }
+
public class Info
{
[JsonProperty("url")]
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BreadcrumbUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BreadcrumbUpdateBlock.cs
index 2bb8be38..260eca82 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BreadcrumbUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BreadcrumbUpdateBlock.cs
@@ -4,18 +4,18 @@ namespace Notion.Client
{
public class BreadcrumbUpdateBlock : IUpdateBlock
{
- public bool Archived { get; set; }
+ public BreadcrumbUpdateBlock()
+ {
+ Breadcrumb = new Info();
+ }
[JsonProperty("breadcrumb")]
public Info Breadcrumb { get; set; }
- public class Info
- {
- }
+ public bool InTrash { get; set; }
- public BreadcrumbUpdateBlock()
+ public class Info
{
- Breadcrumb = new Info();
}
}
}
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BulletedListItemUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BulletedListItemUpdateBlock.cs
index 9225942f..cb1fa405 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BulletedListItemUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BulletedListItemUpdateBlock.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class BulletedListItemUpdateBlock : UpdateBlock, IUpdateBlock
+ public class BulletedListItemUpdateBlock : UpdateBlock
{
[JsonProperty("bulleted_list_item")]
public Info BulletedListItem { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/CalloutUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/CalloutUpdateBlock.cs
index f8562ff3..f4489ff8 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/CalloutUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/CalloutUpdateBlock.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class CalloutUpdateBlock : UpdateBlock, IUpdateBlock
+ public class CalloutUpdateBlock : UpdateBlock
{
[JsonProperty("callout")]
public Info Callout { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/CodeUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/CodeUpdateBlock.cs
index b4fcd6dc..164abb87 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/CodeUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/CodeUpdateBlock.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class CodeUpdateBlock : UpdateBlock, IUpdateBlock
+ public class CodeUpdateBlock : UpdateBlock
{
[JsonProperty("code")]
public Info Code { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/DividerUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/DividerUpdateBlock.cs
index 6c5b447c..62b83451 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/DividerUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/DividerUpdateBlock.cs
@@ -4,18 +4,18 @@ namespace Notion.Client
{
public class DividerUpdateBlock : IUpdateBlock
{
- public bool Archived { get; set; }
+ public DividerUpdateBlock()
+ {
+ Divider = new Info();
+ }
[JsonProperty("divider")]
public Info Divider { get; set; }
- public class Info
- {
- }
+ public bool InTrash { get; set; }
- public DividerUpdateBlock()
+ public class Info
{
- Divider = new Info();
}
}
}
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/EmbedUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/EmbedUpdateBlock.cs
index b0419a23..8dba5a53 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/EmbedUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/EmbedUpdateBlock.cs
@@ -2,7 +2,7 @@
namespace Notion.Client
{
- public class EmbedUpdateBlock : UpdateBlock, IUpdateBlock
+ public class EmbedUpdateBlock : UpdateBlock
{
[JsonProperty("embed")]
public Info Embed { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/EquationUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/EquationUpdateBlock.cs
index b7cb0ad9..b809ba7c 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/EquationUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/EquationUpdateBlock.cs
@@ -2,7 +2,7 @@
namespace Notion.Client
{
- public class EquationUpdateBlock : UpdateBlock, IUpdateBlock
+ public class EquationUpdateBlock : UpdateBlock
{
[JsonProperty("equation")]
public Info Equation { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/FileUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/FileUpdateBlock.cs
index 30d0dd9c..10208c1a 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/FileUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/FileUpdateBlock.cs
@@ -2,7 +2,7 @@
namespace Notion.Client
{
- public class FileUpdateBlock : UpdateBlock, IUpdateBlock
+ public class FileUpdateBlock : UpdateBlock
{
[JsonProperty("file")]
public IFileObjectInput File { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingOneUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingOneUpdateBlock.cs
index aeb4e087..672c8c85 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingOneUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingOneUpdateBlock.cs
@@ -1,11 +1,13 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json;
namespace Notion.Client
{
- public class HeadingOneUpdateBlock : UpdateBlock, IUpdateBlock
+ public class HeadingOneUpdateBlock : UpdateBlock
{
[JsonProperty("heading_1")]
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
public Info Heading_1 { get; set; }
public class Info
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingThreeeUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingThreeeUpdateBlock.cs
index 574ea0f0..d2eb4861 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingThreeeUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingThreeeUpdateBlock.cs
@@ -1,11 +1,13 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json;
namespace Notion.Client
{
- public class HeadingThreeeUpdateBlock : UpdateBlock, IUpdateBlock
+ public class HeadingThreeUpdateBlock : UpdateBlock
{
[JsonProperty("heading_3")]
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
public Info Heading_3 { get; set; }
public class Info
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingTwoUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingTwoUpdateBlock.cs
index 0269a0ce..da1f2833 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingTwoUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingTwoUpdateBlock.cs
@@ -1,11 +1,13 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json;
namespace Notion.Client
{
- public class HeadingTwoUpdateBlock : UpdateBlock, IUpdateBlock
+ public class HeadingTwoUpdateBlock : UpdateBlock
{
[JsonProperty("heading_2")]
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
public Info Heading_2 { get; set; }
public class Info
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/IUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/IUpdateBlock.cs
index ba93fe29..5b1de4be 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/IUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/IUpdateBlock.cs
@@ -4,7 +4,7 @@ namespace Notion.Client
{
public interface IUpdateBlock
{
- [JsonProperty("archived")]
- bool Archived { get; set; }
+ [JsonProperty("in_trash")]
+ bool InTrash { get; set; }
}
}
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ImageUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ImageUpdateBlock.cs
index 6679c61b..791198e9 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ImageUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ImageUpdateBlock.cs
@@ -2,7 +2,7 @@
namespace Notion.Client
{
- public class ImageUpdateBlock : UpdateBlock, IUpdateBlock
+ public class ImageUpdateBlock : UpdateBlock
{
[JsonProperty("image")]
public IFileObjectInput Image { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/LinkToPageUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/LinkToPageUpdateBlock.cs
index f6407cd4..69e088c5 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/LinkToPageUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/LinkToPageUpdateBlock.cs
@@ -2,7 +2,7 @@
namespace Notion.Client
{
- public class LinkToPageUpdateBlock : UpdateBlock, IUpdateBlock
+ public class LinkToPageUpdateBlock : UpdateBlock
{
[JsonProperty("link_to_page")]
public IPageParentInput LinkToPage { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/NumberedListItemUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/NumberedListItemUpdateBlock.cs
index c27363d3..11f92394 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/NumberedListItemUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/NumberedListItemUpdateBlock.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class NumberedListItemUpdateBlock : UpdateBlock, IUpdateBlock
+ public class NumberedListItemUpdateBlock : UpdateBlock
{
[JsonProperty("numbered_list_item")]
public Info NumberedListItem { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/PDFUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/PDFUpdateBlock.cs
index 8c56b7ff..c6e9ba0e 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/PDFUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/PDFUpdateBlock.cs
@@ -1,8 +1,10 @@
-using Newtonsoft.Json;
+using System.Diagnostics.CodeAnalysis;
+using Newtonsoft.Json;
namespace Notion.Client
{
- public class PDFUpdateBlock : UpdateBlock, IUpdateBlock
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
+ public class PDFUpdateBlock : UpdateBlock
{
[JsonProperty("pdf")]
public IFileObjectInput PDF { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ParagraphUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ParagraphUpdateBlock.cs
index 2e49c64a..63aa2724 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ParagraphUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ParagraphUpdateBlock.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class ParagraphUpdateBlock : UpdateBlock, IUpdateBlock
+ public class ParagraphUpdateBlock : UpdateBlock
{
[JsonProperty("paragraph")]
public Info Paragraph { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/QuoteUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/QuoteUpdateBlock.cs
index fdfd189c..9222112e 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/QuoteUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/QuoteUpdateBlock.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class QuoteUpdateBlock : UpdateBlock, IUpdateBlock
+ public class QuoteUpdateBlock : UpdateBlock
{
[JsonProperty("quote")]
public Info Quote { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/SyncedBlockUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/SyncedBlockUpdateBlock.cs
index 9cb234d8..e275f371 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/SyncedBlockUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/SyncedBlockUpdateBlock.cs
@@ -2,7 +2,7 @@
namespace Notion.Client
{
- public class SyncedBlockUpdateBlock : UpdateBlock, IUpdateBlock
+ public class SyncedBlockUpdateBlock : UpdateBlock
{
[JsonProperty("synced_block")]
public Info SyncedBlock { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TableOfContentsUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TableOfContentsUpdateBlock.cs
index 36eee182..2e4adff9 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TableOfContentsUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TableOfContentsUpdateBlock.cs
@@ -4,18 +4,18 @@ namespace Notion.Client
{
public class TableOfContentsUpdateBlock : IUpdateBlock
{
- public bool Archived { get; set; }
+ public TableOfContentsUpdateBlock()
+ {
+ TableOfContents = new Info();
+ }
[JsonProperty("table_of_contents")]
public Info TableOfContents { get; set; }
- public class Info
- {
- }
+ public bool InTrash { get; set; }
- public TableOfContentsUpdateBlock()
+ public class Info
{
- TableOfContents = new Info();
}
}
}
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TableRowUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TableRowUpdateBlock.cs
index c228de66..143f3e2d 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TableRowUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TableRowUpdateBlock.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class TableRowUpdateBlock : UpdateBlock, IUpdateBlock
+ public class TableRowUpdateBlock : UpdateBlock
{
[JsonProperty("table_row")]
public Info TableRow { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TableUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TableUpdateBlock.cs
index ef0e8933..7c1f8046 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TableUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TableUpdateBlock.cs
@@ -2,7 +2,7 @@
namespace Notion.Client
{
- public class TableUpdateBlock : UpdateBlock, IUpdateBlock
+ public class TableUpdateBlock : UpdateBlock
{
[JsonProperty("table")]
public Info Table { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TemplateUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TemplateUpdateBlock.cs
index 62457971..32a393cd 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TemplateUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TemplateUpdateBlock.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class TemplateUpdateBlock : UpdateBlock, IUpdateBlock
+ public class TemplateUpdateBlock : UpdateBlock
{
[JsonProperty("template")]
public Info Template { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToDoUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToDoUpdateBlock.cs
index f1accfc8..9e244f44 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToDoUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToDoUpdateBlock.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class ToDoUpdateBlock : UpdateBlock, IUpdateBlock
+ public class ToDoUpdateBlock : UpdateBlock
{
[JsonProperty("to_do")]
public Info ToDo { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToggleUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToggleUpdateBlock.cs
index b87834d1..3d7e8e87 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToggleUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToggleUpdateBlock.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class ToggleUpdateBlock : UpdateBlock, IUpdateBlock
+ public class ToggleUpdateBlock : UpdateBlock
{
[JsonProperty("toggle")]
public Info Toggle { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/UpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/UpdateBlock.cs
index d0321e52..14704cb2 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/UpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/UpdateBlock.cs
@@ -2,6 +2,6 @@
{
public abstract class UpdateBlock : IUpdateBlock
{
- public bool Archived { get; set; }
+ public bool InTrash { get; set; }
}
}
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/VideoUpdateBlock.cs b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/VideoUpdateBlock.cs
index ec28aae3..a317139a 100644
--- a/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/VideoUpdateBlock.cs
+++ b/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/VideoUpdateBlock.cs
@@ -2,7 +2,7 @@
namespace Notion.Client
{
- public class VideoUpdateBlock : UpdateBlock, IUpdateBlock
+ public class VideoUpdateBlock : UpdateBlock
{
[JsonProperty("video")]
public IFileObjectInput Video { get; set; }
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/IBlocksAppendChildrenBodyParameters.cs b/Src/Notion.Client/Api/Blocks/RequestParams/IBlocksAppendChildrenBodyParameters.cs
deleted file mode 100644
index bdd4d324..00000000
--- a/Src/Notion.Client/Api/Blocks/RequestParams/IBlocksAppendChildrenBodyParameters.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System.Collections.Generic;
-using Newtonsoft.Json;
-
-namespace Notion.Client
-{
- // TODO: need an input version of Block
- public interface IBlocksAppendChildrenBodyParameters
- {
- [JsonProperty("children")]
- IEnumerable Children { get; set; }
- }
-}
diff --git a/Src/Notion.Client/Api/Blocks/RequestParams/IBlocksRetrieveChildrenQueryParameters.cs b/Src/Notion.Client/Api/Blocks/RequestParams/IBlocksRetrieveChildrenQueryParameters.cs
deleted file mode 100644
index 5c85e06a..00000000
--- a/Src/Notion.Client/Api/Blocks/RequestParams/IBlocksRetrieveChildrenQueryParameters.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Notion.Client
-{
- public interface IBlocksRetrieveChildrenQueryParameters : IPaginationParameters
- {
- }
-}
diff --git a/Src/Notion.Client/Api/Blocks/RetrieveChildren/BlocksClient.cs b/Src/Notion.Client/Api/Blocks/RetrieveChildren/BlocksClient.cs
new file mode 100644
index 00000000..c91f5c6d
--- /dev/null
+++ b/Src/Notion.Client/Api/Blocks/RetrieveChildren/BlocksClient.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Notion.Client
+{
+ public sealed partial class BlocksClient
+ {
+ public async Task RetrieveChildrenAsync(
+ BlockRetrieveChildrenRequest request,
+ CancellationToken cancellationToken = default)
+ {
+ if (string.IsNullOrWhiteSpace(request.BlockId))
+ {
+ throw new ArgumentNullException(nameof(request.BlockId));
+ }
+
+ var url = ApiEndpoints.BlocksApiUrls.RetrieveChildren(request.BlockId);
+
+ var queryParameters = (IBlockRetrieveChildrenQueryParameters)request;
+
+ var queryParams = new Dictionary
+ {
+ { "start_cursor", queryParameters?.StartCursor },
+ { "page_size", queryParameters?.PageSize?.ToString() }
+ };
+
+ return await _client.GetAsync(
+ url,
+ queryParams,
+ cancellationToken: cancellationToken
+ );
+ }
+ }
+}
diff --git a/Src/Notion.Client/Api/Blocks/RetrieveChildren/Request/BlockRetrieveChildrenRequest.cs b/Src/Notion.Client/Api/Blocks/RetrieveChildren/Request/BlockRetrieveChildrenRequest.cs
new file mode 100644
index 00000000..c0e87f3e
--- /dev/null
+++ b/Src/Notion.Client/Api/Blocks/RetrieveChildren/Request/BlockRetrieveChildrenRequest.cs
@@ -0,0 +1,13 @@
+namespace Notion.Client
+{
+ public class BlockRetrieveChildrenRequest :
+ IBlockRetrieveChildrenQueryParameters,
+ IBlockRetrieveChildrenPathParameters
+ {
+ public string StartCursor { get; set; }
+
+ public int? PageSize { get; set; }
+
+ public string BlockId { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Blocks/RetrieveChildren/Request/IBlockRetrieveChildrenPathParameters.cs b/Src/Notion.Client/Api/Blocks/RetrieveChildren/Request/IBlockRetrieveChildrenPathParameters.cs
new file mode 100644
index 00000000..c23c2e90
--- /dev/null
+++ b/Src/Notion.Client/Api/Blocks/RetrieveChildren/Request/IBlockRetrieveChildrenPathParameters.cs
@@ -0,0 +1,7 @@
+namespace Notion.Client
+{
+ public interface IBlockRetrieveChildrenPathParameters
+ {
+ public string BlockId { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Blocks/RetrieveChildren/Request/IBlockRetrieveChildrenQueryParameters.cs b/Src/Notion.Client/Api/Blocks/RetrieveChildren/Request/IBlockRetrieveChildrenQueryParameters.cs
new file mode 100644
index 00000000..68c7de32
--- /dev/null
+++ b/Src/Notion.Client/Api/Blocks/RetrieveChildren/Request/IBlockRetrieveChildrenQueryParameters.cs
@@ -0,0 +1,6 @@
+namespace Notion.Client
+{
+ public interface IBlockRetrieveChildrenQueryParameters : IPaginationParameters
+ {
+ }
+}
diff --git a/Src/Notion.Client/Api/Blocks/RetrieveChildren/Response/RetrieveChildrenResponse.cs b/Src/Notion.Client/Api/Blocks/RetrieveChildren/Response/RetrieveChildrenResponse.cs
new file mode 100644
index 00000000..0b34619f
--- /dev/null
+++ b/Src/Notion.Client/Api/Blocks/RetrieveChildren/Response/RetrieveChildrenResponse.cs
@@ -0,0 +1,11 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class RetrieveChildrenResponse : PaginatedList
+ {
+ [JsonProperty("block")]
+ public Dictionary Block { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Comments/CommentsClient.cs b/Src/Notion.Client/Api/Comments/CommentsClient.cs
new file mode 100644
index 00000000..51dadeff
--- /dev/null
+++ b/Src/Notion.Client/Api/Comments/CommentsClient.cs
@@ -0,0 +1,12 @@
+namespace Notion.Client
+{
+ public partial class CommentsClient : ICommentsClient
+ {
+ private readonly IRestClient _client;
+
+ public CommentsClient(IRestClient restClient)
+ {
+ _client = restClient;
+ }
+ }
+}
diff --git a/Src/Notion.Client/Api/Comments/Create/CommentsClient.cs b/Src/Notion.Client/Api/Comments/Create/CommentsClient.cs
new file mode 100644
index 00000000..ac2244ea
--- /dev/null
+++ b/Src/Notion.Client/Api/Comments/Create/CommentsClient.cs
@@ -0,0 +1,19 @@
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Notion.Client
+{
+ public partial class CommentsClient
+ {
+ public async Task CreateAsync(CreateCommentParameters parameters, CancellationToken cancellationToken = default)
+ {
+ var body = (ICreateCommentsBodyParameters)parameters;
+
+ return await _client.PostAsync(
+ ApiEndpoints.CommentsApiUrls.Create(),
+ body,
+ cancellationToken: cancellationToken
+ );
+ }
+ }
+}
diff --git a/Src/Notion.Client/Api/Comments/Create/Request/CreateCommentParameters.cs b/Src/Notion.Client/Api/Comments/Create/Request/CreateCommentParameters.cs
new file mode 100644
index 00000000..f9532726
--- /dev/null
+++ b/Src/Notion.Client/Api/Comments/Create/Request/CreateCommentParameters.cs
@@ -0,0 +1,54 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public interface ICreateCommentsBodyParameters
+ {
+ [JsonProperty("rich_text")]
+ public IEnumerable RichText { get; set; }
+ }
+
+ public interface ICreateDiscussionCommentBodyParameters : ICreateCommentsBodyParameters
+ {
+ [JsonProperty("discussion_id")]
+ public string DiscussionId { get; set; }
+ }
+
+ public interface ICreatePageCommentBodyParameters : ICreateCommentsBodyParameters
+ {
+ [JsonProperty("parent")]
+ public ParentPageInput Parent { get; set; }
+ }
+
+ public class CreateCommentParameters : ICreateDiscussionCommentBodyParameters, ICreatePageCommentBodyParameters
+ {
+ public string DiscussionId { get; set; }
+
+ public IEnumerable RichText { get; set; }
+
+ public ParentPageInput Parent { get; set; }
+
+ public static CreateCommentParameters CreatePageComment(
+ ParentPageInput parent,
+ IEnumerable richText)
+ {
+ return new CreateCommentParameters
+ {
+ Parent = parent,
+ RichText = richText
+ };
+ }
+
+ public static CreateCommentParameters CreateDiscussionComment(
+ string discussionId,
+ IEnumerable richText)
+ {
+ return new CreateCommentParameters
+ {
+ DiscussionId = discussionId,
+ RichText = richText
+ };
+ }
+ }
+}
diff --git a/Src/Notion.Client/Api/Comments/Create/Response/CreateCommentResponse.cs b/Src/Notion.Client/Api/Comments/Create/Response/CreateCommentResponse.cs
new file mode 100644
index 00000000..0171d92d
--- /dev/null
+++ b/Src/Notion.Client/Api/Comments/Create/Response/CreateCommentResponse.cs
@@ -0,0 +1,9 @@
+using System.Diagnostics.CodeAnalysis;
+
+namespace Notion.Client
+{
+ [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
+ public class CreateCommentResponse : Comment
+ {
+ }
+}
diff --git a/Src/Notion.Client/Api/Comments/ICommentsClient.cs b/Src/Notion.Client/Api/Comments/ICommentsClient.cs
new file mode 100644
index 00000000..7b7af943
--- /dev/null
+++ b/Src/Notion.Client/Api/Comments/ICommentsClient.cs
@@ -0,0 +1,12 @@
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Notion.Client
+{
+ public interface ICommentsClient
+ {
+ Task CreateAsync(CreateCommentParameters createCommentParameters, CancellationToken cancellationToken = default);
+
+ Task RetrieveAsync(RetrieveCommentsParameters parameters, CancellationToken cancellationToken = default);
+ }
+}
diff --git a/Src/Notion.Client/Api/Comments/Retrieve/CommentsClient.cs b/Src/Notion.Client/Api/Comments/Retrieve/CommentsClient.cs
new file mode 100644
index 00000000..45c64f00
--- /dev/null
+++ b/Src/Notion.Client/Api/Comments/Retrieve/CommentsClient.cs
@@ -0,0 +1,29 @@
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Notion.Client
+{
+ public partial class CommentsClient
+ {
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
+ public async Task RetrieveAsync(RetrieveCommentsParameters parameters, CancellationToken cancellationToken = default)
+ {
+ var qp = (IRetrieveCommentsQueryParameters)parameters;
+
+ var queryParams = new Dictionary
+ {
+ { "block_id", qp.BlockId },
+ { "start_cursor", qp.StartCursor },
+ { "page_size", qp.PageSize.ToString() }
+ };
+
+ return await _client.GetAsync(
+ ApiEndpoints.CommentsApiUrls.Retrieve(),
+ queryParams,
+ cancellationToken: cancellationToken
+ );
+ }
+ }
+}
diff --git a/Src/Notion.Client/Api/Comments/Retrieve/Request/IRetrieveCommentsQueryParameters.cs b/Src/Notion.Client/Api/Comments/Retrieve/Request/IRetrieveCommentsQueryParameters.cs
new file mode 100644
index 00000000..123a5844
--- /dev/null
+++ b/Src/Notion.Client/Api/Comments/Retrieve/Request/IRetrieveCommentsQueryParameters.cs
@@ -0,0 +1,10 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public interface IRetrieveCommentsQueryParameters : IPaginationParameters
+ {
+ [JsonProperty("block_id")]
+ string BlockId { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Comments/Retrieve/Request/RetrieveCommentsParameters.cs b/Src/Notion.Client/Api/Comments/Retrieve/Request/RetrieveCommentsParameters.cs
new file mode 100644
index 00000000..25d3d54d
--- /dev/null
+++ b/Src/Notion.Client/Api/Comments/Retrieve/Request/RetrieveCommentsParameters.cs
@@ -0,0 +1,14 @@
+using System.Diagnostics.CodeAnalysis;
+
+namespace Notion.Client
+{
+ [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
+ public class RetrieveCommentsParameters : IRetrieveCommentsQueryParameters
+ {
+ public string BlockId { get; set; }
+
+ public string StartCursor { get; set; }
+
+ public int? PageSize { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Comments/Retrieve/Response/Comment.cs b/Src/Notion.Client/Api/Comments/Retrieve/Response/Comment.cs
new file mode 100644
index 00000000..9b9ef2ae
--- /dev/null
+++ b/Src/Notion.Client/Api/Comments/Retrieve/Response/Comment.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class Comment : IObject
+ {
+ [JsonProperty("parent")]
+ public ICommentParent Parent { get; set; }
+
+ [JsonProperty("discussion_id")]
+ public string DiscussionId { get; set; }
+
+ [JsonProperty("rich_text")]
+ public IEnumerable RichText { get; set; }
+
+ [JsonProperty("created_by")]
+ public PartialUser CreatedBy { get; set; }
+
+ [JsonProperty("created_time")]
+ public DateTime CreatedTime { get; set; }
+
+ [JsonProperty("last_edited_time")]
+ public DateTime LastEditedTime { get; set; }
+
+ public string Id { get; set; }
+
+ public ObjectType Object => ObjectType.Comment;
+ }
+}
diff --git a/Src/Notion.Client/Api/Comments/Retrieve/Response/Comments.cs b/Src/Notion.Client/Api/Comments/Retrieve/Response/Comments.cs
new file mode 100644
index 00000000..8b3b43b3
--- /dev/null
+++ b/Src/Notion.Client/Api/Comments/Retrieve/Response/Comments.cs
@@ -0,0 +1,11 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class RetrieveCommentsResponse : PaginatedList
+ {
+ [JsonProperty("comment")]
+ public Dictionary Comment { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Comments/Retrieve/Response/ICommentParent.cs b/Src/Notion.Client/Api/Comments/Retrieve/Response/ICommentParent.cs
new file mode 100644
index 00000000..9e05d019
--- /dev/null
+++ b/Src/Notion.Client/Api/Comments/Retrieve/Response/ICommentParent.cs
@@ -0,0 +1,12 @@
+using JsonSubTypes;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ [JsonConverter(typeof(JsonSubtypes), "type")]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(PageParent), ParentType.PageId)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(BlockParent), ParentType.BlockId)]
+ public interface ICommentParent
+ {
+ }
+}
diff --git a/Src/Notion.Client/Api/Databases/DatabasesClient.cs b/Src/Notion.Client/Api/Databases/DatabasesClient.cs
index 2ab17a8b..a3dc9a8c 100644
--- a/Src/Notion.Client/Api/Databases/DatabasesClient.cs
+++ b/Src/Notion.Client/Api/Databases/DatabasesClient.cs
@@ -1,9 +1,11 @@
-using System.Threading.Tasks;
+using System;
+using System.Threading;
+using System.Threading.Tasks;
using static Notion.Client.ApiEndpoints;
namespace Notion.Client
{
- public class DatabasesClient : IDatabasesClient
+ public sealed partial class DatabasesClient : IDatabasesClient
{
private readonly IRestClient _client;
@@ -12,30 +14,28 @@ public DatabasesClient(IRestClient client)
_client = client;
}
- public async Task RetrieveAsync(string databaseId)
+ public async Task RetrieveAsync(string databaseId, CancellationToken cancellationToken = default)
{
- return await _client.GetAsync(DatabasesApiUrls.Retrieve(databaseId));
- }
-
- public async Task> QueryAsync(string databaseId, DatabasesQueryParameters databasesQueryParameters)
- {
- var body = (IDatabaseQueryBodyParameters)databasesQueryParameters;
+ if (string.IsNullOrWhiteSpace(databaseId))
+ {
+ throw new ArgumentNullException(nameof(databaseId));
+ }
- return await _client.PostAsync>(DatabasesApiUrls.Query(databaseId), body);
+ return await _client.GetAsync(DatabasesApiUrls.Retrieve(databaseId), cancellationToken: cancellationToken);
}
- public async Task CreateAsync(DatabasesCreateParameters databasesCreateParameters)
+ public async Task CreateAsync(DatabasesCreateParameters databasesCreateParameters, CancellationToken cancellationToken = default)
{
var body = (IDatabasesCreateBodyParameters)databasesCreateParameters;
- return await _client.PostAsync(DatabasesApiUrls.Create, body);
+ return await _client.PostAsync(DatabasesApiUrls.Create, body, cancellationToken: cancellationToken);
}
- public async Task UpdateAsync(string databaseId, DatabasesUpdateParameters databasesUpdateParameters)
+ public async Task UpdateAsync(string databaseId, DatabasesUpdateParameters databasesUpdateParameters, CancellationToken cancellationToken = default)
{
var body = (IDatabasesUpdateBodyParameters)databasesUpdateParameters;
- return await _client.PatchAsync(DatabasesApiUrls.Update(databaseId), body);
+ return await _client.PatchAsync(DatabasesApiUrls.Update(databaseId), body, cancellationToken: cancellationToken);
}
}
}
diff --git a/Src/Notion.Client/Api/Databases/IDatabasesClient.cs b/Src/Notion.Client/Api/Databases/IDatabasesClient.cs
index 2b2c2746..98df1273 100644
--- a/Src/Notion.Client/Api/Databases/IDatabasesClient.cs
+++ b/Src/Notion.Client/Api/Databases/IDatabasesClient.cs
@@ -1,25 +1,48 @@
-using System.Threading.Tasks;
+using System.Threading;
+using System.Threading.Tasks;
namespace Notion.Client
{
public interface IDatabasesClient
{
- Task RetrieveAsync(string databaseId);
- Task> QueryAsync(string databaseId, DatabasesQueryParameters databasesQueryParameters);
+ ///
+ /// Retrieves a Database object using the ID specified.
+ ///
+ /// Identifier for a Notion database
+ ///
+ ///
+ ///
+ Task RetrieveAsync(string databaseId, CancellationToken cancellationToken = default);
+
+ ///
+ /// Gets a list of Pages contained in the database, filtered and ordered according to the
+ /// filter conditions and sort criteria provided in the request. The response may contain
+ /// fewer than page_size of results.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task QueryAsync(string databaseId, DatabasesQueryParameters databasesQueryParameters, CancellationToken cancellationToken = default);
///
- /// Creates a database as a subpage in the specified parent page, with the specified properties schema.
+ /// Creates a database as a subpage in the specified parent page, with the specified properties schema.
///
///
- /// Database
- Task CreateAsync(DatabasesCreateParameters databasesCreateParameters);
+ ///
+ ///
+ ///
+ Task CreateAsync(DatabasesCreateParameters databasesCreateParameters, CancellationToken cancellationToken = default);
///
- /// Updates an existing database as specified by the parameters.
+ /// Updates an existing database as specified by the parameters.
///
///
///
- /// Database
- Task UpdateAsync(string databaseId, DatabasesUpdateParameters databasesUpdateParameters);
+ ///
+ ///
+ ///
+ Task UpdateAsync(string databaseId, DatabasesUpdateParameters databasesUpdateParameters, CancellationToken cancellationToken = default);
}
}
diff --git a/Src/Notion.Client/Api/Databases/Query/DatabasesClient.cs b/Src/Notion.Client/Api/Databases/Query/DatabasesClient.cs
new file mode 100644
index 00000000..2d0c62be
--- /dev/null
+++ b/Src/Notion.Client/Api/Databases/Query/DatabasesClient.cs
@@ -0,0 +1,28 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Notion.Client
+{
+ public sealed partial class DatabasesClient
+ {
+ public async Task QueryAsync(
+ string databaseId,
+ DatabasesQueryParameters databasesQueryParameters, CancellationToken cancellationToken = default)
+ {
+ var body = (IDatabaseQueryBodyParameters)databasesQueryParameters;
+ var queryParameters = (IDatabaseQueryQueryParameters)databasesQueryParameters;
+
+ var queryParams = queryParameters.FilterProperties?
+ .Select(x => new KeyValuePair("filter_properties", x));
+
+ return await _client.PostAsync(
+ ApiEndpoints.DatabasesApiUrls.Query(databaseId),
+ body,
+ queryParams,
+ cancellationToken: cancellationToken
+ );
+ }
+ }
+}
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesQueryParameters.cs b/Src/Notion.Client/Api/Databases/Query/Request/DatabasesQueryParameters.cs
similarity index 75%
rename from Src/Notion.Client/Api/Databases/RequestParams/DatabasesQueryParameters.cs
rename to Src/Notion.Client/Api/Databases/Query/Request/DatabasesQueryParameters.cs
index 454961a2..2c2bb030 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesQueryParameters.cs
+++ b/Src/Notion.Client/Api/Databases/Query/Request/DatabasesQueryParameters.cs
@@ -2,11 +2,16 @@
namespace Notion.Client
{
- public class DatabasesQueryParameters : IDatabaseQueryBodyParameters
+ public class DatabasesQueryParameters : IDatabaseQueryBodyParameters, IDatabaseQueryQueryParameters
{
public Filter Filter { get; set; }
+
public List Sorts { get; set; }
+
public string StartCursor { get; set; }
+
public int? PageSize { get; set; }
+
+ public List FilterProperties { get; set; }
}
}
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/IDatabaseQueryBodyParameters.cs b/Src/Notion.Client/Api/Databases/Query/Request/IDatabaseQueryBodyParameters.cs
similarity index 100%
rename from Src/Notion.Client/Api/Databases/RequestParams/IDatabaseQueryBodyParameters.cs
rename to Src/Notion.Client/Api/Databases/Query/Request/IDatabaseQueryBodyParameters.cs
diff --git a/Src/Notion.Client/Api/Databases/Query/Request/IDatabaseQueryQueryParameters.cs b/Src/Notion.Client/Api/Databases/Query/Request/IDatabaseQueryQueryParameters.cs
new file mode 100644
index 00000000..f8ba1f41
--- /dev/null
+++ b/Src/Notion.Client/Api/Databases/Query/Request/IDatabaseQueryQueryParameters.cs
@@ -0,0 +1,11 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public interface IDatabaseQueryQueryParameters
+ {
+ [JsonProperty("filter_properties")]
+ List FilterProperties { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Databases/Query/Response/DatabaseQueryResponse.cs b/Src/Notion.Client/Api/Databases/Query/Response/DatabaseQueryResponse.cs
new file mode 100644
index 00000000..5b7c9ec6
--- /dev/null
+++ b/Src/Notion.Client/Api/Databases/Query/Response/DatabaseQueryResponse.cs
@@ -0,0 +1,12 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ // ReSharper disable once ClassNeverInstantiated.Global
+ public class DatabaseQueryResponse : PaginatedList
+ {
+ [JsonProperty("database")]
+ public Dictionary Database { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/DatabasesCreateParameters.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/DatabasesCreateParameters.cs
index bafad0ec..9cb7086b 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/DatabasesCreateParameters.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/DatabasesCreateParameters.cs
@@ -5,6 +5,12 @@ namespace Notion.Client
{
public class DatabasesCreateParameters : IDatabasesCreateBodyParameters, IDatabasesCreateQueryParameters
{
+ [JsonProperty("icon")]
+ public IPageIcon Icon { get; set; }
+
+ [JsonProperty("cover")]
+ public FileObject Cover { get; set; }
+
[JsonProperty("parent")]
public ParentPageInput Parent { get; set; }
@@ -14,12 +20,6 @@ public class DatabasesCreateParameters : IDatabasesCreateBodyParameters, IDataba
[JsonProperty("title")]
public List Title { get; set; }
- [JsonProperty("icon")]
- public IPageIcon Icon { get; set; }
-
- [JsonProperty("cover")]
- public FileObject Cover { get; set; }
-
public bool? IsInline { get; set; }
public List Description { get; set; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/MentionInput.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/MentionInput.cs
index 83d1e699..48b34948 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/MentionInput.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/MentionInput.cs
@@ -17,6 +17,6 @@ public class MentionInput
public ObjectId Database { get; set; }
[JsonProperty("date")]
- public DatePropertyValue Date { get; set; }
+ public Date Date { get; set; }
}
}
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/MultiSelectOptionSchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/MultiSelectOptionSchema.cs
index 89fdb0ab..a13d0930 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/MultiSelectOptionSchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/MultiSelectOptionSchema.cs
@@ -1,5 +1,8 @@
-namespace Notion.Client
+using System.Diagnostics.CodeAnalysis;
+
+namespace Notion.Client
{
+ [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
public class MultiSelectOptionSchema : SelectOptionSchema
{
}
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RelationPropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RelationPropertySchema.cs
index bee17690..4c278ac2 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RelationPropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RelationPropertySchema.cs
@@ -1,23 +1,10 @@
-using System;
-using Newtonsoft.Json;
+using Newtonsoft.Json;
namespace Notion.Client
{
public class RelationPropertySchema : IPropertySchema
{
[JsonProperty("relation")]
- public RelationInfo Relation { get; set; }
-
- public class RelationInfo
- {
- [JsonProperty("database_id")]
- public Guid DatabaseId { get; set; }
-
- [JsonProperty("synced_property_id")]
- public string SynchedPropertyId { get; set; }
-
- [JsonProperty("synced_property_name")]
- public string SynchedPropertyName { get; set; }
- }
+ public RelationData Relation { get; set; }
}
}
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesListParameters.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesListParameters.cs
deleted file mode 100644
index 51136e47..00000000
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesListParameters.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace Notion.Client
-{
- public class DatabasesListParameters : IDatabasesListQueryParmaters
- {
- public string StartCursor { get; set; }
- public int? PageSize { get; set; }
- }
-}
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/DatabasesUpdateParameters.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/DatabasesUpdateParameters.cs
index b9cb182e..5147a6b0 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/DatabasesUpdateParameters.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/DatabasesUpdateParameters.cs
@@ -1,5 +1,4 @@
using System.Collections.Generic;
-using Newtonsoft.Json;
namespace Notion.Client
{
@@ -13,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; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/IDatabasesUpdateBodyParameters.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/IDatabasesUpdateBodyParameters.cs
index b1dc419a..f37df431 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/IDatabasesUpdateBodyParameters.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/IDatabasesUpdateBodyParameters.cs
@@ -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; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/CheckboxUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/CheckboxUpdatePropertySchema.cs
index a13f2911..a6890d6e 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/CheckboxUpdatePropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/CheckboxUpdatePropertySchema.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class CheckboxUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema
+ public class CheckboxUpdatePropertySchema : UpdatePropertySchema
{
[JsonProperty("checkbox")]
public Dictionary Checkbox { get; set; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/CreatedByUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/CreatedByUpdatePropertySchema.cs
index 394868db..08a5cf74 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/CreatedByUpdatePropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/CreatedByUpdatePropertySchema.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class CreatedByUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema
+ public class CreatedByUpdatePropertySchema : UpdatePropertySchema
{
[JsonProperty("created_by")]
public Dictionary CreatedBy { get; set; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/CreatedTimeUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/CreatedTimeUpdatePropertySchema.cs
index dee266f3..8089ecbb 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/CreatedTimeUpdatePropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/CreatedTimeUpdatePropertySchema.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class CreatedTimeUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema
+ public class CreatedTimeUpdatePropertySchema : UpdatePropertySchema
{
[JsonProperty("created_time")]
public Dictionary CreatedTime { get; set; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/DateUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/DateUpdatePropertySchema.cs
index 0c2b2143..65487dd7 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/DateUpdatePropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/DateUpdatePropertySchema.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class DateUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema
+ public class DateUpdatePropertySchema : UpdatePropertySchema
{
[JsonProperty("date")]
public Dictionary Date { get; set; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/EmailUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/EmailUpdatePropertySchema.cs
index 412c9115..5905e68e 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/EmailUpdatePropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/EmailUpdatePropertySchema.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class EmailUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema
+ public class EmailUpdatePropertySchema : UpdatePropertySchema
{
[JsonProperty("email")]
public Dictionary Email { get; set; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/FilesUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/FilesUpdatePropertySchema.cs
index c7b84218..9fb3b531 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/FilesUpdatePropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/FilesUpdatePropertySchema.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class FilesUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema
+ public class FilesUpdatePropertySchema : UpdatePropertySchema
{
[JsonProperty("files")]
public Dictionary Files { get; set; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/FormulaUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/FormulaUpdatePropertySchema.cs
index 158a42bb..40cc398a 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/FormulaUpdatePropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/FormulaUpdatePropertySchema.cs
@@ -2,7 +2,7 @@
namespace Notion.Client
{
- public class FormulaUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema
+ public class FormulaUpdatePropertySchema : UpdatePropertySchema
{
[JsonProperty("formula")]
public Formula Formula { get; set; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/LastEditedByUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/LastEditedByUpdatePropertySchema.cs
index 939bc69d..c547538a 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/LastEditedByUpdatePropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/LastEditedByUpdatePropertySchema.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class LastEditedByUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema
+ public class LastEditedByUpdatePropertySchema : UpdatePropertySchema
{
[JsonProperty("last_edited_by")]
public Dictionary LastEditedBy { get; set; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/LastEditedTimeUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/LastEditedTimeUpdatePropertySchema.cs
index f48ddf5a..28c9e55b 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/LastEditedTimeUpdatePropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/LastEditedTimeUpdatePropertySchema.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class LastEditedTimeUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema
+ public class LastEditedTimeUpdatePropertySchema : UpdatePropertySchema
{
[JsonProperty("last_edited_time")]
public Dictionary LastEditedTime { get; set; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/MultiSelectUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/MultiSelectUpdatePropertySchema.cs
index a6b32ad3..0b7b1c0c 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/MultiSelectUpdatePropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/MultiSelectUpdatePropertySchema.cs
@@ -2,7 +2,7 @@
namespace Notion.Client
{
- public class MultiSelectUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema
+ public class MultiSelectUpdatePropertySchema : UpdatePropertySchema
{
[JsonProperty("multi_select")]
public OptionWrapper MultiSelect { get; set; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/NumberUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/NumberUpdatePropertySchema.cs
index e1f0b734..23f3ea3a 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/NumberUpdatePropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/NumberUpdatePropertySchema.cs
@@ -2,7 +2,7 @@
namespace Notion.Client
{
- public class NumberUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema
+ public class NumberUpdatePropertySchema : UpdatePropertySchema
{
[JsonProperty("number")]
public Number Number { get; set; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/PeopleUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/PeopleUpdatePropertySchema.cs
index 6fab728e..41a8892d 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/PeopleUpdatePropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/PeopleUpdatePropertySchema.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class PeopleUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema
+ public class PeopleUpdatePropertySchema : UpdatePropertySchema
{
[JsonProperty("people")]
public Dictionary People { get; set; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/PhoneNumberUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/PhoneNumberUpdatePropertySchema.cs
index 7813671c..7d01f506 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/PhoneNumberUpdatePropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/PhoneNumberUpdatePropertySchema.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class PhoneNumberUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema
+ public class PhoneNumberUpdatePropertySchema : UpdatePropertySchema
{
[JsonProperty("phone_number")]
public Dictionary PhoneNumber { get; set; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RelationUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RelationUpdatePropertySchema.cs
index 2091df91..25f65cd4 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RelationUpdatePropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RelationUpdatePropertySchema.cs
@@ -1,23 +1,10 @@
-using System;
-using Newtonsoft.Json;
+using Newtonsoft.Json;
namespace Notion.Client
{
- public class RelationUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema
+ public class RelationUpdatePropertySchema : UpdatePropertySchema
{
[JsonProperty("relation")]
- public RelationInfo Relation { get; set; }
-
- public class RelationInfo
- {
- [JsonProperty("database_id")]
- public Guid DatabaseId { get; set; }
-
- [JsonProperty("synced_property_id")]
- public string SynchedPropertyId { get; set; }
-
- [JsonProperty("synced_property_name")]
- public string SynchedPropertyName { get; set; }
- }
+ public RelationData Relation { get; set; }
}
}
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RichTextUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RichTextUpdatePropertySchema.cs
index 3d6c5ec2..a20ca0ea 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RichTextUpdatePropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RichTextUpdatePropertySchema.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class RichTextUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema
+ public class RichTextUpdatePropertySchema : UpdatePropertySchema
{
[JsonProperty("rich_text")]
public Dictionary RichText { get; set; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RollupConfigUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RollupConfigUpdatePropertySchema.cs
index 2f38731b..8ee2d908 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RollupConfigUpdatePropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RollupConfigUpdatePropertySchema.cs
@@ -2,7 +2,7 @@
namespace Notion.Client
{
- public class RollupConfigUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema
+ public class RollupConfigUpdatePropertySchema : UpdatePropertySchema
{
[JsonProperty("relation_property_name")]
public string RelationPropertyName { get; set; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/SelectUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/SelectUpdatePropertySchema.cs
index b833d0bc..678e452d 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/SelectUpdatePropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/SelectUpdatePropertySchema.cs
@@ -2,7 +2,7 @@
namespace Notion.Client
{
- public class SelectUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema
+ public class SelectUpdatePropertySchema : UpdatePropertySchema
{
[JsonProperty("select")]
public OptionWrapper Select { get; set; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/TitleUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/TitleUpdatePropertySchema.cs
index 1a74085c..54052dfc 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/TitleUpdatePropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/TitleUpdatePropertySchema.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class TitleUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema
+ public class TitleUpdatePropertySchema : UpdatePropertySchema
{
[JsonProperty("title")]
public Dictionary Title { get; set; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/URLUpdatePropertySchema.cs b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/URLUpdatePropertySchema.cs
index 7aa9c701..f56d6507 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/URLUpdatePropertySchema.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/URLUpdatePropertySchema.cs
@@ -3,7 +3,7 @@
namespace Notion.Client
{
- public class UrlUpdatePropertySchema : UpdatePropertySchema, IUpdatePropertySchema
+ public class UrlUpdatePropertySchema : UpdatePropertySchema
{
[JsonProperty("url")]
public Dictionary Url { get; set; }
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/Direction.cs b/Src/Notion.Client/Api/Databases/RequestParams/Direction.cs
index c79d501d..059f42b3 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/Direction.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/Direction.cs
@@ -1,7 +1,9 @@
-using System.Runtime.Serialization;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.Serialization;
namespace Notion.Client
{
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
public enum Direction
{
[EnumMember(Value = null)]
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/IDatabasesListQueryParmaters.cs b/Src/Notion.Client/Api/Databases/RequestParams/IDatabasesListQueryParmaters.cs
deleted file mode 100644
index 4432f421..00000000
--- a/Src/Notion.Client/Api/Databases/RequestParams/IDatabasesListQueryParmaters.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Notion.Client
-{
- public interface IDatabasesListQueryParmaters : IPaginationParameters
- {
- }
-}
diff --git a/Src/Notion.Client/Api/Databases/RequestParams/Timestamp.cs b/Src/Notion.Client/Api/Databases/RequestParams/Timestamp.cs
index 334b8c22..df2c69ca 100644
--- a/Src/Notion.Client/Api/Databases/RequestParams/Timestamp.cs
+++ b/Src/Notion.Client/Api/Databases/RequestParams/Timestamp.cs
@@ -1,7 +1,9 @@
-using System.Runtime.Serialization;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.Serialization;
namespace Notion.Client
{
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
public enum Timestamp
{
[EnumMember(Value = null)]
diff --git a/Src/Notion.Client/Api/Pages/IPagesClient.cs b/Src/Notion.Client/Api/Pages/IPagesClient.cs
index b4fc728f..8dc8f5ce 100644
--- a/Src/Notion.Client/Api/Pages/IPagesClient.cs
+++ b/Src/Notion.Client/Api/Pages/IPagesClient.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Threading;
using System.Threading.Tasks;
namespace Notion.Client
@@ -6,37 +7,58 @@ namespace Notion.Client
public interface IPagesClient
{
///
- /// Creates a new page in the specified database or as a child of an existing page.
- ///
- /// If the parent is a database, the property values of the new page in the properties parameter must conform to the parent database's property schema.
- ///
- /// If the parent is a page, the only valid property is title.
+ /// Creates a new page in the specified database or as a child of an existing page.
+ /// If the parent is a database, the
+ /// property values of the
+ /// new page in the properties parameter must conform to the parent
+ /// database's property schema.
+ /// If the parent is a page, the only valid property is title.
///
/// Create page parameters
- /// Created page.
- Task CreateAsync(PagesCreateParameters pagesCreateParameters);
+ /// Created object.
+ Task CreateAsync(PagesCreateParameters pagesCreateParameters, CancellationToken cancellationToken = default);
- Task RetrieveAsync(string pageId);
+ ///
+ /// Retrieves a Page object using the ID specified.
+ ///
+ /// Identifier for a Notion page
+ ///
+ ///
+ ///
+ Task RetrieveAsync(string pageId, CancellationToken cancellationToken = default);
+ ///
+ /// Updates page property values for the specified page.
+ /// Note: Properties that are not set via the properties parameter will remain unchanged.
+ ///
+ /// Identifier for a Notion page
+ ///
+ /// Property values to update for this page. The keys are the names or IDs of the property
+ /// and the values are property values.
+ ///
+ /// Updated object
Task UpdatePropertiesAsync(
string pageId,
- IDictionary updatedProperties
- );
+ IDictionary updatedProperties, CancellationToken cancellationToken = default);
///
- /// Updates page property values for the specified page.
- /// Properties that are not set via the properties parameter will remain unchanged.
+ /// Updates page property values for the specified page.
+ /// Properties that are not set via the properties parameter will remain unchanged.
///
- ///
- ///
- /// Updated page.
- Task UpdateAsync(string pageId, PagesUpdateParameters pagesUpdateParameters);
+ /// Identifier for a Notion page
+ /// Update property parameters
+ /// Updated object
+ Task UpdateAsync(string pageId, PagesUpdateParameters pagesUpdateParameters, CancellationToken cancellationToken = default);
///
- /// 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.
+ /// 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);
+ /// Property body and query parameters
+ ///
+ ///
+ ///
+ Task RetrievePagePropertyItemAsync(
+ RetrievePropertyItemParameters retrievePropertyItemParameters, CancellationToken cancellationToken = default);
}
}
diff --git a/Src/Notion.Client/Api/Pages/PagesClient.cs b/Src/Notion.Client/Api/Pages/PagesClient.cs
index 5bce1904..76b3e41a 100644
--- a/Src/Notion.Client/Api/Pages/PagesClient.cs
+++ b/Src/Notion.Client/Api/Pages/PagesClient.cs
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Threading;
using System.Threading.Tasks;
using static Notion.Client.ApiEndpoints;
@@ -15,15 +17,16 @@ public PagesClient(IRestClient client)
}
///
- /// Creates a new page in the specified database or as a child of an existing page.
- ///
- /// If the parent is a database, the property values of the new page in the properties parameter must conform to the parent database's property schema.
- ///
- /// If the parent is a page, the only valid property is title.
+ /// Creates a new page in the specified database or as a child of an existing page.
+ /// If the parent is a database, the
+ /// property values of the
+ /// new page in the properties parameter must conform to the parent
+ /// database's property schema.
+ /// If the parent is a page, the only valid property is title.
///
/// Create page parameters
/// Created page.
- public async Task CreateAsync(PagesCreateParameters pagesCreateParameters)
+ public async Task CreateAsync(PagesCreateParameters pagesCreateParameters, CancellationToken cancellationToken = default)
{
if (pagesCreateParameters is null)
{
@@ -42,50 +45,54 @@ public async Task CreateAsync(PagesCreateParameters pagesCreateParameters)
throw new ArgumentNullException(nameof(bodyParameters.Properties), "Properties are required!");
}
- return await _client.PostAsync(PagesApiUrls.Create(), bodyParameters);
+ return await _client.PostAsync(PagesApiUrls.Create(), bodyParameters, cancellationToken: cancellationToken);
}
- public async Task RetrieveAsync(string pageId)
+ public async Task RetrieveAsync(string pageId, CancellationToken cancellationToken = default)
{
var url = PagesApiUrls.Retrieve(pageId);
- return await _client.GetAsync(url);
+
+ return await _client.GetAsync(url, cancellationToken: cancellationToken);
}
- public async Task RetrievePagePropertyItem(RetrievePropertyItemParameters retrievePropertyItemParameters)
+ public async Task RetrievePagePropertyItemAsync(
+ RetrievePropertyItemParameters retrievePropertyItemParameters, CancellationToken cancellationToken = default)
{
var pathParameters = (IRetrievePropertyItemPathParameters)retrievePropertyItemParameters;
var queryParameters = (IRetrievePropertyQueryParameters)retrievePropertyItemParameters;
var url = PagesApiUrls.RetrievePropertyItem(pathParameters.PageId, pathParameters.PropertyId);
- var queryParams = new Dictionary()
+ var queryParams = new Dictionary
{
{ "start_cursor", queryParameters?.StartCursor },
{ "page_size", queryParameters?.PageSize?.ToString() }
};
- return await _client.GetAsync(url, queryParams);
+ return await _client.GetAsync(url, queryParams, cancellationToken: cancellationToken);
}
- public async Task UpdateAsync(string pageId, PagesUpdateParameters pagesUpdateParameters)
+ public async Task UpdateAsync(string pageId, PagesUpdateParameters pagesUpdateParameters, CancellationToken cancellationToken = default)
{
var url = PagesApiUrls.Update(pageId);
var body = (IPagesUpdateBodyParameters)pagesUpdateParameters;
- return await _client.PatchAsync(url, body);
+ return await _client.PatchAsync(url, body, cancellationToken: cancellationToken);
}
- [Obsolete("This method is obsolute. Use UpdateAsync instead. This API will be removed in future release")]
+ [Obsolete("This method is obsolete. Use UpdateAsync instead. This API will be removed in future release")]
public async Task UpdatePropertiesAsync(
string pageId,
- IDictionary updatedProperties)
+ IDictionary updatedProperties, CancellationToken cancellationToken = default)
{
var url = PagesApiUrls.UpdateProperties(pageId);
+
var body = new UpdatePropertiesParameters { Properties = updatedProperties };
- return await _client.PatchAsync(url, body);
+ return await _client.PatchAsync(url, body, cancellationToken: cancellationToken);
}
+ [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Local")]
private class UpdatePropertiesParameters
{
public IDictionary Properties { get; set; }
diff --git a/Src/Notion.Client/Api/Pages/RequestParams/IPagesUpdateBodyParameters.cs b/Src/Notion.Client/Api/Pages/RequestParams/IPagesUpdateBodyParameters.cs
index b37dd1fd..b7ea1ea6 100644
--- a/Src/Notion.Client/Api/Pages/RequestParams/IPagesUpdateBodyParameters.cs
+++ b/Src/Notion.Client/Api/Pages/RequestParams/IPagesUpdateBodyParameters.cs
@@ -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 Properties { get; set; }
diff --git a/Src/Notion.Client/Api/Pages/RequestParams/PagesCreateParameters/PagesCreateParameters.cs b/Src/Notion.Client/Api/Pages/RequestParams/PagesCreateParameters/PagesCreateParameters.cs
index 52cb0a89..08572811 100644
--- a/Src/Notion.Client/Api/Pages/RequestParams/PagesCreateParameters/PagesCreateParameters.cs
+++ b/Src/Notion.Client/Api/Pages/RequestParams/PagesCreateParameters/PagesCreateParameters.cs
@@ -5,9 +5,13 @@ namespace Notion.Client
public class PagesCreateParameters : IPagesCreateBodyParameters, IPagesCreateQueryParameters
{
public IPageParentInput Parent { get; set; }
+
public IDictionary Properties { get; set; }
+
public IList Children { get; set; }
+
public IPageIcon Icon { get; set; }
+
public FileObject Cover { get; set; }
}
}
diff --git a/Src/Notion.Client/Api/Pages/RequestParams/PagesCreateParameters/PagesCreateParametersBuilder.cs b/Src/Notion.Client/Api/Pages/RequestParams/PagesCreateParameters/PagesCreateParametersBuilder.cs
index b86a207a..ed85117d 100644
--- a/Src/Notion.Client/Api/Pages/RequestParams/PagesCreateParameters/PagesCreateParametersBuilder.cs
+++ b/Src/Notion.Client/Api/Pages/RequestParams/PagesCreateParameters/PagesCreateParametersBuilder.cs
@@ -1,14 +1,16 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
namespace Notion.Client
{
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
public class PagesCreateParametersBuilder
{
- private IPageParentInput parent;
- private readonly Dictionary properties = new Dictionary();
- private readonly IList children = new List();
- private IPageIcon icon;
- private FileObject cover;
+ private readonly IList _children = new List();
+ private readonly Dictionary _properties = new();
+ private FileObject _cover;
+ private IPageIcon _icon;
+ private IPageParentInput _parent;
private PagesCreateParametersBuilder()
{
@@ -16,33 +18,34 @@ private PagesCreateParametersBuilder()
public static PagesCreateParametersBuilder Create(IPageParentInput parent)
{
- return new PagesCreateParametersBuilder
- {
- parent = parent
- };
+ return new PagesCreateParametersBuilder { _parent = parent };
}
public PagesCreateParametersBuilder AddProperty(string nameOrId, PropertyValue value)
{
- properties[nameOrId] = value;
+ _properties[nameOrId] = value;
+
return this;
}
public PagesCreateParametersBuilder AddPageContent(IBlock block)
{
- children.Add(block);
+ _children.Add(block);
+
return this;
}
public PagesCreateParametersBuilder SetIcon(IPageIcon pageIcon)
{
- icon = pageIcon;
+ _icon = pageIcon;
+
return this;
}
public PagesCreateParametersBuilder SetCover(FileObject pageCover)
{
- cover = pageCover;
+ _cover = pageCover;
+
return this;
}
@@ -50,11 +53,11 @@ public PagesCreateParameters Build()
{
return new PagesCreateParameters
{
- Parent = parent,
- Properties = properties,
- Children = children,
- Icon = icon,
- Cover = cover
+ Parent = _parent,
+ Properties = _properties,
+ Children = _children,
+ Icon = _icon,
+ Cover = _cover
};
}
}
diff --git a/Src/Notion.Client/Api/Pages/RequestParams/PagesUpdateParameters.cs b/Src/Notion.Client/Api/Pages/RequestParams/PagesUpdateParameters.cs
index 40f06b12..6845f27b 100644
--- a/Src/Notion.Client/Api/Pages/RequestParams/PagesUpdateParameters.cs
+++ b/Src/Notion.Client/Api/Pages/RequestParams/PagesUpdateParameters.cs
@@ -5,16 +5,16 @@ namespace Notion.Client
{
public class PagesUpdateParameters : IPagesUpdateBodyParameters
{
- [JsonProperty("archived")]
- public bool Archived { get; set; }
-
- [JsonProperty("properties")]
- public IDictionary Properties { get; set; }
-
[JsonProperty("icon")]
public IPageIcon Icon { get; set; }
[JsonProperty("cover")]
public FileObject Cover { get; set; }
+
+ [JsonProperty("in_trash")]
+ public bool InTrash { get; set; }
+
+ [JsonProperty("properties")]
+ public IDictionary Properties { get; set; }
}
}
diff --git a/Src/Notion.Client/Api/Search/ISearchClient.cs b/Src/Notion.Client/Api/Search/ISearchClient.cs
index 883c86ba..accee1e1 100644
--- a/Src/Notion.Client/Api/Search/ISearchClient.cs
+++ b/Src/Notion.Client/Api/Search/ISearchClient.cs
@@ -1,9 +1,24 @@
-using System.Threading.Tasks;
+using System.Diagnostics.CodeAnalysis;
+using System.Threading;
+using System.Threading.Tasks;
namespace Notion.Client
{
+ [SuppressMessage("ReSharper", "UnusedMemberInSuper.Global")]
public interface ISearchClient
{
- Task> SearchAsync(SearchParameters parameters);
+ ///
+ /// Searches all original pages, databases, and child pages/databases that are shared with the integration.
+ /// It will not return linked databases, since these duplicate their source databases.
+ ///
+ /// Search filters and body parameters
+ ///
+ ///
+ ///
+ ///
+ Task SearchAsync(
+ SearchRequest request,
+ CancellationToken cancellationToken = default
+ );
}
}
diff --git a/Src/Notion.Client/Api/Search/Parameters/ISearchBodyParameters.cs b/Src/Notion.Client/Api/Search/Request/ISearchBodyParameters.cs
similarity index 100%
rename from Src/Notion.Client/Api/Search/Parameters/ISearchBodyParameters.cs
rename to Src/Notion.Client/Api/Search/Request/ISearchBodyParameters.cs
diff --git a/Src/Notion.Client/Api/Search/Parameters/SearchDirection.cs b/Src/Notion.Client/Api/Search/Request/SearchDirection.cs
similarity index 59%
rename from Src/Notion.Client/Api/Search/Parameters/SearchDirection.cs
rename to Src/Notion.Client/Api/Search/Request/SearchDirection.cs
index fdac0b59..da52b11b 100644
--- a/Src/Notion.Client/Api/Search/Parameters/SearchDirection.cs
+++ b/Src/Notion.Client/Api/Search/Request/SearchDirection.cs
@@ -1,7 +1,9 @@
-using System.Runtime.Serialization;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.Serialization;
namespace Notion.Client
{
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
public enum SearchDirection
{
[EnumMember(Value = "ascending")]
diff --git a/Src/Notion.Client/Api/Search/Parameters/SearchFilter.cs b/Src/Notion.Client/Api/Search/Request/SearchFilter.cs
similarity index 56%
rename from Src/Notion.Client/Api/Search/Parameters/SearchFilter.cs
rename to Src/Notion.Client/Api/Search/Request/SearchFilter.cs
index cc84a9a3..b36ca873 100644
--- a/Src/Notion.Client/Api/Search/Parameters/SearchFilter.cs
+++ b/Src/Notion.Client/Api/Search/Request/SearchFilter.cs
@@ -1,12 +1,16 @@
-using Newtonsoft.Json;
+using System.Diagnostics.CodeAnalysis;
+using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace Notion.Client
{
+ [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
public class SearchFilter
{
[JsonConverter(typeof(StringEnumConverter))]
public SearchObjectType Value { get; set; }
+
public string Property => "object";
}
}
diff --git a/Src/Notion.Client/Api/Search/Parameters/SearchObjectType.cs b/Src/Notion.Client/Api/Search/Request/SearchObjectType.cs
similarity index 57%
rename from Src/Notion.Client/Api/Search/Parameters/SearchObjectType.cs
rename to Src/Notion.Client/Api/Search/Request/SearchObjectType.cs
index 78a012df..e3e6181b 100644
--- a/Src/Notion.Client/Api/Search/Parameters/SearchObjectType.cs
+++ b/Src/Notion.Client/Api/Search/Request/SearchObjectType.cs
@@ -1,7 +1,9 @@
-using System.Runtime.Serialization;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.Serialization;
namespace Notion.Client
{
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
public enum SearchObjectType
{
[EnumMember(Value = "page")]
diff --git a/Src/Notion.Client/Api/Search/Parameters/SearchParameters.cs b/Src/Notion.Client/Api/Search/Request/SearchRequest.cs
similarity index 82%
rename from Src/Notion.Client/Api/Search/Parameters/SearchParameters.cs
rename to Src/Notion.Client/Api/Search/Request/SearchRequest.cs
index ae02c0f4..a9ac887f 100644
--- a/Src/Notion.Client/Api/Search/Parameters/SearchParameters.cs
+++ b/Src/Notion.Client/Api/Search/Request/SearchRequest.cs
@@ -1,11 +1,15 @@
namespace Notion.Client
{
- public class SearchParameters : ISearchBodyParameters
+ public class SearchRequest : ISearchBodyParameters
{
public string Query { get; set; }
+
public SearchSort Sort { get; set; }
+
public SearchFilter Filter { get; set; }
+
public string StartCursor { get; set; }
+
public int? PageSize { get; set; }
}
}
diff --git a/Src/Notion.Client/Api/Search/Parameters/SearchSort.cs b/Src/Notion.Client/Api/Search/Request/SearchSort.cs
similarity index 100%
rename from Src/Notion.Client/Api/Search/Parameters/SearchSort.cs
rename to Src/Notion.Client/Api/Search/Request/SearchSort.cs
diff --git a/Src/Notion.Client/Api/Search/Response/SearchResponse.cs b/Src/Notion.Client/Api/Search/Response/SearchResponse.cs
new file mode 100644
index 00000000..2be0e2f1
--- /dev/null
+++ b/Src/Notion.Client/Api/Search/Response/SearchResponse.cs
@@ -0,0 +1,11 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class SearchResponse : PaginatedList
+ {
+ [JsonProperty("page_or_database")]
+ public Dictionary PageOrDatabase { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Search/SearchClient.cs b/Src/Notion.Client/Api/Search/SearchClient.cs
index 87de9270..492e0940 100644
--- a/Src/Notion.Client/Api/Search/SearchClient.cs
+++ b/Src/Notion.Client/Api/Search/SearchClient.cs
@@ -1,24 +1,27 @@
-using System.Threading.Tasks;
+using System.Threading;
+using System.Threading.Tasks;
using static Notion.Client.ApiEndpoints;
namespace Notion.Client
{
- public class SearchClient : ISearchClient
+ public sealed class SearchClient : ISearchClient
{
- private readonly IRestClient client;
+ private readonly IRestClient _client;
public SearchClient(IRestClient client)
{
- this.client = client;
+ _client = client;
}
- public async Task> SearchAsync(SearchParameters parameters)
+ public async Task SearchAsync(
+ SearchRequest request,
+ CancellationToken cancellationToken = default)
{
var url = SearchApiUrls.Search();
- var body = (ISearchBodyParameters)parameters;
+ var body = (ISearchBodyParameters)request;
- return await client.PostAsync>(url, body);
+ return await _client.PostAsync(url, body, cancellationToken: cancellationToken);
}
}
}
diff --git a/Src/Notion.Client/Api/Users/IUsersClient.cs b/Src/Notion.Client/Api/Users/IUsersClient.cs
index 95427f2b..bc0c3d8a 100644
--- a/Src/Notion.Client/Api/Users/IUsersClient.cs
+++ b/Src/Notion.Client/Api/Users/IUsersClient.cs
@@ -1,16 +1,51 @@
-using System.Threading.Tasks;
+using System.Threading;
+using System.Threading.Tasks;
+using Notion.Client.List.Request;
namespace Notion.Client
{
public interface IUsersClient
{
- Task RetrieveAsync(string userId);
- Task> ListAsync();
+ ///
+ /// Retrieves a User using the ID specified.
+ ///
+ /// Identifier for a Notion user
+ ///
+ ///
+ ///
+ Task RetrieveAsync(string userId, CancellationToken cancellationToken = default);
+
+ ///
+ /// Returns a paginated list of Users for the workspace.
+ /// The response may contain fewer than page_size of results.
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task ListAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Returns a paginated list of Users for the workspace.
+ /// The response may contain fewer than page_size of results.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task ListAsync(
+ ListUsersRequest listUsersRequest,
+ CancellationToken cancellationToken = default
+ );
///
- /// Retrieves the bot User associated with the API token provided in the authorization header.
+ /// Retrieves the bot User associated with the API token provided in the authorization header.
///
- /// User object of type bot having an owner field with information about the person who authorized the integration.
- Task MeAsync();
+ ///
+ /// object of type bot having an owner field with information about the person who authorized
+ /// the integration.
+ ///
+ Task MeAsync(CancellationToken cancellationToken = default);
}
}
diff --git a/Src/Notion.Client/Api/Users/List/Request/ListUsersRequest.cs b/Src/Notion.Client/Api/Users/List/Request/ListUsersRequest.cs
new file mode 100644
index 00000000..f3684d09
--- /dev/null
+++ b/Src/Notion.Client/Api/Users/List/Request/ListUsersRequest.cs
@@ -0,0 +1,13 @@
+namespace Notion.Client.List.Request
+{
+ public interface IListUsersQueryParameters : IPaginationParameters
+ {
+ }
+
+ public class ListUsersRequest : IListUsersQueryParameters
+ {
+ public string StartCursor { get; set; }
+
+ public int? PageSize { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Users/List/Response/ListUsersResponse.cs b/Src/Notion.Client/Api/Users/List/Response/ListUsersResponse.cs
new file mode 100644
index 00000000..2d30237f
--- /dev/null
+++ b/Src/Notion.Client/Api/Users/List/Response/ListUsersResponse.cs
@@ -0,0 +1,11 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class ListUsersResponse : PaginatedList
+ {
+ [JsonProperty("user")]
+ public Dictionary User { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Api/Users/List/UsersClient.cs b/Src/Notion.Client/Api/Users/List/UsersClient.cs
new file mode 100644
index 00000000..ce13633a
--- /dev/null
+++ b/Src/Notion.Client/Api/Users/List/UsersClient.cs
@@ -0,0 +1,38 @@
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using Notion.Client.List.Request;
+
+namespace Notion.Client
+{
+ public partial class UsersClient
+ {
+ public async Task ListAsync(CancellationToken cancellationToken = default)
+ {
+ return await _client.GetAsync(
+ ApiEndpoints.UsersApiUrls.List(),
+ cancellationToken: cancellationToken
+ );
+ }
+
+ public async Task ListAsync(
+ ListUsersRequest listUsersRequest,
+ CancellationToken cancellationToken = default
+ )
+ {
+ var queryParameters = (IListUsersQueryParameters)listUsersRequest;
+
+ var queryParams = new Dictionary
+ {
+ { "start_cursor", queryParameters?.StartCursor },
+ { "page_size", queryParameters?.PageSize?.ToString() }
+ };
+
+ return await _client.GetAsync(
+ ApiEndpoints.UsersApiUrls.List(),
+ queryParams,
+ cancellationToken: cancellationToken
+ );
+ }
+ }
+}
diff --git a/Src/Notion.Client/Api/Users/UsersClient.cs b/Src/Notion.Client/Api/Users/UsersClient.cs
index 5c745f72..24681b53 100644
--- a/Src/Notion.Client/Api/Users/UsersClient.cs
+++ b/Src/Notion.Client/Api/Users/UsersClient.cs
@@ -1,9 +1,10 @@
-using System.Threading.Tasks;
+using System.Threading;
+using System.Threading.Tasks;
using static Notion.Client.ApiEndpoints;
namespace Notion.Client
{
- public class UsersClient : IUsersClient
+ public partial class UsersClient : IUsersClient
{
private readonly IRestClient _client;
@@ -12,23 +13,21 @@ public UsersClient(IRestClient client)
_client = client;
}
- public async Task RetrieveAsync(string userId)
+ public async Task RetrieveAsync(string userId, CancellationToken cancellationToken = default)
{
- return await _client.GetAsync(UsersApiUrls.Retrieve(userId));
- }
-
- public async Task> ListAsync()
- {
- return await _client.GetAsync>(UsersApiUrls.List());
+ return await _client.GetAsync(UsersApiUrls.Retrieve(userId), cancellationToken: cancellationToken);
}
///
- /// Retrieves the bot User associated with the API token provided in the authorization header.
+ /// Retrieves the bot User associated with the API token provided in the authorization header.
///
- /// User object of type bot having an owner field with information about the person who authorized the integration.
- public async Task MeAsync()
+ ///
+ /// User object of type bot having an owner field with information about the person who authorized the
+ /// integration.
+ ///
+ public async Task MeAsync(CancellationToken cancellationToken = default)
{
- return await _client.GetAsync(UsersApiUrls.Me());
+ return await _client.GetAsync(UsersApiUrls.Me(), cancellationToken: cancellationToken);
}
}
}
diff --git a/Src/Notion.Client/Constants.cs b/Src/Notion.Client/Constants.cs
index 5034edae..779bcb47 100644
--- a/Src/Notion.Client/Constants.cs
+++ b/Src/Notion.Client/Constants.cs
@@ -1,11 +1,12 @@
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Notion.UnitTests")]
+
namespace Notion.Client
{
- internal class Constants
+ internal static class Constants
{
- internal static string BASE_URL = "https://api.notion.com/";
- internal static string DEFAULT_NOTION_VERSION = "2022-06-28";
+ internal const string BaseUrl = "https://api.notion.com/";
+ internal const string DefaultNotionVersion = "2022-06-28";
}
}
diff --git a/Src/Notion.Client/DI/ServiceCollectionExtensions.cs b/Src/Notion.Client/DI/ServiceCollectionExtensions.cs
index a4aed7fd..9a658077 100644
--- a/Src/Notion.Client/DI/ServiceCollectionExtensions.cs
+++ b/Src/Notion.Client/DI/ServiceCollectionExtensions.cs
@@ -1,13 +1,18 @@
using System;
+using System.Diagnostics.CodeAnalysis;
using Notion.Client;
namespace Microsoft.Extensions.DependencyInjection
{
+ [SuppressMessage("ReSharper", "UnusedType.Global")]
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
public static class ServiceCollectionExtensions
{
- public static IServiceCollection AddNotionClient(this IServiceCollection services, Action options)
+ public static IServiceCollection AddNotionClient(
+ this IServiceCollection services,
+ Action options)
{
- services.AddSingleton(sp =>
+ services.AddSingleton(_ =>
{
var clientOptions = new ClientOptions();
options?.Invoke(clientOptions);
diff --git a/Src/Notion.Client/Extensions/EnumExtensions.cs b/Src/Notion.Client/Extensions/EnumExtensions.cs
index 987104b8..cd60aebd 100644
--- a/Src/Notion.Client/Extensions/EnumExtensions.cs
+++ b/Src/Notion.Client/Extensions/EnumExtensions.cs
@@ -1,15 +1,18 @@
-using System.Linq;
+using System;
+using System.Linq;
using System.Runtime.Serialization;
namespace Notion.Client.Extensions
{
public static class EnumExtensions
{
- public static string GetEnumMemberValue(this T enumValue) where T : System.Enum
+ public static string GetEnumMemberValue(this T enumValue) where T : Enum
{
var enumType = typeof(T);
var memInfo = enumType.GetMember(enumValue.ToString());
- var attr = memInfo.FirstOrDefault()?.GetCustomAttributes(false).OfType().FirstOrDefault();
+
+ var attr = memInfo.FirstOrDefault()?.GetCustomAttributes(false).OfType()
+ .FirstOrDefault();
if (attr != null)
{
diff --git a/Src/Notion.Client/Extensions/HttpResponseMessageExtensions.cs b/Src/Notion.Client/Extensions/HttpResponseMessageExtensions.cs
index 9b01580d..cc6f9698 100644
--- a/Src/Notion.Client/Extensions/HttpResponseMessageExtensions.cs
+++ b/Src/Notion.Client/Extensions/HttpResponseMessageExtensions.cs
@@ -7,29 +7,19 @@ namespace Notion.Client.Extensions
{
internal static class HttpResponseMessageExtensions
{
- internal static async Task ParseStreamAsync(this HttpResponseMessage response, JsonSerializerSettings serializerSettings = null)
+ internal static async Task ParseStreamAsync(
+ this HttpResponseMessage response,
+ JsonSerializerSettings serializerSettings = null)
{
- using (Stream stream = await response.Content.ReadAsStreamAsync())
- {
- using (StreamReader streamReader = new StreamReader(stream))
- {
- using (JsonReader jsonReader = new JsonTextReader(streamReader))
- {
- JsonSerializer serializer = null;
+ using var stream = await response.Content.ReadAsStreamAsync();
+ using var streamReader = new StreamReader(stream);
+ using JsonReader jsonReader = new JsonTextReader(streamReader);
- if (serializerSettings == null)
- {
- serializer = JsonSerializer.CreateDefault();
- }
- else
- {
- serializer = JsonSerializer.Create(serializerSettings);
- }
+ var serializer = serializerSettings == null
+ ? JsonSerializer.CreateDefault()
+ : JsonSerializer.Create(serializerSettings);
- return serializer.Deserialize(jsonReader);
- }
- }
- }
+ return serializer.Deserialize(jsonReader);
}
}
}
diff --git a/Src/Notion.Client/Logging/Log.cs b/Src/Notion.Client/Logging/Log.cs
index 7fda66a5..47beea5e 100644
--- a/Src/Notion.Client/Logging/Log.cs
+++ b/Src/Notion.Client/Logging/Log.cs
@@ -1,25 +1,27 @@
using System;
+using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Logging;
namespace Notion.Client
{
internal static class Log
{
- internal static ILogger logger;
+ internal static ILogger Logger;
internal static void Trace(string message, params object[] args)
{
- logger?.LogTrace(message, args);
+ Logger?.LogTrace(message, args);
}
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
internal static void Information(string message, params object[] args)
{
- logger?.LogInformation(message, args);
+ Logger?.LogInformation(message, args);
}
internal static void Error(Exception ex, string message, params object[] args)
{
- logger?.LogError(ex, message, args);
+ Logger?.LogError(ex, message, args);
}
}
}
diff --git a/Src/Notion.Client/Logging/NotionClientLogging.cs b/Src/Notion.Client/Logging/NotionClientLogging.cs
index b77ff15e..07a18514 100644
--- a/Src/Notion.Client/Logging/NotionClientLogging.cs
+++ b/Src/Notion.Client/Logging/NotionClientLogging.cs
@@ -1,16 +1,19 @@
-using Microsoft.Extensions.Logging;
+using System.Diagnostics.CodeAnalysis;
+using Microsoft.Extensions.Logging;
namespace Notion.Client
{
+ [SuppressMessage("ReSharper", "UnusedType.Global")]
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
public static class NotionClientLogging
{
- internal static ILoggerFactory factory;
+ private static ILoggerFactory _factory;
public static void ConfigureLogger(ILoggerFactory loggerFactory)
{
- factory = loggerFactory;
+ _factory = loggerFactory;
- Log.logger = Log.logger == null ? factory?.CreateLogger("Notion.Client") : Log.logger;
+ Log.Logger = Log.Logger == null ? _factory?.CreateLogger("Notion.Client") : Log.Logger;
}
}
}
diff --git a/Src/Notion.Client/Models/Blocks/AudioBlock.cs b/Src/Notion.Client/Models/Blocks/AudioBlock.cs
index 040f346b..1ba1a4a3 100644
--- a/Src/Notion.Client/Models/Blocks/AudioBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/AudioBlock.cs
@@ -4,9 +4,9 @@ namespace Notion.Client
{
public class AudioBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.Audio;
-
[JsonProperty("audio")]
public FileObject Audio { get; set; }
+
+ public override BlockType Type => BlockType.Audio;
}
}
diff --git a/Src/Notion.Client/Models/Blocks/Block.cs b/Src/Notion.Client/Models/Blocks/Block.cs
index 1baf2533..fa1ef612 100644
--- a/Src/Notion.Client/Models/Blocks/Block.cs
+++ b/Src/Notion.Client/Models/Blocks/Block.cs
@@ -1,5 +1,4 @@
using System;
-using Notion.Client.Models.Blocks;
namespace Notion.Client
{
@@ -17,12 +16,14 @@ 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; }
///
- /// Information about the block's parent.
+ /// Information about the block's parent.
///
public IBlockParent Parent { get; set; }
}
diff --git a/Src/Notion.Client/Models/Blocks/BlockType.cs b/Src/Notion.Client/Models/Blocks/BlockType.cs
index f3181b22..92de4b6b 100644
--- a/Src/Notion.Client/Models/Blocks/BlockType.cs
+++ b/Src/Notion.Client/Models/Blocks/BlockType.cs
@@ -1,4 +1,5 @@
-using System.Runtime.Serialization;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.Serialization;
namespace Notion.Client
{
@@ -8,12 +9,15 @@ public enum BlockType
Paragraph,
[EnumMember(Value = "heading_1")]
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
Heading_1,
[EnumMember(Value = "heading_2")]
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
Heading_2,
[EnumMember(Value = "heading_3")]
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
Heading_3,
[EnumMember(Value = "bulleted_list_item")]
@@ -97,6 +101,9 @@ public enum BlockType
[EnumMember(Value = "table_row")]
TableRow,
+ [EnumMember(Value = "link_preview")]
+ LinkPreview,
+
[EnumMember(Value = "unsupported")]
Unsupported
}
diff --git a/Src/Notion.Client/Models/Blocks/BookmarkBlock.cs b/Src/Notion.Client/Models/Blocks/BookmarkBlock.cs
index 735b1725..73099c82 100644
--- a/Src/Notion.Client/Models/Blocks/BookmarkBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/BookmarkBlock.cs
@@ -5,11 +5,11 @@ namespace Notion.Client
{
public class BookmarkBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.Bookmark;
-
[JsonProperty("bookmark")]
public Info Bookmark { get; set; }
+ public override BlockType Type => BlockType.Bookmark;
+
public class Info
{
[JsonProperty("url")]
diff --git a/Src/Notion.Client/Models/Blocks/BreadcrumbBlock.cs b/Src/Notion.Client/Models/Blocks/BreadcrumbBlock.cs
index 73ae614d..d5585a40 100644
--- a/Src/Notion.Client/Models/Blocks/BreadcrumbBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/BreadcrumbBlock.cs
@@ -4,11 +4,11 @@ namespace Notion.Client
{
public class BreadcrumbBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.Breadcrumb;
-
[JsonProperty("breadcrumb")]
public Data Breadcrumb { get; set; }
+ public override BlockType Type => BlockType.Breadcrumb;
+
public class Data
{
}
diff --git a/Src/Notion.Client/Models/Blocks/BulletedListItemBlock.cs b/Src/Notion.Client/Models/Blocks/BulletedListItemBlock.cs
index 7eca3397..c823b4bd 100644
--- a/Src/Notion.Client/Models/Blocks/BulletedListItemBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/BulletedListItemBlock.cs
@@ -6,11 +6,11 @@ namespace Notion.Client
{
public class BulletedListItemBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.BulletedListItem;
-
[JsonProperty("bulleted_list_item")]
public Info BulletedListItem { get; set; }
+ public override BlockType Type => BlockType.BulletedListItem;
+
public class Info
{
[JsonProperty("rich_text")]
diff --git a/Src/Notion.Client/Models/Blocks/CalloutBlock.cs b/Src/Notion.Client/Models/Blocks/CalloutBlock.cs
index 8cc4bb7a..d4ef61c4 100644
--- a/Src/Notion.Client/Models/Blocks/CalloutBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/CalloutBlock.cs
@@ -6,11 +6,11 @@ namespace Notion.Client
{
public class CalloutBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.Callout;
-
[JsonProperty("callout")]
public Info Callout { get; set; }
+ public override BlockType Type => BlockType.Callout;
+
public class Info
{
[JsonProperty("rich_text")]
diff --git a/Src/Notion.Client/Models/Blocks/ChildDatabaseBlock.cs b/Src/Notion.Client/Models/Blocks/ChildDatabaseBlock.cs
index 273836a9..e56fcadb 100644
--- a/Src/Notion.Client/Models/Blocks/ChildDatabaseBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/ChildDatabaseBlock.cs
@@ -4,11 +4,11 @@ namespace Notion.Client
{
public class ChildDatabaseBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.ChildDatabase;
-
[JsonProperty("child_database")]
public Info ChildDatabase { get; set; }
+ public override BlockType Type => BlockType.ChildDatabase;
+
public class Info
{
[JsonProperty("title")]
diff --git a/Src/Notion.Client/Models/Blocks/ChildPageBlock.cs b/Src/Notion.Client/Models/Blocks/ChildPageBlock.cs
index 91c8f343..216b0d82 100644
--- a/Src/Notion.Client/Models/Blocks/ChildPageBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/ChildPageBlock.cs
@@ -4,11 +4,11 @@ namespace Notion.Client
{
public class ChildPageBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.ChildPage;
-
[JsonProperty("child_page")]
public Info ChildPage { get; set; }
+ public override BlockType Type => BlockType.ChildPage;
+
public class Info
{
[JsonProperty("title")]
diff --git a/Src/Notion.Client/Models/Blocks/CodeBlock.cs b/Src/Notion.Client/Models/Blocks/CodeBlock.cs
index 5eb1456b..9cb2c350 100644
--- a/Src/Notion.Client/Models/Blocks/CodeBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/CodeBlock.cs
@@ -5,11 +5,11 @@ namespace Notion.Client
{
public class CodeBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.Code;
-
[JsonProperty("code")]
public Info Code { get; set; }
+ public override BlockType Type => BlockType.Code;
+
public class Info
{
[JsonProperty("rich_text")]
diff --git a/Src/Notion.Client/Models/Blocks/Color.cs b/Src/Notion.Client/Models/Blocks/Color.cs
index b4682a7b..46e38e2a 100644
--- a/Src/Notion.Client/Models/Blocks/Color.cs
+++ b/Src/Notion.Client/Models/Blocks/Color.cs
@@ -1,7 +1,9 @@
-using System.Runtime.Serialization;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.Serialization;
namespace Notion.Client
{
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
public enum Color
{
[EnumMember(Value = "default")]
@@ -59,6 +61,6 @@ public enum Color
PinkBackground,
[EnumMember(Value = "red_background")]
- RedBackground,
+ RedBackground
}
}
diff --git a/Src/Notion.Client/Models/Blocks/ColumnListBlock.cs b/Src/Notion.Client/Models/Blocks/ColumnListBlock.cs
index f86ecba0..59bd6245 100644
--- a/Src/Notion.Client/Models/Blocks/ColumnListBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/ColumnListBlock.cs
@@ -5,11 +5,11 @@ namespace Notion.Client
{
public class ColumnListBlock : Block, INonColumnBlock
{
- public override BlockType Type => BlockType.ColumnList;
-
[JsonProperty("column_list")]
public Info ColumnList { get; set; }
+ public override BlockType Type => BlockType.ColumnList;
+
public class Info
{
[JsonProperty("children")]
diff --git a/Src/Notion.Client/Models/Blocks/DividerBlock.cs b/Src/Notion.Client/Models/Blocks/DividerBlock.cs
index 61e0301b..26c55783 100644
--- a/Src/Notion.Client/Models/Blocks/DividerBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/DividerBlock.cs
@@ -4,11 +4,11 @@ namespace Notion.Client
{
public class DividerBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.Divider;
-
[JsonProperty("divider")]
public Data Divider { get; set; }
+ public override BlockType Type => BlockType.Divider;
+
public class Data
{
}
diff --git a/Src/Notion.Client/Models/Blocks/EmbedBlock.cs b/Src/Notion.Client/Models/Blocks/EmbedBlock.cs
index bbd93e10..92c1dfdd 100644
--- a/Src/Notion.Client/Models/Blocks/EmbedBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/EmbedBlock.cs
@@ -5,11 +5,11 @@ namespace Notion.Client
{
public class EmbedBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.Embed;
-
[JsonProperty("embed")]
public Info Embed { get; set; }
+ public override BlockType Type => BlockType.Embed;
+
public class Info
{
[JsonProperty("url")]
@@ -17,7 +17,6 @@ public class Info
[JsonProperty("caption")]
public IEnumerable Caption { get; set; }
-
}
}
}
diff --git a/Src/Notion.Client/Models/Blocks/EquationBlock.cs b/Src/Notion.Client/Models/Blocks/EquationBlock.cs
index 310a76df..411c4e3b 100644
--- a/Src/Notion.Client/Models/Blocks/EquationBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/EquationBlock.cs
@@ -4,11 +4,11 @@ namespace Notion.Client
{
public class EquationBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.Equation;
-
[JsonProperty("equation")]
public Info Equation { get; set; }
+ public override BlockType Type => BlockType.Equation;
+
public class Info
{
[JsonProperty("expression")]
diff --git a/Src/Notion.Client/Models/Blocks/FileBlock.cs b/Src/Notion.Client/Models/Blocks/FileBlock.cs
index 5495e4bc..7749a693 100644
--- a/Src/Notion.Client/Models/Blocks/FileBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/FileBlock.cs
@@ -4,9 +4,9 @@ namespace Notion.Client
{
public class FileBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.File;
-
[JsonProperty("file")]
public FileObject File { get; set; }
+
+ public override BlockType Type => BlockType.File;
}
}
diff --git a/Src/Notion.Client/Models/Blocks/HeadingOneBlock.cs b/Src/Notion.Client/Models/Blocks/HeadingOneBlock.cs
index 853f9ae5..1e8474a4 100644
--- a/Src/Notion.Client/Models/Blocks/HeadingOneBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/HeadingOneBlock.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
@@ -6,12 +7,11 @@ namespace Notion.Client
{
public class HeadingOneBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.Heading_1;
-
[JsonProperty("heading_1")]
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
public Info Heading_1 { get; set; }
- public override bool HasChildren => false;
+ public override BlockType Type => BlockType.Heading_1;
public class Info
{
@@ -21,6 +21,9 @@ public class Info
[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color? Color { get; set; }
+
+ [JsonProperty("is_toggleable")]
+ public bool IsToggleable { get; set; }
}
}
}
diff --git a/Src/Notion.Client/Models/Blocks/HeadingThreeeBlock.cs b/Src/Notion.Client/Models/Blocks/HeadingThreeBlock.cs
similarity index 67%
rename from Src/Notion.Client/Models/Blocks/HeadingThreeeBlock.cs
rename to Src/Notion.Client/Models/Blocks/HeadingThreeBlock.cs
index 99d9b861..e300a511 100644
--- a/Src/Notion.Client/Models/Blocks/HeadingThreeeBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/HeadingThreeBlock.cs
@@ -1,17 +1,17 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace Notion.Client
{
- public class HeadingThreeeBlock : Block, IColumnChildrenBlock, INonColumnBlock
+ public class HeadingThreeBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.Heading_3;
-
[JsonProperty("heading_3")]
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
public Info Heading_3 { get; set; }
- public override bool HasChildren => false;
+ public override BlockType Type => BlockType.Heading_3;
public class Info
{
@@ -21,6 +21,9 @@ public class Info
[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color? Color { get; set; }
+
+ [JsonProperty("is_toggleable")]
+ public bool IsToggleable { get; set; }
}
}
}
diff --git a/Src/Notion.Client/Models/Blocks/HeadingTwoBlock.cs b/Src/Notion.Client/Models/Blocks/HeadingTwoBlock.cs
index ea074e8a..3be849a8 100644
--- a/Src/Notion.Client/Models/Blocks/HeadingTwoBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/HeadingTwoBlock.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
@@ -6,12 +7,11 @@ namespace Notion.Client
{
public class HeadingTwoBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.Heading_2;
-
[JsonProperty("heading_2")]
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
public Info Heading_2 { get; set; }
- public override bool HasChildren => false;
+ public override BlockType Type => BlockType.Heading_2;
public class Info
{
@@ -21,6 +21,9 @@ public class Info
[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
public Color? Color { get; set; }
+
+ [JsonProperty("is_toggleable")]
+ public bool IsToggleable { get; set; }
}
}
}
diff --git a/Src/Notion.Client/Models/Blocks/IBlock.cs b/Src/Notion.Client/Models/Blocks/IBlock.cs
index 58b17b93..b06a3646 100644
--- a/Src/Notion.Client/Models/Blocks/IBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/IBlock.cs
@@ -1,42 +1,43 @@
using JsonSubTypes;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
-using Notion.Client.Models.Blocks;
namespace Notion.Client
{
[JsonConverter(typeof(JsonSubtypes), "type")]
- [JsonSubtypes.KnownSubType(typeof(AudioBlock), BlockType.Audio)]
- [JsonSubtypes.KnownSubType(typeof(BookmarkBlock), BlockType.Bookmark)]
- [JsonSubtypes.KnownSubType(typeof(BreadcrumbBlock), BlockType.Breadcrumb)]
- [JsonSubtypes.KnownSubType(typeof(BulletedListItemBlock), BlockType.BulletedListItem)]
- [JsonSubtypes.KnownSubType(typeof(CalloutBlock), BlockType.Callout)]
- [JsonSubtypes.KnownSubType(typeof(ChildPageBlock), BlockType.ChildPage)]
- [JsonSubtypes.KnownSubType(typeof(ChildDatabaseBlock), BlockType.ChildDatabase)]
- [JsonSubtypes.KnownSubType(typeof(CodeBlock), BlockType.Code)]
- [JsonSubtypes.KnownSubType(typeof(ColumnBlock), BlockType.Column)]
- [JsonSubtypes.KnownSubType(typeof(ColumnListBlock), BlockType.ColumnList)]
- [JsonSubtypes.KnownSubType(typeof(DividerBlock), BlockType.Divider)]
- [JsonSubtypes.KnownSubType(typeof(EmbedBlock), BlockType.Embed)]
- [JsonSubtypes.KnownSubType(typeof(EquationBlock), BlockType.Equation)]
- [JsonSubtypes.KnownSubType(typeof(FileBlock), BlockType.File)]
- [JsonSubtypes.KnownSubType(typeof(HeadingOneBlock), BlockType.Heading_1)]
- [JsonSubtypes.KnownSubType(typeof(HeadingTwoBlock), BlockType.Heading_2)]
- [JsonSubtypes.KnownSubType(typeof(HeadingThreeeBlock), BlockType.Heading_3)]
- [JsonSubtypes.KnownSubType(typeof(ImageBlock), BlockType.Image)]
- [JsonSubtypes.KnownSubType(typeof(LinkToPageBlock), BlockType.LinkToPage)]
- [JsonSubtypes.KnownSubType(typeof(NumberedListItemBlock), BlockType.NumberedListItem)]
- [JsonSubtypes.KnownSubType(typeof(ParagraphBlock), BlockType.Paragraph)]
- [JsonSubtypes.KnownSubType(typeof(PDFBlock), BlockType.PDF)]
- [JsonSubtypes.KnownSubType(typeof(QuoteBlock), BlockType.Quote)]
- [JsonSubtypes.KnownSubType(typeof(TableBlock), BlockType.Table)]
- [JsonSubtypes.KnownSubType(typeof(TableRowBlock), BlockType.TableRow)]
- [JsonSubtypes.KnownSubType(typeof(TableOfContentsBlock), BlockType.TableOfContents)]
- [JsonSubtypes.KnownSubType(typeof(TemplateBlock), BlockType.Template)]
- [JsonSubtypes.KnownSubType(typeof(ToDoBlock), BlockType.ToDo)]
- [JsonSubtypes.KnownSubType(typeof(ToggleBlock), BlockType.Toggle)]
- [JsonSubtypes.KnownSubType(typeof(VideoBlock), BlockType.Video)]
- [JsonSubtypes.KnownSubType(typeof(UnsupportedBlock), BlockType.Unsupported)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(AudioBlock), BlockType.Audio)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(BookmarkBlock), BlockType.Bookmark)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(BreadcrumbBlock), BlockType.Breadcrumb)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(BulletedListItemBlock), BlockType.BulletedListItem)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(CalloutBlock), BlockType.Callout)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(ChildPageBlock), BlockType.ChildPage)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(ChildDatabaseBlock), BlockType.ChildDatabase)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(CodeBlock), BlockType.Code)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(ColumnBlock), BlockType.Column)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(ColumnListBlock), BlockType.ColumnList)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(DividerBlock), BlockType.Divider)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(EmbedBlock), BlockType.Embed)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(EquationBlock), BlockType.Equation)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(FileBlock), BlockType.File)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(HeadingOneBlock), BlockType.Heading_1)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(HeadingTwoBlock), BlockType.Heading_2)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(HeadingThreeBlock), BlockType.Heading_3)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(ImageBlock), BlockType.Image)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(LinkPreviewBlock), BlockType.LinkPreview)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(LinkToPageBlock), BlockType.LinkToPage)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(NumberedListItemBlock), BlockType.NumberedListItem)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(ParagraphBlock), BlockType.Paragraph)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(PDFBlock), BlockType.PDF)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(QuoteBlock), BlockType.Quote)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(SyncedBlockBlock), BlockType.SyncedBlock)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(TableBlock), BlockType.Table)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(TableRowBlock), BlockType.TableRow)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(TableOfContentsBlock), BlockType.TableOfContents)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(TemplateBlock), BlockType.Template)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(ToDoBlock), BlockType.ToDo)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(ToggleBlock), BlockType.Toggle)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(VideoBlock), BlockType.Video)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(UnsupportedBlock), BlockType.Unsupported)]
public interface IBlock : IObject, IObjectModificationData
{
[JsonProperty("type")]
@@ -46,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; }
}
diff --git a/Src/Notion.Client/Models/Blocks/IBlockParent.cs b/Src/Notion.Client/Models/Blocks/IBlockParent.cs
index 4e1d7a17..b2f8783f 100644
--- a/Src/Notion.Client/Models/Blocks/IBlockParent.cs
+++ b/Src/Notion.Client/Models/Blocks/IBlockParent.cs
@@ -1,14 +1,14 @@
using JsonSubTypes;
using Newtonsoft.Json;
-namespace Notion.Client.Models.Blocks
+namespace Notion.Client
{
[JsonConverter(typeof(JsonSubtypes), "type")]
- [JsonSubtypes.KnownSubType(typeof(DatabaseParent), ParentType.DatabaseId)]
- [JsonSubtypes.KnownSubType(typeof(PageParent), ParentType.PageId)]
- [JsonSubtypes.KnownSubType(typeof(WorkspaceParent), ParentType.Workspace)]
- [JsonSubtypes.KnownSubType(typeof(BlockParent), ParentType.BlockId)]
- public interface IBlockParent
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(DatabaseParent), ParentType.DatabaseId)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(PageParent), ParentType.PageId)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(WorkspaceParent), ParentType.Workspace)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(BlockParent), ParentType.BlockId)]
+ public interface IBlockParent : IParent
{
}
}
diff --git a/Src/Notion.Client/Models/Blocks/IColumnChildrenBlock.cs b/Src/Notion.Client/Models/Blocks/IColumnChildrenBlock.cs
index 673bc156..769487c8 100644
--- a/Src/Notion.Client/Models/Blocks/IColumnChildrenBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/IColumnChildrenBlock.cs
@@ -1,6 +1,6 @@
namespace Notion.Client
{
- public interface ITemplateChildrendBlock : IBlock
+ public interface ITemplateChildrenBlock : IBlock
{
}
@@ -8,7 +8,7 @@ public interface ISyncedBlockChildren : IBlock
{
}
- public interface IColumnChildrenBlock : IBlock, ITemplateChildrendBlock, ISyncedBlockChildren
+ public interface IColumnChildrenBlock : ITemplateChildrenBlock, ISyncedBlockChildren
{
}
diff --git a/Src/Notion.Client/Models/Blocks/ImageBlock.cs b/Src/Notion.Client/Models/Blocks/ImageBlock.cs
index 17aa6bae..cd6b055f 100644
--- a/Src/Notion.Client/Models/Blocks/ImageBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/ImageBlock.cs
@@ -4,9 +4,9 @@ namespace Notion.Client
{
public class ImageBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.Image;
-
[JsonProperty("image")]
public FileObject Image { get; set; }
+
+ public override BlockType Type => BlockType.Image;
}
}
diff --git a/Src/Notion.Client/Models/Blocks/LinkPreviewBlock.cs b/Src/Notion.Client/Models/Blocks/LinkPreviewBlock.cs
new file mode 100644
index 00000000..72107e48
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/LinkPreviewBlock.cs
@@ -0,0 +1,18 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class LinkPreviewBlock : Block, IColumnChildrenBlock, INonColumnBlock
+ {
+ [JsonProperty("link_preview")]
+ public Data LinkPreview { get; set; }
+
+ public override BlockType Type => BlockType.LinkPreview;
+
+ public class Data
+ {
+ [JsonProperty("url")]
+ public string Url { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/LinkToPageBlock.cs b/Src/Notion.Client/Models/Blocks/LinkToPageBlock.cs
index 30d3d7dd..ad688ca2 100644
--- a/Src/Notion.Client/Models/Blocks/LinkToPageBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/LinkToPageBlock.cs
@@ -4,9 +4,9 @@ namespace Notion.Client
{
public class LinkToPageBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.LinkToPage;
-
[JsonProperty("link_to_page")]
public IPageParent LinkToPage { get; set; }
+
+ public override BlockType Type => BlockType.LinkToPage;
}
}
diff --git a/Src/Notion.Client/Models/Blocks/NumberedListItemBlock.cs b/Src/Notion.Client/Models/Blocks/NumberedListItemBlock.cs
index 3fe0d76a..f4a645e9 100644
--- a/Src/Notion.Client/Models/Blocks/NumberedListItemBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/NumberedListItemBlock.cs
@@ -6,11 +6,11 @@ namespace Notion.Client
{
public class NumberedListItemBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.NumberedListItem;
-
[JsonProperty("numbered_list_item")]
public Info NumberedListItem { get; set; }
+ public override BlockType Type => BlockType.NumberedListItem;
+
public class Info
{
[JsonProperty("rich_text")]
diff --git a/Src/Notion.Client/Models/Blocks/PDFBlock.cs b/Src/Notion.Client/Models/Blocks/PDFBlock.cs
index 85458796..6d7486d7 100644
--- a/Src/Notion.Client/Models/Blocks/PDFBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/PDFBlock.cs
@@ -1,12 +1,14 @@
-using Newtonsoft.Json;
+using System.Diagnostics.CodeAnalysis;
+using Newtonsoft.Json;
namespace Notion.Client
{
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
public class PDFBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.PDF;
-
[JsonProperty("pdf")]
public FileObject PDF { get; set; }
+
+ public override BlockType Type => BlockType.PDF;
}
}
diff --git a/Src/Notion.Client/Models/Blocks/ParagraphBlock.cs b/Src/Notion.Client/Models/Blocks/ParagraphBlock.cs
index 67458b3c..f3b73f36 100644
--- a/Src/Notion.Client/Models/Blocks/ParagraphBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/ParagraphBlock.cs
@@ -6,11 +6,11 @@ namespace Notion.Client
{
public class ParagraphBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.Paragraph;
-
[JsonProperty("paragraph")]
public Info Paragraph { get; set; }
+ public override BlockType Type => BlockType.Paragraph;
+
public class Info
{
[JsonProperty("rich_text")]
diff --git a/Src/Notion.Client/Models/Blocks/QuoteBlock.cs b/Src/Notion.Client/Models/Blocks/QuoteBlock.cs
index 5fdad7da..e1466be6 100644
--- a/Src/Notion.Client/Models/Blocks/QuoteBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/QuoteBlock.cs
@@ -6,11 +6,11 @@ namespace Notion.Client
{
public class QuoteBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.Quote;
-
[JsonProperty("quote")]
public Info Quote { get; set; }
+ public override BlockType Type => BlockType.Quote;
+
public class Info
{
[JsonProperty("rich_text")]
diff --git a/Src/Notion.Client/Models/Blocks/Request/AudioBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/AudioBlockRequest.cs
new file mode 100644
index 00000000..8378574e
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/AudioBlockRequest.cs
@@ -0,0 +1,12 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class AudioBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("audio")]
+ public FileObject Audio { get; set; }
+
+ public override BlockType Type => BlockType.Audio;
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/BlockObjectRequest.cs b/Src/Notion.Client/Models/Blocks/Request/BlockObjectRequest.cs
new file mode 100644
index 00000000..a3eb3182
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/BlockObjectRequest.cs
@@ -0,0 +1,28 @@
+using System;
+
+namespace Notion.Client
+{
+ public abstract class BlockObjectRequest : IBlockObjectRequest
+ {
+ public ObjectType Object => ObjectType.Block;
+
+ public string Id { get; set; }
+
+ public virtual BlockType Type { get; set; }
+
+ public DateTime CreatedTime { get; set; }
+
+ public DateTime LastEditedTime { get; set; }
+
+ public virtual bool HasChildren { get; set; }
+
+ public PartialUser CreatedBy { get; set; }
+
+ public PartialUser LastEditedBy { get; set; }
+
+ ///
+ /// Information about the block's parent.
+ ///
+ public IBlockParent Parent { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/BookmarkBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/BookmarkBlockRequest.cs
new file mode 100644
index 00000000..0c7c0be2
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/BookmarkBlockRequest.cs
@@ -0,0 +1,22 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class BookmarkBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("bookmark")]
+ public Info Bookmark { get; set; }
+
+ public override BlockType Type => BlockType.Bookmark;
+
+ public class Info
+ {
+ [JsonProperty("url")]
+ public string Url { get; set; }
+
+ [JsonProperty("caption")]
+ public IEnumerable Caption { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/BreadcrumbBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/BreadcrumbBlockRequest.cs
new file mode 100644
index 00000000..f6039456
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/BreadcrumbBlockRequest.cs
@@ -0,0 +1,16 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class BreadcrumbBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("breadcrumb")]
+ public Data Breadcrumb { get; set; }
+
+ public override BlockType Type => BlockType.Breadcrumb;
+
+ public class Data
+ {
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/BulletedListItemBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/BulletedListItemBlockRequest.cs
new file mode 100644
index 00000000..0aa8a183
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/BulletedListItemBlockRequest.cs
@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+
+namespace Notion.Client
+{
+ public class BulletedListItemBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("bulleted_list_item")]
+ public Info BulletedListItem { get; set; }
+
+ public override BlockType Type => BlockType.BulletedListItem;
+
+ public class Info
+ {
+ [JsonProperty("rich_text")]
+ public IEnumerable RichText { get; set; }
+
+ [JsonProperty("color")]
+ [JsonConverter(typeof(StringEnumConverter))]
+ public Color? Color { get; set; }
+
+ [JsonProperty("children")]
+ public IEnumerable Children { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/CalloutBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/CalloutBlockRequest.cs
new file mode 100644
index 00000000..b8a56823
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/CalloutBlockRequest.cs
@@ -0,0 +1,30 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+
+namespace Notion.Client
+{
+ public class CalloutBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("callout")]
+ public Info Callout { get; set; }
+
+ public override BlockType Type => BlockType.Callout;
+
+ public class Info
+ {
+ [JsonProperty("rich_text")]
+ public IEnumerable RichText { get; set; }
+
+ [JsonProperty("icon")]
+ public IPageIcon Icon { get; set; }
+
+ [JsonProperty("color")]
+ [JsonConverter(typeof(StringEnumConverter))]
+ public Color? Color { get; set; }
+
+ [JsonProperty("children")]
+ public IEnumerable Children { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/ChildDatabaseBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/ChildDatabaseBlockRequest.cs
new file mode 100644
index 00000000..34ff9387
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/ChildDatabaseBlockRequest.cs
@@ -0,0 +1,18 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class ChildDatabaseBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("child_database")]
+ public Info ChildDatabase { get; set; }
+
+ public override BlockType Type => BlockType.ChildDatabase;
+
+ public class Info
+ {
+ [JsonProperty("title")]
+ public string Title { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/ChildPageBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/ChildPageBlockRequest.cs
new file mode 100644
index 00000000..43213b77
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/ChildPageBlockRequest.cs
@@ -0,0 +1,18 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class ChildPageBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("child_page")]
+ public Info ChildPage { get; set; }
+
+ public override BlockType Type => BlockType.ChildPage;
+
+ public class Info
+ {
+ [JsonProperty("title")]
+ public string Title { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/CodeBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/CodeBlockRequest.cs
new file mode 100644
index 00000000..732e3208
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/CodeBlockRequest.cs
@@ -0,0 +1,25 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class CodeBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("code")]
+ public Info Code { get; set; }
+
+ public override BlockType Type => BlockType.Code;
+
+ public class Info
+ {
+ [JsonProperty("rich_text")]
+ public IEnumerable RichText { get; set; }
+
+ [JsonProperty("language")]
+ public string Language { get; set; }
+
+ [JsonProperty("caption")]
+ public IEnumerable Caption { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/ColumnBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/ColumnBlockRequest.cs
new file mode 100644
index 00000000..c4136294
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/ColumnBlockRequest.cs
@@ -0,0 +1,19 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class ColumnBlockRequest : BlockObjectRequest
+ {
+ public override BlockType Type => BlockType.Column;
+
+ [JsonProperty("column")]
+ public Info Column { get; set; }
+
+ public class Info
+ {
+ [JsonProperty("children")]
+ public IEnumerable Children { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/ColumnListBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/ColumnListBlockRequest.cs
new file mode 100644
index 00000000..431acf8e
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/ColumnListBlockRequest.cs
@@ -0,0 +1,19 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class ColumnListBlockRequest : BlockObjectRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("column_list")]
+ public Info ColumnList { get; set; }
+
+ public override BlockType Type => BlockType.ColumnList;
+
+ public class Info
+ {
+ [JsonProperty("children")]
+ public IEnumerable Children { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/DividerBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/DividerBlockRequest.cs
new file mode 100644
index 00000000..49c81059
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/DividerBlockRequest.cs
@@ -0,0 +1,16 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class DividerBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("divider")]
+ public Data Divider { get; set; }
+
+ public override BlockType Type => BlockType.Divider;
+
+ public class Data
+ {
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/EmbedBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/EmbedBlockRequest.cs
new file mode 100644
index 00000000..81cb2339
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/EmbedBlockRequest.cs
@@ -0,0 +1,22 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class EmbedBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("embed")]
+ public Info Embed { get; set; }
+
+ public override BlockType Type => BlockType.Embed;
+
+ public class Info
+ {
+ [JsonProperty("url")]
+ public string Url { get; set; }
+
+ [JsonProperty("caption")]
+ public IEnumerable Caption { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/EquationBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/EquationBlockRequest.cs
new file mode 100644
index 00000000..5c2ddb8a
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/EquationBlockRequest.cs
@@ -0,0 +1,18 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class EquationBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("equation")]
+ public Info Equation { get; set; }
+
+ public override BlockType Type => BlockType.Equation;
+
+ public class Info
+ {
+ [JsonProperty("expression")]
+ public string Expression { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/FileBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/FileBlockRequest.cs
new file mode 100644
index 00000000..0539c41c
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/FileBlockRequest.cs
@@ -0,0 +1,12 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class FileBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("file")]
+ public FileObject File { get; set; }
+
+ public override BlockType Type => BlockType.File;
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/HeadingOneBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/HeadingOneBlockRequest.cs
new file mode 100644
index 00000000..dd91451a
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/HeadingOneBlockRequest.cs
@@ -0,0 +1,29 @@
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+
+namespace Notion.Client
+{
+ public class HeadingOneBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("heading_1")]
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
+ public Info Heading_1 { get; set; }
+
+ public override BlockType Type => BlockType.Heading_1;
+
+ public class Info
+ {
+ [JsonProperty("rich_text")]
+ public IEnumerable RichText { get; set; }
+
+ [JsonProperty("color")]
+ [JsonConverter(typeof(StringEnumConverter))]
+ public Color? Color { get; set; }
+
+ [JsonProperty("is_toggleable")]
+ public bool IsToggleable { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/HeadingThreeBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/HeadingThreeBlockRequest.cs
new file mode 100644
index 00000000..9b78c80e
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/HeadingThreeBlockRequest.cs
@@ -0,0 +1,29 @@
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+
+namespace Notion.Client
+{
+ public class HeadingThreeBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("heading_3")]
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
+ public Info Heading_3 { get; set; }
+
+ public override BlockType Type => BlockType.Heading_3;
+
+ public class Info
+ {
+ [JsonProperty("rich_text")]
+ public IEnumerable RichText { get; set; }
+
+ [JsonProperty("color")]
+ [JsonConverter(typeof(StringEnumConverter))]
+ public Color? Color { get; set; }
+
+ [JsonProperty("is_toggleable")]
+ public bool IsToggleable { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/HeadingTwoBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/HeadingTwoBlockRequest.cs
new file mode 100644
index 00000000..dfdeb9dd
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/HeadingTwoBlockRequest.cs
@@ -0,0 +1,29 @@
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+
+namespace Notion.Client
+{
+ public class HeadingTwoBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("heading_2")]
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
+ public Info Heading_2 { get; set; }
+
+ public override BlockType Type => BlockType.Heading_2;
+
+ public class Info
+ {
+ [JsonProperty("rich_text")]
+ public IEnumerable RichText { get; set; }
+
+ [JsonProperty("color")]
+ [JsonConverter(typeof(StringEnumConverter))]
+ public Color? Color { get; set; }
+
+ [JsonProperty("is_toggleable")]
+ public bool IsToggleable { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/IBlockObjectRequest.cs b/Src/Notion.Client/Models/Blocks/Request/IBlockObjectRequest.cs
new file mode 100644
index 00000000..b3fbaf55
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/IBlockObjectRequest.cs
@@ -0,0 +1,19 @@
+using JsonSubTypes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+
+namespace Notion.Client
+{
+ public interface IBlockObjectRequest : IObject, IObjectModificationData
+ {
+ [JsonProperty("type")]
+ [JsonConverter(typeof(StringEnumConverter))]
+ BlockType Type { get; }
+
+ [JsonProperty("has_children")]
+ bool HasChildren { get; set; }
+
+ [JsonProperty("parent")]
+ IBlockParent Parent { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/IColumnChildrenBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/IColumnChildrenBlockRequest.cs
new file mode 100644
index 00000000..54e08fab
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/IColumnChildrenBlockRequest.cs
@@ -0,0 +1,18 @@
+namespace Notion.Client
+{
+ public interface ITemplateChildrenBlockRequest : IBlockObjectRequest
+ {
+ }
+
+ public interface ISyncedBlockChildrenRequest : IBlockObjectRequest
+ {
+ }
+
+ public interface IColumnChildrenBlockRequest : ITemplateChildrenBlockRequest, ISyncedBlockChildrenRequest
+ {
+ }
+
+ public interface INonColumnBlockRequest : IBlockObjectRequest
+ {
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/ImageBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/ImageBlockRequest.cs
new file mode 100644
index 00000000..d3ec252b
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/ImageBlockRequest.cs
@@ -0,0 +1,12 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class ImageBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("image")]
+ public FileObject Image { get; set; }
+
+ public override BlockType Type => BlockType.Image;
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/LinkPreviewBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/LinkPreviewBlockRequest.cs
new file mode 100644
index 00000000..11a47592
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/LinkPreviewBlockRequest.cs
@@ -0,0 +1,18 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class LinkPreviewBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("link_preview")]
+ public Data LinkPreview { get; set; }
+
+ public override BlockType Type => BlockType.LinkPreview;
+
+ public class Data
+ {
+ [JsonProperty("url")]
+ public string Url { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/LinkToPageBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/LinkToPageBlockRequest.cs
new file mode 100644
index 00000000..ec182df5
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/LinkToPageBlockRequest.cs
@@ -0,0 +1,12 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class LinkToPageBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("link_to_page")]
+ public IPageParent LinkToPage { get; set; }
+
+ public override BlockType Type => BlockType.LinkToPage;
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/NumberedListItemBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/NumberedListItemBlockRequest.cs
new file mode 100644
index 00000000..87342c1d
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/NumberedListItemBlockRequest.cs
@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+
+namespace Notion.Client
+{
+ public class NumberedListItemBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("numbered_list_item")]
+ public Info NumberedListItem { get; set; }
+
+ public override BlockType Type => BlockType.NumberedListItem;
+
+ public class Info
+ {
+ [JsonProperty("rich_text")]
+ public IEnumerable RichText { get; set; }
+
+ [JsonProperty("color")]
+ [JsonConverter(typeof(StringEnumConverter))]
+ public Color? Color { get; set; }
+
+ [JsonProperty("children")]
+ public IEnumerable Children { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/PDFBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/PDFBlockRequest.cs
new file mode 100644
index 00000000..5590000d
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/PDFBlockRequest.cs
@@ -0,0 +1,14 @@
+using System.Diagnostics.CodeAnalysis;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
+ public class PDFBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("pdf")]
+ public FileObject PDF { get; set; }
+
+ public override BlockType Type => BlockType.PDF;
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/ParagraphBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/ParagraphBlockRequest.cs
new file mode 100644
index 00000000..8e8dfa51
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/ParagraphBlockRequest.cs
@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+
+namespace Notion.Client
+{
+ public class ParagraphBlockRequest : Block, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("paragraph")]
+ public Info Paragraph { get; set; }
+
+ public override BlockType Type => BlockType.Paragraph;
+
+ public class Info
+ {
+ [JsonProperty("rich_text")]
+ public IEnumerable RichText { get; set; }
+
+ [JsonProperty("color")]
+ [JsonConverter(typeof(StringEnumConverter))]
+ public Color? Color { get; set; }
+
+ [JsonProperty("children")]
+ public IEnumerable Children { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/QuoteBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/QuoteBlockRequest.cs
new file mode 100644
index 00000000..3acd3130
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/QuoteBlockRequest.cs
@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+
+namespace Notion.Client
+{
+ public class QuoteBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("quote")]
+ public Info Quote { get; set; }
+
+ public override BlockType Type => BlockType.Quote;
+
+ public class Info
+ {
+ [JsonProperty("rich_text")]
+ public IEnumerable RichText { get; set; }
+
+ [JsonProperty("color")]
+ [JsonConverter(typeof(StringEnumConverter))]
+ public Color? Color { get; set; }
+
+ [JsonProperty("children")]
+ public IEnumerable Children { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/SyncedBlockBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/SyncedBlockBlockRequest.cs
new file mode 100644
index 00000000..5338e5bb
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/SyncedBlockBlockRequest.cs
@@ -0,0 +1,31 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class SyncedBlockBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("synced_block")]
+ public Data SyncedBlock { get; set; }
+
+ public override BlockType Type => BlockType.SyncedBlock;
+
+ public class Data
+ {
+ [JsonProperty("synced_from")]
+ public SyncedFromBlockId SyncedFrom { get; set; }
+
+ [JsonProperty("children")]
+ public IEnumerable Children { get; set; }
+
+ public class SyncedFromBlockId
+ {
+ [JsonProperty("type")]
+ public string Type { get; set; }
+
+ [JsonProperty("block_id")]
+ public string BlockId { get; set; }
+ }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/TableBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/TableBlockRequest.cs
new file mode 100644
index 00000000..1e966182
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/TableBlockRequest.cs
@@ -0,0 +1,28 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class TableBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("table")]
+ public Info Table { get; set; }
+
+ public override BlockType Type => BlockType.Table;
+
+ public class Info
+ {
+ [JsonProperty("table_width")]
+ public int TableWidth { get; set; }
+
+ [JsonProperty("has_column_header")]
+ public bool HasColumnHeader { get; set; }
+
+ [JsonProperty("has_row_header")]
+ public bool HasRowHeader { get; set; }
+
+ [JsonProperty("children")]
+ public IEnumerable Children { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/TableOfContentsBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/TableOfContentsBlockRequest.cs
new file mode 100644
index 00000000..2aef499d
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/TableOfContentsBlockRequest.cs
@@ -0,0 +1,20 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+
+namespace Notion.Client
+{
+ public class TableOfContentsBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("table_of_contents")]
+ public Data TableOfContents { get; set; }
+
+ public override BlockType Type => BlockType.TableOfContents;
+
+ public class Data
+ {
+ [JsonProperty("color")]
+ [JsonConverter(typeof(StringEnumConverter))]
+ public Color? Color { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/TableRowBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/TableRowBlockRequest.cs
new file mode 100644
index 00000000..ead85b33
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/TableRowBlockRequest.cs
@@ -0,0 +1,19 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class TableRowBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("table_row")]
+ public Info TableRow { get; set; }
+
+ public override BlockType Type => BlockType.TableRow;
+
+ public class Info
+ {
+ [JsonProperty("cells")]
+ public IEnumerable> Cells { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/TemplateBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/TemplateBlockRequest.cs
new file mode 100644
index 00000000..04c161d2
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/TemplateBlockRequest.cs
@@ -0,0 +1,22 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class TemplateBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("template")]
+ public Data Template { get; set; }
+
+ public override BlockType Type => BlockType.Template;
+
+ public class Data
+ {
+ [JsonProperty("rich_text")]
+ public IEnumerable RichText { get; set; }
+
+ [JsonProperty("children")]
+ public IEnumerable Children { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/ToDoBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/ToDoBlockRequest.cs
new file mode 100644
index 00000000..ed7b09c3
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/ToDoBlockRequest.cs
@@ -0,0 +1,30 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+
+namespace Notion.Client
+{
+ public class ToDoBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("to_do")]
+ public Info ToDo { get; set; }
+
+ public override BlockType Type => BlockType.ToDo;
+
+ public class Info
+ {
+ [JsonProperty("rich_text")]
+ public IEnumerable RichText { get; set; }
+
+ [JsonProperty("checked")]
+ public bool IsChecked { get; set; }
+
+ [JsonProperty("color")]
+ [JsonConverter(typeof(StringEnumConverter))]
+ public Color? Color { get; set; }
+
+ [JsonProperty("children")]
+ public IEnumerable Children { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/ToggleBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/ToggleBlockRequest.cs
new file mode 100644
index 00000000..fbbbcd37
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/ToggleBlockRequest.cs
@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+
+namespace Notion.Client
+{
+ public class ToggleBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("toggle")]
+ public Info Toggle { get; set; }
+
+ public override BlockType Type => BlockType.Toggle;
+
+ public class Info
+ {
+ [JsonProperty("rich_text")]
+ public IEnumerable RichText { get; set; }
+
+ [JsonProperty("color")]
+ [JsonConverter(typeof(StringEnumConverter))]
+ public Color? Color { get; set; }
+
+ [JsonProperty("children")]
+ public IEnumerable Children { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/Request/VideoBlockRequest.cs b/Src/Notion.Client/Models/Blocks/Request/VideoBlockRequest.cs
new file mode 100644
index 00000000..238b2d26
--- /dev/null
+++ b/Src/Notion.Client/Models/Blocks/Request/VideoBlockRequest.cs
@@ -0,0 +1,12 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class VideoBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest
+ {
+ [JsonProperty("video")]
+ public FileObject Video { get; set; }
+
+ public override BlockType Type => BlockType.Video;
+ }
+}
diff --git a/Src/Notion.Client/Models/Blocks/SyncedBlockBlock.cs b/Src/Notion.Client/Models/Blocks/SyncedBlockBlock.cs
index 33c4dd25..98aa1d0f 100644
--- a/Src/Notion.Client/Models/Blocks/SyncedBlockBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/SyncedBlockBlock.cs
@@ -5,11 +5,11 @@ namespace Notion.Client
{
public class SyncedBlockBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.SyncedBlock;
-
[JsonProperty("synced_block")]
public Data SyncedBlock { get; set; }
+ public override BlockType Type => BlockType.SyncedBlock;
+
public class Data
{
[JsonProperty("synced_from")]
diff --git a/Src/Notion.Client/Models/Blocks/TableBlock.cs b/Src/Notion.Client/Models/Blocks/TableBlock.cs
index dd20d94b..80fe72bc 100644
--- a/Src/Notion.Client/Models/Blocks/TableBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/TableBlock.cs
@@ -1,15 +1,16 @@
-using Newtonsoft.Json;
+using System.Collections.Generic;
+using Newtonsoft.Json;
namespace Notion.Client
{
public class TableBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.Table;
-
[JsonProperty("table")]
- public TableInfo Table { get; set; }
+ public Info Table { get; set; }
+
+ public override BlockType Type => BlockType.Table;
- public class TableInfo
+ public class Info
{
[JsonProperty("table_width")]
public int TableWidth { get; set; }
@@ -21,7 +22,7 @@ public class TableInfo
public bool HasRowHeader { get; set; }
[JsonProperty("children")]
- public TableRowBlock Children { get; set; }
+ public IEnumerable Children { get; set; }
}
}
}
diff --git a/Src/Notion.Client/Models/Blocks/TableOfContentsBlock.cs b/Src/Notion.Client/Models/Blocks/TableOfContentsBlock.cs
index 991ff903..0a6c9f26 100644
--- a/Src/Notion.Client/Models/Blocks/TableOfContentsBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/TableOfContentsBlock.cs
@@ -5,11 +5,11 @@ namespace Notion.Client
{
public class TableOfContentsBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.TableOfContents;
-
[JsonProperty("table_of_contents")]
public Data TableOfContents { get; set; }
+ public override BlockType Type => BlockType.TableOfContents;
+
public class Data
{
[JsonProperty("color")]
diff --git a/Src/Notion.Client/Models/Blocks/TableRowBlock.cs b/Src/Notion.Client/Models/Blocks/TableRowBlock.cs
index e7214e6c..be105447 100644
--- a/Src/Notion.Client/Models/Blocks/TableRowBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/TableRowBlock.cs
@@ -5,11 +5,11 @@ namespace Notion.Client
{
public class TableRowBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.TableRow;
-
[JsonProperty("table_row")]
public Info TableRow { get; set; }
+ public override BlockType Type => BlockType.TableRow;
+
public class Info
{
[JsonProperty("cells")]
diff --git a/Src/Notion.Client/Models/Blocks/TemplateBlock.cs b/Src/Notion.Client/Models/Blocks/TemplateBlock.cs
index 69a78b62..867e7c85 100644
--- a/Src/Notion.Client/Models/Blocks/TemplateBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/TemplateBlock.cs
@@ -5,18 +5,18 @@ namespace Notion.Client
{
public class TemplateBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.Template;
-
[JsonProperty("template")]
public Data Template { get; set; }
+ public override BlockType Type => BlockType.Template;
+
public class Data
{
[JsonProperty("rich_text")]
public IEnumerable RichText { get; set; }
[JsonProperty("children")]
- public IEnumerable Children { get; set; }
+ public IEnumerable Children { get; set; }
}
}
}
diff --git a/Src/Notion.Client/Models/Blocks/ToDoBlock.cs b/Src/Notion.Client/Models/Blocks/ToDoBlock.cs
index 8b153f3b..0c52201a 100644
--- a/Src/Notion.Client/Models/Blocks/ToDoBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/ToDoBlock.cs
@@ -6,11 +6,11 @@ namespace Notion.Client
{
public class ToDoBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.ToDo;
-
[JsonProperty("to_do")]
public Info ToDo { get; set; }
+ public override BlockType Type => BlockType.ToDo;
+
public class Info
{
[JsonProperty("rich_text")]
diff --git a/Src/Notion.Client/Models/Blocks/ToggleBlock.cs b/Src/Notion.Client/Models/Blocks/ToggleBlock.cs
index 6646e9be..f61a1368 100644
--- a/Src/Notion.Client/Models/Blocks/ToggleBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/ToggleBlock.cs
@@ -6,11 +6,11 @@ namespace Notion.Client
{
public class ToggleBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.Toggle;
-
[JsonProperty("toggle")]
public Info Toggle { get; set; }
+ public override BlockType Type => BlockType.Toggle;
+
public class Info
{
[JsonProperty("rich_text")]
diff --git a/Src/Notion.Client/Models/Blocks/VideoBlock.cs b/Src/Notion.Client/Models/Blocks/VideoBlock.cs
index 015bed96..7713ff7b 100644
--- a/Src/Notion.Client/Models/Blocks/VideoBlock.cs
+++ b/Src/Notion.Client/Models/Blocks/VideoBlock.cs
@@ -4,9 +4,9 @@ namespace Notion.Client
{
public class VideoBlock : Block, IColumnChildrenBlock, INonColumnBlock
{
- public override BlockType Type => BlockType.Video;
-
[JsonProperty("video")]
public FileObject Video { get; set; }
+
+ public override BlockType Type => BlockType.Video;
}
}
diff --git a/Src/Notion.Client/Models/Common/IObjectModificationData.cs b/Src/Notion.Client/Models/Common/IObjectModificationData.cs
index 06177ccd..0e70ffcf 100644
--- a/Src/Notion.Client/Models/Common/IObjectModificationData.cs
+++ b/Src/Notion.Client/Models/Common/IObjectModificationData.cs
@@ -6,25 +6,25 @@ namespace Notion.Client
public interface IObjectModificationData
{
///
- /// Date and time when this object was created.
+ /// Date and time when this object was created.
///
[JsonProperty("created_time")]
DateTime CreatedTime { get; set; }
///
- /// Date and time when this object was updated.
+ /// Date and time when this object was updated.
///
[JsonProperty("last_edited_time")]
DateTime LastEditedTime { get; set; }
///
- /// User who created the object.
+ /// User who created the object.
///
[JsonProperty("created_by")]
PartialUser CreatedBy { get; set; }
///
- /// User who last modified the object.
+ /// User who last modified the object.
///
[JsonProperty("last_edited_by")]
PartialUser LastEditedBy { get; set; }
diff --git a/Src/Notion.Client/Models/CustomEmoji.cs b/Src/Notion.Client/Models/CustomEmoji.cs
new file mode 100644
index 00000000..0f7a4c48
--- /dev/null
+++ b/Src/Notion.Client/Models/CustomEmoji.cs
@@ -0,0 +1,16 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class CustomEmoji
+ {
+ [JsonProperty("id")]
+ public string Id { get; set; }
+
+ [JsonProperty("name")]
+ public string Name { get; set; }
+
+ [JsonProperty("url")]
+ public string Url { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Models/CustomEmojiObject.cs b/Src/Notion.Client/Models/CustomEmojiObject.cs
new file mode 100644
index 00000000..1faa4d74
--- /dev/null
+++ b/Src/Notion.Client/Models/CustomEmojiObject.cs
@@ -0,0 +1,13 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class CustomEmojiObject : IPageIcon
+ {
+ [JsonProperty("custom_emoji")]
+ public CustomEmoji CustomEmoji { get; set; }
+
+ [JsonProperty("type")]
+ public string Type { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Models/Database/Database.cs b/Src/Notion.Client/Models/Database/Database.cs
index 502d8a5a..be288ea0 100644
--- a/Src/Notion.Client/Models/Database/Database.cs
+++ b/Src/Notion.Client/Models/Database/Database.cs
@@ -4,18 +4,8 @@
namespace Notion.Client
{
- public class Database : IObject, IObjectModificationData
+ public class Database : IObject, IObjectModificationData, IWikiDatabase
{
- public ObjectType Object => ObjectType.Database;
-
- public string Id { get; set; }
-
- [JsonProperty("created_time")]
- public DateTime CreatedTime { get; set; }
-
- [JsonProperty("last_edited_time")]
- public DateTime LastEditedTime { get; set; }
-
[JsonProperty("title")]
public List Title { get; set; }
@@ -32,25 +22,38 @@ public class Database : IObject, IObjectModificationData
public FileObject Cover { get; set; }
///
- /// The URL of the Notion database.
+ /// The URL of the Notion database.
///
[JsonProperty("url")]
public string Url { get; set; }
- ///
- /// The archived status of the database.
- ///
- [JsonProperty("archived")]
- public bool Archived { get; set; }
-
- public PartialUser CreatedBy { get; set; }
-
- public PartialUser LastEditedBy { get; set; }
+ [JsonProperty("in_trash")]
+ public bool InTrash { get; set; }
[JsonProperty("is_inline")]
public bool IsInline { get; set; }
[JsonProperty("description")]
public IEnumerable Description { get; set; }
+
+ public ObjectType Object => ObjectType.Database;
+
+ public string Id { get; set; }
+
+ [JsonProperty("created_time")]
+ public DateTime CreatedTime { get; set; }
+
+ [JsonProperty("last_edited_time")]
+ public DateTime LastEditedTime { get; set; }
+
+ public PartialUser CreatedBy { get; set; }
+
+ public PartialUser LastEditedBy { get; set; }
+
+ ///
+ /// The public page URL if the page has been published to the web. Otherwise, null.
+ ///
+ [JsonProperty("public_url")]
+ public string PublicUrl { get; set; }
}
}
diff --git a/Src/Notion.Client/Models/Database/IDatabaseParent.cs b/Src/Notion.Client/Models/Database/IDatabaseParent.cs
index 59233c38..768f815b 100644
--- a/Src/Notion.Client/Models/Database/IDatabaseParent.cs
+++ b/Src/Notion.Client/Models/Database/IDatabaseParent.cs
@@ -4,9 +4,9 @@
namespace Notion.Client
{
[JsonConverter(typeof(JsonSubtypes), "type")]
- [JsonSubtypes.KnownSubType(typeof(PageParent), ParentType.PageId)]
- [JsonSubtypes.KnownSubType(typeof(WorkspaceParent), ParentType.Workspace)]
- [JsonSubtypes.KnownSubType(typeof(BlockParent), ParentType.BlockId)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(PageParent), ParentType.PageId)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(WorkspaceParent), ParentType.Workspace)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(BlockParent), ParentType.BlockId)]
public interface IDatabaseParent : IParent
{
}
diff --git a/Src/Notion.Client/Models/Database/IWikiDatabase.cs b/Src/Notion.Client/Models/Database/IWikiDatabase.cs
new file mode 100644
index 00000000..59969175
--- /dev/null
+++ b/Src/Notion.Client/Models/Database/IWikiDatabase.cs
@@ -0,0 +1,12 @@
+using JsonSubTypes;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ [JsonConverter(typeof(JsonSubtypes), "object")]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(Page), ObjectType.Page)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(Database), ObjectType.Database)]
+ public interface IWikiDatabase : IObject
+ {
+ }
+}
diff --git a/Src/Notion.Client/Models/Database/Properties/ButtonProperty.cs b/Src/Notion.Client/Models/Database/Properties/ButtonProperty.cs
new file mode 100644
index 00000000..983138e2
--- /dev/null
+++ b/Src/Notion.Client/Models/Database/Properties/ButtonProperty.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Newtonsoft.Json;
+using System.Threading.Tasks;
+
+namespace Notion.Client
+{
+ public class ButtonProperty : Property
+ {
+ public override PropertyType Type => PropertyType.Button;
+
+ [JsonProperty("button")]
+ public Dictionary Button { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Models/Database/Properties/Property.cs b/Src/Notion.Client/Models/Database/Properties/Property.cs
index 1f61b0dc..6392bbaf 100644
--- a/Src/Notion.Client/Models/Database/Properties/Property.cs
+++ b/Src/Notion.Client/Models/Database/Properties/Property.cs
@@ -5,26 +5,28 @@
namespace Notion.Client
{
[JsonConverter(typeof(JsonSubtypes), "type")]
- [JsonSubtypes.KnownSubType(typeof(CheckboxProperty), PropertyType.Checkbox)]
- [JsonSubtypes.KnownSubType(typeof(CreatedByProperty), PropertyType.CreatedBy)]
- [JsonSubtypes.KnownSubType(typeof(CreatedTimeProperty), PropertyType.CreatedTime)]
- [JsonSubtypes.KnownSubType(typeof(DateProperty), PropertyType.Date)]
- [JsonSubtypes.KnownSubType(typeof(EmailProperty), PropertyType.Email)]
- [JsonSubtypes.KnownSubType(typeof(FilesProperty), PropertyType.Files)]
- [JsonSubtypes.KnownSubType(typeof(FormulaProperty), PropertyType.Formula)]
- [JsonSubtypes.KnownSubType(typeof(LastEditedByProperty), PropertyType.LastEditedBy)]
- [JsonSubtypes.KnownSubType(typeof(LastEditedTimeProperty), PropertyType.LastEditedTime)]
- [JsonSubtypes.KnownSubType(typeof(MultiSelectProperty), PropertyType.MultiSelect)]
- [JsonSubtypes.KnownSubType(typeof(NumberProperty), PropertyType.Number)]
- [JsonSubtypes.KnownSubType(typeof(PeopleProperty), PropertyType.People)]
- [JsonSubtypes.KnownSubType(typeof(PhoneNumberProperty), PropertyType.PhoneNumber)]
- [JsonSubtypes.KnownSubType(typeof(RelationProperty), PropertyType.Relation)]
- [JsonSubtypes.KnownSubType(typeof(RichTextProperty), PropertyType.RichText)]
- [JsonSubtypes.KnownSubType(typeof(RollupProperty), PropertyType.Rollup)]
- [JsonSubtypes.KnownSubType(typeof(SelectProperty), PropertyType.Select)]
- [JsonSubtypes.KnownSubType(typeof(StatusProperty), PropertyType.Status)]
- [JsonSubtypes.KnownSubType(typeof(TitleProperty), PropertyType.Title)]
- [JsonSubtypes.KnownSubType(typeof(UrlProperty), PropertyType.Url)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(CheckboxProperty), PropertyType.Checkbox)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(CreatedByProperty), PropertyType.CreatedBy)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(CreatedTimeProperty), PropertyType.CreatedTime)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(DateProperty), PropertyType.Date)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(EmailProperty), PropertyType.Email)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(FilesProperty), PropertyType.Files)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(FormulaProperty), PropertyType.Formula)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(LastEditedByProperty), PropertyType.LastEditedBy)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(LastEditedTimeProperty), PropertyType.LastEditedTime)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(MultiSelectProperty), PropertyType.MultiSelect)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(NumberProperty), PropertyType.Number)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(PeopleProperty), PropertyType.People)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(PhoneNumberProperty), PropertyType.PhoneNumber)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(RelationProperty), PropertyType.Relation)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(RichTextProperty), PropertyType.RichText)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(RollupProperty), PropertyType.Rollup)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(SelectProperty), PropertyType.Select)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(StatusProperty), PropertyType.Status)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(TitleProperty), PropertyType.Title)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(UrlProperty), PropertyType.Url)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(UniqueIdProperty), PropertyType.UniqueId)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(ButtonProperty), PropertyType.Button)]
public class Property
{
[JsonProperty("id")]
diff --git a/Src/Notion.Client/Models/Database/Properties/PropertyType.cs b/Src/Notion.Client/Models/Database/Properties/PropertyType.cs
index a67b8cd8..206f9fe2 100644
--- a/Src/Notion.Client/Models/Database/Properties/PropertyType.cs
+++ b/Src/Notion.Client/Models/Database/Properties/PropertyType.cs
@@ -1,7 +1,9 @@
-using System.Runtime.Serialization;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.Serialization;
namespace Notion.Client
{
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
public enum PropertyType
{
[EnumMember(Value = null)]
@@ -66,5 +68,11 @@ public enum PropertyType
[EnumMember(Value = "status")]
Status,
+
+ [EnumMember(Value = "unique_id")]
+ UniqueId,
+
+ [EnumMember(Value = "button")]
+ Button,
}
}
diff --git a/Src/Notion.Client/Models/Database/Properties/RelationProperty.cs b/Src/Notion.Client/Models/Database/Properties/RelationProperty.cs
deleted file mode 100644
index 48ffc4e3..00000000
--- a/Src/Notion.Client/Models/Database/Properties/RelationProperty.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using Newtonsoft.Json;
-
-namespace Notion.Client
-{
- public class RelationProperty : Property
- {
- public override PropertyType Type => PropertyType.Relation;
-
-
- [JsonProperty("relation")]
- public Relation Relation { get; set; }
- }
-
- public class Relation
- {
- [JsonProperty("database_id")]
- public string DatabaseId { get; set; }
-
- [JsonProperty("synced_property_name")]
- public string SyncedPropertyName { get; set; }
-
- [JsonProperty("synced_property_id")]
- public string SyncedPropertyId { get; set; }
- }
-}
diff --git a/Src/Notion.Client/Models/Database/Properties/RelationProperty/DualPropertyRelation.cs b/Src/Notion.Client/Models/Database/Properties/RelationProperty/DualPropertyRelation.cs
new file mode 100644
index 00000000..f1c8c1ec
--- /dev/null
+++ b/Src/Notion.Client/Models/Database/Properties/RelationProperty/DualPropertyRelation.cs
@@ -0,0 +1,21 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class DualPropertyRelation : RelationData
+ {
+ public override RelationType Type => RelationType.Dual;
+
+ [JsonProperty("dual_property")]
+ public Data DualProperty { get; set; }
+
+ public class Data
+ {
+ [JsonProperty("synced_property_name")]
+ public string SyncedPropertyName { get; set; }
+
+ [JsonProperty("synced_property_id")]
+ public string SyncedPropertyId { get; set; }
+ }
+ }
+}
diff --git a/Src/Notion.Client/Models/Database/Properties/RelationProperty/RelationData.cs b/Src/Notion.Client/Models/Database/Properties/RelationProperty/RelationData.cs
new file mode 100644
index 00000000..d129acc6
--- /dev/null
+++ b/Src/Notion.Client/Models/Database/Properties/RelationProperty/RelationData.cs
@@ -0,0 +1,19 @@
+using JsonSubTypes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+
+namespace Notion.Client
+{
+ [JsonConverter(typeof(JsonSubtypes), "type")]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(SinglePropertyRelation), RelationType.Single)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(DualPropertyRelation), RelationType.Dual)]
+ public abstract class RelationData
+ {
+ [JsonProperty("database_id")]
+ public string DatabaseId { get; set; }
+
+ [JsonProperty("type")]
+ [JsonConverter(typeof(StringEnumConverter))]
+ public virtual RelationType Type { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Models/Database/Properties/RelationProperty/RelationProperty.cs b/Src/Notion.Client/Models/Database/Properties/RelationProperty/RelationProperty.cs
new file mode 100644
index 00000000..382e7088
--- /dev/null
+++ b/Src/Notion.Client/Models/Database/Properties/RelationProperty/RelationProperty.cs
@@ -0,0 +1,12 @@
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class RelationProperty : Property
+ {
+ public override PropertyType Type => PropertyType.Relation;
+
+ [JsonProperty("relation")]
+ public RelationData Relation { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Models/Database/Properties/RelationProperty/RelationType.cs b/Src/Notion.Client/Models/Database/Properties/RelationProperty/RelationType.cs
new file mode 100644
index 00000000..89ce1c56
--- /dev/null
+++ b/Src/Notion.Client/Models/Database/Properties/RelationProperty/RelationType.cs
@@ -0,0 +1,13 @@
+using System.Runtime.Serialization;
+
+namespace Notion.Client
+{
+ public enum RelationType
+ {
+ [EnumMember(Value = "single_property")]
+ Single,
+
+ [EnumMember(Value = "dual_property")]
+ Dual
+ }
+}
diff --git a/Src/Notion.Client/Models/Database/Properties/RelationProperty/SinglePropertyRelation.cs b/Src/Notion.Client/Models/Database/Properties/RelationProperty/SinglePropertyRelation.cs
new file mode 100644
index 00000000..9ba8ae12
--- /dev/null
+++ b/Src/Notion.Client/Models/Database/Properties/RelationProperty/SinglePropertyRelation.cs
@@ -0,0 +1,13 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class SinglePropertyRelation : RelationData
+ {
+ public override RelationType Type => RelationType.Single;
+
+ [JsonProperty("single_property")]
+ public Dictionary SingleProperty { get; set; }
+ }
+}
diff --git a/Src/Notion.Client/Models/Database/Properties/SelectProperty.cs b/Src/Notion.Client/Models/Database/Properties/SelectProperty.cs
index 3ed99234..f9675443 100644
--- a/Src/Notion.Client/Models/Database/Properties/SelectProperty.cs
+++ b/Src/Notion.Client/Models/Database/Properties/SelectProperty.cs
@@ -1,12 +1,15 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace Notion.Client
{
+ [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")]
public class SelectProperty : Property
{
public override PropertyType Type => PropertyType.Select;
+
public OptionWrapper Select { get; set; }
}
@@ -19,19 +22,20 @@ public class OptionWrapper
public class SelectOption
{
///
- /// Name of the option as it appears in Notion.
+ /// Name of the option as it appears in Notion.
///
[JsonProperty("name")]
public string Name { get; set; }
///
- /// ID of the option.
+ /// ID of the option.
///
[JsonProperty("id")]
public string Id { get; set; }
///
- /// Color of the option. Possible values are: "default", "gray", "brown", "red", "orange", "yellow", "green", "blue", "purple", "pink". Defaults to "default".
+ /// Color of the option. Possible values are: "default", "gray", "brown", "red", "orange", "yellow", "green", "blue",
+ /// "purple", "pink". Defaults to "default".
///
[JsonProperty("color")]
[JsonConverter(typeof(StringEnumConverter))]
diff --git a/Src/Notion.Client/Models/Database/Properties/UniqueIdProperty.cs b/Src/Notion.Client/Models/Database/Properties/UniqueIdProperty.cs
new file mode 100644
index 00000000..4a9e9d5d
--- /dev/null
+++ b/Src/Notion.Client/Models/Database/Properties/UniqueIdProperty.cs
@@ -0,0 +1,14 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
+{
+ public class UniqueIdProperty : Property
+ {
+ public override PropertyType Type => PropertyType.UniqueId;
+
+ [JsonProperty("unique_id")]
+ public Dictionary UniqueId { get; set; }
+ }
+}
+
diff --git a/Src/Notion.Client/Models/Database/RichText/RichTextBase.cs b/Src/Notion.Client/Models/Database/RichText/RichTextBase.cs
index 88af1acd..3f10d578 100644
--- a/Src/Notion.Client/Models/Database/RichText/RichTextBase.cs
+++ b/Src/Notion.Client/Models/Database/RichText/RichTextBase.cs
@@ -5,9 +5,9 @@
namespace Notion.Client
{
[JsonConverter(typeof(JsonSubtypes), "type")]
- [JsonSubtypes.KnownSubType(typeof(RichTextText), RichTextType.Text)]
- [JsonSubtypes.KnownSubType(typeof(RichTextEquation), RichTextType.Equation)]
- [JsonSubtypes.KnownSubType(typeof(RichTextMention), RichTextType.Mention)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(RichTextText), RichTextType.Text)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(RichTextEquation), RichTextType.Equation)]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(RichTextMention), RichTextType.Mention)]
public class RichTextBase
{
[JsonProperty("plain_text")]
diff --git a/Src/Notion.Client/Models/Database/RichText/RichTextMention.cs b/Src/Notion.Client/Models/Database/RichText/RichTextMention.cs
index 02f6beb0..5a5b6d0c 100644
--- a/Src/Notion.Client/Models/Database/RichText/RichTextMention.cs
+++ b/Src/Notion.Client/Models/Database/RichText/RichTextMention.cs
@@ -25,7 +25,7 @@ public class Mention
public ObjectId Database { get; set; }
[JsonProperty("date")]
- public DatePropertyValue Date { get; set; }
+ public Date Date { get; set; }
}
public class ObjectId
diff --git a/Src/Notion.Client/Models/Database/RichText/RichTextType.cs b/Src/Notion.Client/Models/Database/RichText/RichTextType.cs
index 59bc414f..91031138 100644
--- a/Src/Notion.Client/Models/Database/RichText/RichTextType.cs
+++ b/Src/Notion.Client/Models/Database/RichText/RichTextType.cs
@@ -1,7 +1,9 @@
-using System.Runtime.Serialization;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.Serialization;
namespace Notion.Client
{
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
public enum RichTextType
{
[EnumMember(Value = null)]
diff --git a/Src/Notion.Client/Models/EmojiObject.cs b/Src/Notion.Client/Models/EmojiObject.cs
index 95c67b61..9b5c64df 100644
--- a/Src/Notion.Client/Models/EmojiObject.cs
+++ b/Src/Notion.Client/Models/EmojiObject.cs
@@ -4,10 +4,10 @@ namespace Notion.Client
{
public class EmojiObject : IPageIcon
{
- [JsonProperty("type")]
- public string Type { get; set; }
-
[JsonProperty("emoji")]
public string Emoji { get; set; }
+
+ [JsonProperty("type")]
+ public string Type { get; set; }
}
}
diff --git a/Src/Notion.Client/Models/File/FIleInput/ExternalFileInput.cs b/Src/Notion.Client/Models/File/FIleInput/ExternalFileInput.cs
index 9c258ceb..6e2627cf 100644
--- a/Src/Notion.Client/Models/File/FIleInput/ExternalFileInput.cs
+++ b/Src/Notion.Client/Models/File/FIleInput/ExternalFileInput.cs
@@ -1,4 +1,5 @@
-using Newtonsoft.Json;
+using System.Collections.Generic;
+using Newtonsoft.Json;
namespace Notion.Client
{
@@ -7,6 +8,12 @@ public class ExternalFileInput : IFileObjectInput
[JsonProperty("external")]
public Data External { get; set; }
+ [JsonProperty("name")]
+ public string Name { get; set; }
+
+ [JsonProperty("caption")]
+ public IEnumerable Caption { get; set; }
+
public class Data
{
[JsonProperty("url")]
diff --git a/Src/Notion.Client/Models/File/FIleInput/IFileObjectInput.cs b/Src/Notion.Client/Models/File/FIleInput/IFileObjectInput.cs
index 31df1573..5883b7c1 100644
--- a/Src/Notion.Client/Models/File/FIleInput/IFileObjectInput.cs
+++ b/Src/Notion.Client/Models/File/FIleInput/IFileObjectInput.cs
@@ -1,6 +1,14 @@
-namespace Notion.Client
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Notion.Client
{
public interface IFileObjectInput
{
+ [JsonProperty("name")]
+ public string Name { get; set; }
+
+ [JsonProperty("caption")]
+ public IEnumerable Caption { get; set; }
}
}
diff --git a/Src/Notion.Client/Models/File/FIleInput/UploadedFileInput.cs b/Src/Notion.Client/Models/File/FIleInput/UploadedFileInput.cs
index 52d7934d..949df10c 100644
--- a/Src/Notion.Client/Models/File/FIleInput/UploadedFileInput.cs
+++ b/Src/Notion.Client/Models/File/FIleInput/UploadedFileInput.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using Newtonsoft.Json;
namespace Notion.Client
@@ -8,6 +9,12 @@ public class UploadedFileInput : IFileObjectInput
[JsonProperty("file")]
public Data File { get; set; }
+ [JsonProperty("name")]
+ public string Name { get; set; }
+
+ [JsonProperty("caption")]
+ public IEnumerable Caption { get; set; }
+
public class Data
{
[JsonProperty("url")]
diff --git a/Src/Notion.Client/Models/File/FileObject.cs b/Src/Notion.Client/Models/File/FileObject.cs
index ce4d02f0..0ac30a6c 100644
--- a/Src/Notion.Client/Models/File/FileObject.cs
+++ b/Src/Notion.Client/Models/File/FileObject.cs
@@ -5,14 +5,20 @@
namespace Notion.Client
{
[JsonConverter(typeof(JsonSubtypes), "type")]
- [JsonSubtypes.KnownSubType(typeof(UploadedFile), "file")]
- [JsonSubtypes.KnownSubType(typeof(ExternalFile), "external")]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(UploadedFile), "file")]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(ExternalFile), "external")]
public abstract class FileObject : IPageIcon
{
- [JsonProperty("type")]
- public virtual string Type { get; set; }
-
[JsonProperty("caption")]
public IEnumerable Caption { get; set; }
+
+ ///
+ /// The name of the file block, as shown in the Notion UI. Note that the UI may auto-append .pdf or other extensions.
+ ///
+ [JsonProperty("name")]
+ public string Name { get; set; }
+
+ [JsonProperty("type")]
+ public virtual string Type { get; set; }
}
}
diff --git a/Src/Notion.Client/Models/File/FileObjectWithName.cs b/Src/Notion.Client/Models/File/FileObjectWithName.cs
index a7381929..855a5e0f 100644
--- a/Src/Notion.Client/Models/File/FileObjectWithName.cs
+++ b/Src/Notion.Client/Models/File/FileObjectWithName.cs
@@ -4,8 +4,8 @@
namespace Notion.Client
{
[JsonConverter(typeof(JsonSubtypes), "type")]
- [JsonSubtypes.KnownSubType(typeof(UploadedFileWithName), "file")]
- [JsonSubtypes.KnownSubType(typeof(ExternalFileWithName), "external")]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(UploadedFileWithName), "file")]
+ [JsonSubtypes.KnownSubTypeAttribute(typeof(ExternalFileWithName), "external")]
public abstract class FileObjectWithName
{
[JsonProperty("type")]
diff --git a/Src/Notion.Client/Models/Filters/CheckboxFilter.cs b/Src/Notion.Client/Models/Filters/CheckboxFilter.cs
index da144aec..53343e35 100644
--- a/Src/Notion.Client/Models/Filters/CheckboxFilter.cs
+++ b/Src/Notion.Client/Models/Filters/CheckboxFilter.cs
@@ -1,35 +1,34 @@
-using System;
-using Newtonsoft.Json;
+using Newtonsoft.Json;
namespace Notion.Client
{
public class CheckboxFilter : SinglePropertyFilter, IRollupSubPropertyFilter
{
- [JsonProperty("checkbox")]
- public Condition Checkbox { get; set; }
-
public CheckboxFilter(
string propertyName,
bool? equal = null,
bool? doesNotEqual = null)
{
Property = propertyName;
- Checkbox = new Condition(equal: equal, doesNotEqual: doesNotEqual);
+ Checkbox = new Condition(equal, doesNotEqual);
}
+ [JsonProperty("checkbox")]
+ public Condition Checkbox { get; set; }
+
public class Condition
{
+ public Condition(bool? equal = null, bool? doesNotEqual = null)
+ {
+ Equal = equal;
+ DoesNotEqual = doesNotEqual;
+ }
+
[JsonProperty("equals")]
public bool? Equal { get; set; }
[JsonProperty("does_not_equal")]
public bool? DoesNotEqual { get; set; }
-
- public Condition(Nullable equal = null, Nullable doesNotEqual = null)
- {
- Equal = equal;
- DoesNotEqual = doesNotEqual;
- }
}
}
}
diff --git a/Src/Notion.Client/Models/Filters/DateFilter.cs b/Src/Notion.Client/Models/Filters/DateFilter.cs
index 51b38dc2..dde7ad47 100644
--- a/Src/Notion.Client/Models/Filters/DateFilter.cs
+++ b/Src/Notion.Client/Models/Filters/DateFilter.cs
@@ -7,9 +7,6 @@ namespace Notion.Client
{
public class DateFilter : SinglePropertyFilter, IRollupSubPropertyFilter
{
- [JsonProperty("date")]
- public Condition Date { get; set; }
-
public DateFilter(
string propertyName,
DateTime? equal = null,
@@ -27,25 +24,59 @@ public DateFilter(
bool? isNotEmpty = null)
{
Property = propertyName;
+
Date = new Condition(
- equal: equal,
- before: before,
- after: after,
- onOrBefore: onOrBefore,
- onOrAfter: onOrAfter,
- pastWeek: pastWeek,
- pastMonth: pastMonth,
- pastYear: pastYear,
- nextWeek: nextWeek,
- nextMonth: nextMonth,
- nextYear: nextYear,
- isEmpty: isEmpty,
- isNotEmpty: isNotEmpty
+ equal,
+ before,
+ after,
+ onOrBefore,
+ onOrAfter,
+ pastWeek,
+ pastMonth,
+ pastYear,
+ nextWeek,
+ nextMonth,
+ nextYear,
+ isEmpty,
+ isNotEmpty
);
}
+ [JsonProperty("date")]
+ public Condition Date { get; set; }
+
public class Condition
{
+ public Condition(
+ DateTime? equal = null,
+ DateTime? before = null,
+ DateTime? after = null,
+ DateTime? onOrBefore = null,
+ DateTime? onOrAfter = null,
+ Dictionary pastWeek = null,
+ Dictionary pastMonth = null,
+ Dictionary pastYear = null,
+ Dictionary nextWeek = null,
+ Dictionary nextMonth = null,
+ Dictionary nextYear = null,
+ bool? isEmpty = null,
+ bool? isNotEmpty = null)
+ {
+ Equal = equal;
+ Before = before;
+ After = after;
+ OnOrBefore = onOrBefore;
+ OnOrAfter = onOrAfter;
+ PastWeek = pastWeek;
+ PastMonth = pastMonth;
+ PastYear = pastYear;
+ NextWeek = nextWeek;
+ NextMonth = nextMonth;
+ NextYear = nextYear;
+ IsEmpty = isEmpty;
+ IsNotEmpty = isNotEmpty;
+ }
+
[JsonProperty("equals")]
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTime? Equal { get; set; }
@@ -89,36 +120,6 @@ public class Condition
[JsonProperty("is_not_empty")]
public bool? IsNotEmpty { get; set; }
-
- public Condition(
- DateTime? equal = null,
- DateTime? before = null,
- DateTime? after = null,
- DateTime? onOrBefore = null,
- DateTime? onOrAfter = null,
- Dictionary pastWeek = null,
- Dictionary pastMonth = null,
- Dictionary pastYear = null,
- Dictionary nextWeek = null,
- Dictionary nextMonth = null,
- Dictionary nextYear = null,
- bool? isEmpty = null,
- bool? isNotEmpty = null)
- {
- Equal = equal;
- Before = before;
- After = after;
- OnOrBefore = onOrBefore;
- OnOrAfter = onOrAfter;
- PastWeek = pastWeek;
- PastMonth = pastMonth;
- PastYear = pastYear;
- NextWeek = nextWeek;
- NextMonth = nextMonth;
- NextYear = nextYear;
- IsEmpty = isEmpty;
- IsNotEmpty = isNotEmpty;
- }
}
}
}
diff --git a/Src/Notion.Client/Models/Filters/EmailFilter.cs b/Src/Notion.Client/Models/Filters/EmailFilter.cs
index ff5feda9..36bc3dde 100644
--- a/Src/Notion.Client/Models/Filters/EmailFilter.cs
+++ b/Src/Notion.Client/Models/Filters/EmailFilter.cs
@@ -4,9 +4,6 @@ namespace Notion.Client
{
public class EmailFilter : SinglePropertyFilter
{
- [JsonProperty("email")]
- public TextFilter.Condition Email { get; set; }
-
public EmailFilter(
string propertyName,
string equal = null,
@@ -19,16 +16,20 @@ public EmailFilter(
bool? isNotEmpty = null)
{
Property = propertyName;
+
Email = new TextFilter.Condition(
- equal: equal,
- doesNotEqual: doesNotEqual,
- contains: contains,
- doesNotContain: doesNotContain,
- startsWith: startsWith,
- endsWith: endsWith,
- isEmpty: isEmpty,
- isNotEmpty: isNotEmpty
+ equal,
+ doesNotEqual,
+ contains,
+ doesNotContain,
+ startsWith,
+ endsWith,
+ isEmpty,
+ isNotEmpty
);
}
+
+ [JsonProperty("email")]
+ public TextFilter.Condition Email { get; set; }
}
}
diff --git a/Src/Notion.Client/Models/Filters/FilesFilter.cs b/Src/Notion.Client/Models/Filters/FilesFilter.cs
index a32d4d7b..6c4b23c6 100644
--- a/Src/Notion.Client/Models/Filters/FilesFilter.cs
+++ b/Src/Notion.Client/Models/Filters/FilesFilter.cs
@@ -4,26 +4,20 @@ namespace Notion.Client
{
public class FilesFilter : SinglePropertyFilter, IRollupSubPropertyFilter
{
- [JsonProperty("files")]
- public Condition Files { get; set; }
-
public FilesFilter(
string propertyName,
bool? isEmpty = null,
bool? isNotEmpty = null)
{
Property = propertyName;
- Files = new Condition(isEmpty: isEmpty, isNotEmpty: isNotEmpty);
+ Files = new Condition(isEmpty, isNotEmpty);
}
+ [JsonProperty("files")]
+ public Condition Files { get; set; }
+
public class Condition
{
- [JsonProperty("is_empty")]
- public bool? IsEmpty { get; set; }
-
- [JsonProperty("is_not_empty")]
- public bool? IsNotEmpty { get; set; }
-
public Condition(
bool? isEmpty = null,
bool? isNotEmpty = null)
@@ -31,6 +25,12 @@ public Condition(
IsEmpty = isEmpty;
IsNotEmpty = isNotEmpty;
}
+
+ [JsonProperty("is_empty")]
+ public bool? IsEmpty { get; set; }
+
+ [JsonProperty("is_not_empty")]
+ public bool? IsNotEmpty { get; set; }
}
}
}
diff --git a/Src/Notion.Client/Models/Filters/Filter.cs b/Src/Notion.Client/Models/Filters/Filter.cs
index 61f81f7e..47eced53 100644
--- a/Src/Notion.Client/Models/Filters/Filter.cs
+++ b/Src/Notion.Client/Models/Filters/Filter.cs
@@ -5,7 +5,6 @@ namespace Notion.Client
{
public class Filter
{
-
}
public class SinglePropertyFilter : Filter
@@ -16,16 +15,16 @@ public class SinglePropertyFilter : Filter
public class CompoundFilter : Filter
{
- [JsonProperty("or")]
- public List