├── .config └── dotnet-tools.json ├── .devcontainer ├── Dockerfile └── devcontainer.json ├── .editorconfig ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── dependabot.yml ├── release-drafter.yml ├── scripts │ └── check.sh └── workflows │ ├── build-artifacts-code.yml │ ├── ci-build.yml │ ├── codeql-analysis.yml │ ├── greetings.yml │ ├── publish-code.yml │ ├── release-drafter.yml │ ├── sonar-cloud-analysis.yml │ └── test-publish-code.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE.md ├── Notion.sln ├── Notion.sln.DotSettings ├── PULL_REQUEST_TEMPLATE.md ├── README.md ├── Src └── Notion.Client │ ├── Api │ ├── ApiEndpoints.cs │ ├── Authentication │ │ ├── AuthenticationClient.cs │ │ ├── CreateToken │ │ │ ├── AuthenticationClient.cs │ │ │ ├── Request │ │ │ │ ├── CreateTokenRequest.cs │ │ │ │ ├── ExternalAccount.cs │ │ │ │ └── ICreateTokenBodyParameters.cs │ │ │ └── Response │ │ │ │ └── CreateTokenResponse.cs │ │ ├── IAuthenticationClient.cs │ │ └── RevokeToken │ │ │ ├── AuthenticationClient.cs │ │ │ ├── Request │ │ │ ├── IRevokeTokenBodyParameters.cs │ │ │ └── RevokeTokenRequest.cs │ │ │ └── Response │ │ │ └── RevokeTokenResponse.cs │ ├── Blocks │ │ ├── AppendChildren │ │ │ ├── BlocksClient.cs │ │ │ ├── Request │ │ │ │ ├── BlockAppendChildrenRequest.cs │ │ │ │ ├── IBlockAppendChildrenBodyParameters.cs │ │ │ │ └── IBlockAppendChildrenPathParameters.cs │ │ │ └── Response │ │ │ │ └── AppendChildrenResponse.cs │ │ ├── BlocksClient.cs │ │ ├── IBlocksClient.cs │ │ ├── RequestParams │ │ │ └── BlocksUpdateParameters │ │ │ │ └── UpdateBlocks │ │ │ │ ├── AudioUpdateBlock.cs │ │ │ │ ├── BookmarkUpdateBlock.cs │ │ │ │ ├── BreadcrumbUpdateBlock.cs │ │ │ │ ├── BulletedListItemUpdateBlock.cs │ │ │ │ ├── CalloutUpdateBlock.cs │ │ │ │ ├── CodeUpdateBlock.cs │ │ │ │ ├── DividerUpdateBlock.cs │ │ │ │ ├── EmbedUpdateBlock.cs │ │ │ │ ├── EquationUpdateBlock.cs │ │ │ │ ├── FileUpdateBlock.cs │ │ │ │ ├── HeadingOneUpdateBlock.cs │ │ │ │ ├── HeadingThreeeUpdateBlock.cs │ │ │ │ ├── HeadingTwoUpdateBlock.cs │ │ │ │ ├── IUpdateBlock.cs │ │ │ │ ├── ImageUpdateBlock.cs │ │ │ │ ├── LinkToPageUpdateBlock.cs │ │ │ │ ├── NumberedListItemUpdateBlock.cs │ │ │ │ ├── PDFUpdateBlock.cs │ │ │ │ ├── ParagraphUpdateBlock.cs │ │ │ │ ├── QuoteUpdateBlock.cs │ │ │ │ ├── SyncedBlockUpdateBlock.cs │ │ │ │ ├── TableOfContentsUpdateBlock.cs │ │ │ │ ├── TableRowUpdateBlock.cs │ │ │ │ ├── TableUpdateBlock.cs │ │ │ │ ├── TemplateUpdateBlock.cs │ │ │ │ ├── ToDoUpdateBlock.cs │ │ │ │ ├── ToggleUpdateBlock.cs │ │ │ │ ├── UpdateBlock.cs │ │ │ │ └── VideoUpdateBlock.cs │ │ └── RetrieveChildren │ │ │ ├── BlocksClient.cs │ │ │ ├── Request │ │ │ ├── BlockRetrieveChildrenRequest.cs │ │ │ ├── IBlockRetrieveChildrenPathParameters.cs │ │ │ └── IBlockRetrieveChildrenQueryParameters.cs │ │ │ └── Response │ │ │ └── RetrieveChildrenResponse.cs │ ├── Comments │ │ ├── CommentsClient.cs │ │ ├── Create │ │ │ ├── CommentsClient.cs │ │ │ ├── Request │ │ │ │ └── CreateCommentParameters.cs │ │ │ └── Response │ │ │ │ └── CreateCommentResponse.cs │ │ ├── ICommentsClient.cs │ │ └── Retrieve │ │ │ ├── CommentsClient.cs │ │ │ ├── Request │ │ │ ├── IRetrieveCommentsQueryParameters.cs │ │ │ └── RetrieveCommentsParameters.cs │ │ │ └── Response │ │ │ ├── Comment.cs │ │ │ ├── Comments.cs │ │ │ └── ICommentParent.cs │ ├── Databases │ │ ├── DatabasesClient.cs │ │ ├── IDatabasesClient.cs │ │ ├── Query │ │ │ ├── DatabasesClient.cs │ │ │ ├── Request │ │ │ │ ├── DatabasesQueryParameters.cs │ │ │ │ ├── IDatabaseQueryBodyParameters.cs │ │ │ │ └── IDatabaseQueryQueryParameters.cs │ │ │ └── Response │ │ │ │ └── DatabaseQueryResponse.cs │ │ └── RequestParams │ │ │ ├── DatabasesCreateParameters │ │ │ ├── DatabasesCreateParameters.cs │ │ │ ├── IDatabasesCreateBodyParameters.cs │ │ │ ├── IDatabasesCreateQueryParameters.cs │ │ │ ├── MentionInput.cs │ │ │ ├── ParentPageInput.cs │ │ │ ├── PropertySchema │ │ │ │ ├── CheckboxPropertySchema.cs │ │ │ │ ├── CreatedByPropertySchema.cs │ │ │ │ ├── CreatedTimePropertySchema.cs │ │ │ │ ├── DatePropertySchema.cs │ │ │ │ ├── EmailPropertySchema.cs │ │ │ │ ├── FilePropertySchema.cs │ │ │ │ ├── FormulaPropertySchema.cs │ │ │ │ ├── IPropertySchema.cs │ │ │ │ ├── LastEditedByPropertySchema.cs │ │ │ │ ├── LastEditedTimePropertySchema.cs │ │ │ │ ├── MultiSelectOptionSchema.cs │ │ │ │ ├── MultiSelectPropertySchema.cs │ │ │ │ ├── NumberPropertySchema.cs │ │ │ │ ├── PeoplePropertySchema.cs │ │ │ │ ├── PhoneNumberPropertySchema.cs │ │ │ │ ├── RelationPropertySchema.cs │ │ │ │ ├── RichTextPropertySchema.cs │ │ │ │ ├── RollupConfigPropertySchema.cs │ │ │ │ ├── SelectOptionSchema.cs │ │ │ │ ├── SelectPropertySchema.cs │ │ │ │ ├── TitlePropertySchema.cs │ │ │ │ └── UrlPropertySchema.cs │ │ │ ├── RichTextBaseInput.cs │ │ │ ├── RichTextEquationInput.cs │ │ │ ├── RichTextMentionInput.cs │ │ │ └── RichTextTextInput.cs │ │ │ ├── DatabasesUpdateParameters │ │ │ ├── DatabasesUpdateParameters.cs │ │ │ ├── IDatabasesUpdateBodyParameters.cs │ │ │ └── PropertySchema │ │ │ │ ├── CheckboxUpdatePropertySchema.cs │ │ │ │ ├── CreatedByUpdatePropertySchema.cs │ │ │ │ ├── CreatedTimeUpdatePropertySchema.cs │ │ │ │ ├── DateUpdatePropertySchema.cs │ │ │ │ ├── EmailUpdatePropertySchema.cs │ │ │ │ ├── FilesUpdatePropertySchema.cs │ │ │ │ ├── FormulaUpdatePropertySchema.cs │ │ │ │ ├── IUpdatePropertySchema.cs │ │ │ │ ├── LastEditedByUpdatePropertySchema.cs │ │ │ │ ├── LastEditedTimeUpdatePropertySchema.cs │ │ │ │ ├── MultiSelectUpdatePropertySchema.cs │ │ │ │ ├── NumberUpdatePropertySchema.cs │ │ │ │ ├── PeopleUpdatePropertySchema.cs │ │ │ │ ├── PhoneNumberUpdatePropertySchema.cs │ │ │ │ ├── RelationUpdatePropertySchema.cs │ │ │ │ ├── RichTextUpdatePropertySchema.cs │ │ │ │ ├── RollupConfigUpdatePropertySchema.cs │ │ │ │ ├── SelectUpdatePropertySchema.cs │ │ │ │ ├── TitleUpdatePropertySchema.cs │ │ │ │ └── URLUpdatePropertySchema.cs │ │ │ ├── Direction.cs │ │ │ ├── Sort.cs │ │ │ └── Timestamp.cs │ ├── Pages │ │ ├── IPagesClient.cs │ │ ├── PagesClient.cs │ │ └── RequestParams │ │ │ ├── IPagesUpdateBodyParameters.cs │ │ │ ├── PagesCreateParameters │ │ │ ├── DatabaseParentInput.cs │ │ │ ├── IPageParentInput.cs │ │ │ ├── IPagesCreateBodyParameters.cs │ │ │ ├── IPagesCreateQueryParameters.cs │ │ │ ├── PagesCreateParameters.cs │ │ │ └── PagesCreateParametersBuilder.cs │ │ │ ├── PagesUpdateParameters.cs │ │ │ └── RetrievePropertyItemParameters │ │ │ ├── IRetrievePropertyItemPathParameters.cs │ │ │ ├── IRetrievePropertyQueryParameters.cs │ │ │ └── RetrievePropertyItemParameters.cs │ ├── Search │ │ ├── ISearchClient.cs │ │ ├── Request │ │ │ ├── ISearchBodyParameters.cs │ │ │ ├── SearchDirection.cs │ │ │ ├── SearchFilter.cs │ │ │ ├── SearchObjectType.cs │ │ │ ├── SearchRequest.cs │ │ │ └── SearchSort.cs │ │ ├── Response │ │ │ └── SearchResponse.cs │ │ └── SearchClient.cs │ └── Users │ │ ├── IUsersClient.cs │ │ ├── List │ │ ├── Request │ │ │ └── ListUsersRequest.cs │ │ ├── Response │ │ │ └── ListUsersResponse.cs │ │ └── UsersClient.cs │ │ └── UsersClient.cs │ ├── Constants.cs │ ├── DI │ └── ServiceCollectionExtensions.cs │ ├── Extensions │ ├── EnumExtensions.cs │ └── HttpResponseMessageExtensions.cs │ ├── Logging │ ├── Log.cs │ └── NotionClientLogging.cs │ ├── Models │ ├── Blocks │ │ ├── AudioBlock.cs │ │ ├── Block.cs │ │ ├── BlockType.cs │ │ ├── BookmarkBlock.cs │ │ ├── BreadcrumbBlock.cs │ │ ├── BulletedListItemBlock.cs │ │ ├── CalloutBlock.cs │ │ ├── ChildDatabaseBlock.cs │ │ ├── ChildPageBlock.cs │ │ ├── CodeBlock.cs │ │ ├── Color.cs │ │ ├── ColumnBlock.cs │ │ ├── ColumnListBlock.cs │ │ ├── DividerBlock.cs │ │ ├── EmbedBlock.cs │ │ ├── EquationBlock.cs │ │ ├── FileBlock.cs │ │ ├── HeadingOneBlock.cs │ │ ├── HeadingThreeBlock.cs │ │ ├── HeadingTwoBlock.cs │ │ ├── IBlock.cs │ │ ├── IBlockParent.cs │ │ ├── IColumnChildrenBlock.cs │ │ ├── ImageBlock.cs │ │ ├── LinkPreviewBlock.cs │ │ ├── LinkToPageBlock.cs │ │ ├── NumberedListItemBlock.cs │ │ ├── PDFBlock.cs │ │ ├── ParagraphBlock.cs │ │ ├── QuoteBlock.cs │ │ ├── Request │ │ │ ├── AudioBlockRequest.cs │ │ │ ├── BlockObjectRequest.cs │ │ │ ├── BookmarkBlockRequest.cs │ │ │ ├── BreadcrumbBlockRequest.cs │ │ │ ├── BulletedListItemBlockRequest.cs │ │ │ ├── CalloutBlockRequest.cs │ │ │ ├── ChildDatabaseBlockRequest.cs │ │ │ ├── ChildPageBlockRequest.cs │ │ │ ├── CodeBlockRequest.cs │ │ │ ├── ColumnBlockRequest.cs │ │ │ ├── ColumnListBlockRequest.cs │ │ │ ├── DividerBlockRequest.cs │ │ │ ├── EmbedBlockRequest.cs │ │ │ ├── EquationBlockRequest.cs │ │ │ ├── FileBlockRequest.cs │ │ │ ├── HeadingOneBlockRequest.cs │ │ │ ├── HeadingThreeBlockRequest.cs │ │ │ ├── HeadingTwoBlockRequest.cs │ │ │ ├── IBlockObjectRequest.cs │ │ │ ├── IColumnChildrenBlockRequest.cs │ │ │ ├── ImageBlockRequest.cs │ │ │ ├── LinkPreviewBlockRequest.cs │ │ │ ├── LinkToPageBlockRequest.cs │ │ │ ├── NumberedListItemBlockRequest.cs │ │ │ ├── PDFBlockRequest.cs │ │ │ ├── ParagraphBlockRequest.cs │ │ │ ├── QuoteBlockRequest.cs │ │ │ ├── SyncedBlockBlockRequest.cs │ │ │ ├── TableBlockRequest.cs │ │ │ ├── TableOfContentsBlockRequest.cs │ │ │ ├── TableRowBlockRequest.cs │ │ │ ├── TemplateBlockRequest.cs │ │ │ ├── ToDoBlockRequest.cs │ │ │ ├── ToggleBlockRequest.cs │ │ │ └── VideoBlockRequest.cs │ │ ├── SyncedBlockBlock.cs │ │ ├── TableBlock.cs │ │ ├── TableOfContentsBlock.cs │ │ ├── TableRowBlock.cs │ │ ├── TemplateBlock.cs │ │ ├── ToDoBlock.cs │ │ ├── ToggleBlock.cs │ │ ├── UnsupportedBlock.cs │ │ └── VideoBlock.cs │ ├── Common │ │ └── IObjectModificationData.cs │ ├── CustomEmoji.cs │ ├── CustomEmojiObject.cs │ ├── Database │ │ ├── Database.cs │ │ ├── IDatabaseParent.cs │ │ ├── IWikiDatabase.cs │ │ ├── Properties │ │ │ ├── ButtonProperty.cs │ │ │ ├── CheckboxProperty.cs │ │ │ ├── CreatedByProperty.cs │ │ │ ├── CreatedTimeProperty.cs │ │ │ ├── DateProperty.cs │ │ │ ├── EmailProperty.cs │ │ │ ├── FilesProperty.cs │ │ │ ├── FormulaProperty.cs │ │ │ ├── LastEditedByProperty.cs │ │ │ ├── LastEditedTimeProperty.cs │ │ │ ├── NumberProperty.cs │ │ │ ├── PeopleProperty.cs │ │ │ ├── PhoneNumberProperty.cs │ │ │ ├── Property.cs │ │ │ ├── PropertyType.cs │ │ │ ├── RelationProperty │ │ │ │ ├── DualPropertyRelation.cs │ │ │ │ ├── RelationData.cs │ │ │ │ ├── RelationProperty.cs │ │ │ │ ├── RelationType.cs │ │ │ │ └── SinglePropertyRelation.cs │ │ │ ├── RichTextProperty.cs │ │ │ ├── RollupProperty.cs │ │ │ ├── SelectProperty.cs │ │ │ ├── StatusProperty.cs │ │ │ ├── TitleProperty.cs │ │ │ ├── UniqueIdProperty.cs │ │ │ └── UrlProperty.cs │ │ └── RichText │ │ │ ├── RichTextBase.cs │ │ │ ├── RichTextEquation.cs │ │ │ ├── RichTextMention.cs │ │ │ ├── RichTextText.cs │ │ │ └── RichTextType.cs │ ├── EmojiObject.cs │ ├── File │ │ ├── ExternalFile.cs │ │ ├── ExternalFileWithName.cs │ │ ├── FIleInput │ │ │ ├── ExternalFileInput.cs │ │ │ ├── IFileObjectInput.cs │ │ │ └── UploadedFileInput.cs │ │ ├── FileObject.cs │ │ ├── FileObjectWithName.cs │ │ ├── UploadedFile.cs │ │ └── UploadedFileWithName.cs │ ├── Filters │ │ ├── CheckboxFilter.cs │ │ ├── DateFilter.cs │ │ ├── EmailFilter.cs │ │ ├── FilesFilter.cs │ │ ├── Filter.cs │ │ ├── FormulaFilter.cs │ │ ├── MultiSelectFilter.cs │ │ ├── NumberFilter.cs │ │ ├── PeopleFilter.cs │ │ ├── PhoneNumberFilter.cs │ │ ├── RelationFilter.cs │ │ ├── RichTextFilter.cs │ │ ├── Rollup │ │ │ ├── IRollupSubPropertyFilter.cs │ │ │ └── RollupFilter.cs │ │ ├── SelectFilter.cs │ │ ├── StatusFilter.cs │ │ ├── TimestampCreatedTimeFilter.cs │ │ ├── TimestampLastEditedTimeFilter.cs │ │ ├── TitleFilter.cs │ │ └── URLFilter.cs │ ├── IObject.cs │ ├── ObjectType.cs │ ├── Page │ │ ├── IPageIcon.cs │ │ ├── IPageParent.cs │ │ ├── Page.cs │ │ └── PagePropertyOnId.cs │ ├── PaginatedList.cs │ ├── Parents │ │ ├── BlockParent.cs │ │ ├── DatabaseParent.cs │ │ ├── IParent.cs │ │ ├── PageParent.cs │ │ ├── ParentType.cs │ │ └── WorkspaceParent.cs │ ├── PropertyItems │ │ ├── CheckboxPropertyItem.cs │ │ ├── CreatedByPropertyItem.cs │ │ ├── CreatedTimePropertyItem.cs │ │ ├── DatePropertyItem.cs │ │ ├── EmailPropertyItem.cs │ │ ├── FilesPropertyItem.cs │ │ ├── FormulaPropertyItem.cs │ │ ├── IPropertyItemObject.cs │ │ ├── LastEditedByPropertyItem.cs │ │ ├── LastEditedTimePropertyItem.cs │ │ ├── ListPropertyItem.cs │ │ ├── MultiSelectPropertyItem.cs │ │ ├── NumberPropertyItem.cs │ │ ├── PeoplePropertyItem.cs │ │ ├── PhoneNumberPropertyItem.cs │ │ ├── RelationPropertyItem.cs │ │ ├── RichTextPropertyItem.cs │ │ ├── RollupPropertyItem.cs │ │ ├── SelectPropertyItem.cs │ │ ├── SimplePropertyItem.cs │ │ ├── StatusPropertyItem.cs │ │ ├── TitlePropertyItem.cs │ │ └── UrlPropertyItem.cs │ ├── PropertyValue │ │ ├── ButtonPropertyValue.cs │ │ ├── CheckboxPropertyValue.cs │ │ ├── CreatedByPropertyValue.cs │ │ ├── CreatedTimePropertyValue.cs │ │ ├── DateCustomConverter.cs │ │ ├── DateJsonObject.cs │ │ ├── DatePropertyValue.cs │ │ ├── EmailPropertyValue.cs │ │ ├── FilesPropertyValue.cs │ │ ├── FormulaPropertyValue.cs │ │ ├── LastEditedByPropertyValue.cs │ │ ├── LastEditedTimePropertyValue.cs │ │ ├── MultiSelectPropertyValue.cs │ │ ├── NumberPropertyValue.cs │ │ ├── PeoplePropertyValue.cs │ │ ├── PhoneNumberPropertyValue.cs │ │ ├── PropertyValue.cs │ │ ├── PropertyValueType.cs │ │ ├── RelationPropertyValue.cs │ │ ├── RichTextPropertyValue.cs │ │ ├── RollupPropertyValue.cs │ │ ├── SelectPropertyValue.cs │ │ ├── StatusPropertyValue.cs │ │ ├── TitlePropertyValue.cs │ │ ├── UniqueIdPropertyValue.cs │ │ ├── UrlPropertyValue.cs │ │ └── VerificationPropertyValue.cs │ └── User │ │ ├── Bot.cs │ │ ├── BotOwner │ │ ├── IBotOwner.cs │ │ ├── UserOwner.cs │ │ └── WorkspaceIntegrationOwner.cs │ │ ├── PartialUser.cs │ │ ├── Person.cs │ │ └── User.cs │ ├── Notion.Client.csproj │ ├── NotionAPIErrorCode.cs │ ├── NotionApiErrorResponse.cs │ ├── NotionApiException.cs │ ├── NotionApiRateLimitException.cs │ ├── NotionClient.cs │ ├── NotionClientFactory.cs │ ├── RestClient │ ├── ClientOptions.cs │ ├── IRestClient.cs │ ├── LoggingHandler.cs │ └── RestClient.cs │ └── http │ └── QueryHelpers.cs ├── Test ├── Notion.IntegrationTests │ ├── BlocksClientTests.cs │ ├── CommentsClientTests.cs │ ├── DatabasesClientTests.cs │ ├── IntegrationTestBase.cs │ ├── Notion.IntegrationTests.csproj │ ├── PageClientTests.cs │ └── PageWithPageParentTests.cs └── Notion.UnitTests │ ├── ApiTestBase.cs │ ├── BlocksClientTests.cs │ ├── DatabasesClientTests.cs │ ├── DateCustomConverterTests.cs │ ├── FilterTests.cs │ ├── HelperAsserts.cs │ ├── Notion.UnitTests.csproj │ ├── PagesClientTests.cs │ ├── PropertyTests.cs │ ├── SearchClientTest.cs │ ├── UserClientTest.cs │ └── data │ ├── blocks │ ├── AppendBlockChildrenResponse.json │ ├── RetrieveBlockChildrenResponse.json │ ├── RetrieveBlockResponse.json │ └── UpdateBlockResponse.json │ ├── databases │ ├── CreateDatabaseResponse.json │ ├── DatabasePropertyObjectContainNameProperty.json │ ├── DatabasePropertyObjectContainParentProperty.json │ ├── DatabasePropertyObjectContainRelation.json │ ├── DatabaseRetrieveResponse.json │ ├── DatabasesListResponse.json │ ├── DatabasesQueryResponse.json │ ├── Fix123QueryAsyncDateFormulaValueReturnsNullResponse.json │ ├── FormulaPropertyCanBeSetWhenCreatingDatabaseResponse.json │ └── UpdateDatabaseResponse.json │ ├── pages │ ├── CreatePageResponse.json │ ├── PageObjectShouldHaveUrlPropertyResponse.json │ ├── TrashPageResponse.json │ └── UpdatePagePropertiesResponse.json │ ├── search │ └── SearchResponse.json │ └── users │ ├── ListUsersResponse.json │ ├── MeResponse.json │ ├── MeUserLevelResponse.json │ └── RetrieveUserResponse.json ├── assets └── notion-logo.png ├── docs └── README.md ├── examples ├── aspnet-core-app │ ├── Controllers │ │ └── AppController.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── appsettings.Development.json │ ├── appsettings.json │ └── aspnet-core-app.csproj ├── list-users │ ├── Program.cs │ ├── appsettings.json │ └── list-users.csproj └── print-database-property-name-and-values │ ├── .vscode │ ├── launch.json │ └── tasks.json │ ├── Program.cs │ └── print-database-property-name-and-values.csproj ├── nuget.config └── package.json /.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "jetbrains.resharper.globaltools": { 6 | "version": "2022.2.3", 7 | "commands": [ 8 | "jb" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.241.1/containers/dotnet/.devcontainer/base.Dockerfile 2 | 3 | # [Choice] .NET version: 6.0, 3.1, 6.0-bullseye, 3.1-bullseye, 6.0-focal, 3.1-focal 4 | ARG VARIANT="6.0-bullseye-slim" 5 | FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${VARIANT} 6 | 7 | # [Choice] Node.js version: none, lts/*, 18, 16, 14 8 | ARG NODE_VERSION="none" 9 | RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi 10 | 11 | # [Optional] Uncomment this section to install additional OS packages. 12 | # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ 13 | # && apt-get -y install --no-install-recommends 14 | 15 | # [Optional] Uncomment this line to install global node packages. 16 | # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | *.{cmd,[cC][mM][dD]} text eol=crlf 3 | *.{bat,[bB][aA][tT]} text eol=crlf 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "nuget" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | open-pull-requests-limit: 10 13 | commit-message: 14 | prefix: "deps" 15 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | categories: 2 | - title: '🚀 Features' 3 | labels: 4 | - 'feature' 5 | - 'enhancement' 6 | - title: '🐛 Bug Fixes' 7 | labels: 8 | - 'fix' 9 | - 'bugfix' 10 | - 'bug' 11 | - title: '🧰 Maintenance' 12 | label: 'chore' 13 | template: | 14 | ## Changes 15 | 16 | $CHANGES -------------------------------------------------------------------------------- /.github/scripts/check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dotnet jb inspectcode Notion.sln -f="Text" --no-build --include="**.cs" -o=".lint/CodeWarningResults.txt" 4 | 5 | totalLines=$(file .lint/CodeWarningResults.txt | nl | wc -l) 6 | 7 | if [[ "$totalLines" -gt 1 ]]; then 8 | echo "There are few linter warnings - please fix them before running the pipeline" 9 | cat .lint/CodeWarningResults.txt 10 | exit 1 11 | fi 12 | -------------------------------------------------------------------------------- /.github/workflows/ci-build.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v2 15 | 16 | - name: Setup .NET 17 | uses: actions/setup-dotnet@v2 18 | with: 19 | dotnet-version: 6.0.x 20 | 21 | - name: Restore dependencies 22 | run: dotnet restore 23 | 24 | # Install dotnet format as a global tool 25 | - name: Install dotnet tools 26 | run: dotnet tool restore 27 | 28 | - name: Run Linter 29 | run: | 30 | sudo chmod +x ./.github/scripts/check.sh 31 | ./.github/scripts/check.sh 32 | shell: bash 33 | 34 | - name: Build 35 | run: dotnet build --no-restore 36 | 37 | - name: Test 38 | run: dotnet test --filter "FullyQualifiedName~Notion.UnitTests" --no-build --verbosity normal 39 | -------------------------------------------------------------------------------- /.github/workflows/greetings.yml: -------------------------------------------------------------------------------- 1 | name: Greetings 2 | 3 | on: [pull_request_target, issues] 4 | 5 | jobs: 6 | greet-first-time-contributors: 7 | name: Greet First-Time Contributors 8 | runs-on: ubuntu-latest 9 | permissions: 10 | issues: write 11 | pull-requests: write 12 | 13 | steps: 14 | - name: Send greeting to first-time contributors 15 | uses: actions/first-interaction@v1 16 | with: 17 | repo-token: ${{ secrets.GITHUB_TOKEN }} 18 | issue-message: > 19 | 👋 Hi there! Thanks for opening your first issue in this repository. 20 | We appreciate your contribution. A maintainer will take a look soon. 21 | pr-message: > 22 | 🎉 Thanks for your first pull request! 23 | The team will review it shortly. We’re excited to have you contribute! 24 | -------------------------------------------------------------------------------- /Notion.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | PDF 3 | API 4 | JSON 5 | URL 6 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Authentication/AuthenticationClient.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public sealed partial class AuthenticationClient : IAuthenticationClient 4 | { 5 | private readonly IRestClient _client; 6 | 7 | public AuthenticationClient(IRestClient restClient) 8 | { 9 | _client = restClient; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Authentication/CreateToken/AuthenticationClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | 4 | namespace Notion.Client 5 | { 6 | public sealed partial class AuthenticationClient 7 | { 8 | public async Task CreateTokenAsync( 9 | CreateTokenRequest createTokenRequest, 10 | CancellationToken cancellationToken = default) 11 | { 12 | var body = (ICreateTokenBodyParameters)createTokenRequest; 13 | 14 | return await _client.PostAsync( 15 | ApiEndpoints.AuthenticationUrls.CreateToken(), 16 | body, 17 | cancellationToken: cancellationToken 18 | ); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Authentication/CreateToken/Request/CreateTokenRequest.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public class CreateTokenRequest : ICreateTokenBodyParameters 4 | { 5 | public string GrantType => "authorization_code"; 6 | 7 | public string Code { get; set; } 8 | 9 | public string RedirectUri { get; set; } 10 | 11 | public ExternalAccount ExternalAccount { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Authentication/CreateToken/Request/ExternalAccount.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | /// 6 | /// External account info 7 | /// 8 | public class ExternalAccount 9 | { 10 | /// 11 | /// External account key 12 | /// 13 | [JsonProperty("key")] 14 | public string Key { get; set; } 15 | 16 | /// 17 | /// External account name 18 | /// 19 | [JsonProperty("name")] 20 | public string Name { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Authentication/RevokeToken/AuthenticationClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | 4 | namespace Notion.Client 5 | { 6 | public sealed partial class AuthenticationClient 7 | { 8 | public async Task RevokeTokenAsync( 9 | RevokeTokenRequest revokeTokenRequest, 10 | CancellationToken cancellationToken = default) 11 | { 12 | var body = (IRevokeTokenBodyParameters)revokeTokenRequest; 13 | 14 | await _client.PostAsync( 15 | ApiEndpoints.AuthenticationUrls.RevokeToken(), 16 | body, 17 | cancellationToken: cancellationToken 18 | ); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Authentication/RevokeToken/Request/IRevokeTokenBodyParameters.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public interface IRevokeTokenBodyParameters 6 | { 7 | /// 8 | /// The token to be revoked. 9 | /// 10 | [JsonProperty("token")] 11 | string Token { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Authentication/RevokeToken/Request/RevokeTokenRequest.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public class RevokeTokenRequest : IRevokeTokenBodyParameters 4 | { 5 | public string Token { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Authentication/RevokeToken/Response/RevokeTokenResponse.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | internal class RevokeTokenResponse 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/AppendChildren/BlocksClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | 5 | namespace Notion.Client 6 | { 7 | public sealed partial class BlocksClient 8 | { 9 | public async Task AppendChildrenAsync( 10 | BlockAppendChildrenRequest request, 11 | CancellationToken cancellationToken = default) 12 | { 13 | if (string.IsNullOrWhiteSpace(request.BlockId)) 14 | { 15 | throw new ArgumentNullException(nameof(request.BlockId)); 16 | } 17 | 18 | var url = ApiEndpoints.BlocksApiUrls.AppendChildren(request.BlockId); 19 | 20 | var body = new BlockAppendChildrenBodyParameters(request); 21 | 22 | return await _client.PatchAsync(url, body, cancellationToken: cancellationToken); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/AppendChildren/Request/BlockAppendChildrenRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Notion.Client 4 | { 5 | public class BlockAppendChildrenRequest : IBlockAppendChildrenBodyParameters, IBlockAppendChildrenPathParameters 6 | { 7 | public IEnumerable Children { get; set; } 8 | 9 | public string After { get; set; } 10 | 11 | public string BlockId { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/AppendChildren/Request/IBlockAppendChildrenPathParameters.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public interface IBlockAppendChildrenPathParameters 4 | { 5 | public string BlockId { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/AppendChildren/Response/AppendChildrenResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class AppendChildrenResponse : PaginatedList 7 | { 8 | [JsonProperty("block")] 9 | public Dictionary Block { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/AudioUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class AudioUpdateBlock : UpdateBlock 6 | { 7 | [JsonProperty("audio")] 8 | public IFileObjectInput Audio { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BookmarkUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class BookmarkUpdateBlock : IUpdateBlock 7 | { 8 | [JsonProperty("bookmark")] 9 | public Info Bookmark { get; set; } 10 | 11 | public bool InTrash { get; set; } 12 | 13 | public class Info 14 | { 15 | [JsonProperty("url")] 16 | public string Url { get; set; } 17 | 18 | [JsonProperty("caption")] 19 | public IEnumerable Caption { get; set; } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BreadcrumbUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class BreadcrumbUpdateBlock : IUpdateBlock 6 | { 7 | public BreadcrumbUpdateBlock() 8 | { 9 | Breadcrumb = new Info(); 10 | } 11 | 12 | [JsonProperty("breadcrumb")] 13 | public Info Breadcrumb { get; set; } 14 | 15 | public bool InTrash { get; set; } 16 | 17 | public class Info 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/BulletedListItemUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class BulletedListItemUpdateBlock : UpdateBlock 7 | { 8 | [JsonProperty("bulleted_list_item")] 9 | public Info BulletedListItem { get; set; } 10 | 11 | public class Info 12 | { 13 | [JsonProperty("rich_text")] 14 | public IEnumerable RichText { get; set; } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/CalloutUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class CalloutUpdateBlock : UpdateBlock 7 | { 8 | [JsonProperty("callout")] 9 | public Info Callout { get; set; } 10 | 11 | public class Info 12 | { 13 | [JsonProperty("rich_text")] 14 | public IEnumerable RichText { get; set; } 15 | 16 | [JsonProperty("icon")] 17 | public IPageIcon Icon { get; set; } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/CodeUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class CodeUpdateBlock : UpdateBlock 7 | { 8 | [JsonProperty("code")] 9 | public Info Code { get; set; } 10 | 11 | public class Info 12 | { 13 | [JsonProperty("rich_text")] 14 | public IEnumerable RichText { get; set; } 15 | 16 | [JsonProperty("language")] 17 | public string Language { get; set; } 18 | 19 | [JsonProperty("caption")] 20 | public IEnumerable Caption { get; set; } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/DividerUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class DividerUpdateBlock : IUpdateBlock 6 | { 7 | public DividerUpdateBlock() 8 | { 9 | Divider = new Info(); 10 | } 11 | 12 | [JsonProperty("divider")] 13 | public Info Divider { get; set; } 14 | 15 | public bool InTrash { get; set; } 16 | 17 | public class Info 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/EmbedUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class EmbedUpdateBlock : UpdateBlock 6 | { 7 | [JsonProperty("embed")] 8 | public Info Embed { get; set; } 9 | 10 | public class Info 11 | { 12 | [JsonProperty("url")] 13 | public string Url { get; set; } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/EquationUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class EquationUpdateBlock : UpdateBlock 6 | { 7 | [JsonProperty("equation")] 8 | public Info Equation { get; set; } 9 | 10 | public class Info 11 | { 12 | [JsonProperty("expression")] 13 | public string Expression { get; set; } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/FileUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class FileUpdateBlock : UpdateBlock 6 | { 7 | [JsonProperty("file")] 8 | public IFileObjectInput File { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingOneUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Diagnostics.CodeAnalysis; 3 | using Newtonsoft.Json; 4 | 5 | namespace Notion.Client 6 | { 7 | public class HeadingOneUpdateBlock : UpdateBlock 8 | { 9 | [JsonProperty("heading_1")] 10 | [SuppressMessage("ReSharper", "InconsistentNaming")] 11 | public Info Heading_1 { get; set; } 12 | 13 | public class Info 14 | { 15 | [JsonProperty("rich_text")] 16 | public IEnumerable RichText { get; set; } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingThreeeUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Diagnostics.CodeAnalysis; 3 | using Newtonsoft.Json; 4 | 5 | namespace Notion.Client 6 | { 7 | public class HeadingThreeUpdateBlock : UpdateBlock 8 | { 9 | [JsonProperty("heading_3")] 10 | [SuppressMessage("ReSharper", "InconsistentNaming")] 11 | public Info Heading_3 { get; set; } 12 | 13 | public class Info 14 | { 15 | [JsonProperty("rich_text")] 16 | public IEnumerable RichText { get; set; } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/HeadingTwoUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Diagnostics.CodeAnalysis; 3 | using Newtonsoft.Json; 4 | 5 | namespace Notion.Client 6 | { 7 | public class HeadingTwoUpdateBlock : UpdateBlock 8 | { 9 | [JsonProperty("heading_2")] 10 | [SuppressMessage("ReSharper", "InconsistentNaming")] 11 | public Info Heading_2 { get; set; } 12 | 13 | public class Info 14 | { 15 | [JsonProperty("rich_text")] 16 | public IEnumerable RichText { get; set; } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/IUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public interface IUpdateBlock 6 | { 7 | [JsonProperty("in_trash")] 8 | bool InTrash { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ImageUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class ImageUpdateBlock : UpdateBlock 6 | { 7 | [JsonProperty("image")] 8 | public IFileObjectInput Image { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/LinkToPageUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class LinkToPageUpdateBlock : UpdateBlock 6 | { 7 | [JsonProperty("link_to_page")] 8 | public IPageParentInput LinkToPage { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/NumberedListItemUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class NumberedListItemUpdateBlock : UpdateBlock 7 | { 8 | [JsonProperty("numbered_list_item")] 9 | public Info NumberedListItem { get; set; } 10 | 11 | public class Info 12 | { 13 | [JsonProperty("rich_text")] 14 | public IEnumerable RichText { get; set; } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/PDFUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | [SuppressMessage("ReSharper", "InconsistentNaming")] 7 | public class PDFUpdateBlock : UpdateBlock 8 | { 9 | [JsonProperty("pdf")] 10 | public IFileObjectInput PDF { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ParagraphUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class ParagraphUpdateBlock : UpdateBlock 7 | { 8 | [JsonProperty("paragraph")] 9 | public Info Paragraph { get; set; } 10 | 11 | public class Info 12 | { 13 | [JsonProperty("rich_text")] 14 | public IEnumerable RichText { get; set; } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/QuoteUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class QuoteUpdateBlock : UpdateBlock 7 | { 8 | [JsonProperty("quote")] 9 | public Info Quote { get; set; } 10 | 11 | public class Info 12 | { 13 | [JsonProperty("rich_text")] 14 | public IEnumerable RichText { get; set; } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/SyncedBlockUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class SyncedBlockUpdateBlock : UpdateBlock 6 | { 7 | [JsonProperty("synced_block")] 8 | public Info SyncedBlock { get; set; } 9 | 10 | public class Info 11 | { 12 | [JsonProperty("synced_from")] 13 | public SyncedFromBlockId SyncedFrom { get; set; } 14 | 15 | public class SyncedFromBlockId 16 | { 17 | [JsonProperty("block_id")] 18 | public string BlockId { get; set; } 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TableOfContentsUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class TableOfContentsUpdateBlock : IUpdateBlock 6 | { 7 | public TableOfContentsUpdateBlock() 8 | { 9 | TableOfContents = new Info(); 10 | } 11 | 12 | [JsonProperty("table_of_contents")] 13 | public Info TableOfContents { get; set; } 14 | 15 | public bool InTrash { get; set; } 16 | 17 | public class Info 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TableRowUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class TableRowUpdateBlock : UpdateBlock 7 | { 8 | [JsonProperty("table_row")] 9 | public Info TableRow { get; set; } 10 | 11 | public class Info 12 | { 13 | [JsonProperty("cells")] 14 | public IEnumerable> Cells { get; set; } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TableUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class TableUpdateBlock : UpdateBlock 6 | { 7 | [JsonProperty("table")] 8 | public Info Table { get; set; } 9 | 10 | public class Info 11 | { 12 | [JsonProperty("has_column_header")] 13 | public bool HasColumnHeader { get; set; } 14 | 15 | [JsonProperty("has_row_header")] 16 | public bool HasRowHeader { get; set; } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/TemplateUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class TemplateUpdateBlock : UpdateBlock 7 | { 8 | [JsonProperty("template")] 9 | public Info Template { get; set; } 10 | 11 | public class Info 12 | { 13 | [JsonProperty("rich_text")] 14 | public IEnumerable RichText { get; set; } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToDoUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class ToDoUpdateBlock : UpdateBlock 7 | { 8 | [JsonProperty("to_do")] 9 | public Info ToDo { get; set; } 10 | 11 | public class Info 12 | { 13 | [JsonProperty("rich_text")] 14 | public IEnumerable RichText { get; set; } 15 | 16 | [JsonProperty("checked")] 17 | public bool IsChecked { get; set; } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToggleUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class ToggleUpdateBlock : UpdateBlock 7 | { 8 | [JsonProperty("toggle")] 9 | public Info Toggle { get; set; } 10 | 11 | public class Info 12 | { 13 | [JsonProperty("rich_text")] 14 | public IEnumerable RichText { get; set; } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/UpdateBlock.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public abstract class UpdateBlock : IUpdateBlock 4 | { 5 | public bool InTrash { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/VideoUpdateBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class VideoUpdateBlock : UpdateBlock 6 | { 7 | [JsonProperty("video")] 8 | public IFileObjectInput Video { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RetrieveChildren/Request/BlockRetrieveChildrenRequest.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public class BlockRetrieveChildrenRequest : 4 | IBlockRetrieveChildrenQueryParameters, 5 | IBlockRetrieveChildrenPathParameters 6 | { 7 | public string StartCursor { get; set; } 8 | 9 | public int? PageSize { get; set; } 10 | 11 | public string BlockId { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RetrieveChildren/Request/IBlockRetrieveChildrenPathParameters.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public interface IBlockRetrieveChildrenPathParameters 4 | { 5 | public string BlockId { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RetrieveChildren/Request/IBlockRetrieveChildrenQueryParameters.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public interface IBlockRetrieveChildrenQueryParameters : IPaginationParameters 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Blocks/RetrieveChildren/Response/RetrieveChildrenResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class RetrieveChildrenResponse : PaginatedList 7 | { 8 | [JsonProperty("block")] 9 | public Dictionary Block { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Comments/CommentsClient.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public partial class CommentsClient : ICommentsClient 4 | { 5 | private readonly IRestClient _client; 6 | 7 | public CommentsClient(IRestClient restClient) 8 | { 9 | _client = restClient; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Comments/Create/CommentsClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | 4 | namespace Notion.Client 5 | { 6 | public partial class CommentsClient 7 | { 8 | public async Task CreateAsync(CreateCommentParameters parameters, CancellationToken cancellationToken = default) 9 | { 10 | var body = (ICreateCommentsBodyParameters)parameters; 11 | 12 | return await _client.PostAsync( 13 | ApiEndpoints.CommentsApiUrls.Create(), 14 | body, 15 | cancellationToken: cancellationToken 16 | ); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Comments/Create/Response/CreateCommentResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | 3 | namespace Notion.Client 4 | { 5 | [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] 6 | public class CreateCommentResponse : Comment 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Comments/ICommentsClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | 4 | namespace Notion.Client 5 | { 6 | public interface ICommentsClient 7 | { 8 | Task CreateAsync(CreateCommentParameters createCommentParameters, CancellationToken cancellationToken = default); 9 | 10 | Task RetrieveAsync(RetrieveCommentsParameters parameters, CancellationToken cancellationToken = default); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Comments/Retrieve/Request/IRetrieveCommentsQueryParameters.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public interface IRetrieveCommentsQueryParameters : IPaginationParameters 6 | { 7 | [JsonProperty("block_id")] 8 | string BlockId { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Comments/Retrieve/Request/RetrieveCommentsParameters.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | 3 | namespace Notion.Client 4 | { 5 | [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] 6 | public class RetrieveCommentsParameters : IRetrieveCommentsQueryParameters 7 | { 8 | public string BlockId { get; set; } 9 | 10 | public string StartCursor { get; set; } 11 | 12 | public int? PageSize { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Comments/Retrieve/Response/Comment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Notion.Client 6 | { 7 | public class Comment : IObject 8 | { 9 | [JsonProperty("parent")] 10 | public ICommentParent Parent { get; set; } 11 | 12 | [JsonProperty("discussion_id")] 13 | public string DiscussionId { get; set; } 14 | 15 | [JsonProperty("rich_text")] 16 | public IEnumerable RichText { get; set; } 17 | 18 | [JsonProperty("created_by")] 19 | public PartialUser CreatedBy { get; set; } 20 | 21 | [JsonProperty("created_time")] 22 | public DateTime CreatedTime { get; set; } 23 | 24 | [JsonProperty("last_edited_time")] 25 | public DateTime LastEditedTime { get; set; } 26 | 27 | public string Id { get; set; } 28 | 29 | public ObjectType Object => ObjectType.Comment; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Comments/Retrieve/Response/Comments.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class RetrieveCommentsResponse : PaginatedList 7 | { 8 | [JsonProperty("comment")] 9 | public Dictionary Comment { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Comments/Retrieve/Response/ICommentParent.cs: -------------------------------------------------------------------------------- 1 | using JsonSubTypes; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | [JsonConverter(typeof(JsonSubtypes), "type")] 7 | [JsonSubtypes.KnownSubTypeAttribute(typeof(PageParent), ParentType.PageId)] 8 | [JsonSubtypes.KnownSubTypeAttribute(typeof(BlockParent), ParentType.BlockId)] 9 | public interface ICommentParent 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/Query/Request/DatabasesQueryParameters.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Notion.Client 4 | { 5 | public class DatabasesQueryParameters : IDatabaseQueryBodyParameters, IDatabaseQueryQueryParameters 6 | { 7 | public Filter Filter { get; set; } 8 | 9 | public List Sorts { get; set; } 10 | 11 | public string StartCursor { get; set; } 12 | 13 | public int? PageSize { get; set; } 14 | 15 | public List FilterProperties { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/Query/Request/IDatabaseQueryBodyParameters.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public interface IDatabaseQueryBodyParameters : IPaginationParameters 7 | { 8 | [JsonProperty("filter")] 9 | Filter Filter { get; set; } 10 | 11 | [JsonProperty("sorts")] 12 | List Sorts { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/Query/Request/IDatabaseQueryQueryParameters.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public interface IDatabaseQueryQueryParameters 7 | { 8 | [JsonProperty("filter_properties")] 9 | List FilterProperties { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/Query/Response/DatabaseQueryResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | // ReSharper disable once ClassNeverInstantiated.Global 7 | public class DatabaseQueryResponse : PaginatedList 8 | { 9 | [JsonProperty("database")] 10 | public Dictionary Database { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/DatabasesCreateParameters.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class DatabasesCreateParameters : IDatabasesCreateBodyParameters, IDatabasesCreateQueryParameters 7 | { 8 | [JsonProperty("icon")] 9 | public IPageIcon Icon { get; set; } 10 | 11 | [JsonProperty("cover")] 12 | public FileObject Cover { get; set; } 13 | 14 | [JsonProperty("parent")] 15 | public ParentPageInput Parent { get; set; } 16 | 17 | [JsonProperty("properties")] 18 | public Dictionary Properties { get; set; } 19 | 20 | [JsonProperty("title")] 21 | public List Title { get; set; } 22 | 23 | public bool? IsInline { get; set; } 24 | 25 | public List Description { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/IDatabasesCreateBodyParameters.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public interface IDatabasesCreateBodyParameters 7 | { 8 | [JsonProperty("parent")] 9 | ParentPageInput Parent { get; set; } 10 | 11 | [JsonProperty("properties")] 12 | Dictionary Properties { get; set; } 13 | 14 | [JsonProperty("title")] 15 | List Title { get; set; } 16 | 17 | [JsonProperty("is_inline")] 18 | bool? IsInline { get; set; } 19 | 20 | [JsonProperty("description")] 21 | List Description { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/IDatabasesCreateQueryParameters.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public interface IDatabasesCreateQueryParameters 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/MentionInput.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class MentionInput 6 | { 7 | [JsonProperty("type")] 8 | public string Type { get; set; } 9 | 10 | [JsonProperty("user")] 11 | public Person User { get; set; } 12 | 13 | [JsonProperty("page")] 14 | public ObjectId Page { get; set; } 15 | 16 | [JsonProperty("database")] 17 | public ObjectId Database { get; set; } 18 | 19 | [JsonProperty("date")] 20 | public Date Date { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/ParentPageInput.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class ParentPageInput : IPageParentInput 6 | { 7 | [JsonProperty("page_id")] 8 | public string PageId { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/CheckboxPropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class CheckboxPropertySchema : IPropertySchema 7 | { 8 | [JsonProperty("checkbox")] 9 | public Dictionary Checkbox { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/CreatedByPropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class CreatedByPropertySchema : IPropertySchema 7 | { 8 | [JsonProperty("created_by")] 9 | public Dictionary CreatedBy { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/CreatedTimePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class CreatedTimePropertySchema : IPropertySchema 7 | { 8 | [JsonProperty("created_time")] 9 | public Dictionary CreatedTime { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/DatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class DatePropertySchema : IPropertySchema 7 | { 8 | [JsonProperty("date")] 9 | public Dictionary Date { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/EmailPropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class EmailPropertySchema : IPropertySchema 7 | { 8 | [JsonProperty("email")] 9 | public Dictionary Email { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/FilePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class FilePropertySchema : IPropertySchema 7 | { 8 | [JsonProperty("files")] 9 | public Dictionary Files { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/FormulaPropertySchema.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class FormulaPropertySchema : IPropertySchema 6 | { 7 | [JsonProperty("formula")] 8 | public Formula Formula { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/IPropertySchema.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public interface IPropertySchema 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/LastEditedByPropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class LastEditedByPropertySchema : IPropertySchema 7 | { 8 | [JsonProperty("last_edited_by")] 9 | public Dictionary LastEditedBy { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/LastEditedTimePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class LastEditedTimePropertySchema : IPropertySchema 7 | { 8 | [JsonProperty("last_edited_time")] 9 | public Dictionary LastEditedTime { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/MultiSelectOptionSchema.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | 3 | namespace Notion.Client 4 | { 5 | [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] 6 | public class MultiSelectOptionSchema : SelectOptionSchema 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/MultiSelectPropertySchema.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class MultiSelectPropertySchema : IPropertySchema 6 | { 7 | [JsonProperty("multi_select")] 8 | public OptionWrapper MultiSelect { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/NumberPropertySchema.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class NumberPropertySchema : IPropertySchema 6 | { 7 | [JsonProperty("number")] 8 | public Number Number { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/PeoplePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class PeoplePropertySchema : IPropertySchema 7 | { 8 | [JsonProperty("people")] 9 | public Dictionary People { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/PhoneNumberPropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class PhoneNumberPropertySchema : IPropertySchema 7 | { 8 | [JsonProperty("phone_number")] 9 | public Dictionary PhoneNumber { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RelationPropertySchema.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class RelationPropertySchema : IPropertySchema 6 | { 7 | [JsonProperty("relation")] 8 | public RelationData Relation { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RichTextPropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class RichTextPropertySchema : IPropertySchema 7 | { 8 | [JsonProperty("rich_text")] 9 | public Dictionary RichText { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/RollupConfigPropertySchema.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class RollupConfigPropertySchema : IPropertySchema 6 | { 7 | [JsonProperty("relation_property_name")] 8 | public string RelationPropertyName { get; set; } 9 | 10 | [JsonProperty("relation_property_id")] 11 | public string RelationPropertyId { get; set; } 12 | 13 | [JsonProperty("rollup_property_name")] 14 | public string RollupPropertyName { get; set; } 15 | 16 | [JsonProperty("rollup_property_id")] 17 | public string RollupPropertyId { get; set; } 18 | 19 | [JsonProperty("function")] 20 | public string Function { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/SelectOptionSchema.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Converters; 3 | 4 | namespace Notion.Client 5 | { 6 | public class SelectOptionSchema 7 | { 8 | [JsonProperty("name")] 9 | public string Name { get; set; } 10 | 11 | [JsonProperty("color")] 12 | [JsonConverter(typeof(StringEnumConverter))] 13 | public Color? Color { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/SelectPropertySchema.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class SelectPropertySchema : IPropertySchema 6 | { 7 | [JsonProperty("select")] 8 | public OptionWrapper Select { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/TitlePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class TitlePropertySchema : IPropertySchema 7 | { 8 | [JsonProperty("title")] 9 | public Dictionary Title { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/PropertySchema/UrlPropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class UrlPropertySchema : IPropertySchema 7 | { 8 | [JsonProperty("url")] 9 | public Dictionary Url { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/RichTextBaseInput.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public class RichTextBaseInput : RichTextBase 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/RichTextEquationInput.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class RichTextEquationInput : RichTextBaseInput 6 | { 7 | public override RichTextType Type => RichTextType.Equation; 8 | 9 | [JsonProperty("equation")] 10 | public Equation Equation { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/RichTextMentionInput.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class RichTextMentionInput : RichTextBaseInput 6 | { 7 | public override RichTextType Type => RichTextType.Mention; 8 | 9 | [JsonProperty("mention")] 10 | public MentionInput Mention { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesCreateParameters/RichTextTextInput.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class RichTextTextInput : RichTextBaseInput 6 | { 7 | public override RichTextType Type => RichTextType.Text; 8 | 9 | [JsonProperty("text")] 10 | public Text Text { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/DatabasesUpdateParameters.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Notion.Client 4 | { 5 | public class DatabasesUpdateParameters : IDatabasesUpdateBodyParameters 6 | { 7 | public Dictionary Properties { get; set; } 8 | 9 | public List Title { get; set; } 10 | 11 | public IPageIcon Icon { get; set; } 12 | 13 | public FileObject Cover { get; set; } 14 | 15 | public bool InTrash { get; set; } 16 | 17 | public bool? IsInline { get; set; } 18 | 19 | public List Description { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/IDatabasesUpdateBodyParameters.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public interface IDatabasesUpdateBodyParameters 7 | { 8 | [JsonProperty("properties")] 9 | Dictionary Properties { get; set; } 10 | 11 | [JsonProperty("title")] 12 | List Title { get; set; } 13 | 14 | [JsonProperty("icon")] 15 | IPageIcon Icon { get; set; } 16 | 17 | [JsonProperty("cover")] 18 | FileObject Cover { get; set; } 19 | 20 | [JsonProperty("in_trash")] 21 | bool InTrash { get; set; } 22 | 23 | [JsonProperty("is_inline")] 24 | bool? IsInline { get; set; } 25 | 26 | [JsonProperty("description")] 27 | List Description { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/CheckboxUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class CheckboxUpdatePropertySchema : UpdatePropertySchema 7 | { 8 | [JsonProperty("checkbox")] 9 | public Dictionary Checkbox { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/CreatedByUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class CreatedByUpdatePropertySchema : UpdatePropertySchema 7 | { 8 | [JsonProperty("created_by")] 9 | public Dictionary CreatedBy { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/CreatedTimeUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class CreatedTimeUpdatePropertySchema : UpdatePropertySchema 7 | { 8 | [JsonProperty("created_time")] 9 | public Dictionary CreatedTime { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/DateUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class DateUpdatePropertySchema : UpdatePropertySchema 7 | { 8 | [JsonProperty("date")] 9 | public Dictionary Date { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/EmailUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class EmailUpdatePropertySchema : UpdatePropertySchema 7 | { 8 | [JsonProperty("email")] 9 | public Dictionary Email { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/FilesUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class FilesUpdatePropertySchema : UpdatePropertySchema 7 | { 8 | [JsonProperty("files")] 9 | public Dictionary Files { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/FormulaUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class FormulaUpdatePropertySchema : UpdatePropertySchema 6 | { 7 | [JsonProperty("formula")] 8 | public Formula Formula { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/IUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Converters; 3 | 4 | namespace Notion.Client 5 | { 6 | public interface IUpdatePropertySchema 7 | { 8 | [JsonProperty("name")] 9 | string Name { get; set; } 10 | 11 | [JsonProperty("type")] 12 | [JsonConverter(typeof(StringEnumConverter))] 13 | PropertyType? Type { get; set; } 14 | } 15 | 16 | public abstract class UpdatePropertySchema : IUpdatePropertySchema 17 | { 18 | public string Name { get; set; } 19 | 20 | public PropertyType? Type { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/LastEditedByUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class LastEditedByUpdatePropertySchema : UpdatePropertySchema 7 | { 8 | [JsonProperty("last_edited_by")] 9 | public Dictionary LastEditedBy { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/LastEditedTimeUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class LastEditedTimeUpdatePropertySchema : UpdatePropertySchema 7 | { 8 | [JsonProperty("last_edited_time")] 9 | public Dictionary LastEditedTime { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/MultiSelectUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class MultiSelectUpdatePropertySchema : UpdatePropertySchema 6 | { 7 | [JsonProperty("multi_select")] 8 | public OptionWrapper MultiSelect { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/NumberUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class NumberUpdatePropertySchema : UpdatePropertySchema 6 | { 7 | [JsonProperty("number")] 8 | public Number Number { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/PeopleUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class PeopleUpdatePropertySchema : UpdatePropertySchema 7 | { 8 | [JsonProperty("people")] 9 | public Dictionary People { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/PhoneNumberUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class PhoneNumberUpdatePropertySchema : UpdatePropertySchema 7 | { 8 | [JsonProperty("phone_number")] 9 | public Dictionary PhoneNumber { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RelationUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class RelationUpdatePropertySchema : UpdatePropertySchema 6 | { 7 | [JsonProperty("relation")] 8 | public RelationData Relation { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RichTextUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class RichTextUpdatePropertySchema : UpdatePropertySchema 7 | { 8 | [JsonProperty("rich_text")] 9 | public Dictionary RichText { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/RollupConfigUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class RollupConfigUpdatePropertySchema : UpdatePropertySchema 6 | { 7 | [JsonProperty("relation_property_name")] 8 | public string RelationPropertyName { get; set; } 9 | 10 | [JsonProperty("relation_property_id")] 11 | public string RelationPropertyId { get; set; } 12 | 13 | [JsonProperty("rollup_property_name")] 14 | public string RollupPropertyName { get; set; } 15 | 16 | [JsonProperty("rollup_property_id")] 17 | public string RollupPropertyId { get; set; } 18 | 19 | [JsonProperty("function")] 20 | public string Function { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/SelectUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class SelectUpdatePropertySchema : UpdatePropertySchema 6 | { 7 | [JsonProperty("select")] 8 | public OptionWrapper Select { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/TitleUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class TitleUpdatePropertySchema : UpdatePropertySchema 7 | { 8 | [JsonProperty("title")] 9 | public Dictionary Title { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/DatabasesUpdateParameters/PropertySchema/URLUpdatePropertySchema.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class UrlUpdatePropertySchema : UpdatePropertySchema 7 | { 8 | [JsonProperty("url")] 9 | public Dictionary Url { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/Direction.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Notion.Client 5 | { 6 | [SuppressMessage("ReSharper", "UnusedMember.Global")] 7 | public enum Direction 8 | { 9 | [EnumMember(Value = null)] 10 | Unknown, 11 | 12 | [EnumMember(Value = "ascending")] 13 | Ascending, 14 | 15 | [EnumMember(Value = "descending")] 16 | Descending 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/Sort.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Converters; 3 | 4 | namespace Notion.Client 5 | { 6 | public class Sort 7 | { 8 | [JsonProperty("property")] 9 | public string Property { get; set; } 10 | 11 | [JsonProperty("timestamp")] 12 | [JsonConverter(typeof(StringEnumConverter))] 13 | public Timestamp Timestamp { get; set; } 14 | 15 | [JsonProperty("direction")] 16 | [JsonConverter(typeof(StringEnumConverter))] 17 | public Direction Direction { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Databases/RequestParams/Timestamp.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Notion.Client 5 | { 6 | [SuppressMessage("ReSharper", "UnusedMember.Global")] 7 | public enum Timestamp 8 | { 9 | [EnumMember(Value = null)] 10 | Unknown, 11 | 12 | [EnumMember(Value = "created_time")] 13 | CreatedTime, 14 | 15 | [EnumMember(Value = "last_edited_time")] 16 | LastEditedTime 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Pages/RequestParams/IPagesUpdateBodyParameters.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public interface IPagesUpdateBodyParameters 7 | { 8 | [JsonProperty("in_trash")] 9 | bool InTrash { get; set; } 10 | 11 | [JsonProperty("properties")] 12 | IDictionary Properties { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Pages/RequestParams/PagesCreateParameters/DatabaseParentInput.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class DatabaseParentInput : IPageParentInput 6 | { 7 | [JsonProperty("database_id")] 8 | public string DatabaseId { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Pages/RequestParams/PagesCreateParameters/IPageParentInput.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public interface IPageParentInput 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Pages/RequestParams/PagesCreateParameters/IPagesCreateBodyParameters.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public interface IPagesCreateBodyParameters 7 | { 8 | [JsonProperty("parent")] 9 | IPageParentInput Parent { get; set; } 10 | 11 | [JsonProperty("properties")] 12 | IDictionary Properties { get; set; } 13 | 14 | [JsonProperty("children")] 15 | IList Children { get; set; } 16 | 17 | [JsonProperty("icon")] 18 | IPageIcon Icon { get; set; } 19 | 20 | [JsonProperty("cover")] 21 | FileObject Cover { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Pages/RequestParams/PagesCreateParameters/IPagesCreateQueryParameters.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public interface IPagesCreateQueryParameters 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Pages/RequestParams/PagesCreateParameters/PagesCreateParameters.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Notion.Client 4 | { 5 | public class PagesCreateParameters : IPagesCreateBodyParameters, IPagesCreateQueryParameters 6 | { 7 | public IPageParentInput Parent { get; set; } 8 | 9 | public IDictionary Properties { get; set; } 10 | 11 | public IList Children { get; set; } 12 | 13 | public IPageIcon Icon { get; set; } 14 | 15 | public FileObject Cover { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Pages/RequestParams/PagesUpdateParameters.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class PagesUpdateParameters : IPagesUpdateBodyParameters 7 | { 8 | [JsonProperty("icon")] 9 | public IPageIcon Icon { get; set; } 10 | 11 | [JsonProperty("cover")] 12 | public FileObject Cover { get; set; } 13 | 14 | [JsonProperty("in_trash")] 15 | public bool InTrash { get; set; } 16 | 17 | [JsonProperty("properties")] 18 | public IDictionary Properties { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Pages/RequestParams/RetrievePropertyItemParameters/IRetrievePropertyItemPathParameters.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public interface IRetrievePropertyItemPathParameters 6 | { 7 | [JsonProperty("page_id")] 8 | string PageId { get; set; } 9 | 10 | [JsonProperty("property_id")] 11 | string PropertyId { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Pages/RequestParams/RetrievePropertyItemParameters/IRetrievePropertyQueryParameters.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public interface IRetrievePropertyQueryParameters : IPaginationParameters 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Pages/RequestParams/RetrievePropertyItemParameters/RetrievePropertyItemParameters.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public class RetrievePropertyItemParameters : IRetrievePropertyItemPathParameters, IRetrievePropertyQueryParameters 4 | { 5 | public string PageId { get; set; } 6 | 7 | public string PropertyId { get; set; } 8 | 9 | public string StartCursor { get; set; } 10 | 11 | public int? PageSize { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Search/ISearchClient.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | 5 | namespace Notion.Client 6 | { 7 | [SuppressMessage("ReSharper", "UnusedMemberInSuper.Global")] 8 | public interface ISearchClient 9 | { 10 | /// 11 | /// Searches all original pages, databases, and child pages/databases that are shared with the integration. 12 | /// It will not return linked databases, since these duplicate their source databases. 13 | /// 14 | /// Search filters and body parameters 15 | /// 16 | /// 17 | /// 18 | /// 19 | Task SearchAsync( 20 | SearchRequest request, 21 | CancellationToken cancellationToken = default 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Search/Request/ISearchBodyParameters.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public interface ISearchBodyParameters : IPaginationParameters 6 | { 7 | [JsonProperty("query")] 8 | string Query { get; set; } 9 | 10 | [JsonProperty("sort")] 11 | SearchSort Sort { get; set; } 12 | 13 | [JsonProperty("filter")] 14 | SearchFilter Filter { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Search/Request/SearchDirection.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Notion.Client 5 | { 6 | [SuppressMessage("ReSharper", "UnusedMember.Global")] 7 | public enum SearchDirection 8 | { 9 | [EnumMember(Value = "ascending")] 10 | Ascending, 11 | 12 | [EnumMember(Value = "descending")] 13 | Descending 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Search/Request/SearchFilter.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | 5 | namespace Notion.Client 6 | { 7 | [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] 8 | [SuppressMessage("ReSharper", "UnusedMember.Global")] 9 | public class SearchFilter 10 | { 11 | [JsonConverter(typeof(StringEnumConverter))] 12 | public SearchObjectType Value { get; set; } 13 | 14 | public string Property => "object"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Search/Request/SearchObjectType.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Notion.Client 5 | { 6 | [SuppressMessage("ReSharper", "UnusedMember.Global")] 7 | public enum SearchObjectType 8 | { 9 | [EnumMember(Value = "page")] 10 | Page, 11 | 12 | [EnumMember(Value = "database")] 13 | Database 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Search/Request/SearchRequest.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public class SearchRequest : ISearchBodyParameters 4 | { 5 | public string Query { get; set; } 6 | 7 | public SearchSort Sort { get; set; } 8 | 9 | public SearchFilter Filter { get; set; } 10 | 11 | public string StartCursor { get; set; } 12 | 13 | public int? PageSize { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Search/Request/SearchSort.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Converters; 3 | 4 | namespace Notion.Client 5 | { 6 | public class SearchSort 7 | { 8 | [JsonProperty("direction")] 9 | [JsonConverter(typeof(StringEnumConverter))] 10 | public SearchDirection Direction { get; set; } 11 | 12 | [JsonProperty("timestamp")] 13 | public string Timestamp { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Search/Response/SearchResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class SearchResponse : PaginatedList 7 | { 8 | [JsonProperty("page_or_database")] 9 | public Dictionary PageOrDatabase { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Search/SearchClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using static Notion.Client.ApiEndpoints; 4 | 5 | namespace Notion.Client 6 | { 7 | public sealed class SearchClient : ISearchClient 8 | { 9 | private readonly IRestClient _client; 10 | 11 | public SearchClient(IRestClient client) 12 | { 13 | _client = client; 14 | } 15 | 16 | public async Task SearchAsync( 17 | SearchRequest request, 18 | CancellationToken cancellationToken = default) 19 | { 20 | var url = SearchApiUrls.Search(); 21 | 22 | var body = (ISearchBodyParameters)request; 23 | 24 | return await _client.PostAsync(url, body, cancellationToken: cancellationToken); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Users/List/Request/ListUsersRequest.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client.List.Request 2 | { 3 | public interface IListUsersQueryParameters : IPaginationParameters 4 | { 5 | } 6 | 7 | public class ListUsersRequest : IListUsersQueryParameters 8 | { 9 | public string StartCursor { get; set; } 10 | 11 | public int? PageSize { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Api/Users/List/Response/ListUsersResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class ListUsersResponse : PaginatedList 7 | { 8 | [JsonProperty("user")] 9 | public Dictionary User { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/Constants.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("Notion.UnitTests")] 4 | 5 | namespace Notion.Client 6 | { 7 | internal static class Constants 8 | { 9 | internal const string BaseUrl = "https://api.notion.com/"; 10 | internal const string DefaultNotionVersion = "2022-06-28"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/DI/ServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | using Notion.Client; 4 | 5 | namespace Microsoft.Extensions.DependencyInjection 6 | { 7 | [SuppressMessage("ReSharper", "UnusedType.Global")] 8 | [SuppressMessage("ReSharper", "UnusedMember.Global")] 9 | public static class ServiceCollectionExtensions 10 | { 11 | public static IServiceCollection AddNotionClient( 12 | this IServiceCollection services, 13 | Action options) 14 | { 15 | services.AddSingleton(_ => 16 | { 17 | var clientOptions = new ClientOptions(); 18 | options?.Invoke(clientOptions); 19 | 20 | return NotionClientFactory.Create(clientOptions); 21 | }); 22 | 23 | return services; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Src/Notion.Client/Extensions/EnumExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Runtime.Serialization; 4 | 5 | namespace Notion.Client.Extensions 6 | { 7 | public static class EnumExtensions 8 | { 9 | public static string GetEnumMemberValue(this T enumValue) where T : Enum 10 | { 11 | var enumType = typeof(T); 12 | var memInfo = enumType.GetMember(enumValue.ToString()); 13 | 14 | var attr = memInfo.FirstOrDefault()?.GetCustomAttributes(false).OfType() 15 | .FirstOrDefault(); 16 | 17 | if (attr != null) 18 | { 19 | return attr.Value; 20 | } 21 | 22 | return null; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Src/Notion.Client/Extensions/HttpResponseMessageExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Net.Http; 3 | using System.Threading.Tasks; 4 | using Newtonsoft.Json; 5 | 6 | namespace Notion.Client.Extensions 7 | { 8 | internal static class HttpResponseMessageExtensions 9 | { 10 | internal static async Task ParseStreamAsync( 11 | this HttpResponseMessage response, 12 | JsonSerializerSettings serializerSettings = null) 13 | { 14 | using var stream = await response.Content.ReadAsStreamAsync(); 15 | using var streamReader = new StreamReader(stream); 16 | using JsonReader jsonReader = new JsonTextReader(streamReader); 17 | 18 | var serializer = serializerSettings == null 19 | ? JsonSerializer.CreateDefault() 20 | : JsonSerializer.Create(serializerSettings); 21 | 22 | return serializer.Deserialize(jsonReader); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Src/Notion.Client/Logging/Log.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | using Microsoft.Extensions.Logging; 4 | 5 | namespace Notion.Client 6 | { 7 | internal static class Log 8 | { 9 | internal static ILogger Logger; 10 | 11 | internal static void Trace(string message, params object[] args) 12 | { 13 | Logger?.LogTrace(message, args); 14 | } 15 | 16 | [SuppressMessage("ReSharper", "UnusedMember.Global")] 17 | internal static void Information(string message, params object[] args) 18 | { 19 | Logger?.LogInformation(message, args); 20 | } 21 | 22 | internal static void Error(Exception ex, string message, params object[] args) 23 | { 24 | Logger?.LogError(ex, message, args); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Src/Notion.Client/Logging/NotionClientLogging.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using Microsoft.Extensions.Logging; 3 | 4 | namespace Notion.Client 5 | { 6 | [SuppressMessage("ReSharper", "UnusedType.Global")] 7 | [SuppressMessage("ReSharper", "UnusedMember.Global")] 8 | public static class NotionClientLogging 9 | { 10 | private static ILoggerFactory _factory; 11 | 12 | public static void ConfigureLogger(ILoggerFactory loggerFactory) 13 | { 14 | _factory = loggerFactory; 15 | 16 | Log.Logger = Log.Logger == null ? _factory?.CreateLogger("Notion.Client") : Log.Logger; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/AudioBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class AudioBlock : Block, IColumnChildrenBlock, INonColumnBlock 6 | { 7 | [JsonProperty("audio")] 8 | public FileObject Audio { get; set; } 9 | 10 | public override BlockType Type => BlockType.Audio; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Block.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Notion.Client 4 | { 5 | public abstract class Block : IBlock 6 | { 7 | public ObjectType Object => ObjectType.Block; 8 | 9 | public string Id { get; set; } 10 | 11 | public virtual BlockType Type { get; set; } 12 | 13 | public DateTime CreatedTime { get; set; } 14 | 15 | public DateTime LastEditedTime { get; set; } 16 | 17 | public virtual bool HasChildren { get; set; } 18 | 19 | public bool InTrash { get; set; } 20 | 21 | public PartialUser CreatedBy { get; set; } 22 | 23 | public PartialUser LastEditedBy { get; set; } 24 | 25 | /// 26 | /// Information about the block's parent. 27 | /// 28 | public IBlockParent Parent { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/BookmarkBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class BookmarkBlock : Block, IColumnChildrenBlock, INonColumnBlock 7 | { 8 | [JsonProperty("bookmark")] 9 | public Info Bookmark { get; set; } 10 | 11 | public override BlockType Type => BlockType.Bookmark; 12 | 13 | public class Info 14 | { 15 | [JsonProperty("url")] 16 | public string Url { get; set; } 17 | 18 | [JsonProperty("caption")] 19 | public IEnumerable Caption { get; set; } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/BreadcrumbBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class BreadcrumbBlock : Block, IColumnChildrenBlock, INonColumnBlock 6 | { 7 | [JsonProperty("breadcrumb")] 8 | public Data Breadcrumb { get; set; } 9 | 10 | public override BlockType Type => BlockType.Breadcrumb; 11 | 12 | public class Data 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/BulletedListItemBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | 5 | namespace Notion.Client 6 | { 7 | public class BulletedListItemBlock : Block, IColumnChildrenBlock, INonColumnBlock 8 | { 9 | [JsonProperty("bulleted_list_item")] 10 | public Info BulletedListItem { get; set; } 11 | 12 | public override BlockType Type => BlockType.BulletedListItem; 13 | 14 | public class Info 15 | { 16 | [JsonProperty("rich_text")] 17 | public IEnumerable RichText { get; set; } 18 | 19 | [JsonProperty("color")] 20 | [JsonConverter(typeof(StringEnumConverter))] 21 | public Color? Color { get; set; } 22 | 23 | [JsonProperty("children")] 24 | public IEnumerable Children { get; set; } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/CalloutBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | 5 | namespace Notion.Client 6 | { 7 | public class CalloutBlock : Block, IColumnChildrenBlock, INonColumnBlock 8 | { 9 | [JsonProperty("callout")] 10 | public Info Callout { get; set; } 11 | 12 | public override BlockType Type => BlockType.Callout; 13 | 14 | public class Info 15 | { 16 | [JsonProperty("rich_text")] 17 | public IEnumerable RichText { get; set; } 18 | 19 | [JsonProperty("icon")] 20 | public IPageIcon Icon { get; set; } 21 | 22 | [JsonProperty("color")] 23 | [JsonConverter(typeof(StringEnumConverter))] 24 | public Color? Color { get; set; } 25 | 26 | [JsonProperty("children")] 27 | public IEnumerable Children { get; set; } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/ChildDatabaseBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class ChildDatabaseBlock : Block, IColumnChildrenBlock, INonColumnBlock 6 | { 7 | [JsonProperty("child_database")] 8 | public Info ChildDatabase { get; set; } 9 | 10 | public override BlockType Type => BlockType.ChildDatabase; 11 | 12 | public class Info 13 | { 14 | [JsonProperty("title")] 15 | public string Title { get; set; } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/ChildPageBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class ChildPageBlock : Block, IColumnChildrenBlock, INonColumnBlock 6 | { 7 | [JsonProperty("child_page")] 8 | public Info ChildPage { get; set; } 9 | 10 | public override BlockType Type => BlockType.ChildPage; 11 | 12 | public class Info 13 | { 14 | [JsonProperty("title")] 15 | public string Title { get; set; } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/CodeBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class CodeBlock : Block, IColumnChildrenBlock, INonColumnBlock 7 | { 8 | [JsonProperty("code")] 9 | public Info Code { get; set; } 10 | 11 | public override BlockType Type => BlockType.Code; 12 | 13 | public class Info 14 | { 15 | [JsonProperty("rich_text")] 16 | public IEnumerable RichText { get; set; } 17 | 18 | [JsonProperty("language")] 19 | public string Language { get; set; } 20 | 21 | [JsonProperty("caption")] 22 | public IEnumerable Caption { get; set; } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/ColumnBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class ColumnBlock : Block 7 | { 8 | public override BlockType Type => BlockType.Column; 9 | 10 | [JsonProperty("column")] 11 | public Info Column { get; set; } 12 | 13 | public class Info 14 | { 15 | [JsonProperty("children")] 16 | public IEnumerable Children { get; set; } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/ColumnListBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class ColumnListBlock : Block, INonColumnBlock 7 | { 8 | [JsonProperty("column_list")] 9 | public Info ColumnList { get; set; } 10 | 11 | public override BlockType Type => BlockType.ColumnList; 12 | 13 | public class Info 14 | { 15 | [JsonProperty("children")] 16 | public IEnumerable Children { get; set; } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/DividerBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class DividerBlock : Block, IColumnChildrenBlock, INonColumnBlock 6 | { 7 | [JsonProperty("divider")] 8 | public Data Divider { get; set; } 9 | 10 | public override BlockType Type => BlockType.Divider; 11 | 12 | public class Data 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/EmbedBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class EmbedBlock : Block, IColumnChildrenBlock, INonColumnBlock 7 | { 8 | [JsonProperty("embed")] 9 | public Info Embed { get; set; } 10 | 11 | public override BlockType Type => BlockType.Embed; 12 | 13 | public class Info 14 | { 15 | [JsonProperty("url")] 16 | public string Url { get; set; } 17 | 18 | [JsonProperty("caption")] 19 | public IEnumerable Caption { get; set; } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/EquationBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class EquationBlock : Block, IColumnChildrenBlock, INonColumnBlock 6 | { 7 | [JsonProperty("equation")] 8 | public Info Equation { get; set; } 9 | 10 | public override BlockType Type => BlockType.Equation; 11 | 12 | public class Info 13 | { 14 | [JsonProperty("expression")] 15 | public string Expression { get; set; } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/FileBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class FileBlock : Block, IColumnChildrenBlock, INonColumnBlock 6 | { 7 | [JsonProperty("file")] 8 | public FileObject File { get; set; } 9 | 10 | public override BlockType Type => BlockType.File; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/IBlockParent.cs: -------------------------------------------------------------------------------- 1 | using JsonSubTypes; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | [JsonConverter(typeof(JsonSubtypes), "type")] 7 | [JsonSubtypes.KnownSubTypeAttribute(typeof(DatabaseParent), ParentType.DatabaseId)] 8 | [JsonSubtypes.KnownSubTypeAttribute(typeof(PageParent), ParentType.PageId)] 9 | [JsonSubtypes.KnownSubTypeAttribute(typeof(WorkspaceParent), ParentType.Workspace)] 10 | [JsonSubtypes.KnownSubTypeAttribute(typeof(BlockParent), ParentType.BlockId)] 11 | public interface IBlockParent : IParent 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/IColumnChildrenBlock.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public interface ITemplateChildrenBlock : IBlock 4 | { 5 | } 6 | 7 | public interface ISyncedBlockChildren : IBlock 8 | { 9 | } 10 | 11 | public interface IColumnChildrenBlock : ITemplateChildrenBlock, ISyncedBlockChildren 12 | { 13 | } 14 | 15 | public interface INonColumnBlock : IBlock 16 | { 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/ImageBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class ImageBlock : Block, IColumnChildrenBlock, INonColumnBlock 6 | { 7 | [JsonProperty("image")] 8 | public FileObject Image { get; set; } 9 | 10 | public override BlockType Type => BlockType.Image; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/LinkPreviewBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class LinkPreviewBlock : Block, IColumnChildrenBlock, INonColumnBlock 6 | { 7 | [JsonProperty("link_preview")] 8 | public Data LinkPreview { get; set; } 9 | 10 | public override BlockType Type => BlockType.LinkPreview; 11 | 12 | public class Data 13 | { 14 | [JsonProperty("url")] 15 | public string Url { get; set; } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/LinkToPageBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class LinkToPageBlock : Block, IColumnChildrenBlock, INonColumnBlock 6 | { 7 | [JsonProperty("link_to_page")] 8 | public IPageParent LinkToPage { get; set; } 9 | 10 | public override BlockType Type => BlockType.LinkToPage; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/NumberedListItemBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | 5 | namespace Notion.Client 6 | { 7 | public class NumberedListItemBlock : Block, IColumnChildrenBlock, INonColumnBlock 8 | { 9 | [JsonProperty("numbered_list_item")] 10 | public Info NumberedListItem { get; set; } 11 | 12 | public override BlockType Type => BlockType.NumberedListItem; 13 | 14 | public class Info 15 | { 16 | [JsonProperty("rich_text")] 17 | public IEnumerable RichText { get; set; } 18 | 19 | [JsonProperty("color")] 20 | [JsonConverter(typeof(StringEnumConverter))] 21 | public Color? Color { get; set; } 22 | 23 | [JsonProperty("children")] 24 | public IEnumerable Children { get; set; } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/PDFBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | [SuppressMessage("ReSharper", "InconsistentNaming")] 7 | public class PDFBlock : Block, IColumnChildrenBlock, INonColumnBlock 8 | { 9 | [JsonProperty("pdf")] 10 | public FileObject PDF { get; set; } 11 | 12 | public override BlockType Type => BlockType.PDF; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/ParagraphBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | 5 | namespace Notion.Client 6 | { 7 | public class ParagraphBlock : Block, IColumnChildrenBlock, INonColumnBlock 8 | { 9 | [JsonProperty("paragraph")] 10 | public Info Paragraph { get; set; } 11 | 12 | public override BlockType Type => BlockType.Paragraph; 13 | 14 | public class Info 15 | { 16 | [JsonProperty("rich_text")] 17 | public IEnumerable RichText { get; set; } 18 | 19 | [JsonProperty("color")] 20 | [JsonConverter(typeof(StringEnumConverter))] 21 | public Color? Color { get; set; } 22 | 23 | [JsonProperty("children")] 24 | public IEnumerable Children { get; set; } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/QuoteBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | 5 | namespace Notion.Client 6 | { 7 | public class QuoteBlock : Block, IColumnChildrenBlock, INonColumnBlock 8 | { 9 | [JsonProperty("quote")] 10 | public Info Quote { get; set; } 11 | 12 | public override BlockType Type => BlockType.Quote; 13 | 14 | public class Info 15 | { 16 | [JsonProperty("rich_text")] 17 | public IEnumerable RichText { get; set; } 18 | 19 | [JsonProperty("color")] 20 | [JsonConverter(typeof(StringEnumConverter))] 21 | public Color? Color { get; set; } 22 | 23 | [JsonProperty("children")] 24 | public IEnumerable Children { get; set; } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/AudioBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class AudioBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 6 | { 7 | [JsonProperty("audio")] 8 | public FileObject Audio { get; set; } 9 | 10 | public override BlockType Type => BlockType.Audio; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/BlockObjectRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Notion.Client 4 | { 5 | public abstract class BlockObjectRequest : IBlockObjectRequest 6 | { 7 | public ObjectType Object => ObjectType.Block; 8 | 9 | public string Id { get; set; } 10 | 11 | public virtual BlockType Type { get; set; } 12 | 13 | public DateTime CreatedTime { get; set; } 14 | 15 | public DateTime LastEditedTime { get; set; } 16 | 17 | public virtual bool HasChildren { get; set; } 18 | 19 | public PartialUser CreatedBy { get; set; } 20 | 21 | public PartialUser LastEditedBy { get; set; } 22 | 23 | /// 24 | /// Information about the block's parent. 25 | /// 26 | public IBlockParent Parent { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/BookmarkBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class BookmarkBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 7 | { 8 | [JsonProperty("bookmark")] 9 | public Info Bookmark { get; set; } 10 | 11 | public override BlockType Type => BlockType.Bookmark; 12 | 13 | public class Info 14 | { 15 | [JsonProperty("url")] 16 | public string Url { get; set; } 17 | 18 | [JsonProperty("caption")] 19 | public IEnumerable Caption { get; set; } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/BreadcrumbBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class BreadcrumbBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 6 | { 7 | [JsonProperty("breadcrumb")] 8 | public Data Breadcrumb { get; set; } 9 | 10 | public override BlockType Type => BlockType.Breadcrumb; 11 | 12 | public class Data 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/BulletedListItemBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | 5 | namespace Notion.Client 6 | { 7 | public class BulletedListItemBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 8 | { 9 | [JsonProperty("bulleted_list_item")] 10 | public Info BulletedListItem { get; set; } 11 | 12 | public override BlockType Type => BlockType.BulletedListItem; 13 | 14 | public class Info 15 | { 16 | [JsonProperty("rich_text")] 17 | public IEnumerable RichText { get; set; } 18 | 19 | [JsonProperty("color")] 20 | [JsonConverter(typeof(StringEnumConverter))] 21 | public Color? Color { get; set; } 22 | 23 | [JsonProperty("children")] 24 | public IEnumerable Children { get; set; } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/ChildDatabaseBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class ChildDatabaseBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 6 | { 7 | [JsonProperty("child_database")] 8 | public Info ChildDatabase { get; set; } 9 | 10 | public override BlockType Type => BlockType.ChildDatabase; 11 | 12 | public class Info 13 | { 14 | [JsonProperty("title")] 15 | public string Title { get; set; } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/ChildPageBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class ChildPageBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 6 | { 7 | [JsonProperty("child_page")] 8 | public Info ChildPage { get; set; } 9 | 10 | public override BlockType Type => BlockType.ChildPage; 11 | 12 | public class Info 13 | { 14 | [JsonProperty("title")] 15 | public string Title { get; set; } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/CodeBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class CodeBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 7 | { 8 | [JsonProperty("code")] 9 | public Info Code { get; set; } 10 | 11 | public override BlockType Type => BlockType.Code; 12 | 13 | public class Info 14 | { 15 | [JsonProperty("rich_text")] 16 | public IEnumerable RichText { get; set; } 17 | 18 | [JsonProperty("language")] 19 | public string Language { get; set; } 20 | 21 | [JsonProperty("caption")] 22 | public IEnumerable Caption { get; set; } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/ColumnBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class ColumnBlockRequest : BlockObjectRequest 7 | { 8 | public override BlockType Type => BlockType.Column; 9 | 10 | [JsonProperty("column")] 11 | public Info Column { get; set; } 12 | 13 | public class Info 14 | { 15 | [JsonProperty("children")] 16 | public IEnumerable Children { get; set; } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/ColumnListBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class ColumnListBlockRequest : BlockObjectRequest, INonColumnBlockRequest 7 | { 8 | [JsonProperty("column_list")] 9 | public Info ColumnList { get; set; } 10 | 11 | public override BlockType Type => BlockType.ColumnList; 12 | 13 | public class Info 14 | { 15 | [JsonProperty("children")] 16 | public IEnumerable Children { get; set; } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/DividerBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class DividerBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 6 | { 7 | [JsonProperty("divider")] 8 | public Data Divider { get; set; } 9 | 10 | public override BlockType Type => BlockType.Divider; 11 | 12 | public class Data 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/EmbedBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class EmbedBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 7 | { 8 | [JsonProperty("embed")] 9 | public Info Embed { get; set; } 10 | 11 | public override BlockType Type => BlockType.Embed; 12 | 13 | public class Info 14 | { 15 | [JsonProperty("url")] 16 | public string Url { get; set; } 17 | 18 | [JsonProperty("caption")] 19 | public IEnumerable Caption { get; set; } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/EquationBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class EquationBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 6 | { 7 | [JsonProperty("equation")] 8 | public Info Equation { get; set; } 9 | 10 | public override BlockType Type => BlockType.Equation; 11 | 12 | public class Info 13 | { 14 | [JsonProperty("expression")] 15 | public string Expression { get; set; } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/FileBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class FileBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 6 | { 7 | [JsonProperty("file")] 8 | public FileObject File { get; set; } 9 | 10 | public override BlockType Type => BlockType.File; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/IBlockObjectRequest.cs: -------------------------------------------------------------------------------- 1 | using JsonSubTypes; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | 5 | namespace Notion.Client 6 | { 7 | public interface IBlockObjectRequest : IObject, IObjectModificationData 8 | { 9 | [JsonProperty("type")] 10 | [JsonConverter(typeof(StringEnumConverter))] 11 | BlockType Type { get; } 12 | 13 | [JsonProperty("has_children")] 14 | bool HasChildren { get; set; } 15 | 16 | [JsonProperty("parent")] 17 | IBlockParent Parent { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/IColumnChildrenBlockRequest.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public interface ITemplateChildrenBlockRequest : IBlockObjectRequest 4 | { 5 | } 6 | 7 | public interface ISyncedBlockChildrenRequest : IBlockObjectRequest 8 | { 9 | } 10 | 11 | public interface IColumnChildrenBlockRequest : ITemplateChildrenBlockRequest, ISyncedBlockChildrenRequest 12 | { 13 | } 14 | 15 | public interface INonColumnBlockRequest : IBlockObjectRequest 16 | { 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/ImageBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class ImageBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 6 | { 7 | [JsonProperty("image")] 8 | public FileObject Image { get; set; } 9 | 10 | public override BlockType Type => BlockType.Image; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/LinkPreviewBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class LinkPreviewBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 6 | { 7 | [JsonProperty("link_preview")] 8 | public Data LinkPreview { get; set; } 9 | 10 | public override BlockType Type => BlockType.LinkPreview; 11 | 12 | public class Data 13 | { 14 | [JsonProperty("url")] 15 | public string Url { get; set; } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/LinkToPageBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class LinkToPageBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 6 | { 7 | [JsonProperty("link_to_page")] 8 | public IPageParent LinkToPage { get; set; } 9 | 10 | public override BlockType Type => BlockType.LinkToPage; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/NumberedListItemBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | 5 | namespace Notion.Client 6 | { 7 | public class NumberedListItemBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 8 | { 9 | [JsonProperty("numbered_list_item")] 10 | public Info NumberedListItem { get; set; } 11 | 12 | public override BlockType Type => BlockType.NumberedListItem; 13 | 14 | public class Info 15 | { 16 | [JsonProperty("rich_text")] 17 | public IEnumerable RichText { get; set; } 18 | 19 | [JsonProperty("color")] 20 | [JsonConverter(typeof(StringEnumConverter))] 21 | public Color? Color { get; set; } 22 | 23 | [JsonProperty("children")] 24 | public IEnumerable Children { get; set; } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/PDFBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | [SuppressMessage("ReSharper", "InconsistentNaming")] 7 | public class PDFBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 8 | { 9 | [JsonProperty("pdf")] 10 | public FileObject PDF { get; set; } 11 | 12 | public override BlockType Type => BlockType.PDF; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/ParagraphBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | 5 | namespace Notion.Client 6 | { 7 | public class ParagraphBlockRequest : Block, IColumnChildrenBlockRequest, INonColumnBlockRequest 8 | { 9 | [JsonProperty("paragraph")] 10 | public Info Paragraph { get; set; } 11 | 12 | public override BlockType Type => BlockType.Paragraph; 13 | 14 | public class Info 15 | { 16 | [JsonProperty("rich_text")] 17 | public IEnumerable RichText { get; set; } 18 | 19 | [JsonProperty("color")] 20 | [JsonConverter(typeof(StringEnumConverter))] 21 | public Color? Color { get; set; } 22 | 23 | [JsonProperty("children")] 24 | public IEnumerable Children { get; set; } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/QuoteBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | 5 | namespace Notion.Client 6 | { 7 | public class QuoteBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 8 | { 9 | [JsonProperty("quote")] 10 | public Info Quote { get; set; } 11 | 12 | public override BlockType Type => BlockType.Quote; 13 | 14 | public class Info 15 | { 16 | [JsonProperty("rich_text")] 17 | public IEnumerable RichText { get; set; } 18 | 19 | [JsonProperty("color")] 20 | [JsonConverter(typeof(StringEnumConverter))] 21 | public Color? Color { get; set; } 22 | 23 | [JsonProperty("children")] 24 | public IEnumerable Children { get; set; } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/TableBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class TableBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 7 | { 8 | [JsonProperty("table")] 9 | public Info Table { get; set; } 10 | 11 | public override BlockType Type => BlockType.Table; 12 | 13 | public class Info 14 | { 15 | [JsonProperty("table_width")] 16 | public int TableWidth { get; set; } 17 | 18 | [JsonProperty("has_column_header")] 19 | public bool HasColumnHeader { get; set; } 20 | 21 | [JsonProperty("has_row_header")] 22 | public bool HasRowHeader { get; set; } 23 | 24 | [JsonProperty("children")] 25 | public IEnumerable Children { get; set; } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/TableOfContentsBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Converters; 3 | 4 | namespace Notion.Client 5 | { 6 | public class TableOfContentsBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 7 | { 8 | [JsonProperty("table_of_contents")] 9 | public Data TableOfContents { get; set; } 10 | 11 | public override BlockType Type => BlockType.TableOfContents; 12 | 13 | public class Data 14 | { 15 | [JsonProperty("color")] 16 | [JsonConverter(typeof(StringEnumConverter))] 17 | public Color? Color { get; set; } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/TableRowBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class TableRowBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 7 | { 8 | [JsonProperty("table_row")] 9 | public Info TableRow { get; set; } 10 | 11 | public override BlockType Type => BlockType.TableRow; 12 | 13 | public class Info 14 | { 15 | [JsonProperty("cells")] 16 | public IEnumerable> Cells { get; set; } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/TemplateBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class TemplateBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 7 | { 8 | [JsonProperty("template")] 9 | public Data Template { get; set; } 10 | 11 | public override BlockType Type => BlockType.Template; 12 | 13 | public class Data 14 | { 15 | [JsonProperty("rich_text")] 16 | public IEnumerable RichText { get; set; } 17 | 18 | [JsonProperty("children")] 19 | public IEnumerable Children { get; set; } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/ToggleBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | 5 | namespace Notion.Client 6 | { 7 | public class ToggleBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 8 | { 9 | [JsonProperty("toggle")] 10 | public Info Toggle { get; set; } 11 | 12 | public override BlockType Type => BlockType.Toggle; 13 | 14 | public class Info 15 | { 16 | [JsonProperty("rich_text")] 17 | public IEnumerable RichText { get; set; } 18 | 19 | [JsonProperty("color")] 20 | [JsonConverter(typeof(StringEnumConverter))] 21 | public Color? Color { get; set; } 22 | 23 | [JsonProperty("children")] 24 | public IEnumerable Children { get; set; } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/Request/VideoBlockRequest.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class VideoBlockRequest : BlockObjectRequest, IColumnChildrenBlockRequest, INonColumnBlockRequest 6 | { 7 | [JsonProperty("video")] 8 | public FileObject Video { get; set; } 9 | 10 | public override BlockType Type => BlockType.Video; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/TableBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class TableBlock : Block, IColumnChildrenBlock, INonColumnBlock 7 | { 8 | [JsonProperty("table")] 9 | public Info Table { get; set; } 10 | 11 | public override BlockType Type => BlockType.Table; 12 | 13 | public class Info 14 | { 15 | [JsonProperty("table_width")] 16 | public int TableWidth { get; set; } 17 | 18 | [JsonProperty("has_column_header")] 19 | public bool HasColumnHeader { get; set; } 20 | 21 | [JsonProperty("has_row_header")] 22 | public bool HasRowHeader { get; set; } 23 | 24 | [JsonProperty("children")] 25 | public IEnumerable Children { get; set; } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/TableOfContentsBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Converters; 3 | 4 | namespace Notion.Client 5 | { 6 | public class TableOfContentsBlock : Block, IColumnChildrenBlock, INonColumnBlock 7 | { 8 | [JsonProperty("table_of_contents")] 9 | public Data TableOfContents { get; set; } 10 | 11 | public override BlockType Type => BlockType.TableOfContents; 12 | 13 | public class Data 14 | { 15 | [JsonProperty("color")] 16 | [JsonConverter(typeof(StringEnumConverter))] 17 | public Color? Color { get; set; } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/TableRowBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class TableRowBlock : Block, IColumnChildrenBlock, INonColumnBlock 7 | { 8 | [JsonProperty("table_row")] 9 | public Info TableRow { get; set; } 10 | 11 | public override BlockType Type => BlockType.TableRow; 12 | 13 | public class Info 14 | { 15 | [JsonProperty("cells")] 16 | public IEnumerable> Cells { get; set; } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/TemplateBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class TemplateBlock : Block, IColumnChildrenBlock, INonColumnBlock 7 | { 8 | [JsonProperty("template")] 9 | public Data Template { get; set; } 10 | 11 | public override BlockType Type => BlockType.Template; 12 | 13 | public class Data 14 | { 15 | [JsonProperty("rich_text")] 16 | public IEnumerable RichText { get; set; } 17 | 18 | [JsonProperty("children")] 19 | public IEnumerable Children { get; set; } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/ToDoBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | 5 | namespace Notion.Client 6 | { 7 | public class ToDoBlock : Block, IColumnChildrenBlock, INonColumnBlock 8 | { 9 | [JsonProperty("to_do")] 10 | public Info ToDo { get; set; } 11 | 12 | public override BlockType Type => BlockType.ToDo; 13 | 14 | public class Info 15 | { 16 | [JsonProperty("rich_text")] 17 | public IEnumerable RichText { get; set; } 18 | 19 | [JsonProperty("checked")] 20 | public bool IsChecked { get; set; } 21 | 22 | [JsonProperty("color")] 23 | [JsonConverter(typeof(StringEnumConverter))] 24 | public Color? Color { get; set; } 25 | 26 | [JsonProperty("children")] 27 | public IEnumerable Children { get; set; } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/ToggleBlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | 5 | namespace Notion.Client 6 | { 7 | public class ToggleBlock : Block, IColumnChildrenBlock, INonColumnBlock 8 | { 9 | [JsonProperty("toggle")] 10 | public Info Toggle { get; set; } 11 | 12 | public override BlockType Type => BlockType.Toggle; 13 | 14 | public class Info 15 | { 16 | [JsonProperty("rich_text")] 17 | public IEnumerable RichText { get; set; } 18 | 19 | [JsonProperty("color")] 20 | [JsonConverter(typeof(StringEnumConverter))] 21 | public Color? Color { get; set; } 22 | 23 | [JsonProperty("children")] 24 | public IEnumerable Children { get; set; } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/UnsupportedBlock.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public class UnsupportedBlock : Block, IColumnChildrenBlock, INonColumnBlock 4 | { 5 | public override BlockType Type => BlockType.Unsupported; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Blocks/VideoBlock.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class VideoBlock : Block, IColumnChildrenBlock, INonColumnBlock 6 | { 7 | [JsonProperty("video")] 8 | public FileObject Video { get; set; } 9 | 10 | public override BlockType Type => BlockType.Video; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/CustomEmoji.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class CustomEmoji 6 | { 7 | [JsonProperty("id")] 8 | public string Id { get; set; } 9 | 10 | [JsonProperty("name")] 11 | public string Name { get; set; } 12 | 13 | [JsonProperty("url")] 14 | public string Url { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/CustomEmojiObject.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class CustomEmojiObject : IPageIcon 6 | { 7 | [JsonProperty("custom_emoji")] 8 | public CustomEmoji CustomEmoji { get; set; } 9 | 10 | [JsonProperty("type")] 11 | public string Type { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/IDatabaseParent.cs: -------------------------------------------------------------------------------- 1 | using JsonSubTypes; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | [JsonConverter(typeof(JsonSubtypes), "type")] 7 | [JsonSubtypes.KnownSubTypeAttribute(typeof(PageParent), ParentType.PageId)] 8 | [JsonSubtypes.KnownSubTypeAttribute(typeof(WorkspaceParent), ParentType.Workspace)] 9 | [JsonSubtypes.KnownSubTypeAttribute(typeof(BlockParent), ParentType.BlockId)] 10 | public interface IDatabaseParent : IParent 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/IWikiDatabase.cs: -------------------------------------------------------------------------------- 1 | using JsonSubTypes; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | [JsonConverter(typeof(JsonSubtypes), "object")] 7 | [JsonSubtypes.KnownSubTypeAttribute(typeof(Page), ObjectType.Page)] 8 | [JsonSubtypes.KnownSubTypeAttribute(typeof(Database), ObjectType.Database)] 9 | public interface IWikiDatabase : IObject 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/ButtonProperty.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Newtonsoft.Json; 5 | using System.Threading.Tasks; 6 | 7 | namespace Notion.Client 8 | { 9 | public class ButtonProperty : Property 10 | { 11 | public override PropertyType Type => PropertyType.Button; 12 | 13 | [JsonProperty("button")] 14 | public Dictionary Button { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/CheckboxProperty.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class CheckboxProperty : Property 7 | { 8 | public override PropertyType Type => PropertyType.Checkbox; 9 | 10 | [JsonProperty("checkbox")] 11 | public Dictionary Checkbox { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/CreatedByProperty.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class CreatedByProperty : Property 7 | { 8 | public override PropertyType Type => PropertyType.CreatedBy; 9 | 10 | [JsonProperty("created_by")] 11 | public Dictionary CreatedBy { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/CreatedTimeProperty.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class CreatedTimeProperty : Property 7 | { 8 | public override PropertyType Type => PropertyType.CreatedTime; 9 | 10 | [JsonProperty("created_time")] 11 | public Dictionary CreatedTime { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/DateProperty.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class DateProperty : Property 7 | { 8 | public override PropertyType Type => PropertyType.Date; 9 | 10 | [JsonProperty("date")] 11 | public Dictionary Date { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/EmailProperty.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class EmailProperty : Property 7 | { 8 | public override PropertyType Type => PropertyType.Email; 9 | 10 | [JsonProperty("email")] 11 | public Dictionary Email { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/FilesProperty.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class FilesProperty : Property 7 | { 8 | public override PropertyType Type => PropertyType.Files; 9 | 10 | [JsonProperty("files")] 11 | public Dictionary Files { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/FormulaProperty.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class FormulaProperty : Property 6 | { 7 | public override PropertyType Type => PropertyType.Formula; 8 | 9 | [JsonProperty("formula")] 10 | public Formula Formula { get; set; } 11 | } 12 | 13 | public class Formula 14 | { 15 | [JsonProperty("expression")] 16 | public string Expression { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/LastEditedByProperty.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class LastEditedByProperty : Property 7 | { 8 | public override PropertyType Type => PropertyType.LastEditedBy; 9 | 10 | [JsonProperty("last_edited_by")] 11 | public Dictionary LastEditedBy { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/LastEditedTimeProperty.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class LastEditedTimeProperty : Property 7 | { 8 | public override PropertyType Type => PropertyType.LastEditedTime; 9 | 10 | [JsonProperty("last_edited_time")] 11 | public Dictionary LastEditedTime { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/NumberProperty.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class NumberProperty : Property 6 | { 7 | public override PropertyType Type => PropertyType.Number; 8 | 9 | [JsonProperty("number")] 10 | public Number Number { get; set; } 11 | } 12 | 13 | public class Number 14 | { 15 | [JsonProperty("format")] 16 | public string Format { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/PeopleProperty.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class PeopleProperty : Property 7 | { 8 | public override PropertyType Type => PropertyType.People; 9 | 10 | [JsonProperty("people")] 11 | public Dictionary People { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/PhoneNumberProperty.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class PhoneNumberProperty : Property 7 | { 8 | public override PropertyType Type => PropertyType.PhoneNumber; 9 | 10 | [JsonProperty("phone_number")] 11 | public Dictionary PhoneNumber { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/RelationProperty/DualPropertyRelation.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class DualPropertyRelation : RelationData 6 | { 7 | public override RelationType Type => RelationType.Dual; 8 | 9 | [JsonProperty("dual_property")] 10 | public Data DualProperty { get; set; } 11 | 12 | public class Data 13 | { 14 | [JsonProperty("synced_property_name")] 15 | public string SyncedPropertyName { get; set; } 16 | 17 | [JsonProperty("synced_property_id")] 18 | public string SyncedPropertyId { get; set; } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/RelationProperty/RelationData.cs: -------------------------------------------------------------------------------- 1 | using JsonSubTypes; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | 5 | namespace Notion.Client 6 | { 7 | [JsonConverter(typeof(JsonSubtypes), "type")] 8 | [JsonSubtypes.KnownSubTypeAttribute(typeof(SinglePropertyRelation), RelationType.Single)] 9 | [JsonSubtypes.KnownSubTypeAttribute(typeof(DualPropertyRelation), RelationType.Dual)] 10 | public abstract class RelationData 11 | { 12 | [JsonProperty("database_id")] 13 | public string DatabaseId { get; set; } 14 | 15 | [JsonProperty("type")] 16 | [JsonConverter(typeof(StringEnumConverter))] 17 | public virtual RelationType Type { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/RelationProperty/RelationProperty.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class RelationProperty : Property 6 | { 7 | public override PropertyType Type => PropertyType.Relation; 8 | 9 | [JsonProperty("relation")] 10 | public RelationData Relation { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/RelationProperty/RelationType.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | 3 | namespace Notion.Client 4 | { 5 | public enum RelationType 6 | { 7 | [EnumMember(Value = "single_property")] 8 | Single, 9 | 10 | [EnumMember(Value = "dual_property")] 11 | Dual 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/RelationProperty/SinglePropertyRelation.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class SinglePropertyRelation : RelationData 7 | { 8 | public override RelationType Type => RelationType.Single; 9 | 10 | [JsonProperty("single_property")] 11 | public Dictionary SingleProperty { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/RichTextProperty.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class RichTextProperty : Property 7 | { 8 | public override PropertyType Type => PropertyType.RichText; 9 | 10 | [JsonProperty("rich_text")] 11 | public Dictionary RichText { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/RollupProperty.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class RollupProperty : Property 6 | { 7 | public override PropertyType Type => PropertyType.Rollup; 8 | 9 | [JsonProperty("rollup")] 10 | public Rollup Rollup { get; set; } 11 | } 12 | 13 | public class Rollup 14 | { 15 | [JsonProperty("relation_property_name")] 16 | public string RelationPropertyName { get; set; } 17 | 18 | [JsonProperty("relation_property_id")] 19 | public string RelationPropertyId { get; set; } 20 | 21 | [JsonProperty("rollup_property_name")] 22 | public string RollupPropertyName { get; set; } 23 | 24 | [JsonProperty("rollup_property_id")] 25 | public string RollupPropertyId { get; set; } 26 | 27 | [JsonProperty("function")] 28 | public string Function { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/StatusProperty.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class StatusProperty : Property 7 | { 8 | public override PropertyType Type => PropertyType.Status; 9 | 10 | [JsonProperty("status")] 11 | public Dictionary Status { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/TitleProperty.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class TitleProperty : Property 7 | { 8 | public override PropertyType Type => PropertyType.Title; 9 | 10 | [JsonProperty("title")] 11 | public Dictionary Title { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/UniqueIdProperty.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class UniqueIdProperty : Property 7 | { 8 | public override PropertyType Type => PropertyType.UniqueId; 9 | 10 | [JsonProperty("unique_id")] 11 | public Dictionary UniqueId { get; set; } 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/Properties/UrlProperty.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class UrlProperty : Property 7 | { 8 | public override PropertyType Type => PropertyType.Url; 9 | 10 | [JsonProperty("url")] 11 | public Dictionary Url { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/RichText/RichTextEquation.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class RichTextEquation : RichTextBase 6 | { 7 | public override RichTextType Type => RichTextType.Equation; 8 | 9 | [JsonProperty("equation")] 10 | public Equation Equation { get; set; } 11 | } 12 | 13 | public class Equation 14 | { 15 | [JsonProperty("expression")] 16 | public string Expression { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/RichText/RichTextMention.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class RichTextMention : RichTextBase 6 | { 7 | public override RichTextType Type => RichTextType.Mention; 8 | 9 | [JsonProperty("mention")] 10 | public Mention Mention { get; set; } 11 | } 12 | 13 | public class Mention 14 | { 15 | [JsonProperty("type")] 16 | public string Type { get; set; } 17 | 18 | [JsonProperty("user")] 19 | public User User { get; set; } 20 | 21 | [JsonProperty("page")] 22 | public ObjectId Page { get; set; } 23 | 24 | [JsonProperty("database")] 25 | public ObjectId Database { get; set; } 26 | 27 | [JsonProperty("date")] 28 | public Date Date { get; set; } 29 | } 30 | 31 | public class ObjectId 32 | { 33 | [JsonProperty("id")] 34 | public string Id { get; set; } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/RichText/RichTextText.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class RichTextText : RichTextBase 6 | { 7 | public override RichTextType Type => RichTextType.Text; 8 | 9 | [JsonProperty("text")] 10 | public Text Text { get; set; } 11 | } 12 | 13 | public class Text 14 | { 15 | [JsonProperty("content")] 16 | public string Content { get; set; } 17 | 18 | [JsonProperty("link")] 19 | public Link Link { get; set; } 20 | } 21 | 22 | public class Link 23 | { 24 | [JsonProperty("type")] 25 | public string Type => "url"; 26 | 27 | [JsonProperty("url")] 28 | public string Url { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Database/RichText/RichTextType.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Notion.Client 5 | { 6 | [SuppressMessage("ReSharper", "UnusedMember.Global")] 7 | public enum RichTextType 8 | { 9 | [EnumMember(Value = null)] 10 | Unknown, 11 | 12 | [EnumMember(Value = "text")] 13 | Text, 14 | 15 | [EnumMember(Value = "mention")] 16 | Mention, 17 | 18 | [EnumMember(Value = "equation")] 19 | Equation 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/EmojiObject.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class EmojiObject : IPageIcon 6 | { 7 | [JsonProperty("emoji")] 8 | public string Emoji { get; set; } 9 | 10 | [JsonProperty("type")] 11 | public string Type { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/File/ExternalFile.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class ExternalFile : FileObject 6 | { 7 | public override string Type => "external"; 8 | 9 | [JsonProperty("external")] 10 | public Info External { get; set; } 11 | 12 | public class Info 13 | { 14 | [JsonProperty("url")] 15 | public string Url { get; set; } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/File/ExternalFileWithName.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class ExternalFileWithName : FileObjectWithName 6 | { 7 | public override string Type => "external"; 8 | 9 | [JsonProperty("external")] 10 | public Info External { get; set; } 11 | 12 | public class Info 13 | { 14 | [JsonProperty("url")] 15 | public string Url { get; set; } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/File/FIleInput/ExternalFileInput.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class ExternalFileInput : IFileObjectInput 7 | { 8 | [JsonProperty("external")] 9 | public Data External { get; set; } 10 | 11 | [JsonProperty("name")] 12 | public string Name { get; set; } 13 | 14 | [JsonProperty("caption")] 15 | public IEnumerable Caption { get; set; } 16 | 17 | public class Data 18 | { 19 | [JsonProperty("url")] 20 | public string Url { get; set; } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/File/FIleInput/IFileObjectInput.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public interface IFileObjectInput 7 | { 8 | [JsonProperty("name")] 9 | public string Name { get; set; } 10 | 11 | [JsonProperty("caption")] 12 | public IEnumerable Caption { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/File/FIleInput/UploadedFileInput.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Notion.Client 6 | { 7 | public class UploadedFileInput : IFileObjectInput 8 | { 9 | [JsonProperty("file")] 10 | public Data File { get; set; } 11 | 12 | [JsonProperty("name")] 13 | public string Name { get; set; } 14 | 15 | [JsonProperty("caption")] 16 | public IEnumerable Caption { get; set; } 17 | 18 | public class Data 19 | { 20 | [JsonProperty("url")] 21 | public string Url { get; set; } 22 | 23 | [JsonProperty("expiry_time")] 24 | public DateTime ExpiryTime { get; set; } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/File/FileObject.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using JsonSubTypes; 3 | using Newtonsoft.Json; 4 | 5 | namespace Notion.Client 6 | { 7 | [JsonConverter(typeof(JsonSubtypes), "type")] 8 | [JsonSubtypes.KnownSubTypeAttribute(typeof(UploadedFile), "file")] 9 | [JsonSubtypes.KnownSubTypeAttribute(typeof(ExternalFile), "external")] 10 | public abstract class FileObject : IPageIcon 11 | { 12 | [JsonProperty("caption")] 13 | public IEnumerable Caption { get; set; } 14 | 15 | /// 16 | /// The name of the file block, as shown in the Notion UI. Note that the UI may auto-append .pdf or other extensions. 17 | /// 18 | [JsonProperty("name")] 19 | public string Name { get; set; } 20 | 21 | [JsonProperty("type")] 22 | public virtual string Type { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/File/FileObjectWithName.cs: -------------------------------------------------------------------------------- 1 | using JsonSubTypes; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | [JsonConverter(typeof(JsonSubtypes), "type")] 7 | [JsonSubtypes.KnownSubTypeAttribute(typeof(UploadedFileWithName), "file")] 8 | [JsonSubtypes.KnownSubTypeAttribute(typeof(ExternalFileWithName), "external")] 9 | public abstract class FileObjectWithName 10 | { 11 | [JsonProperty("type")] 12 | public virtual string Type { get; set; } 13 | 14 | [JsonProperty("name")] 15 | public string Name { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/File/UploadedFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class UploadedFile : FileObject 7 | { 8 | public override string Type => "file"; 9 | 10 | [JsonProperty("file")] 11 | public Info File { get; set; } 12 | 13 | public class Info 14 | { 15 | [JsonProperty("url")] 16 | public string Url { get; set; } 17 | 18 | [JsonProperty("expiry_time")] 19 | public DateTime ExpiryTime { get; set; } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/File/UploadedFileWithName.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class UploadedFileWithName : FileObjectWithName 7 | { 8 | public override string Type => "file"; 9 | 10 | [JsonProperty("file")] 11 | public Info File { get; set; } 12 | 13 | public class Info 14 | { 15 | [JsonProperty("url")] 16 | public string Url { get; set; } 17 | 18 | [JsonProperty("expiry_time")] 19 | public DateTime ExpiryTime { get; set; } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Filters/Filter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class Filter 7 | { 8 | } 9 | 10 | public class SinglePropertyFilter : Filter 11 | { 12 | [JsonProperty("property")] 13 | public string Property { get; set; } 14 | } 15 | 16 | public class CompoundFilter : Filter 17 | { 18 | public CompoundFilter(List or = null, List and = null) 19 | { 20 | Or = or; 21 | And = and; 22 | } 23 | 24 | [JsonProperty("or")] 25 | public List Or { get; set; } 26 | 27 | [JsonProperty("and")] 28 | public List And { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Filters/Rollup/IRollupSubPropertyFilter.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public interface IRollupSubPropertyFilter 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/IObject.cs: -------------------------------------------------------------------------------- 1 | using JsonSubTypes; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | 5 | namespace Notion.Client 6 | { 7 | [JsonConverter(typeof(JsonSubtypes), "object")] 8 | [JsonSubtypes.KnownSubTypeAttribute(typeof(Page), ObjectType.Page)] 9 | [JsonSubtypes.KnownSubTypeAttribute(typeof(Database), ObjectType.Database)] 10 | [JsonSubtypes.KnownSubTypeAttribute(typeof(IBlock), ObjectType.Block)] 11 | [JsonSubtypes.KnownSubTypeAttribute(typeof(User), ObjectType.User)] 12 | public interface IObject 13 | { 14 | [JsonProperty("id")] 15 | string Id { get; set; } 16 | 17 | [JsonProperty("object")] 18 | [JsonConverter(typeof(StringEnumConverter))] 19 | ObjectType Object { get; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/ObjectType.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | 3 | namespace Notion.Client 4 | { 5 | public enum ObjectType 6 | { 7 | [EnumMember(Value = "page")] 8 | Page, 9 | 10 | [EnumMember(Value = "database")] 11 | Database, 12 | 13 | [EnumMember(Value = "block")] 14 | Block, 15 | 16 | [EnumMember(Value = "user")] 17 | User, 18 | 19 | [EnumMember(Value = "comment")] 20 | Comment 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Page/IPageIcon.cs: -------------------------------------------------------------------------------- 1 | using JsonSubTypes; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | [JsonConverter(typeof(JsonSubtypes), "type")] 7 | [JsonSubtypes.KnownSubTypeAttribute(typeof(EmojiObject), "emoji")] 8 | [JsonSubtypes.KnownSubTypeAttribute(typeof(CustomEmojiObject), "custom_emoji")] 9 | [JsonSubtypes.KnownSubTypeAttribute(typeof(FileObject), "file")] 10 | [JsonSubtypes.KnownSubTypeAttribute(typeof(FileObject), "external")] 11 | public interface IPageIcon 12 | { 13 | [JsonProperty("type")] 14 | string Type { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Page/IPageParent.cs: -------------------------------------------------------------------------------- 1 | using JsonSubTypes; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | [JsonConverter(typeof(JsonSubtypes), "type")] 7 | [JsonSubtypes.KnownSubTypeAttribute(typeof(DatabaseParent), ParentType.DatabaseId)] 8 | [JsonSubtypes.KnownSubTypeAttribute(typeof(PageParent), ParentType.PageId)] 9 | [JsonSubtypes.KnownSubTypeAttribute(typeof(WorkspaceParent), ParentType.Workspace)] 10 | [JsonSubtypes.KnownSubTypeAttribute(typeof(BlockParent), ParentType.BlockId)] 11 | public interface IPageParent : IParent 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Page/PagePropertyOnId.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class PagePropertyOnId 6 | { 7 | [JsonProperty("id")] 8 | public string Id { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PaginatedList.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public interface IPaginationParameters 7 | { 8 | [JsonProperty("start_cursor")] 9 | string StartCursor { get; set; } 10 | 11 | [JsonProperty("page_size")] 12 | int? PageSize { get; set; } 13 | } 14 | 15 | public class PaginatedList 16 | { 17 | [JsonProperty("object")] 18 | public const string Object = "list"; 19 | 20 | [JsonProperty("results")] 21 | public List Results { get; set; } 22 | 23 | [JsonProperty("has_more")] 24 | public bool HasMore { get; set; } 25 | 26 | [JsonProperty("next_cursor")] 27 | public string NextCursor { get; set; } 28 | 29 | [JsonProperty("type")] 30 | public string Type { get; set; } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Parents/BlockParent.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class BlockParent : IPageParent, IDatabaseParent, IBlockParent, ICommentParent 6 | { 7 | /// 8 | /// The ID of the block that the element belongs to. 9 | /// 10 | [JsonProperty("block_id")] 11 | public string BlockId { get; set; } 12 | 13 | /// 14 | /// Always has a value "block_id" 15 | /// 16 | public ParentType Type { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Parents/DatabaseParent.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class DatabaseParent : IPageParent, IBlockParent 6 | { 7 | /// 8 | /// The ID of the database that this page belongs to. 9 | /// 10 | [JsonProperty("database_id")] 11 | public string DatabaseId { get; set; } 12 | 13 | /// 14 | /// Always "database_id" 15 | /// 16 | public ParentType Type { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Parents/IParent.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | 5 | namespace Notion.Client 6 | { 7 | [SuppressMessage("ReSharper", "UnusedMemberInSuper.Global")] 8 | public interface IParent 9 | { 10 | [JsonConverter(typeof(StringEnumConverter))] 11 | ParentType Type { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Parents/PageParent.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class PageParent : IPageParent, IDatabaseParent, IBlockParent, ICommentParent 6 | { 7 | /// 8 | /// The ID of the page that this page belongs to. 9 | /// 10 | [JsonProperty("page_id")] 11 | public string PageId { get; set; } 12 | 13 | /// 14 | /// Always "page_id". 15 | /// 16 | public ParentType Type { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Parents/ParentType.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Notion.Client 5 | { 6 | [SuppressMessage("ReSharper", "UnusedMember.Global")] 7 | public enum ParentType 8 | { 9 | [EnumMember(Value = null)] 10 | Unknown, 11 | 12 | [EnumMember(Value = "database_id")] 13 | DatabaseId, 14 | 15 | [EnumMember(Value = "page_id")] 16 | PageId, 17 | 18 | [EnumMember(Value = "workspace")] 19 | Workspace, 20 | 21 | [EnumMember(Value = "block_id")] 22 | BlockId 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/Parents/WorkspaceParent.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public class WorkspaceParent : IPageParent, IDatabaseParent, IBlockParent 4 | { 5 | /// 6 | /// Always "workspace". 7 | /// 8 | public ParentType Type { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/CheckboxPropertyItem.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class CheckboxPropertyItem : SimplePropertyItem 6 | { 7 | public override string Type => "checkbox"; 8 | 9 | [JsonProperty("checkbox")] 10 | public bool Checkbox { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/CreatedByPropertyItem.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class CreatedByPropertyItem : SimplePropertyItem 6 | { 7 | public override string Type => "created_by"; 8 | 9 | [JsonProperty("created_by")] 10 | public User CreatedBy { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/CreatedTimePropertyItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class CreatedTimePropertyItem : SimplePropertyItem 7 | { 8 | public override string Type => "created_time"; 9 | 10 | [JsonProperty("created_time")] 11 | public DateTime CreatedTime { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/DatePropertyItem.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class DatePropertyItem : SimplePropertyItem 6 | { 7 | public override string Type => "date"; 8 | 9 | [JsonProperty("date")] 10 | public Date Date { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/EmailPropertyItem.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class EmailPropertyItem : SimplePropertyItem 6 | { 7 | public override string Type => "email"; 8 | 9 | [JsonProperty("email")] 10 | public string Email { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/FilesPropertyItem.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class FilesPropertyItem : SimplePropertyItem 7 | { 8 | public override string Type => "files"; 9 | 10 | [JsonProperty("files")] 11 | public IEnumerable Files { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/FormulaPropertyItem.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class FormulaPropertyItem : SimplePropertyItem 6 | { 7 | public override string Type => "formula"; 8 | 9 | [JsonProperty("formula")] 10 | public FormulaValue Formula { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/IPropertyItemObject.cs: -------------------------------------------------------------------------------- 1 | using JsonSubTypes; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | [JsonConverter(typeof(JsonSubtypes), "object")] 7 | [JsonSubtypes.KnownSubTypeAttribute(typeof(SimplePropertyItem), "property_item")] 8 | [JsonSubtypes.KnownSubTypeAttribute(typeof(ListPropertyItem), "list")] 9 | public interface IPropertyItemObject 10 | { 11 | [JsonProperty("object")] 12 | string Object { get; } 13 | 14 | [JsonProperty("type")] 15 | string Type { get; } 16 | 17 | [JsonProperty("id")] 18 | string Id { get; } 19 | 20 | /// 21 | /// Only present in paginated property values with another page of results. If present, the url the user can request to 22 | /// get the next page of results. 23 | /// 24 | [JsonProperty("next_url")] 25 | string NextURL { get; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/LastEditedByPropertyItem.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class LastEditedByPropertyItem : SimplePropertyItem 6 | { 7 | public override string Type => "last_edited_by"; 8 | 9 | [JsonProperty("last_edited_by")] 10 | public User LastEditedBy { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/LastEditedTimePropertyItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class LastEditedTimePropertyItem : SimplePropertyItem 7 | { 8 | public override string Type => "last_edited_time"; 9 | 10 | [JsonProperty("last_edited_time")] 11 | public DateTime LastEditedTime { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/MultiSelectPropertyItem.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | public class MultiSelectPropertyItem : SimplePropertyItem 7 | { 8 | public override string Type => "multi_select"; 9 | 10 | [JsonProperty("multi_select")] 11 | public IEnumerable MultiSelect { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/NumberPropertyItem.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class NumberPropertyItem : SimplePropertyItem 6 | { 7 | public override string Type => "number"; 8 | 9 | [JsonProperty("number")] 10 | public double? Number { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/PeoplePropertyItem.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class PeoplePropertyItem : SimplePropertyItem 6 | { 7 | public override string Type => "people"; 8 | 9 | [JsonProperty("people")] 10 | public User People { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/PhoneNumberPropertyItem.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class PhoneNumberPropertyItem : SimplePropertyItem 6 | { 7 | public override string Type => "phone_number"; 8 | 9 | [JsonProperty("phone_number")] 10 | public string PhoneNumber { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/RelationPropertyItem.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class RelationPropertyItem : SimplePropertyItem 6 | { 7 | public override string Type => "relation"; 8 | 9 | [JsonProperty("relation")] 10 | public ObjectId Relation { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/RichTextPropertyItem.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class RichTextPropertyItem : SimplePropertyItem 6 | { 7 | public override string Type => "rich_text"; 8 | 9 | [JsonProperty("rich_text")] 10 | public RichTextBase RichText { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/SelectPropertyItem.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class SelectPropertyItem : SimplePropertyItem 6 | { 7 | public override string Type => "select"; 8 | 9 | [JsonProperty("select")] 10 | public SelectOption Select { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/StatusPropertyItem.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class StatusPropertyItem : SimplePropertyItem 6 | { 7 | public override string Type => "status"; 8 | 9 | [JsonProperty("status")] 10 | public SelectOption Status { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/TitlePropertyItem.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class TitlePropertyItem : SimplePropertyItem 6 | { 7 | public override string Type => "title"; 8 | 9 | [JsonProperty("title")] 10 | public RichTextBase Title { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyItems/UrlPropertyItem.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class UrlPropertyItem : SimplePropertyItem 6 | { 7 | public override string Type => "url"; 8 | 9 | [JsonProperty("url")] 10 | public string Url { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyValue/ButtonPropertyValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Newtonsoft.Json; 5 | 6 | namespace Notion.Client 7 | { 8 | public class ButtonPropertyValue : PropertyValue 9 | { 10 | public override PropertyValueType Type => PropertyValueType.Button; 11 | 12 | [JsonProperty("button")] 13 | public ButtonValue Button { get; set; } 14 | 15 | public class ButtonValue { } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyValue/CheckboxPropertyValue.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | /// 6 | /// Checkbox property value objects contain a boolean within the checkbox property. 7 | /// 8 | public class CheckboxPropertyValue : PropertyValue 9 | { 10 | public override PropertyValueType Type => PropertyValueType.Checkbox; 11 | 12 | [JsonProperty("checkbox")] 13 | public bool Checkbox { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyValue/CreatedByPropertyValue.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | /// 6 | /// Created by property value object 7 | /// 8 | public class CreatedByPropertyValue : PropertyValue 9 | { 10 | public override PropertyValueType Type => PropertyValueType.CreatedBy; 11 | 12 | /// 13 | /// Describes the user who created this page. 14 | /// 15 | [JsonProperty("created_by")] 16 | public User CreatedBy { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyValue/CreatedTimePropertyValue.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | /// 6 | /// Created time property value object. 7 | /// 8 | public class CreatedTimePropertyValue : PropertyValue 9 | { 10 | public override PropertyValueType Type => PropertyValueType.CreatedTime; 11 | 12 | /// 13 | /// The date and time when this page was created. 14 | /// 15 | [JsonProperty("created_time")] 16 | public string CreatedTime { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyValue/DateJsonObject.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | internal class DateJsonObject 6 | { 7 | [JsonProperty("start")] 8 | public string Start { get; set; } 9 | 10 | [JsonProperty("end")] 11 | public string End { get; set; } 12 | 13 | [JsonProperty("time_zone")] 14 | public string TimeZone { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyValue/EmailPropertyValue.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | /// 6 | /// Email property value object. 7 | /// 8 | public class EmailPropertyValue : PropertyValue 9 | { 10 | public override PropertyValueType Type => PropertyValueType.Email; 11 | 12 | /// 13 | /// Describes an email address. 14 | /// 15 | [JsonProperty("email", NullValueHandling = NullValueHandling.Include)] 16 | public string Email { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyValue/FilesPropertyValue.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | /// 7 | /// File property value object. 8 | /// 9 | public class FilesPropertyValue : PropertyValue 10 | { 11 | public override PropertyValueType Type => PropertyValueType.Files; 12 | 13 | /// 14 | /// Array of File Object with name. 15 | /// 16 | [JsonProperty("files")] 17 | public List Files { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyValue/LastEditedByPropertyValue.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | /// 6 | /// Last edited by property value object. 7 | /// 8 | public class LastEditedByPropertyValue : PropertyValue 9 | { 10 | public override PropertyValueType Type => PropertyValueType.LastEditedBy; 11 | 12 | /// 13 | /// Describes the user who last updated this page. 14 | /// 15 | [JsonProperty("last_edited_by")] 16 | public User LastEditedBy { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyValue/LastEditedTimePropertyValue.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | /// 6 | /// Last edited time property value object. 7 | /// 8 | public class LastEditedTimePropertyValue : PropertyValue 9 | { 10 | public override PropertyValueType Type => PropertyValueType.LastEditedTime; 11 | 12 | /// 13 | /// The date and time when this page was last updated. 14 | /// 15 | [JsonProperty("last_edited_time")] 16 | public string LastEditedTime { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyValue/MultiSelectPropertyValue.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | /// 7 | /// Multi-select property value object. 8 | /// 9 | public class MultiSelectPropertyValue : PropertyValue 10 | { 11 | public override PropertyValueType Type => PropertyValueType.MultiSelect; 12 | 13 | /// 14 | /// An array of multi-select option values. 15 | /// 16 | [JsonProperty("multi_select")] 17 | public List MultiSelect { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyValue/NumberPropertyValue.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | /// 6 | /// Number formula property value object. 7 | /// 8 | public class NumberPropertyValue : PropertyValue 9 | { 10 | public override PropertyValueType Type => PropertyValueType.Number; 11 | 12 | /// 13 | /// Value of number 14 | /// 15 | [JsonProperty("number", NullValueHandling = NullValueHandling.Include)] 16 | public double? Number { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyValue/PeoplePropertyValue.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | /// 7 | /// People property value object. 8 | /// 9 | public class PeoplePropertyValue : PropertyValue 10 | { 11 | public override PropertyValueType Type => PropertyValueType.People; 12 | 13 | /// 14 | /// List of users. 15 | /// 16 | [JsonProperty("people")] 17 | public List People { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyValue/PhoneNumberPropertyValue.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | /// 6 | /// Phone number property value object. 7 | /// 8 | public class PhoneNumberPropertyValue : PropertyValue 9 | { 10 | public override PropertyValueType Type => PropertyValueType.PhoneNumber; 11 | 12 | /// 13 | /// Phone number value 14 | /// 15 | [JsonProperty("phone_number", NullValueHandling = NullValueHandling.Include)] 16 | public string PhoneNumber { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyValue/RelationPropertyValue.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | /// 7 | /// Relation property value object. 8 | /// 9 | public class RelationPropertyValue : PropertyValue 10 | { 11 | public override PropertyValueType Type => PropertyValueType.Relation; 12 | 13 | /// 14 | /// Array of page references 15 | /// 16 | [JsonProperty("relation")] 17 | public List Relation { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyValue/RichTextPropertyValue.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | /// 7 | /// Rich Text property value object. 8 | /// 9 | public class RichTextPropertyValue : PropertyValue 10 | { 11 | public override PropertyValueType Type => PropertyValueType.RichText; 12 | 13 | /// 14 | /// List of rich text objects 15 | /// 16 | [JsonProperty("rich_text")] 17 | public List RichText { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyValue/SelectPropertyValue.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | /// 6 | /// Select property value object. 7 | /// 8 | public class SelectPropertyValue : PropertyValue 9 | { 10 | public override PropertyValueType Type => PropertyValueType.Select; 11 | 12 | [JsonProperty("select", NullValueHandling = NullValueHandling.Include)] 13 | public SelectOption Select { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyValue/TitlePropertyValue.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | /// 7 | /// Title property value object. 8 | /// 9 | public class TitlePropertyValue : PropertyValue 10 | { 11 | public override PropertyValueType Type => PropertyValueType.Title; 12 | 13 | /// 14 | /// An array of rich text objects 15 | /// 16 | [JsonProperty("title")] 17 | public List Title { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyValue/UniqueIdPropertyValue.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | /// 6 | /// Unique Id property value object. 7 | /// 8 | public class UniqueIdPropertyValue : PropertyValue 9 | { 10 | public override PropertyValueType Type => PropertyValueType.UniqueId; 11 | 12 | /// 13 | /// Unique Id property of database item 14 | /// 15 | [JsonProperty("unique_id")] 16 | public UniqueIdValue UniqueId { get; set; } 17 | } 18 | 19 | public class UniqueIdValue 20 | { 21 | [JsonProperty("prefix")] 22 | public string Prefix { get; set; } 23 | 24 | [JsonProperty("number")] 25 | public double? Number { get; set; } 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/PropertyValue/UrlPropertyValue.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | /// 6 | /// URL property value object. 7 | /// 8 | public class UrlPropertyValue : PropertyValue 9 | { 10 | public override PropertyValueType Type => PropertyValueType.Url; 11 | 12 | /// 13 | /// Describes a web address 14 | /// 15 | [JsonProperty("url", NullValueHandling = NullValueHandling.Include)] 16 | public string Url { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/User/Bot.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class Bot 6 | { 7 | [JsonProperty("owner")] 8 | public IBotOwner Owner { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/User/BotOwner/IBotOwner.cs: -------------------------------------------------------------------------------- 1 | using JsonSubTypes; 2 | using Newtonsoft.Json; 3 | 4 | namespace Notion.Client 5 | { 6 | [JsonConverter(typeof(JsonSubtypes), "type")] 7 | [JsonSubtypes.KnownSubTypeAttribute(typeof(UserOwner), "user")] 8 | [JsonSubtypes.KnownSubTypeAttribute(typeof(WorkspaceIntegrationOwner), "workspace")] 9 | public interface IBotOwner 10 | { 11 | [JsonProperty("type")] 12 | string Type { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/User/BotOwner/UserOwner.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class UserOwner : IBotOwner 6 | { 7 | [JsonProperty("user")] 8 | public User User { get; set; } 9 | 10 | public string Type { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/User/BotOwner/WorkspaceIntegrationOwner.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class WorkspaceIntegrationOwner : IBotOwner 6 | { 7 | [JsonProperty("workspace")] 8 | public bool Workspace { get; set; } 9 | 10 | public string Type { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/User/PartialUser.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | 3 | namespace Notion.Client 4 | { 5 | [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] 6 | public class PartialUser : IObject 7 | { 8 | public string Id { get; set; } 9 | 10 | public ObjectType Object => ObjectType.User; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/User/Person.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class Person 6 | { 7 | [JsonProperty("email")] 8 | public string Email { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/Notion.Client/Models/User/User.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | public class User : IObject 6 | { 7 | [JsonProperty("type")] 8 | public string Type { get; set; } 9 | 10 | [JsonProperty("name")] 11 | public string Name { get; set; } 12 | 13 | [JsonProperty("avatar_url")] 14 | public string AvatarUrl { get; set; } 15 | 16 | [JsonProperty("person")] 17 | public Person Person { get; set; } 18 | 19 | [JsonProperty("bot")] 20 | public Bot Bot { get; set; } 21 | 22 | public ObjectType Object => ObjectType.User; 23 | 24 | public string Id { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Src/Notion.Client/NotionApiErrorResponse.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Notion.Client 4 | { 5 | internal class NotionApiErrorResponse 6 | { 7 | [JsonProperty("code")] 8 | public NotionAPIErrorCode ErrorCode { get; set; } 9 | 10 | [JsonProperty("message")] 11 | public string Message { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/Notion.Client/NotionApiRateLimitException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | 4 | namespace Notion.Client 5 | { 6 | public sealed class NotionApiRateLimitException : NotionApiException 7 | { 8 | public TimeSpan? RetryAfter { get; } 9 | 10 | public NotionApiRateLimitException( 11 | HttpStatusCode statusCode, 12 | NotionAPIErrorCode? notionAPIErrorCode, 13 | string message, 14 | TimeSpan? retryAfter) 15 | : base(statusCode, notionAPIErrorCode, message) 16 | { 17 | RetryAfter = retryAfter; 18 | 19 | Data.Add("RetryAfter", retryAfter); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/Notion.Client/NotionClientFactory.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public static class NotionClientFactory 4 | { 5 | public static NotionClient Create(ClientOptions options) 6 | { 7 | var restClient = new RestClient(options); 8 | 9 | return new NotionClient( 10 | restClient 11 | , new UsersClient(restClient) 12 | , new DatabasesClient(restClient) 13 | , new PagesClient(restClient) 14 | , new SearchClient(restClient) 15 | , new CommentsClient(restClient) 16 | , new BlocksClient(restClient) 17 | , new AuthenticationClient(restClient) 18 | ); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/Notion.Client/RestClient/ClientOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Notion.Client 2 | { 3 | public class ClientOptions 4 | { 5 | public string BaseUrl { get; set; } 6 | 7 | public string NotionVersion { get; set; } 8 | 9 | public string AuthToken { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/Notion.Client/RestClient/LoggingHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | 6 | namespace Notion.Client 7 | { 8 | public class LoggingHandler : DelegatingHandler 9 | { 10 | protected override async Task SendAsync( 11 | HttpRequestMessage request, 12 | CancellationToken cancellationToken) 13 | { 14 | Log.Trace("Request: {request}", request); 15 | 16 | try 17 | { 18 | var response = await base.SendAsync(request, cancellationToken); 19 | 20 | Log.Trace("Response: {response}", response); 21 | 22 | return response; 23 | } 24 | catch (Exception ex) 25 | { 26 | Log.Error(ex, "Failed to get response: {exception}", ex); 27 | 28 | throw; 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Test/Notion.IntegrationTests/IntegrationTestBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Notion.Client; 3 | 4 | namespace Notion.IntegrationTests; 5 | 6 | public abstract class IntegrationTestBase 7 | { 8 | protected readonly INotionClient Client; 9 | protected readonly string ParentPageId; 10 | protected readonly string ParentDatabaseId; 11 | 12 | protected IntegrationTestBase() 13 | { 14 | var options = new ClientOptions { AuthToken = Environment.GetEnvironmentVariable("NOTION_AUTH_TOKEN") }; 15 | 16 | Client = NotionClientFactory.Create(options); 17 | 18 | ParentPageId = Environment.GetEnvironmentVariable("NOTION_PARENT_PAGE_ID") 19 | ?? throw new InvalidOperationException("Parent page id is required."); 20 | 21 | ParentDatabaseId = Environment.GetEnvironmentVariable("NOTION_PARENT_DATABASE_ID") 22 | ?? throw new InvalidOperationException("Parent database id is required."); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Test/Notion.UnitTests/data/blocks/RetrieveBlockResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "object": "block", 3 | "id": "9bc30ad4-9373-46a5-84ab-0a7845ee52e6", 4 | "created_time": "2021-03-16T16:31:00.000Z", 5 | "last_edited_time": "2021-03-16T16:32:00.000Z", 6 | "has_children": false, 7 | "in_trash" : false, 8 | "type": "to_do", 9 | "to_do": { 10 | "rich_text": [ 11 | { 12 | "type": "text", 13 | "text": { 14 | "content": "Lacinato kale", 15 | "link": null 16 | }, 17 | "annotations": { 18 | "bold": false, 19 | "italic": false, 20 | "strikethrough": false, 21 | "underline": false, 22 | "code": false, 23 | "color": "default" 24 | }, 25 | "plain_text": "Lacinato kale", 26 | "href": null 27 | } 28 | ], 29 | "checked": false 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Test/Notion.UnitTests/data/blocks/UpdateBlockResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "object": "block", 3 | "id": "9bc30ad4-9373-46a5-84ab-0a7845ee52e6", 4 | "created_time": "2021-03-16T16:31:00.000Z", 5 | "last_edited_time": "2021-03-16T16:32:00.000Z", 6 | "has_children": false, 7 | "in_trash" : false, 8 | "type": "to_do", 9 | "to_do": { 10 | "rich_text": [ 11 | { 12 | "type": "text", 13 | "text": { 14 | "content": "Lacinato kale", 15 | "link": null 16 | }, 17 | "annotations": { 18 | "bold": false, 19 | "italic": false, 20 | "strikethrough": false, 21 | "underline": false, 22 | "code": false, 23 | "color": "default" 24 | }, 25 | "plain_text": "Lacinato kale", 26 | "href": null 27 | } 28 | ], 29 | "checked": false 30 | } 31 | } -------------------------------------------------------------------------------- /Test/Notion.UnitTests/data/users/ListUsersResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "object": "list", 3 | "results": [ 4 | { 5 | "object": "user", 6 | "id": "5e37c1b4-630f-4e81-bd6b-296af31e345f", 7 | "name": "Vedant Koditkar", 8 | "avatar_url": "https://lh3.googleusercontent.com/a-/AOh14Gg4lnfwJviST_tKZZpMfKrgmjp8wRzPBg9ec6sG7w=s100", 9 | "type": "person", 10 | "person": { 11 | "email": "vedkoditkar@gmail.com" 12 | } 13 | }, 14 | { 15 | "object": "user", 16 | "id": "590693f3-797f-4970-98ff-7284106393e5", 17 | "name": "Test", 18 | "avatar_url": null, 19 | "type": "bot", 20 | "bot": {} 21 | } 22 | ], 23 | "next_cursor": null, 24 | "has_more": false 25 | } 26 | -------------------------------------------------------------------------------- /Test/Notion.UnitTests/data/users/MeResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "object": "user", 3 | "id": "590693f3-797f-4970-98ff-7284106393e5", 4 | "name": "Test", 5 | "avatar_url": null, 6 | "type": "bot", 7 | "bot": { 8 | "owner": { 9 | "type": "workspace", 10 | "workspace": true 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Test/Notion.UnitTests/data/users/MeUserLevelResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "object": "user", 3 | "id": "16d84278-ab0e-484c-9bdd-b35da3bd8905", 4 | "name": "pied piper", 5 | "avatar_url": null, 6 | "type": "bot", 7 | "bot": { 8 | "owner": { 9 | "type": "user", 10 | "user": { 11 | "object": "user", 12 | "id": "5389a034-eb5c-47b5-8a9e-f79c99ef166c", 13 | "name": "christine makenotion", 14 | "avatar_url": null, 15 | "type": "person", 16 | "person": { 17 | "email": "christine@makenotion.com" 18 | } 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Test/Notion.UnitTests/data/users/RetrieveUserResponse.json: -------------------------------------------------------------------------------- 1 | { 2 | "object": "user", 3 | "id": "5e37c1b4-630f-4e81-bd6b-296af31e345f", 4 | "name": "Vedant Koditkar", 5 | "avatar_url": "https://lh3.googleusercontent.com/a-/AOh14Gg4lnfwJviST_tKZZpMfKrgmjp8wRzPBg9ec6sG7w=s100", 6 | "type": "person", 7 | "person": { 8 | "email": "vedkoditkar@gmail.com" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /assets/notion-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/notion-dotnet/notion-sdk-net/d7b76c83d508a3c34c4dfbc9a62b5d18acfadf1e/assets/notion-logo.png -------------------------------------------------------------------------------- /examples/aspnet-core-app/Controllers/AppController.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Microsoft.AspNetCore.Mvc; 3 | using Microsoft.Extensions.Logging; 4 | using Notion.Client; 5 | 6 | namespace aspnet_core_app.Controllers 7 | { 8 | [ApiController] 9 | [Route("[controller]")] 10 | public class AppController : ControllerBase 11 | { 12 | private readonly ILogger _logger; 13 | private readonly INotionClient _notionClient; 14 | 15 | public AppController(ILogger logger, INotionClient notionClient) 16 | { 17 | _logger = logger; 18 | _notionClient = notionClient; 19 | } 20 | 21 | [HttpGet] 22 | public async Task GetUsers() 23 | { 24 | return Ok(await _notionClient.Users.ListAsync()); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /examples/aspnet-core-app/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace aspnet_core_app 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/aspnet-core-app/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:51055", 8 | "sslPort": 44372 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "swagger", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "aspnet_core_app": { 21 | "commandName": "Project", 22 | "dotnetRunMessages": "true", 23 | "launchBrowser": true, 24 | "launchUrl": "swagger", 25 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/aspnet-core-app/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/aspnet-core-app/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | "AuthToken": "" 11 | } 12 | -------------------------------------------------------------------------------- /examples/aspnet-core-app/aspnet-core-app.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net6.0 4 | aspnet_core_app 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/list-users/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Notion.Client": "Trace" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /examples/list-users/list-users.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | Exe 4 | net6.0 5 | list_users 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/print-database-property-name-and-values/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | "program": "${workspaceFolder}/bin/Debug/net6.0/print-database-property-name-and-values.dll", 13 | "args": [], 14 | "cwd": "${workspaceFolder}", 15 | "console": "internalConsole", 16 | "stopAtEntry": false 17 | }, 18 | { 19 | "name": ".NET Core Attach", 20 | "type": "coreclr", 21 | "request": "attach" 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /examples/print-database-property-name-and-values/Program.cs: -------------------------------------------------------------------------------- 1 | using Notion.Client; 2 | 3 | var client = new NotionClient(new ClientOptions 4 | { 5 | AuthToken = "" 6 | }); 7 | 8 | var databasesQueryParameters = new DatabasesQueryParameters(); 9 | var databaseId = ""; 10 | var queryResult = await client.Databases.QueryAsync(databaseId, databasesQueryParameters); 11 | 12 | foreach (var result in queryResult.Results) 13 | { 14 | Console.WriteLine("Page Id: " + result.Id); 15 | foreach (var property in result.Properties) 16 | { 17 | Console.WriteLine(property.Key + " " + GetValue(property.Value)); 18 | } 19 | } 20 | 21 | object GetValue(PropertyValue p) 22 | { 23 | switch (p) 24 | { 25 | case RichTextPropertyValue richTextPropertyValue: 26 | return richTextPropertyValue.RichText.FirstOrDefault()?.PlainText; 27 | default: 28 | return null; 29 | } 30 | } -------------------------------------------------------------------------------- /examples/print-database-property-name-and-values/print-database-property-name-and-values.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | Exe 4 | net6.0 5 | print_database_property_name_and_values 6 | enable 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "notion-sdk-net", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "repository": "git@github.com:notion-dotnet/notion-sdk-net.git", 6 | "author": "Vedant Koditkar", 7 | "license": "MIT", 8 | "scripts": { 9 | "lint": "dotnet jb cleanupcode --include=\"**/**.cs\" .\\Notion.sln" 10 | } 11 | } 12 | --------------------------------------------------------------------------------