├── .gitignore ├── LICENSE ├── README.md ├── pom.xml └── src ├── main └── java │ └── com │ └── _2lazy2name │ ├── notion │ ├── Notion.java │ ├── entity │ │ ├── Comments.java │ │ ├── Database.java │ │ ├── Page.java │ │ ├── User.java │ │ ├── block │ │ │ ├── AbstractBlock.java │ │ │ ├── BookmarkBlock.java │ │ │ ├── BreadcrumbBlock.java │ │ │ ├── CalloutBlock.java │ │ │ ├── ChildPageBlock.java │ │ │ ├── CodeBlock.java │ │ │ ├── ColumnBlock.java │ │ │ ├── ColumnListBlock.java │ │ │ ├── DividerBlock.java │ │ │ ├── EmbedBlock.java │ │ │ ├── EquationBlock.java │ │ │ ├── LinkPreviewBlock.java │ │ │ ├── LinkToPageBlock.java │ │ │ ├── ParagraphBlock.java │ │ │ ├── QuoteBlock.java │ │ │ ├── SyncedBlockBlock.java │ │ │ ├── TableOfContentsBlock.java │ │ │ ├── TemplateBlock.java │ │ │ ├── ToggleBlock.java │ │ │ ├── builder │ │ │ │ ├── IColorBuilder.java │ │ │ │ ├── IRichTextBuilder.java │ │ │ │ └── impl │ │ │ │ │ ├── TextBuilder.java │ │ │ │ │ └── TextColorBuilder.java │ │ │ ├── fileRelated │ │ │ │ ├── FileBlock.java │ │ │ │ ├── ImageBlock.java │ │ │ │ ├── PdfBlock.java │ │ │ │ └── VideoBlock.java │ │ │ ├── heading │ │ │ │ ├── AbstractHeadingBlock.java │ │ │ │ ├── Heading.java │ │ │ │ ├── HeadingOneBlock.java │ │ │ │ ├── HeadingThreeBlock.java │ │ │ │ └── HeadingTwoBlock.java │ │ │ ├── list │ │ │ │ ├── BulletedListItemBlock.java │ │ │ │ ├── NumberedListItemBlock.java │ │ │ │ └── ToDoBlock.java │ │ │ └── table │ │ │ │ ├── TableBlock.java │ │ │ │ └── TableRow.java │ │ └── common │ │ │ ├── Date.java │ │ │ ├── Emoji.java │ │ │ ├── LinkPreview.java │ │ │ ├── PageOrDatabase.java │ │ │ ├── PaginationResult.java │ │ │ ├── PropertyItemResult.java │ │ │ ├── file │ │ │ ├── AbstractFile.java │ │ │ ├── ExternalFile.java │ │ │ └── NotionHostedFile.java │ │ │ ├── filter │ │ │ ├── AbstractFilter.java │ │ │ ├── CompoundFilter.java │ │ │ ├── PropertyFilter.java │ │ │ ├── TimestampFilter.java │ │ │ └── typeSpecific │ │ │ │ ├── CheckboxFilter.java │ │ │ │ ├── DateFilter.java │ │ │ │ ├── FilesFilter.java │ │ │ │ ├── FormulaFilter.java │ │ │ │ ├── IFilterMethod.java │ │ │ │ ├── MultiselectFilter.java │ │ │ │ ├── NumberFilter.java │ │ │ │ ├── PeopleFilter.java │ │ │ │ ├── RelationFilter.java │ │ │ │ ├── RollupFilter.java │ │ │ │ ├── SelectFilter.java │ │ │ │ ├── StatusFilter.java │ │ │ │ └── TextFilter.java │ │ │ ├── icon │ │ │ ├── AbstractIcon.java │ │ │ ├── EmojiIcon.java │ │ │ └── FileIcon.java │ │ │ ├── parent │ │ │ ├── AbstractParent.java │ │ │ ├── BlockParent.java │ │ │ ├── DatabaseParent.java │ │ │ ├── PageParent.java │ │ │ └── WorkSpaceParent.java │ │ │ ├── richText │ │ │ ├── AbstractRichText.java │ │ │ ├── EquationText.java │ │ │ ├── MentionText.java │ │ │ ├── TextText.java │ │ │ └── mention │ │ │ │ ├── AbstractMention.java │ │ │ │ ├── DatabaseMention.java │ │ │ │ ├── DateMention.java │ │ │ │ ├── LinkPreviewMention.java │ │ │ │ ├── PageMention.java │ │ │ │ ├── TemplateMention.java │ │ │ │ └── UserMention.java │ │ │ └── sort │ │ │ ├── AbstractSort.java │ │ │ ├── EntryTimestampSort.java │ │ │ └── PropertyValueSort.java │ ├── enumeration │ │ ├── ColorEnum.java │ │ ├── DateFilterMethodEnum.java │ │ ├── LanguageEnum.java │ │ ├── NumberFormatEnum.java │ │ ├── ObjectEnum.java │ │ ├── RollupFunctionEnum.java │ │ ├── SortDirectionEnum.java │ │ ├── TemplateMentionEnum.java │ │ ├── TemplateMentionValueEnum.java │ │ ├── TimeStampEnum.java │ │ └── type │ │ │ ├── BlockTypeEnum.java │ │ │ ├── FileTypeEnum.java │ │ │ ├── FormulaTypeEnum.java │ │ │ ├── IconTypeEnum.java │ │ │ ├── MentionTypeEnum.java │ │ │ ├── ParentTypeEnum.java │ │ │ ├── PropertyTypeEnum.java │ │ │ ├── RelationTypeEnum.java │ │ │ ├── RollupTypeEnum.java │ │ │ ├── TextTypeEnum.java │ │ │ └── UserTypeEnum.java │ ├── exception │ │ ├── ExceptionCodeEnum.java │ │ └── NotionException.java │ ├── property │ │ ├── AbstractProperty.java │ │ ├── database │ │ │ ├── AbstractDatabaseProperty.java │ │ │ ├── CheckboxConfiguration.java │ │ │ ├── CreatedByConfiguration.java │ │ │ ├── CreatedTimeConfiguration.java │ │ │ ├── DateConfiguration.java │ │ │ ├── EmailConfiguration.java │ │ │ ├── FileConfiguration.java │ │ │ ├── FormulaConfiguration.java │ │ │ ├── LastEditedByConfiguration.java │ │ │ ├── LastEditedTimeConfiguration.java │ │ │ ├── MultiSelectConfiguration.java │ │ │ ├── NumberConfiguration.java │ │ │ ├── PeopleConfiguration.java │ │ │ ├── PhoneNumberConfiguration.java │ │ │ ├── RelationConfiguration.java │ │ │ ├── RenamingProperty.java │ │ │ ├── RichTextConfiguration.java │ │ │ ├── RollupConfiguration.java │ │ │ ├── SelectConfiguration.java │ │ │ ├── SelectOption.java │ │ │ ├── StatusConfiguration.java │ │ │ ├── StatusGroup.java │ │ │ ├── TitleConfiguration.java │ │ │ ├── UrlConfiguration.java │ │ │ └── relation │ │ │ │ ├── AbstractRelation.java │ │ │ │ ├── DualPropertyRelation.java │ │ │ │ └── SinglePropertyRelation.java │ │ └── page │ │ │ ├── AbstractPagePropertyValue.java │ │ │ ├── CheckboxValue.java │ │ │ ├── CreatedByValue.java │ │ │ ├── CreatedTimeValue.java │ │ │ ├── DateValue.java │ │ │ ├── EmailValue.java │ │ │ ├── FilesValue.java │ │ │ ├── FormulaValue.java │ │ │ ├── LastEditedByValue.java │ │ │ ├── LastEditedTimeValue.java │ │ │ ├── MultiselectValue.java │ │ │ ├── NumberValue.java │ │ │ ├── PeopleValue.java │ │ │ ├── PhoneNumberValue.java │ │ │ ├── RelationValue.java │ │ │ ├── RichTextValue.java │ │ │ ├── RollupValue.java │ │ │ ├── SelectValue.java │ │ │ ├── StatusValue.java │ │ │ ├── TitleValue.java │ │ │ └── UrlValue.java │ └── serializer │ │ ├── FilterSerializer.java │ │ └── NullToEmptyObjectSerializer.java │ └── util │ ├── HttpUtil.java │ ├── NotionHttpUtil.java │ └── StringUtil.java └── test ├── java └── com │ └── _2lazy2name │ └── notion │ ├── NotionBlockTest.java │ ├── NotionDatabaseTest.java │ ├── NotionPageTest.java │ ├── NotionTest.java │ ├── entity │ ├── block │ │ ├── BookmarkTest.java │ │ ├── BreadcrumbTest.java │ │ ├── CalloutTest.java │ │ ├── CodeTest.java │ │ ├── ColumnListTest.java │ │ ├── DividerTest.java │ │ ├── EmbedTest.java │ │ ├── EquationTest.java │ │ ├── FileTest.java │ │ ├── HeadingBlockTest.java │ │ ├── LinkToPageTest.java │ │ ├── ListTest.java │ │ └── TableTest.java │ └── common │ │ ├── file │ │ └── AbstractFileTest.java │ │ └── sort │ │ └── PropertyValueSortTest.java │ ├── exception │ └── ExceptionTest.java │ └── property │ ├── database │ └── LastEditedByConfigurationTest.java │ └── page │ └── CreatedByValueTest.java └── resources └── test.properties /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /src/test/resources 3 | /.idea 4 | notion-java-sdk.iml 5 | .DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 YiHeCN 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/BreadcrumbBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.enumeration.type.BlockTypeEnum; 4 | import com._2lazy2name.notion.serializer.NullToEmptyObjectSerializer; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 7 | 8 | public class BreadcrumbBlock extends AbstractBlock { 9 | private static final BlockTypeEnum type = BlockTypeEnum.BREADCRUMB; 10 | @JsonSerialize(nullsUsing = NullToEmptyObjectSerializer.class) 11 | private final Object breadcrumb = null; 12 | private static final BreadcrumbBlock INSTANCE = new BreadcrumbBlock(); 13 | 14 | @Override 15 | public BlockTypeEnum getType() { 16 | return type; 17 | } 18 | 19 | private BreadcrumbBlock() {} 20 | 21 | @JsonIgnore 22 | public static BreadcrumbBlock getInstance() { 23 | return INSTANCE; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/ChildPageBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.enumeration.type.BlockTypeEnum; 4 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | import com.fasterxml.jackson.annotation.JsonInclude; 7 | 8 | // This class is not allowed to create. Use createPage endpoint instead. 9 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 10 | public class ChildPageBlock extends AbstractBlock { 11 | private static final BlockTypeEnum type = BlockTypeEnum.CHILD_PAGE; 12 | private ChildPage childPage; 13 | 14 | @JsonIgnore 15 | public String getTitle() { 16 | return childPage.title; 17 | } 18 | private ChildPageBlock setTitle(String title) { 19 | childPage.title = title; 20 | return this; 21 | } 22 | 23 | @Override 24 | public BlockTypeEnum getType() { 25 | return type; 26 | } 27 | 28 | private ChildPageBlock() {} 29 | 30 | private ChildPageBlock(String title) { 31 | this.childPage = new ChildPage(); 32 | this.childPage.title = title; 33 | } 34 | 35 | @JsonInclude(JsonInclude.Include.NON_NULL) 36 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 37 | private static class ChildPage { 38 | private String title; 39 | 40 | public String getTitle() { 41 | return title; 42 | } 43 | 44 | public ChildPage setTitle(String title) { 45 | this.title = title; 46 | return this; 47 | } 48 | } 49 | 50 | private ChildPage getPage() { 51 | return this.childPage; 52 | } 53 | 54 | private ChildPageBlock setPage(ChildPage childPage) { 55 | this.childPage = childPage; 56 | return this; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/ColumnBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.enumeration.type.BlockTypeEnum; 4 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | 7 | import java.util.List; 8 | 9 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 10 | public class ColumnBlock extends AbstractBlock { 11 | private static final BlockTypeEnum type = BlockTypeEnum.COLUMN; 12 | private Column column; 13 | 14 | public ColumnBlock(List children) { 15 | this.column = new Column(); 16 | this.column.children = children; 17 | } 18 | 19 | public ColumnBlock(AbstractBlock... children) { 20 | this(List.of(children)); 21 | } 22 | 23 | public ColumnBlock(AbstractBlock child) { 24 | this(List.of(child)); 25 | } 26 | 27 | @JsonIgnore 28 | public List getChildren() { 29 | return this.column.children; 30 | } 31 | 32 | public ColumnBlock setChildren(List children) { 33 | if (this.column == null) { 34 | this.column = new Column(); 35 | } 36 | this.column.children = children; 37 | return this; 38 | } 39 | public ColumnBlock appendChildren(AbstractBlock... children) { 40 | if (this.column == null) { 41 | this.column = new Column(); 42 | } 43 | if (this.column.children == null) { 44 | this.column.children = List.of(); 45 | } 46 | this.column.children.addAll(List.of(children)); 47 | return this; 48 | } 49 | public ColumnBlock appendChild(AbstractBlock child) { 50 | return appendChildren(child); 51 | } 52 | 53 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 54 | private static class Column { 55 | private List children; 56 | 57 | private List getChildren() { 58 | return children; 59 | } 60 | 61 | private Column setChildren(List children) { 62 | this.children = children; 63 | return this; 64 | } 65 | } 66 | 67 | @Override 68 | public BlockTypeEnum getType() { 69 | return type; 70 | } 71 | 72 | private ColumnBlock() {} 73 | 74 | private Column getColumn() { 75 | return column; 76 | } 77 | 78 | private ColumnBlock setColumn(Column column) { 79 | this.column = column; 80 | return this; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/ColumnListBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.enumeration.type.BlockTypeEnum; 4 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | 9 | import java.util.ArrayList; 10 | import java.util.Collections; 11 | import java.util.List; 12 | 13 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 14 | public class ColumnListBlock extends AbstractBlock { 15 | public static final BlockTypeEnum type = BlockTypeEnum.COLUMN_LIST; 16 | 17 | private ColumnList columnList; 18 | 19 | public ColumnListBlock(ColumnBlock... columns) { 20 | this.columnList = new ColumnList(); 21 | this.columnList.children = new ArrayList<>(); 22 | Collections.addAll(this.columnList.children, columns); 23 | } 24 | 25 | public ColumnListBlock(List columns) { 26 | this.columnList = new ColumnList(); 27 | this.columnList.children = columns; 28 | } 29 | 30 | @JsonIgnore 31 | public List getColumns() { 32 | return columnList.children; 33 | } 34 | 35 | public ColumnListBlock setColumns(List columns) { 36 | if (this.columnList == null) { 37 | this.columnList = new ColumnList(); 38 | } 39 | this.columnList.children = columns; 40 | return this; 41 | } 42 | public ColumnListBlock appendColumns(ColumnBlock... columns) { 43 | if (this.columnList == null) { 44 | this.columnList = new ColumnList(); 45 | } 46 | if (this.columnList.children == null) { 47 | this.columnList.children = new ArrayList<>(); 48 | } 49 | Collections.addAll(this.columnList.children, columns); 50 | return this; 51 | } 52 | public ColumnListBlock appendColumn(ColumnBlock column) { 53 | return appendColumns(column); 54 | } 55 | 56 | 57 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 58 | private static class ColumnList { 59 | private List children; 60 | 61 | private List getChildren() { 62 | return children; 63 | } 64 | 65 | private ColumnList setChildren(List children) { 66 | this.children = children; 67 | return this; 68 | } 69 | } 70 | 71 | @Override 72 | public BlockTypeEnum getType() { 73 | return type; 74 | } 75 | 76 | private ColumnListBlock() {} 77 | 78 | @JsonProperty("column_list") 79 | private ColumnList getColumnList() { 80 | return columnList; 81 | } 82 | 83 | private ColumnListBlock setColumnList(ColumnList columnList) { 84 | this.columnList = columnList; 85 | return this; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/DividerBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.enumeration.type.BlockTypeEnum; 4 | import com._2lazy2name.notion.serializer.NullToEmptyObjectSerializer; 5 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 6 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 7 | 8 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 9 | public class DividerBlock extends AbstractBlock { 10 | private static final BlockTypeEnum type = BlockTypeEnum.DIVIDER; 11 | @JsonSerialize(nullsUsing = NullToEmptyObjectSerializer.class) 12 | private Object divider = null; 13 | private static final DividerBlock INSTANCE = new DividerBlock(); 14 | 15 | @Override 16 | public BlockTypeEnum getType() { 17 | return type; 18 | } 19 | 20 | private DividerBlock() {} 21 | 22 | public static DividerBlock getInstance() { 23 | return INSTANCE; 24 | } 25 | 26 | private Object getDivider() { 27 | return divider; 28 | } 29 | 30 | private DividerBlock setDivider(Object divider) { 31 | this.divider = divider; 32 | return this; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/EmbedBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.enumeration.type.BlockTypeEnum; 4 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 7 | import com.fasterxml.jackson.annotation.JsonInclude; 8 | 9 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 10 | public class EmbedBlock extends AbstractBlock { 11 | private static final BlockTypeEnum type = BlockTypeEnum.EMBED; 12 | private Embed embed; 13 | 14 | @JsonIgnore 15 | public String getUrl() { 16 | return this.embed.url; 17 | } 18 | private EmbedBlock setUrl(String url) { 19 | this.embed.url = url; 20 | return this; 21 | } 22 | 23 | @Override 24 | public BlockTypeEnum getType() { 25 | return type; 26 | } 27 | 28 | private EmbedBlock() {} 29 | 30 | public EmbedBlock(String url) { 31 | this.embed = new Embed(); 32 | this.embed.url = url; 33 | } 34 | 35 | @JsonIgnoreProperties(ignoreUnknown = true) 36 | @JsonInclude(JsonInclude.Include.NON_NULL) 37 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 38 | private static class Embed { 39 | private String url; 40 | 41 | private String getUrl() { 42 | return url; 43 | } 44 | 45 | private Embed setUrl(String url) { 46 | this.url = url; 47 | return this; 48 | } 49 | } 50 | 51 | private Embed getEmbed() { 52 | return embed; 53 | } 54 | 55 | private EmbedBlock setEmbed(Embed embed) { 56 | this.embed = embed; 57 | return this; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/EquationBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.enumeration.type.BlockTypeEnum; 4 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 7 | import com.fasterxml.jackson.annotation.JsonInclude; 8 | 9 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 10 | public class EquationBlock extends AbstractBlock { 11 | private static final BlockTypeEnum type = BlockTypeEnum.EQUATION; 12 | private Equation equation; 13 | 14 | @JsonIgnore 15 | public String getExpression() { 16 | return this.equation.expression; 17 | } 18 | private EquationBlock setExpression(String expression) { 19 | this.equation.expression = expression; 20 | return this; 21 | } 22 | 23 | @Override 24 | public BlockTypeEnum getType() { 25 | return type; 26 | } 27 | 28 | private EquationBlock() {} 29 | 30 | public EquationBlock(String expression) { 31 | this.equation = new Equation(); 32 | this.equation.expression = expression; 33 | } 34 | 35 | @JsonIgnoreProperties(ignoreUnknown = true) 36 | @JsonInclude(JsonInclude.Include.NON_NULL) 37 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 38 | private static class Equation { 39 | private String expression; 40 | 41 | private String getExpression() { 42 | return expression; 43 | } 44 | 45 | private Equation setExpression(String expression) { 46 | this.expression = expression; 47 | return this; 48 | } 49 | } 50 | 51 | private Equation getEquation() { 52 | return equation; 53 | } 54 | 55 | private EquationBlock setEquation(Equation equation) { 56 | this.equation = equation; 57 | return this; 58 | } 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/LinkPreviewBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.entity.common.LinkPreview; 4 | import com._2lazy2name.notion.enumeration.type.BlockTypeEnum; 5 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 6 | import com.fasterxml.jackson.annotation.JsonIgnore; 7 | 8 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 9 | public class LinkPreviewBlock extends AbstractBlock { 10 | private static final BlockTypeEnum type = BlockTypeEnum.LINK_PREVIEW; 11 | private LinkPreview linkPreview; 12 | 13 | 14 | 15 | @JsonIgnore 16 | public String getUrl() { 17 | return linkPreview.getUrl(); 18 | } 19 | 20 | // The link_preview block can only be returned as part of a response. 21 | // The API does not support creating or appending link_preview blocks. 22 | // See: https://developers.notion.com/reference/block#link-preview 23 | public LinkPreviewBlock setUrl(String url) { 24 | this.linkPreview = linkPreview.setUrl(url); 25 | return this; 26 | } 27 | 28 | @Override 29 | public BlockTypeEnum getType() { 30 | return type; 31 | } 32 | 33 | private LinkPreviewBlock() {} 34 | 35 | private LinkPreviewBlock(LinkPreview linkPreview) { 36 | this.linkPreview = linkPreview; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/LinkToPageBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.enumeration.type.BlockTypeEnum; 4 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 5 | import com.fasterxml.jackson.annotation.JsonInclude; 6 | 7 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 8 | public class LinkToPageBlock extends AbstractBlock { 9 | private static final BlockTypeEnum type = BlockTypeEnum.LINK_TO_PAGE; 10 | private LinkToPage linkToPage; 11 | 12 | public static LinkToPageBlock toPage(String pageId) { 13 | LinkToPageBlock linkToPageBlock = new LinkToPageBlock(); 14 | linkToPageBlock.linkToPage = new LinkToPage(); 15 | linkToPageBlock.linkToPage.type = "page_id"; 16 | linkToPageBlock.linkToPage.pageId = pageId; 17 | return linkToPageBlock; 18 | } 19 | public static LinkToPageBlock toDatabase(String databaseId) { 20 | LinkToPageBlock linkToPageBlock = new LinkToPageBlock(); 21 | linkToPageBlock.linkToPage = new LinkToPage(); 22 | linkToPageBlock.linkToPage.type = "database_id"; 23 | linkToPageBlock.linkToPage.databaseId = databaseId; 24 | return linkToPageBlock; 25 | } 26 | 27 | @Override 28 | public BlockTypeEnum getType() { 29 | return type; 30 | } 31 | 32 | private LinkToPageBlock() {} 33 | 34 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 35 | @JsonInclude(JsonInclude.Include.NON_NULL) 36 | private static class LinkToPage { 37 | private String type; 38 | private String pageId; 39 | private String databaseId; 40 | 41 | private String getType() { 42 | return type; 43 | } 44 | 45 | private LinkToPage setType(String type) { 46 | this.type = type; 47 | return this; 48 | } 49 | 50 | private String getPageId() { 51 | return pageId; 52 | } 53 | 54 | private LinkToPage setPageId(String pageId) { 55 | this.pageId = pageId; 56 | return this; 57 | } 58 | 59 | private String getDatabaseId() { 60 | return databaseId; 61 | } 62 | 63 | private LinkToPage setDatabaseId(String databaseId) { 64 | this.databaseId = databaseId; 65 | return this; 66 | } 67 | } 68 | 69 | private LinkToPage getLinkToPage() { 70 | return linkToPage; 71 | } 72 | 73 | private LinkToPageBlock setLinkToPage(LinkToPage linkToPage) { 74 | this.linkToPage = linkToPage; 75 | return this; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/SyncedBlockBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.enumeration.type.BlockTypeEnum; 4 | 5 | import java.util.List; 6 | 7 | // TODO: not supported yet 8 | public class SyncedBlockBlock extends AbstractBlock { 9 | private static final BlockTypeEnum type = BlockTypeEnum.SYNCED_BLOCK; 10 | private SyncedBlock syncedBlock; 11 | 12 | private static class SyncedBlock { 13 | private SyncedFrom syncedFrom; 14 | private List children; 15 | } 16 | 17 | private static class SyncedFrom { 18 | private String type; 19 | private String blockId; 20 | } 21 | 22 | private SyncedBlockBlock() {} 23 | 24 | public SyncedBlockBlock(String syncedFromId) { 25 | this.syncedBlock = new SyncedBlock(); 26 | this.syncedBlock.syncedFrom = new SyncedFrom(); 27 | this.syncedBlock.syncedFrom.type = "block_id"; 28 | this.syncedBlock.syncedFrom.blockId = syncedFromId; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/TableOfContentsBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.enumeration.ColorEnum; 4 | import com._2lazy2name.notion.enumeration.type.BlockTypeEnum; 5 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 6 | import com.fasterxml.jackson.annotation.JsonIgnore; 7 | 8 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 9 | public class TableOfContentsBlock extends AbstractBlock { 10 | private static final BlockTypeEnum type = BlockTypeEnum.TABLE_OF_CONTENTS; 11 | private TableOfContents tableOfContents; 12 | 13 | @JsonIgnore 14 | public ColorEnum getColor() { 15 | return this.tableOfContents.color; 16 | } 17 | 18 | public TableOfContentsBlock setColor(ColorEnum color) { 19 | this.tableOfContents.color = color; 20 | return this; 21 | } 22 | 23 | @Override 24 | public BlockTypeEnum getType() { 25 | return type; 26 | } 27 | 28 | private TableOfContentsBlock() {} 29 | 30 | public TableOfContentsBlock(ColorEnum color) { 31 | this.tableOfContents = new TableOfContents(); 32 | this.tableOfContents.color = color; 33 | } 34 | 35 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 36 | private static class TableOfContents { 37 | private ColorEnum color; 38 | 39 | public ColorEnum getColor() { 40 | return color; 41 | } 42 | 43 | public TableOfContents setColor(ColorEnum color) { 44 | this.color = color; 45 | return this; 46 | } 47 | } 48 | 49 | public TableOfContents getTableOfContents() { 50 | return tableOfContents; 51 | } 52 | 53 | public TableOfContentsBlock setTableOfContents(TableOfContents tableOfContents) { 54 | this.tableOfContents = tableOfContents; 55 | return this; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/TemplateBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.entity.block.builder.impl.TextBuilder; 4 | import com._2lazy2name.notion.entity.common.richText.AbstractRichText; 5 | import com._2lazy2name.notion.enumeration.type.BlockTypeEnum; 6 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 7 | import com.fasterxml.jackson.annotation.JsonIgnore; 8 | 9 | import java.util.List; 10 | 11 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 12 | public class TemplateBlock extends AbstractBlock { 13 | private static final BlockTypeEnum type = BlockTypeEnum.TEMPLATE; 14 | private Template template; 15 | 16 | public static class Builder extends TextBuilder { 17 | public TemplateBlock build() { 18 | return new TemplateBlock(richText); 19 | } 20 | } 21 | 22 | @JsonIgnore 23 | public List getRichText() { 24 | return this.template.richText; 25 | } 26 | 27 | public TemplateBlock setRichText(List richText) { 28 | this.template.richText = richText; 29 | return this; 30 | } 31 | 32 | @JsonIgnore 33 | public List getChildren() { 34 | return this.template.children; 35 | } 36 | 37 | private TemplateBlock setChildren(List children) { 38 | this.template.children = children; 39 | return this; 40 | } 41 | 42 | @Override 43 | public BlockTypeEnum getType() { 44 | return type; 45 | } 46 | 47 | 48 | private TemplateBlock() {} 49 | private TemplateBlock(List richText) { 50 | this.template = new Template(); 51 | this.template.richText = richText; 52 | } 53 | 54 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 55 | private static class Template { 56 | private List children; 57 | private List richText; 58 | 59 | public List getChildren() { 60 | return children; 61 | } 62 | 63 | public Template setChildren(List children) { 64 | this.children = children; 65 | return this; 66 | } 67 | 68 | public List getRichText() { 69 | return richText; 70 | } 71 | 72 | public Template setRichText(List richText) { 73 | this.richText = richText; 74 | return this; 75 | } 76 | } 77 | 78 | public Template getTemplate() { 79 | return template; 80 | } 81 | 82 | public TemplateBlock setTemplate(Template template) { 83 | this.template = template; 84 | return this; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/builder/IColorBuilder.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block.builder; 2 | 3 | import com._2lazy2name.notion.enumeration.ColorEnum; 4 | 5 | public interface IColorBuilder, T> { 6 | S color(ColorEnum color); 7 | S randomColor(); 8 | S randomColorBackground(); 9 | T build(); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/builder/IRichTextBuilder.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block.builder; 2 | 3 | import com._2lazy2name.notion.entity.common.richText.AbstractRichText; 4 | 5 | import java.util.List; 6 | 7 | public interface IRichTextBuilder, T> { 8 | S richText(String text); 9 | S richText(List text); 10 | T build(); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/builder/impl/TextBuilder.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block.builder.impl; 2 | 3 | import com._2lazy2name.notion.entity.block.builder.IRichTextBuilder; 4 | import com._2lazy2name.notion.entity.common.richText.AbstractRichText; 5 | import com._2lazy2name.notion.entity.common.richText.TextText; 6 | 7 | import java.util.List; 8 | 9 | 10 | /** 11 | * For block contains editable text property. 12 | * @author Chole 13 | * @since 1.0 14 | * @version 1.0 15 | */ 16 | public abstract class TextBuilder, T> 17 | implements IRichTextBuilder 18 | { 19 | protected List richText; 20 | 21 | public TextBuilder() { 22 | super(); 23 | } 24 | 25 | @Override 26 | public S richText(String richText) { 27 | this.richText = List.of(new TextText(richText)); 28 | return self(); 29 | } 30 | 31 | @Override 32 | public S richText(List richText) { 33 | this.richText = richText; 34 | return self(); 35 | } 36 | 37 | 38 | public abstract T build(); 39 | 40 | @SuppressWarnings("unchecked") 41 | private S self() { 42 | return (S) this; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/builder/impl/TextColorBuilder.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block.builder.impl; 2 | 3 | import com._2lazy2name.notion.entity.block.builder.IColorBuilder; 4 | import com._2lazy2name.notion.enumeration.ColorEnum; 5 | 6 | /** 7 | * For block contains editable text and color property. 8 | * @author Chole 9 | * @since 1.0 10 | * @version 1.0 11 | */ 12 | public abstract class TextColorBuilder, T> 13 | extends TextBuilder 14 | implements IColorBuilder { 15 | protected ColorEnum color; 16 | 17 | public TextColorBuilder() { 18 | super(); 19 | } 20 | 21 | @Override 22 | public S color(ColorEnum color) { 23 | this.color = color; 24 | return self(); 25 | } 26 | 27 | @Override 28 | public S randomColor() { 29 | this.color = ColorEnum.getRandomColor(); 30 | return self(); 31 | } 32 | 33 | @Override 34 | public S randomColorBackground() { 35 | this.color = ColorEnum.getRandomColorBackground(); 36 | return self(); 37 | } 38 | 39 | public abstract T build(); 40 | 41 | @SuppressWarnings("unchecked") 42 | private S self() { 43 | return (S) this; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/fileRelated/FileBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block.fileRelated; 2 | 3 | import com._2lazy2name.notion.entity.block.AbstractBlock; 4 | import com._2lazy2name.notion.entity.common.file.AbstractFile; 5 | import com._2lazy2name.notion.entity.common.file.ExternalFile; 6 | import com._2lazy2name.notion.enumeration.type.BlockTypeEnum; 7 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 8 | 9 | /** 10 | * @author Chole 11 | * @since 1.0 12 | * @version 1.0 13 | * @see File 14 | */ 15 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 16 | public class FileBlock extends AbstractBlock { 17 | private static final BlockTypeEnum type = BlockTypeEnum.FILE; 18 | private AbstractFile file; 19 | 20 | @Override 21 | public BlockTypeEnum getType() { 22 | return type; 23 | } 24 | 25 | private FileBlock() {} 26 | 27 | public FileBlock(AbstractFile file) { 28 | this.file = file; 29 | } 30 | 31 | public FileBlock(String url) { 32 | this.file = new ExternalFile(url); 33 | } 34 | 35 | public AbstractFile getFile() { 36 | return file; 37 | } 38 | 39 | public FileBlock setFile(AbstractFile file) { 40 | this.file = file; 41 | return this; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/fileRelated/ImageBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block.fileRelated; 2 | 3 | import com._2lazy2name.notion.entity.block.AbstractBlock; 4 | import com._2lazy2name.notion.entity.common.file.AbstractFile; 5 | import com._2lazy2name.notion.entity.common.file.ExternalFile; 6 | import com._2lazy2name.notion.enumeration.type.BlockTypeEnum; 7 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 8 | 9 | /** 10 | * TODO: Add validation in the constructor. The image must be a valid image link. 11 | * @author Chole 12 | * @since 1.0 13 | * @version 1.0 14 | * @see Image 15 | */ 16 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 17 | public class ImageBlock extends AbstractBlock { 18 | private static final BlockTypeEnum type = BlockTypeEnum.IMAGE; 19 | private AbstractFile image; 20 | 21 | @Override 22 | public BlockTypeEnum getType() { 23 | return type; 24 | } 25 | 26 | private ImageBlock() {} 27 | 28 | public ImageBlock(AbstractFile image) { 29 | this.image = image; 30 | } 31 | 32 | public ImageBlock(String url) { 33 | this.image = new ExternalFile(url); 34 | } 35 | 36 | public AbstractFile getImage() { 37 | return image; 38 | } 39 | 40 | public ImageBlock setImage(AbstractFile image) { 41 | this.image = image; 42 | return this; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/fileRelated/PdfBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block.fileRelated; 2 | 3 | import com._2lazy2name.notion.entity.block.AbstractBlock; 4 | import com._2lazy2name.notion.entity.common.file.AbstractFile; 5 | import com._2lazy2name.notion.entity.common.file.ExternalFile; 6 | import com._2lazy2name.notion.enumeration.type.BlockTypeEnum; 7 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 8 | import com.fasterxml.jackson.annotation.JsonIgnore; 9 | 10 | /** 11 | * TODO: Add validation in the constructor. The image must be a valid pdf link. 12 | * @author Chole 13 | * @since 1.0 14 | * @version 1.0 15 | * @see PDF 16 | */ 17 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 18 | public class PdfBlock extends AbstractBlock { 19 | private static final BlockTypeEnum type = BlockTypeEnum.PDF; 20 | private AbstractFile pdf; 21 | 22 | public PdfBlock(AbstractFile pdf) { 23 | this.pdf = pdf; 24 | } 25 | 26 | public PdfBlock(String url) { 27 | this.pdf = new ExternalFile(url); 28 | } 29 | 30 | @JsonIgnore 31 | public String getUrl() { 32 | return this.pdf.getUrl(); 33 | } 34 | 35 | @Override 36 | public BlockTypeEnum getType() { 37 | return type; 38 | } 39 | 40 | private PdfBlock() {} 41 | 42 | public AbstractFile getPdf() { 43 | return pdf; 44 | } 45 | 46 | public PdfBlock setPdf(AbstractFile pdf) { 47 | this.pdf = pdf; 48 | return this; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/fileRelated/VideoBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block.fileRelated; 2 | 3 | import com._2lazy2name.notion.entity.block.AbstractBlock; 4 | import com._2lazy2name.notion.entity.common.file.AbstractFile; 5 | import com._2lazy2name.notion.entity.common.file.ExternalFile; 6 | import com._2lazy2name.notion.enumeration.type.BlockTypeEnum; 7 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 8 | 9 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 10 | public class VideoBlock extends AbstractBlock { 11 | private static final BlockTypeEnum type = BlockTypeEnum.VIDEO; 12 | private AbstractFile video; 13 | 14 | @Override 15 | public BlockTypeEnum getType() { 16 | return type; 17 | } 18 | 19 | private VideoBlock() {} 20 | 21 | public VideoBlock(AbstractFile video) { 22 | this.video = video; 23 | } 24 | 25 | public VideoBlock(String url) { 26 | this.video = new ExternalFile(url); 27 | } 28 | 29 | public AbstractFile getVideo() { 30 | return video; 31 | } 32 | 33 | public VideoBlock setVideo(AbstractFile video) { 34 | this.video = video; 35 | return this; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/heading/AbstractHeadingBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block.heading; 2 | 3 | import com._2lazy2name.notion.entity.block.AbstractBlock; 4 | import com._2lazy2name.notion.entity.common.richText.AbstractRichText; 5 | import com._2lazy2name.notion.entity.common.richText.TextText; 6 | import com._2lazy2name.notion.enumeration.ColorEnum; 7 | import com.fasterxml.jackson.annotation.*; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author Chole 13 | * @since 1.0 14 | * @version 1.0 15 | */ 16 | @JsonInclude(JsonInclude.Include.NON_NULL) 17 | @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", include = JsonTypeInfo.As.EXISTING_PROPERTY) 18 | @JsonSubTypes({ 19 | @JsonSubTypes.Type(value = HeadingOneBlock.class, name = "heading_1"), 20 | @JsonSubTypes.Type(value = HeadingTwoBlock.class, name = "heading_2"), 21 | @JsonSubTypes.Type(value = HeadingThreeBlock.class, name = "heading_3") 22 | }) 23 | public abstract class AbstractHeadingBlock extends AbstractBlock { 24 | protected List children; 25 | protected Heading heading; 26 | 27 | protected AbstractHeadingBlock() {} 28 | 29 | protected AbstractHeadingBlock(List text, ColorEnum color, Boolean isToggleable) { 30 | this.heading = new Heading(text, color, isToggleable); 31 | } 32 | 33 | public List getChildren() { 34 | return children; 35 | } 36 | 37 | private AbstractHeadingBlock setChildren(List children) { 38 | this.children = children; 39 | return this; 40 | } 41 | 42 | @JsonIgnore 43 | public List getText() { 44 | return heading.getRichText(); 45 | } 46 | 47 | public AbstractHeadingBlock setRichText(List text) { 48 | heading.setRichText(text); 49 | return this; 50 | } 51 | public AbstractHeadingBlock setRichText(AbstractRichText text) { 52 | heading.setRichText(List.of(text)); 53 | return this; 54 | } 55 | public AbstractHeadingBlock setRichText(String text) { 56 | heading.setRichText(List.of(new TextText(text))); 57 | return this; 58 | } 59 | 60 | @JsonIgnore 61 | public ColorEnum getColor() { 62 | return heading.getColor(); 63 | } 64 | 65 | public AbstractHeadingBlock setColor(ColorEnum color) { 66 | heading.setColor(color); 67 | return this; 68 | } 69 | 70 | @JsonIgnore 71 | public Boolean isToggleable() { 72 | return heading.getToggleable(); 73 | } 74 | 75 | public AbstractHeadingBlock setToggleable(Boolean toggleable) { 76 | heading.setToggleable(toggleable); 77 | return this; 78 | } 79 | 80 | protected Heading getHeading() { 81 | return this.heading; 82 | } 83 | protected void setHeading(Heading heading) { 84 | this.heading = heading; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/heading/Heading.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block.heading; 2 | 3 | import com._2lazy2name.notion.entity.common.richText.AbstractRichText; 4 | import com._2lazy2name.notion.enumeration.ColorEnum; 5 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 6 | import com.fasterxml.jackson.annotation.JsonInclude; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author Chole 12 | * @since 1.0 13 | * @version 1.0 14 | */ 15 | @JsonInclude(JsonInclude.Include.NON_NULL) 16 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 17 | class Heading { 18 | private List richText; 19 | private ColorEnum color; 20 | private Boolean isToggleable; 21 | 22 | Heading(List richText, ColorEnum color, Boolean isToggleable) { 23 | this.richText = richText; 24 | this.color = color; 25 | this.isToggleable = isToggleable; 26 | } 27 | 28 | Heading() {} 29 | 30 | List getRichText() { 31 | return richText; 32 | } 33 | 34 | Heading setRichText(List richText) { 35 | this.richText = richText; 36 | return this; 37 | } 38 | 39 | ColorEnum getColor() { 40 | return color; 41 | } 42 | 43 | Heading setColor(ColorEnum color) { 44 | this.color = color; 45 | return this; 46 | } 47 | 48 | Boolean getToggleable() { 49 | return isToggleable; 50 | } 51 | 52 | Heading setToggleable(Boolean toggleable) { 53 | isToggleable = toggleable; 54 | return this; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/heading/HeadingOneBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block.heading; 2 | 3 | import com._2lazy2name.notion.entity.block.builder.impl.TextColorBuilder; 4 | import com._2lazy2name.notion.entity.common.richText.AbstractRichText; 5 | import com._2lazy2name.notion.enumeration.ColorEnum; 6 | import com._2lazy2name.notion.enumeration.type.BlockTypeEnum; 7 | import com.fasterxml.jackson.annotation.JsonProperty; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author Yi 13 | * @since 1.0 14 | * @version 1.0 15 | * @see Heading One Block 16 | */ 17 | public class HeadingOneBlock extends AbstractHeadingBlock { 18 | private final BlockTypeEnum type = BlockTypeEnum.HEADING_1; 19 | 20 | public static class Builder extends TextColorBuilder { 21 | private Boolean isToggleable; 22 | 23 | public Builder isToggleable(Boolean isToggleable) { 24 | this.isToggleable = isToggleable; 25 | return this; 26 | } 27 | 28 | public HeadingOneBlock build() { 29 | return new HeadingOneBlock(richText, color, isToggleable); 30 | } 31 | } 32 | 33 | private HeadingOneBlock() {} 34 | 35 | private HeadingOneBlock(List text, ColorEnum color, Boolean isToggleable) { 36 | super(text, color, isToggleable); 37 | } 38 | 39 | @Override 40 | @JsonProperty("heading_1") 41 | protected Heading getHeading() { 42 | return super.heading; 43 | } 44 | 45 | @Override 46 | protected void setHeading(Heading heading) { 47 | super.setHeading(heading); 48 | } 49 | 50 | public BlockTypeEnum getType() { 51 | return type; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/heading/HeadingThreeBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block.heading; 2 | 3 | import com._2lazy2name.notion.entity.block.builder.impl.TextColorBuilder; 4 | import com._2lazy2name.notion.entity.common.richText.AbstractRichText; 5 | import com._2lazy2name.notion.enumeration.ColorEnum; 6 | import com._2lazy2name.notion.enumeration.type.BlockTypeEnum; 7 | import com.fasterxml.jackson.annotation.JsonProperty; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author Yi 13 | * @since 1.0 14 | * @version 1.0 15 | * @see Heading Three Block 16 | */ 17 | public class HeadingThreeBlock extends AbstractHeadingBlock { 18 | private final BlockTypeEnum type = BlockTypeEnum.HEADING_3; 19 | 20 | public static class Builder extends TextColorBuilder { 21 | private Boolean isToggleable; 22 | 23 | public Builder isToggleable(Boolean isToggleable) { 24 | this.isToggleable = isToggleable; 25 | return this; 26 | } 27 | 28 | public HeadingThreeBlock build() { 29 | return new HeadingThreeBlock(richText, color, isToggleable); 30 | } 31 | } 32 | 33 | 34 | private HeadingThreeBlock() {} 35 | 36 | private HeadingThreeBlock(List text, ColorEnum color, Boolean isToggleable) { 37 | super(text, color, isToggleable); 38 | } 39 | 40 | @Override 41 | @JsonProperty("heading_3") 42 | protected Heading getHeading() { 43 | return super.heading; 44 | } 45 | 46 | @Override 47 | protected void setHeading(Heading heading) { 48 | super.heading = heading; 49 | } 50 | 51 | public BlockTypeEnum getType() { 52 | return type; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/block/heading/HeadingTwoBlock.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block.heading; 2 | 3 | import com._2lazy2name.notion.entity.block.builder.impl.TextColorBuilder; 4 | import com._2lazy2name.notion.entity.common.richText.AbstractRichText; 5 | import com._2lazy2name.notion.enumeration.ColorEnum; 6 | import com._2lazy2name.notion.enumeration.type.BlockTypeEnum; 7 | import com.fasterxml.jackson.annotation.JsonProperty; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author Yi 13 | * @since 1.0 14 | * @version 1.0 15 | * @see Heading Two Block 16 | */ 17 | public class HeadingTwoBlock extends AbstractHeadingBlock { 18 | private final BlockTypeEnum type = BlockTypeEnum.HEADING_2; 19 | 20 | public static class Builder extends TextColorBuilder { 21 | private Boolean isToggleable; 22 | 23 | public Builder isToggleable(Boolean isToggleable) { 24 | this.isToggleable = isToggleable; 25 | return this; 26 | } 27 | 28 | public HeadingTwoBlock build() { 29 | return new HeadingTwoBlock(richText, color, isToggleable); 30 | } 31 | } 32 | 33 | private HeadingTwoBlock() {} 34 | 35 | private HeadingTwoBlock(List text, ColorEnum color, Boolean isToggleable) { 36 | super(text, color, isToggleable); 37 | } 38 | 39 | @Override 40 | @JsonProperty("heading_2") 41 | protected Heading getHeading() { 42 | return super.heading; 43 | } 44 | 45 | @Override 46 | protected void setHeading(Heading heading) { 47 | super.heading = heading; 48 | } 49 | 50 | public BlockTypeEnum getType() { 51 | return type; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/Date.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common; 2 | 3 | 4 | 5 | import com.fasterxml.jackson.annotation.JsonInclude; 6 | 7 | import java.text.SimpleDateFormat; 8 | 9 | /** 10 | * TODO: The official doc does not mention how the TimeZone String should work. It seems this value stay null all the time. 11 | * @author Yi 12 | * @version 1.0 13 | * @since 2023-02-01 14 | * @see ISO_8601 15 | */ 16 | @JsonInclude(JsonInclude.Include.NON_NULL) 17 | public class Date { 18 | private String start; 19 | private String end; 20 | private String timeZone; 21 | public static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); 22 | 23 | private Date() { 24 | } 25 | 26 | public Date(String start) { 27 | this.start = start; 28 | } 29 | 30 | public Date(java.util.Date start) { 31 | this.start = DATE_FORMAT.format(start); 32 | } 33 | 34 | public Date(String start, String end, String timeZone) { 35 | this.start = start; 36 | this.end = end; 37 | this.timeZone = timeZone; 38 | } 39 | 40 | public Date(java.util.Date start, java.util.Date end, String timeZone) { 41 | this.start = DATE_FORMAT.format(start); 42 | this.end = DATE_FORMAT.format(end); 43 | this.timeZone = timeZone; 44 | } 45 | 46 | public String getStart() { 47 | return start; 48 | } 49 | 50 | public Date setStart(String start) { 51 | this.start = start; 52 | return this; 53 | } 54 | 55 | public String getEnd() { 56 | return end; 57 | } 58 | 59 | public Date setEnd(String end) { 60 | this.end = end; 61 | return this; 62 | } 63 | 64 | public String getTimeZone() { 65 | return timeZone; 66 | } 67 | 68 | public Date setTimeZone(String timeZone) { 69 | this.timeZone = timeZone; 70 | return this; 71 | } 72 | 73 | public static SimpleDateFormat getDateFormat() { 74 | return DATE_FORMAT; 75 | } 76 | 77 | public static void setDateFormat(SimpleDateFormat dateFormat) { 78 | DATE_FORMAT = dateFormat; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/Emoji.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common; 2 | 3 | 4 | public class Emoji { 5 | private String type = "emoji"; 6 | private String emoji; 7 | 8 | private Emoji() { 9 | } 10 | 11 | public Emoji(char emoji) { 12 | this.emoji = Character.toString(emoji); 13 | } 14 | 15 | public String getType() { 16 | return type; 17 | } 18 | 19 | public Emoji setType(String type) { 20 | this.type = type; 21 | return this; 22 | } 23 | 24 | public String getEmoji() { 25 | return emoji; 26 | } 27 | 28 | public Emoji setEmoji(String emoji) { 29 | this.emoji = emoji; 30 | return this; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/LinkPreview.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common; 2 | 3 | public class LinkPreview { 4 | private String url; 5 | 6 | public static LinkPreview ofUrl(String url) { 7 | return new LinkPreview(url); 8 | } 9 | 10 | public String getUrl() { 11 | return url; 12 | } 13 | 14 | public LinkPreview setUrl(String url) { 15 | this.url = url; 16 | return this; 17 | } 18 | 19 | private LinkPreview() { 20 | } 21 | 22 | private LinkPreview(String url) { 23 | this.url = url; 24 | } 25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/PageOrDatabase.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common; 2 | 3 | import com._2lazy2name.notion.entity.Database; 4 | import com._2lazy2name.notion.entity.Page; 5 | import com._2lazy2name.notion.enumeration.ObjectEnum; 6 | import com.fasterxml.jackson.annotation.JsonSubTypes; 7 | 8 | /** 9 | * This class is created and only for search method. 10 | * @author Yi 11 | * @since 2023-02-01 12 | * @version 1.0 13 | */ 14 | @JsonSubTypes({ 15 | @JsonSubTypes.Type(value = Database.class, name = "database"), 16 | @JsonSubTypes.Type(value = Page.class, name = "page"), 17 | }) 18 | public class PageOrDatabase { 19 | protected ObjectEnum object; 20 | protected PageOrDatabase() {} 21 | 22 | public boolean isDatabase() { 23 | return object == ObjectEnum.DATABASE; 24 | } 25 | public boolean isPage() { 26 | return object == ObjectEnum.PAGE; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/PaginationResult.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common; 2 | 3 | import com._2lazy2name.notion.enumeration.ObjectEnum; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 6 | 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * TODO: Potential bug: The type object is not included in this class. 12 | * @author Yi 13 | * @since 2021/7/19 14 | */ 15 | @JsonIgnoreProperties(ignoreUnknown = true) 16 | public class PaginationResult { 17 | private ObjectEnum object; 18 | // Can be ObjectEnum or PropertyTypeEnum 19 | // For queryDatabase, it is ObjectEnum 20 | // For retrievePageProperties, it is PropertyTypeEnum 21 | private String type; 22 | private List results; 23 | private String nextCursor; 24 | private boolean hasMore; 25 | 26 | @JsonIgnore 27 | public T getResult() { 28 | if (results == null || results.isEmpty()) { 29 | return null; 30 | } 31 | if (results.size() > 1) { 32 | System.err.println("Warning: More than one result is returned."); 33 | } 34 | return results.get(0); 35 | } 36 | 37 | public ObjectEnum getObject() { 38 | return object; 39 | } 40 | 41 | public PaginationResult setObject(ObjectEnum object) { 42 | this.object = object; 43 | return this; 44 | } 45 | 46 | public String getType() { 47 | return type; 48 | } 49 | 50 | public PaginationResult setType(String type) { 51 | this.type = type; 52 | return this; 53 | } 54 | 55 | public List getResults() { 56 | return results; 57 | } 58 | 59 | public PaginationResult setResults(List results) { 60 | this.results = results; 61 | return this; 62 | } 63 | 64 | public String getNextCursor() { 65 | return nextCursor; 66 | } 67 | 68 | public PaginationResult setNextCursor(String nextCursor) { 69 | this.nextCursor = nextCursor; 70 | return this; 71 | } 72 | 73 | public boolean isHasMore() { 74 | return hasMore; 75 | } 76 | 77 | public PaginationResult setHasMore(boolean hasMore) { 78 | this.hasMore = hasMore; 79 | return this; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/file/AbstractFile.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.file; 2 | 3 | import com._2lazy2name.notion.entity.common.richText.AbstractRichText; 4 | import com._2lazy2name.notion.enumeration.type.FileTypeEnum; 5 | import com.fasterxml.jackson.annotation.JsonInclude; 6 | import com.fasterxml.jackson.annotation.JsonSubTypes; 7 | import com.fasterxml.jackson.annotation.JsonTypeInfo; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * {@link NotionHostedFile} objects contain data about a file that is uploaded to Notion. 13 | * {@link ExternalFile} file that is linked to in Notion. 14 | * Official Notion API does not provide a way to upload a file to Notion. i.e. Only External file is allowed to build. 15 | * However, you can still use the #{@link NotionHostedFile} from results of other API calls. 16 | * "It remains one of the files", according to Notion API. 17 | * TODO: Add a way to upload a file to Notion. 18 | * @version 1.0 19 | * @since 2023-02-01 20 | * @see File object 21 | */ 22 | @JsonInclude(JsonInclude.Include.NON_NULL) 23 | @JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION, property = "type", visible = true) 24 | @JsonSubTypes({ 25 | @JsonSubTypes.Type(value = ExternalFile.class, name = "external"), 26 | @JsonSubTypes.Type(value = NotionHostedFile.class, name = "file"), 27 | }) 28 | public abstract class AbstractFile { 29 | protected FileTypeEnum type; 30 | protected String name; 31 | protected List caption; 32 | 33 | public abstract String getUrl(); 34 | 35 | public FileTypeEnum getType() { 36 | return type; 37 | } 38 | 39 | public AbstractFile setType(FileTypeEnum type) { 40 | this.type = type; 41 | return this; 42 | } 43 | 44 | public String getName() { 45 | return name; 46 | } 47 | 48 | public AbstractFile setName(String name) { 49 | this.name = name; 50 | return this; 51 | } 52 | 53 | public List getCaption() { 54 | return caption; 55 | } 56 | 57 | public AbstractFile setCaption(List caption) { 58 | this.caption = caption; 59 | return this; 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | return "AbstractFile{" + 65 | "type=" + type + 66 | ", name='" + name + '\'' + 67 | ", caption=" + caption + 68 | '}'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/file/ExternalFile.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.file; 2 | 3 | import com._2lazy2name.notion.entity.common.richText.AbstractRichText; 4 | import com._2lazy2name.notion.enumeration.type.FileTypeEnum; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | 7 | import java.util.List; 8 | 9 | public class ExternalFile extends AbstractFile { 10 | private FileTypeEnum type = FileTypeEnum.EXTERNAL; 11 | private External external; 12 | 13 | @JsonIgnore 14 | public String getUrl() { 15 | return this.external.url; 16 | } 17 | 18 | private static class External { 19 | private String url; 20 | 21 | public String getUrl() { 22 | return url; 23 | } 24 | 25 | public External setUrl(String url) { 26 | this.url = url; 27 | return this; 28 | } 29 | } 30 | 31 | private ExternalFile() { 32 | } 33 | 34 | public ExternalFile(String url) { 35 | this.external = new External(); 36 | this.external.url = url; 37 | } 38 | 39 | public ExternalFile(String name, String url) { 40 | this.name = name; 41 | this.external = new External(); 42 | this.external.url = url; 43 | } 44 | 45 | public ExternalFile(List caption, String url) { 46 | this.external = new External(); 47 | this.external.url = url; 48 | this.caption = caption; 49 | } 50 | 51 | @Override 52 | public FileTypeEnum getType() { 53 | return type; 54 | } 55 | 56 | @Override 57 | public ExternalFile setType(FileTypeEnum type) { 58 | this.type = type; 59 | return this; 60 | } 61 | 62 | public External getExternal() { 63 | return external; 64 | } 65 | 66 | public ExternalFile setExternal(External external) { 67 | this.external = external; 68 | return this; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/file/NotionHostedFile.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.file; 2 | 3 | import com._2lazy2name.notion.enumeration.type.FileTypeEnum; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | 6 | 7 | import java.util.Date; 8 | 9 | /** 10 | * @author Chole 11 | * @since 1.0 12 | * @version 1.0 13 | * @see NotionFile 14 | */ 15 | public class NotionHostedFile extends AbstractFile { 16 | private final FileTypeEnum type = FileTypeEnum.FILE; 17 | private File file; 18 | 19 | @JsonIgnore 20 | public Date getExpiryTime() { 21 | return this.file.getExpiryTime(); 22 | } 23 | 24 | @JsonIgnore 25 | public String getUrl() { 26 | return this.file.getUrl(); 27 | } 28 | 29 | private static class File { 30 | private String url; 31 | private Date expiryTime; 32 | 33 | public String getUrl() { 34 | return url; 35 | } 36 | 37 | public File setUrl(String url) { 38 | this.url = url; 39 | return this; 40 | } 41 | 42 | public Date getExpiryTime() { 43 | return expiryTime; 44 | } 45 | 46 | public File setExpiryTime(Date expiryTime) { 47 | this.expiryTime = expiryTime; 48 | return this; 49 | } 50 | } 51 | 52 | private NotionHostedFile(String name, String url, Date expiryTime) { 53 | super(); 54 | this.name = name; 55 | this.file = new File(); 56 | this.file.setUrl(url); 57 | this.file.setExpiryTime(expiryTime); 58 | } 59 | 60 | @Override 61 | public FileTypeEnum getType() { 62 | return type; 63 | } 64 | 65 | private File getFile() { 66 | return file; 67 | } 68 | 69 | private NotionHostedFile setFile(File file) { 70 | this.file = file; 71 | return this; 72 | } 73 | 74 | private NotionHostedFile() { 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/filter/AbstractFilter.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.filter; 2 | 3 | public interface AbstractFilter {} 4 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/filter/CompoundFilter.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.filter; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 5 | 6 | 7 | import java.util.List; 8 | 9 | @JsonSerialize() 10 | @JsonInclude(JsonInclude.Include.NON_NULL) 11 | public class CompoundFilter implements AbstractFilter { 12 | private List or; 13 | private List and; 14 | 15 | public List getOr() { 16 | return or; 17 | } 18 | 19 | public CompoundFilter setOr(List or) { 20 | this.or = or; 21 | return this; 22 | } 23 | 24 | public List getAnd() { 25 | return and; 26 | } 27 | 28 | public CompoundFilter setAnd(List and) { 29 | this.and = and; 30 | return this; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/filter/PropertyFilter.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.filter; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.entity.common.filter.typeSpecific.IFilterMethod; 5 | import com._2lazy2name.notion.serializer.FilterSerializer; 6 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 7 | 8 | @JsonSerialize(using = FilterSerializer.class) 9 | public abstract class PropertyFilter implements AbstractFilter { 10 | protected PropertyTypeEnum type; 11 | protected String property; 12 | protected IFilterMethod method; 13 | protected Object value; 14 | 15 | protected PropertyFilter() { 16 | } 17 | 18 | public PropertyTypeEnum getType() { 19 | return type; 20 | } 21 | 22 | public PropertyFilter setType(PropertyTypeEnum type) { 23 | this.type = type; 24 | return this; 25 | } 26 | 27 | public String getProperty() { 28 | return property; 29 | } 30 | 31 | public PropertyFilter setProperty(String property) { 32 | this.property = property; 33 | return this; 34 | } 35 | 36 | public IFilterMethod getMethod() { 37 | return method; 38 | } 39 | 40 | public PropertyFilter setMethod(IFilterMethod method) { 41 | this.method = method; 42 | return this; 43 | } 44 | 45 | public Object getValue() { 46 | return value; 47 | } 48 | 49 | public PropertyFilter setValue(Object value) { 50 | this.value = value; 51 | return this; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/filter/typeSpecific/CheckboxFilter.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.filter.typeSpecific; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.entity.common.filter.PropertyFilter; 5 | 6 | public class CheckboxFilter extends PropertyFilter { 7 | private final PropertyTypeEnum type = PropertyTypeEnum.CHECKBOX; 8 | private CheckboxFilterMethodEnum method; 9 | 10 | public CheckboxFilter(String property, CheckboxFilterMethodEnum method, Object value) { 11 | this.property = property; 12 | this.method = method; 13 | this.value = value; 14 | } 15 | 16 | public CheckboxFilter on(String propertyName) { 17 | this.property = propertyName; 18 | return this; 19 | } 20 | 21 | public CheckboxFilter equals(Boolean value) { 22 | this.method = CheckboxFilterMethodEnum.EQUALS; 23 | this.value = value; 24 | return this; 25 | } 26 | 27 | public CheckboxFilter doesNotEqual(Boolean value) { 28 | this.method = CheckboxFilterMethodEnum.DOES_NOT_EQUAL; 29 | this.value = value; 30 | return this; 31 | } 32 | 33 | public enum CheckboxFilterMethodEnum implements IFilterMethod { 34 | EQUALS("equals", BOOLEAN), 35 | DOES_NOT_EQUAL("does_not_equal", BOOLEAN); 36 | 37 | private final String method; 38 | private final int valueType; 39 | 40 | CheckboxFilterMethodEnum(String method, int valueType) { 41 | this.method = method; 42 | this.valueType = valueType; 43 | } 44 | 45 | @Override 46 | public String getMethod() { 47 | return method; 48 | } 49 | 50 | @Override 51 | public int getValueType() { 52 | return valueType; 53 | } 54 | } 55 | 56 | @Override 57 | public PropertyTypeEnum getType() { 58 | return type; 59 | } 60 | 61 | @Override 62 | public CheckboxFilterMethodEnum getMethod() { 63 | return method; 64 | } 65 | 66 | public CheckboxFilter setMethod(CheckboxFilterMethodEnum method) { 67 | this.method = method; 68 | return this; 69 | } 70 | 71 | public CheckboxFilter() { 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/filter/typeSpecific/FilesFilter.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.filter.typeSpecific; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.entity.common.filter.PropertyFilter; 5 | 6 | public class FilesFilter extends PropertyFilter { 7 | private final PropertyTypeEnum type = PropertyTypeEnum.FILES; 8 | private FilesFilterMethodEnum method; 9 | 10 | public FilesFilter(String property, FilesFilterMethodEnum method, Object value) { 11 | this.property = property; 12 | this.method = method; 13 | this.value = value; 14 | } 15 | 16 | public FilesFilter on(String property) { 17 | this.property = property; 18 | return this; 19 | } 20 | 21 | public FilesFilter isEmpty() { 22 | this.method = FilesFilterMethodEnum.IS_EMPTY; 23 | this.value = null; 24 | return this; 25 | } 26 | 27 | public FilesFilter isNotEmpty() { 28 | this.method = FilesFilterMethodEnum.IS_NOT_EMPTY; 29 | this.value = null; 30 | return this; 31 | } 32 | 33 | public enum FilesFilterMethodEnum implements IFilterMethod { 34 | IS_EMPTY("is_empty", BOOLEAN_ONLY_TRUE), 35 | IS_NOT_EMPTY("is_not_empty", BOOLEAN_ONLY_TRUE); 36 | 37 | private final String method; 38 | private final int valueType; 39 | 40 | FilesFilterMethodEnum(String method, int valueType) { 41 | this.method = method; 42 | this.valueType = valueType; 43 | } 44 | 45 | @Override 46 | public String getMethod() { 47 | return method; 48 | } 49 | 50 | @Override 51 | public int getValueType() { 52 | return valueType; 53 | } 54 | } 55 | 56 | public FilesFilter() { 57 | } 58 | 59 | @Override 60 | public PropertyTypeEnum getType() { 61 | return type; 62 | } 63 | 64 | @Override 65 | public FilesFilterMethodEnum getMethod() { 66 | return method; 67 | } 68 | 69 | public FilesFilter setMethod(FilesFilterMethodEnum method) { 70 | this.method = method; 71 | return this; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/filter/typeSpecific/FormulaFilter.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.filter.typeSpecific; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.entity.common.filter.PropertyFilter; 5 | 6 | public class FormulaFilter extends PropertyFilter { 7 | private final PropertyTypeEnum type = PropertyTypeEnum.FORMULA; 8 | private FormulaFilterMethodEnum method; 9 | 10 | public FormulaFilter(String property, FormulaFilterMethodEnum method, Object value) { 11 | this.property = property; 12 | this.method = method; 13 | this.value = value; 14 | } 15 | 16 | public FormulaFilter on(String property) { 17 | this.property = property; 18 | return this; 19 | } 20 | 21 | public FormulaFilter string(TextFilter value) { 22 | this.method = FormulaFilterMethodEnum.STRING; 23 | this.value = value; 24 | return this; 25 | } 26 | 27 | public FormulaFilter checkbox(CheckboxFilter value) { 28 | this.method = FormulaFilterMethodEnum.CHECKBOX; 29 | this.value = value; 30 | return this; 31 | } 32 | 33 | public FormulaFilter number(NumberFilter value) { 34 | this.method = FormulaFilterMethodEnum.NUMBER; 35 | this.value = value; 36 | return this; 37 | } 38 | 39 | public FormulaFilter date(DateFilter value) { 40 | this.method = FormulaFilterMethodEnum.DATE; 41 | this.value = value; 42 | return this; 43 | } 44 | 45 | public enum FormulaFilterMethodEnum implements IFilterMethod { 46 | STRING("string", FILTER_OBJECT), 47 | CHECKBOX("checkbox", FILTER_OBJECT), 48 | NUMBER("number", FILTER_OBJECT), 49 | DATE("date", FILTER_OBJECT); 50 | 51 | 52 | private final String method; 53 | private final int valueType; 54 | 55 | FormulaFilterMethodEnum (String method, int valueType) { 56 | this.method = method; 57 | this.valueType = valueType; 58 | } 59 | 60 | @Override 61 | public String getMethod() { 62 | return method; 63 | } 64 | 65 | @Override 66 | public int getValueType() { 67 | return valueType; 68 | } 69 | } 70 | 71 | @Override 72 | public PropertyTypeEnum getType() { 73 | return type; 74 | } 75 | 76 | @Override 77 | public FormulaFilterMethodEnum getMethod() { 78 | return method; 79 | } 80 | 81 | public FormulaFilter setMethod(FormulaFilterMethodEnum method) { 82 | this.method = method; 83 | return this; 84 | } 85 | 86 | public FormulaFilter() { 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/filter/typeSpecific/IFilterMethod.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.filter.typeSpecific; 2 | 3 | public interface IFilterMethod { 4 | int EMPTY_OBJECT = 1; 5 | int FILTER_OBJECT = 2; 6 | int BOOLEAN = 3; 7 | int BOOLEAN_ONLY_TRUE = 4; 8 | int STRING = 5; 9 | int NUMBER = 6; 10 | int DATE = 7; 11 | 12 | String getMethod(); 13 | int getValueType(); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/filter/typeSpecific/MultiselectFilter.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.filter.typeSpecific; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.entity.common.filter.PropertyFilter; 5 | 6 | 7 | public class MultiselectFilter extends PropertyFilter { 8 | private final PropertyTypeEnum type = PropertyTypeEnum.SELECT; 9 | private MultiselectFilterMethodEnum method; 10 | 11 | public MultiselectFilter(String property, MultiselectFilterMethodEnum method, Object value) { 12 | this.property = property; 13 | this.method = method; 14 | this.value = value; 15 | } 16 | 17 | public MultiselectFilter on(String property) { 18 | this.property = property; 19 | return this; 20 | } 21 | 22 | public MultiselectFilter contains(String value) { 23 | this.method = MultiselectFilterMethodEnum.CONTAINS; 24 | this.value = value; 25 | return this; 26 | } 27 | 28 | public MultiselectFilter doesNotContain(String value) { 29 | this.method = MultiselectFilterMethodEnum.DOES_NOT_CONTAIN; 30 | this.value = value; 31 | return this; 32 | } 33 | 34 | public MultiselectFilter isEmpty() { 35 | this.method = MultiselectFilterMethodEnum.IS_EMPTY; 36 | this.value = null; 37 | return this; 38 | } 39 | 40 | public MultiselectFilter isNotEmpty() { 41 | this.method = MultiselectFilterMethodEnum.IS_NOT_EMPTY; 42 | this.value = null; 43 | return this; 44 | } 45 | 46 | public enum MultiselectFilterMethodEnum implements IFilterMethod { 47 | CONTAINS("contains", STRING), 48 | DOES_NOT_CONTAIN("does_not_contain", STRING), 49 | IS_EMPTY("is_empty", BOOLEAN_ONLY_TRUE), 50 | IS_NOT_EMPTY("is_not_empty", BOOLEAN_ONLY_TRUE); 51 | 52 | private final String method; 53 | private final int valueType; 54 | 55 | MultiselectFilterMethodEnum(String method, int valueType) { 56 | this.method = method; 57 | this.valueType = valueType; 58 | } 59 | 60 | @Override 61 | public String getMethod() { 62 | return method; 63 | } 64 | 65 | @Override 66 | public int getValueType() { 67 | return valueType; 68 | } 69 | } 70 | 71 | @Override 72 | public PropertyTypeEnum getType() { 73 | return type; 74 | } 75 | 76 | @Override 77 | public MultiselectFilterMethodEnum getMethod() { 78 | return method; 79 | } 80 | 81 | public MultiselectFilter setMethod(MultiselectFilterMethodEnum method) { 82 | this.method = method; 83 | return this; 84 | } 85 | 86 | public MultiselectFilter() { 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/filter/typeSpecific/RelationFilter.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.filter.typeSpecific; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.entity.common.filter.PropertyFilter; 5 | 6 | public class RelationFilter extends PropertyFilter { 7 | private final PropertyTypeEnum type = PropertyTypeEnum.RELATION; 8 | private RelationFilterMethodEnum method; 9 | 10 | public RelationFilter(String property, RelationFilterMethodEnum method, Object value) { 11 | this.property = property; 12 | this.method = method; 13 | this.value = value; 14 | } 15 | 16 | public RelationFilter on(String property) { 17 | this.property = property; 18 | return this; 19 | } 20 | 21 | public RelationFilter contains(String value) { 22 | this.method = RelationFilterMethodEnum.CONTAINS; 23 | this.value = value; 24 | return this; 25 | } 26 | 27 | public RelationFilter doesNotContain(String value) { 28 | this.method = RelationFilterMethodEnum.DOES_NOT_CONTAIN; 29 | this.value = value; 30 | return this; 31 | } 32 | 33 | public RelationFilter isEmpty() { 34 | this.method = RelationFilterMethodEnum.IS_EMPTY; 35 | this.value = true; 36 | return this; 37 | } 38 | 39 | public RelationFilter isNotEmpty() { 40 | this.method = RelationFilterMethodEnum.IS_NOT_EMPTY; 41 | this.value = true; 42 | return this; 43 | } 44 | 45 | 46 | public enum RelationFilterMethodEnum implements IFilterMethod { 47 | CONTAINS("contains", STRING), 48 | DOES_NOT_CONTAIN("does_not_contain", STRING), 49 | IS_EMPTY("is_empty", BOOLEAN_ONLY_TRUE), 50 | IS_NOT_EMPTY("is_not_empty", BOOLEAN_ONLY_TRUE); 51 | 52 | private final String method; 53 | private final int valueType; 54 | 55 | RelationFilterMethodEnum(String method, int valueType) { 56 | this.method = method; 57 | this.valueType = valueType; 58 | } 59 | 60 | @Override 61 | public String getMethod() { 62 | return method; 63 | } 64 | 65 | @Override 66 | public int getValueType() { 67 | return valueType; 68 | } 69 | } 70 | 71 | public RelationFilter() { 72 | } 73 | 74 | @Override 75 | public PropertyTypeEnum getType() { 76 | return type; 77 | } 78 | 79 | @Override 80 | public RelationFilterMethodEnum getMethod() { 81 | return method; 82 | } 83 | 84 | public RelationFilter setMethod(RelationFilterMethodEnum method) { 85 | this.method = method; 86 | return this; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/filter/typeSpecific/RollupFilter.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.filter.typeSpecific; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.entity.common.filter.PropertyFilter; 5 | 6 | public class RollupFilter extends PropertyFilter { 7 | private final PropertyTypeEnum type = PropertyTypeEnum.ROLLUP; 8 | private RollupFilterMethodEnum method; 9 | 10 | public RollupFilter(String property, RollupFilterMethodEnum method, Object value) { 11 | this.property = property; 12 | } 13 | 14 | public RollupFilter on(String property) { 15 | this.property = property; 16 | return this; 17 | } 18 | 19 | public RollupFilter any(PropertyFilter value) { 20 | this.method = RollupFilterMethodEnum.ANY; 21 | this.value = value; 22 | return this; 23 | } 24 | 25 | public RollupFilter every(PropertyFilter value) { 26 | this.method = RollupFilterMethodEnum.EVERY; 27 | this.value = value; 28 | return this; 29 | } 30 | 31 | public RollupFilter none(PropertyFilter value) { 32 | this.method = RollupFilterMethodEnum.NONE; 33 | this.value = value; 34 | return this; 35 | } 36 | public RollupFilter number(NumberFilter value) { 37 | this.method = RollupFilterMethodEnum.NUMBER; 38 | this.value = value; 39 | return this; 40 | } 41 | 42 | public RollupFilter date(DateFilter value) { 43 | this.method = RollupFilterMethodEnum.DATE; 44 | this.value = value; 45 | return this; 46 | } 47 | 48 | 49 | public enum RollupFilterMethodEnum implements IFilterMethod { 50 | ANY("any", FILTER_OBJECT), 51 | EVERY("every", FILTER_OBJECT), 52 | NONE("none", FILTER_OBJECT), 53 | NUMBER("number", FILTER_OBJECT), 54 | DATE("date", FILTER_OBJECT); 55 | 56 | private final String method; 57 | private final int valueType; 58 | 59 | RollupFilterMethodEnum(String method, int valueType) { 60 | this.method = method; 61 | this.valueType = valueType; 62 | } 63 | 64 | @Override 65 | public String getMethod() { 66 | return method; 67 | } 68 | 69 | @Override 70 | public int getValueType() { 71 | return valueType; 72 | } 73 | } 74 | 75 | @Override 76 | public PropertyTypeEnum getType() { 77 | return type; 78 | } 79 | 80 | @Override 81 | public RollupFilterMethodEnum getMethod() { 82 | return method; 83 | } 84 | 85 | public RollupFilter setMethod(RollupFilterMethodEnum method) { 86 | this.method = method; 87 | return this; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/filter/typeSpecific/SelectFilter.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.filter.typeSpecific; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.entity.common.filter.PropertyFilter; 5 | 6 | public class SelectFilter extends PropertyFilter { 7 | private final PropertyTypeEnum type = PropertyTypeEnum.SELECT; 8 | private SelectFilterMethodEnum method; 9 | 10 | public SelectFilter(String property, SelectFilterMethodEnum method, Object value) { 11 | this.property = property; 12 | this.method = method; 13 | this.value = value; 14 | } 15 | 16 | public SelectFilter on(String property) { 17 | this.property = property; 18 | return this; 19 | } 20 | 21 | public SelectFilter equals(String value) { 22 | this.method = SelectFilterMethodEnum.EQUALS; 23 | this.value = value; 24 | return this; 25 | } 26 | 27 | public SelectFilter doesNotEqual(String value) { 28 | this.method = SelectFilterMethodEnum.DOES_NOT_EQUAL; 29 | this.value = value; 30 | return this; 31 | } 32 | 33 | public SelectFilter isEmpty() { 34 | this.method = SelectFilterMethodEnum.IS_EMPTY; 35 | this.value = null; 36 | return this; 37 | } 38 | 39 | public SelectFilter isNotEmpty() { 40 | this.method = SelectFilterMethodEnum.IS_NOT_EMPTY; 41 | this.value = null; 42 | return this; 43 | } 44 | 45 | public enum SelectFilterMethodEnum implements IFilterMethod { 46 | EQUALS("equals", STRING), 47 | DOES_NOT_EQUAL("does_not_equal", STRING), 48 | IS_EMPTY("is_empty", BOOLEAN_ONLY_TRUE), 49 | IS_NOT_EMPTY("is_not_empty", BOOLEAN_ONLY_TRUE); 50 | 51 | private final String method; 52 | private final int valueType; 53 | 54 | SelectFilterMethodEnum(String method, int valueType) { 55 | this.method = method; 56 | this.valueType = valueType; 57 | } 58 | 59 | @Override 60 | public String getMethod() { 61 | return method; 62 | } 63 | 64 | @Override 65 | public int getValueType() { 66 | return valueType; 67 | } 68 | } 69 | 70 | public SelectFilter() { 71 | } 72 | 73 | @Override 74 | public PropertyTypeEnum getType() { 75 | return type; 76 | } 77 | 78 | @Override 79 | public SelectFilterMethodEnum getMethod() { 80 | return method; 81 | } 82 | 83 | public SelectFilter setMethod(SelectFilterMethodEnum method) { 84 | this.method = method; 85 | return this; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/filter/typeSpecific/StatusFilter.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.filter.typeSpecific; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.entity.common.filter.PropertyFilter; 5 | 6 | public class StatusFilter extends PropertyFilter { 7 | private final PropertyTypeEnum type = PropertyTypeEnum.SELECT; 8 | private StatusFilterMethodEnum method; 9 | 10 | public StatusFilter(String property, StatusFilterMethodEnum method, Object value) { 11 | this.property = property; 12 | this.method = method; 13 | this.value = value; 14 | } 15 | 16 | public StatusFilter on(String property) { 17 | this.property = property; 18 | return this; 19 | } 20 | 21 | public StatusFilter equals(String value) { 22 | this.method = StatusFilterMethodEnum.EQUALS; 23 | this.value = value; 24 | return this; 25 | } 26 | 27 | public StatusFilter doesNotEqual(String value) { 28 | this.method = StatusFilterMethodEnum.DOES_NOT_EQUAL; 29 | this.value = value; 30 | return this; 31 | } 32 | 33 | public StatusFilter isEmpty() { 34 | this.method = StatusFilterMethodEnum.IS_EMPTY; 35 | this.value = null; 36 | return this; 37 | } 38 | 39 | public StatusFilter isNotEmpty() { 40 | this.method = StatusFilterMethodEnum.IS_NOT_EMPTY; 41 | this.value = null; 42 | return this; 43 | } 44 | 45 | public enum StatusFilterMethodEnum implements IFilterMethod { 46 | EQUALS("equals", STRING), 47 | DOES_NOT_EQUAL("does_not_equal", STRING), 48 | IS_EMPTY("is_empty", BOOLEAN_ONLY_TRUE), 49 | IS_NOT_EMPTY("is_not_empty", BOOLEAN_ONLY_TRUE); 50 | 51 | private final String method; 52 | private final int valueType; 53 | 54 | StatusFilterMethodEnum(String method, int valueType) { 55 | this.method = method; 56 | this.valueType = valueType; 57 | } 58 | 59 | @Override 60 | public String getMethod() { 61 | return method; 62 | } 63 | 64 | @Override 65 | public int getValueType() { 66 | return valueType; 67 | } 68 | } 69 | 70 | @Override 71 | public PropertyTypeEnum getType() { 72 | return type; 73 | } 74 | 75 | @Override 76 | public StatusFilterMethodEnum getMethod() { 77 | return method; 78 | } 79 | 80 | public StatusFilter setMethod(StatusFilterMethodEnum method) { 81 | this.method = method; 82 | return this; 83 | } 84 | 85 | public StatusFilter() { 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/icon/AbstractIcon.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.icon; 2 | 3 | import com._2lazy2name.notion.enumeration.type.IconTypeEnum; 4 | import com.fasterxml.jackson.annotation.JsonSubTypes; 5 | import com.fasterxml.jackson.annotation.JsonTypeInfo; 6 | @JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) 7 | @JsonSubTypes({ 8 | @JsonSubTypes.Type(value = EmojiIcon.class, name = "emoji"), 9 | @JsonSubTypes.Type(value = FileIcon.class, name = "external"), 10 | }) 11 | public abstract class AbstractIcon { 12 | protected IconTypeEnum type; 13 | 14 | protected AbstractIcon() { 15 | } 16 | 17 | public abstract IconTypeEnum getType(); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/icon/EmojiIcon.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.icon; 2 | 3 | import com._2lazy2name.notion.entity.common.Emoji; 4 | import com._2lazy2name.notion.enumeration.type.IconTypeEnum; 5 | import com.fasterxml.jackson.annotation.JsonUnwrapped; 6 | 7 | // TODO: Validate emoji 8 | public class EmojiIcon extends AbstractIcon{ 9 | private final IconTypeEnum type = IconTypeEnum.EMOJI; 10 | @JsonUnwrapped 11 | private Emoji emoji; 12 | 13 | private EmojiIcon() {} 14 | 15 | public EmojiIcon(char emoji) { 16 | this.emoji = new Emoji(emoji); 17 | } 18 | 19 | @Override 20 | public IconTypeEnum getType() { 21 | return type; 22 | } 23 | 24 | public Emoji getEmoji() { 25 | return emoji; 26 | } 27 | 28 | public EmojiIcon setEmoji(Emoji emoji) { 29 | this.emoji = emoji; 30 | return this; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/icon/FileIcon.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.icon; 2 | 3 | import com._2lazy2name.notion.entity.common.file.AbstractFile; 4 | import com._2lazy2name.notion.enumeration.type.IconTypeEnum; 5 | import com.fasterxml.jackson.annotation.JsonUnwrapped; 6 | 7 | public class FileIcon extends AbstractIcon { 8 | private final IconTypeEnum type = IconTypeEnum.EXTERNAL; 9 | @JsonUnwrapped 10 | private AbstractFile file; 11 | 12 | private FileIcon() {} 13 | 14 | public FileIcon(AbstractFile file) { 15 | this.file = file; 16 | } 17 | 18 | @Override 19 | public IconTypeEnum getType() { 20 | return this.type; 21 | } 22 | 23 | public AbstractFile getFile() { 24 | return file; 25 | } 26 | 27 | public FileIcon setFile(AbstractFile file) { 28 | this.file = file; 29 | return this; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/parent/AbstractParent.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.parent; 2 | 3 | import com._2lazy2name.notion.enumeration.type.ParentTypeEnum; 4 | import com.fasterxml.jackson.annotation.JsonSubTypes; 5 | import com.fasterxml.jackson.annotation.JsonTypeInfo; 6 | 7 | @JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION, property = "type") 8 | @JsonSubTypes( 9 | { 10 | @JsonSubTypes.Type(value = BlockParent.class, name = "block_id"), 11 | @JsonSubTypes.Type(value = DatabaseParent.class, name = "database_id"), 12 | @JsonSubTypes.Type(value = PageParent.class, name = "page_id"), 13 | @JsonSubTypes.Type(value = WorkSpaceParent.class, name = "workspace") 14 | } 15 | ) 16 | public abstract class AbstractParent { 17 | protected ParentTypeEnum type; 18 | 19 | public abstract ParentTypeEnum getType(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/parent/BlockParent.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.parent; 2 | 3 | import com._2lazy2name.notion.enumeration.type.ParentTypeEnum; 4 | 5 | public class BlockParent extends AbstractParent { 6 | private final ParentTypeEnum type = ParentTypeEnum.BLOCK_ID; 7 | private String blockId; 8 | 9 | private BlockParent() { 10 | } 11 | 12 | public BlockParent(String blockId) { 13 | this.blockId = blockId; 14 | } 15 | 16 | @Override 17 | public ParentTypeEnum getType() { 18 | return this.type; 19 | } 20 | 21 | public String getBlockId() { 22 | return blockId; 23 | } 24 | 25 | public BlockParent setBlockId(String blockId) { 26 | this.blockId = blockId; 27 | return this; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/parent/DatabaseParent.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.parent; 2 | 3 | import com._2lazy2name.notion.enumeration.type.ParentTypeEnum; 4 | 5 | public class DatabaseParent extends AbstractParent { 6 | private final ParentTypeEnum type = ParentTypeEnum.DATABASE_ID; 7 | private String databaseId; 8 | 9 | private DatabaseParent() { 10 | } 11 | 12 | public DatabaseParent(String databaseId) { 13 | this.databaseId = databaseId; 14 | } 15 | 16 | @Override 17 | public ParentTypeEnum getType() { 18 | return type; 19 | } 20 | 21 | public String getDatabaseId() { 22 | return databaseId; 23 | } 24 | 25 | public DatabaseParent setDatabaseId(String databaseId) { 26 | this.databaseId = databaseId; 27 | return this; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/parent/PageParent.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.parent; 2 | 3 | import com._2lazy2name.notion.enumeration.type.ParentTypeEnum; 4 | 5 | public class PageParent extends AbstractParent { 6 | private final ParentTypeEnum type = ParentTypeEnum.PAGE_ID; 7 | private String pageId; 8 | 9 | private PageParent() { 10 | } 11 | 12 | public PageParent(String pageId) { 13 | this.pageId = pageId; 14 | } 15 | 16 | @Override 17 | public ParentTypeEnum getType() { 18 | return type; 19 | } 20 | 21 | public String getPageId() { 22 | return pageId; 23 | } 24 | 25 | public PageParent setPageId(String pageId) { 26 | this.pageId = pageId; 27 | return this; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/parent/WorkSpaceParent.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.parent; 2 | 3 | import com._2lazy2name.notion.enumeration.type.ParentTypeEnum; 4 | 5 | public class WorkSpaceParent extends AbstractParent { 6 | private final ParentTypeEnum type = ParentTypeEnum.WORKSPACE; 7 | private final boolean workspace = true; 8 | private static final WorkSpaceParent INSTANCE = new WorkSpaceParent(); 9 | 10 | private WorkSpaceParent() { 11 | } 12 | 13 | public static WorkSpaceParent getInstance() { 14 | return INSTANCE; 15 | } 16 | 17 | @Override 18 | public ParentTypeEnum getType() { 19 | return type; 20 | } 21 | 22 | public boolean isWorkspace() { 23 | return workspace; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/richText/EquationText.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.richText; 2 | 3 | import com._2lazy2name.notion.enumeration.type.TextTypeEnum; 4 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | 7 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 8 | public class EquationText extends AbstractRichText { 9 | private final static TextTypeEnum type = TextTypeEnum.EQUATION; 10 | private Equation equation; 11 | 12 | private EquationText() { 13 | } 14 | 15 | public EquationText(String equation) { 16 | this.equation = new Equation(); 17 | this.equation.setExpression(equation); 18 | } 19 | 20 | @JsonIgnore 21 | public String getExpression() { 22 | return equation.getExpression(); 23 | } 24 | 25 | public EquationText setExpression(String expression) { 26 | equation.setExpression(expression); 27 | return this; 28 | } 29 | 30 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 31 | private static class Equation { 32 | private String expression; 33 | 34 | private String getExpression() { 35 | return expression; 36 | } 37 | 38 | private Equation setExpression(String expression) { 39 | this.expression = expression; 40 | return this; 41 | } 42 | } 43 | 44 | @Override 45 | public TextTypeEnum getType() { 46 | return type; 47 | } 48 | 49 | private Equation getEquation() { 50 | return equation; 51 | } 52 | 53 | private EquationText setEquation(Equation equation) { 54 | this.equation = equation; 55 | return this; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/richText/MentionText.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.richText; 2 | 3 | import com._2lazy2name.notion.entity.common.richText.mention.AbstractMention; 4 | import com._2lazy2name.notion.enumeration.type.TextTypeEnum; 5 | 6 | public class MentionText extends AbstractRichText { 7 | private final TextTypeEnum type = TextTypeEnum.MENTION; 8 | private AbstractMention mention; 9 | 10 | private MentionText() { 11 | } 12 | 13 | public MentionText(AbstractMention mention) { 14 | this.mention = mention; 15 | } 16 | 17 | public AbstractMention getMention() { 18 | return mention; 19 | } 20 | 21 | public MentionText setMention(AbstractMention mention) { 22 | this.mention = mention; 23 | return this; 24 | } 25 | 26 | @Override 27 | public TextTypeEnum getType() { 28 | return type; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/richText/mention/AbstractMention.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.richText.mention; 2 | 3 | import com._2lazy2name.notion.enumeration.type.MentionTypeEnum; 4 | import com.fasterxml.jackson.annotation.JsonSubTypes; 5 | import com.fasterxml.jackson.annotation.JsonTypeInfo; 6 | 7 | @JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION, property = "type") 8 | @JsonSubTypes({ 9 | @JsonSubTypes.Type(value = DatabaseMention.class, name = "database"), 10 | @JsonSubTypes.Type(value = DateMention.class, name = "date"), 11 | @JsonSubTypes.Type(value = PageMention.class, name = "page"), 12 | @JsonSubTypes.Type(value = UserMention.class, name = "user"), 13 | @JsonSubTypes.Type(value = TemplateMention.class, name = "template_mention"), 14 | @JsonSubTypes.Type(value = LinkPreviewMention.class, name = "link_preview"), 15 | }) 16 | public abstract class AbstractMention { 17 | protected MentionTypeEnum type; 18 | 19 | public abstract MentionTypeEnum getType(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/richText/mention/DatabaseMention.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.richText.mention; 2 | 3 | import com._2lazy2name.notion.enumeration.type.MentionTypeEnum; 4 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | 7 | // TODO: Validate Constructor 8 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 9 | public class DatabaseMention extends AbstractMention { 10 | private final MentionTypeEnum type = MentionTypeEnum.DATABASE; 11 | private DatabaseId database; 12 | 13 | @JsonIgnore 14 | public String getDatabaseId() { 15 | return database == null ? null : database.getId(); 16 | } 17 | 18 | public void setDatabaseId(String databaseId) { 19 | if (this.database == null) this.database = new DatabaseId(); 20 | this.database.id = databaseId; 21 | } 22 | 23 | private DatabaseMention() {} 24 | 25 | public DatabaseMention(String databaseId) { 26 | this.database = new DatabaseId(); 27 | this.database.id = databaseId; 28 | } 29 | 30 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 31 | private static class DatabaseId { 32 | private String id; 33 | 34 | private String getId() { 35 | return id; 36 | } 37 | 38 | private DatabaseId setId(String id) { 39 | this.id = id; 40 | return this; 41 | } 42 | } 43 | 44 | @Override 45 | public MentionTypeEnum getType() { 46 | return type; 47 | } 48 | 49 | private DatabaseId getDatabase() { 50 | return database; 51 | } 52 | 53 | private DatabaseMention setDatabase(DatabaseId database) { 54 | this.database = database; 55 | return this; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/richText/mention/DateMention.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.richText.mention; 2 | 3 | import com._2lazy2name.notion.entity.common.Date; 4 | import com._2lazy2name.notion.enumeration.type.MentionTypeEnum; 5 | 6 | public class DateMention extends AbstractMention { 7 | private final MentionTypeEnum type = MentionTypeEnum.DATE; 8 | private Date date; 9 | 10 | private DateMention() { 11 | } 12 | 13 | public DateMention(Date date) { 14 | this.date = date; 15 | } 16 | 17 | public MentionTypeEnum getType() { 18 | return type; 19 | } 20 | 21 | public Date getDate() { 22 | return date; 23 | } 24 | 25 | public DateMention setDate(Date date) { 26 | this.date = date; 27 | return this; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/richText/mention/LinkPreviewMention.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.richText.mention; 2 | 3 | import com._2lazy2name.notion.entity.common.LinkPreview; 4 | import com._2lazy2name.notion.enumeration.type.MentionTypeEnum; 5 | 6 | public class LinkPreviewMention extends AbstractMention { 7 | private final MentionTypeEnum type = MentionTypeEnum.LINK_PREVIEW; 8 | private LinkPreview linkPreview; 9 | 10 | private LinkPreviewMention() { 11 | } 12 | 13 | public LinkPreviewMention(LinkPreview linkPreview) { 14 | this.linkPreview = linkPreview; 15 | } 16 | 17 | @Override 18 | public MentionTypeEnum getType() { 19 | return type; 20 | } 21 | 22 | public LinkPreview getLinkPreview() { 23 | return linkPreview; 24 | } 25 | 26 | public LinkPreviewMention setLinkPreview(LinkPreview linkPreview) { 27 | this.linkPreview = linkPreview; 28 | return this; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/richText/mention/PageMention.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.richText.mention; 2 | 3 | import com._2lazy2name.notion.enumeration.type.MentionTypeEnum; 4 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | 7 | // TODO: Validate Constructor 8 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 9 | public class PageMention extends AbstractMention { 10 | private final MentionTypeEnum type = MentionTypeEnum.PAGE; 11 | private PageId page; 12 | 13 | @JsonIgnore 14 | public String getPageId() { 15 | return page == null ? null : page.getId(); 16 | } 17 | 18 | public void setPageId(String pageId) { 19 | if (this.page == null) this.page = new PageId(); 20 | this.page.id = pageId; 21 | } 22 | 23 | private PageMention() {} 24 | 25 | public PageMention(String pageId) { 26 | this.page = new PageMention.PageId(); 27 | this.page.id = pageId; 28 | } 29 | 30 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 31 | private static class PageId { 32 | private String id; 33 | 34 | private String getId() { 35 | return id; 36 | } 37 | 38 | private PageMention.PageId setId(String id) { 39 | this.id = id; 40 | return this; 41 | } 42 | } 43 | 44 | public MentionTypeEnum getType() { 45 | return type; 46 | } 47 | 48 | private PageMention.PageId getPage() { 49 | return page; 50 | } 51 | 52 | private PageMention setPage(PageMention.PageId page) { 53 | this.page = page; 54 | return this; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/richText/mention/UserMention.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.richText.mention; 2 | 3 | import com._2lazy2name.notion.enumeration.type.MentionTypeEnum; 4 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | 7 | // TODO: Validate Id. 8 | public class UserMention extends AbstractMention { 9 | private final MentionTypeEnum type = MentionTypeEnum.USER; 10 | private UserId user; 11 | 12 | @JsonIgnore 13 | public String getUserId() { 14 | return user == null ? null : user.getId(); 15 | } 16 | 17 | public void setUserId(String userId) { 18 | if (this.user == null) this.user = new UserMention.UserId(); 19 | this.user.id = userId; 20 | } 21 | 22 | private UserMention() {} 23 | 24 | public UserMention(String userId) { 25 | this.user = new UserMention.UserId(); 26 | this.user.id = userId; 27 | } 28 | 29 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 30 | private static class UserId { 31 | private String id; 32 | 33 | private String getId() { 34 | return id; 35 | } 36 | 37 | private UserMention.UserId setId(String id) { 38 | this.id = id; 39 | return this; 40 | } 41 | } 42 | 43 | @Override 44 | public MentionTypeEnum getType() { 45 | return type; 46 | } 47 | 48 | private UserMention.UserId getUser() { 49 | return user; 50 | } 51 | 52 | private UserMention setUser(UserMention.UserId user) { 53 | this.user = user; 54 | return this; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/sort/AbstractSort.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.sort; 2 | 3 | import com._2lazy2name.notion.enumeration.SortDirectionEnum; 4 | import com._2lazy2name.notion.enumeration.TimeStampEnum; 5 | import com.fasterxml.jackson.annotation.JsonSubTypes; 6 | import com.fasterxml.jackson.annotation.JsonTypeInfo; 7 | 8 | 9 | /*** 10 | * @author Yi 11 | * @since 1.0 12 | * @version 1.0 13 | * @see Sort 14 | */ 15 | @JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION, property = "type") 16 | @JsonSubTypes({ 17 | @JsonSubTypes.Type(value = EntryTimestampSort.class, name = "created_time"), 18 | @JsonSubTypes.Type(value = PropertyValueSort.class, name = "property") 19 | }) 20 | public abstract class AbstractSort { 21 | protected SortDirectionEnum direction; 22 | 23 | protected AbstractSort() { 24 | } 25 | 26 | public static EntryTimestampSort buildEntryTimestampSort(TimeStampEnum timestamp, SortDirectionEnum direction) { 27 | return new EntryTimestampSort(timestamp, direction); 28 | } 29 | public static PropertyValueSort buildPropertyValueSort(String property, SortDirectionEnum direction) { 30 | return new PropertyValueSort(property, direction); 31 | } 32 | 33 | public SortDirectionEnum getDirection() { 34 | return direction; 35 | } 36 | 37 | public AbstractSort setDirection(SortDirectionEnum direction) { 38 | this.direction = direction; 39 | return this; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/sort/EntryTimestampSort.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.sort; 2 | 3 | import com._2lazy2name.notion.enumeration.SortDirectionEnum; 4 | import com._2lazy2name.notion.enumeration.TimeStampEnum; 5 | 6 | 7 | /*** 8 | * @author Yi 9 | * @since 1.0 10 | * @version 1.0 11 | * @see Entry Timestamp Sort 12 | */ 13 | public class EntryTimestampSort extends AbstractSort { 14 | private TimeStampEnum timestamp; 15 | 16 | private EntryTimestampSort() { 17 | } 18 | 19 | public EntryTimestampSort(TimeStampEnum timestamp, SortDirectionEnum direction) { 20 | this.timestamp = timestamp; 21 | this.direction = direction; 22 | } 23 | 24 | public TimeStampEnum getTimestamp() { 25 | return timestamp; 26 | } 27 | 28 | public EntryTimestampSort setTimestamp(TimeStampEnum timestamp) { 29 | this.timestamp = timestamp; 30 | return this; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/entity/common/sort/PropertyValueSort.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.sort; 2 | 3 | import com._2lazy2name.notion.enumeration.SortDirectionEnum; 4 | 5 | 6 | public class PropertyValueSort extends AbstractSort { 7 | private String property; 8 | 9 | private PropertyValueSort() { 10 | } 11 | 12 | public PropertyValueSort(String property, SortDirectionEnum direction) { 13 | this.property = property; 14 | this.direction = direction; 15 | } 16 | 17 | public String getProperty() { 18 | return property; 19 | } 20 | 21 | public PropertyValueSort setProperty(String property) { 22 | this.property = property; 23 | return this; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/ColorEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum ColorEnum { 7 | BLUE("blue"), 8 | BROWN("brown"), 9 | GRAY("gray"), 10 | GREEN("green"), 11 | ORANGE("orange"), 12 | PINK("pink"), 13 | PURPLE("purple"), 14 | RED("red"), 15 | YELLOW("yellow"), 16 | BLUE_BACKGROUND("blue_background"), 17 | BROWN_BACKGROUND("brown_background"), 18 | GRAY_BACKGROUND("gray_background"), 19 | GREEN_BACKGROUND("green_background"), 20 | ORANGE_BACKGROUND("orange_background"), 21 | PINK_BACKGROUND("pink_background"), 22 | PURPLE_BACKGROUND("purple_background"), 23 | RED_BACKGROUND("red_background"), 24 | YELLOW_BACKGROUND("yellow_background"), 25 | DEFAULT("default"); 26 | 27 | final String color; 28 | 29 | @JsonCreator 30 | ColorEnum(String color) { 31 | this.color = color; 32 | } 33 | 34 | @Override 35 | @JsonValue 36 | public String toString() { 37 | return color; 38 | } 39 | 40 | public static ColorEnum getRandomColor() { 41 | return values()[(int) (Math.random() * 9)]; 42 | } 43 | 44 | public static ColorEnum getRandomColorBackground() { 45 | return values()[(int) (Math.random() * 9) + 9]; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/DateFilterMethodEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration; 2 | 3 | import com._2lazy2name.notion.entity.common.filter.typeSpecific.IFilterMethod; 4 | 5 | 6 | public enum DateFilterMethodEnum implements IFilterMethod { 7 | EQUALS("equals", DATE), 8 | BEFORE("before", DATE), 9 | AFTER("after", DATE), 10 | ON_OR_BEFORE("on_or_before", DATE), 11 | ON_OR_AFTER("on_or_after", DATE), 12 | IS_EMPTY("is_empty", BOOLEAN_ONLY_TRUE), 13 | IS_NOT_EMPTY("is_not_empty", BOOLEAN_ONLY_TRUE), 14 | PAST_WEEK("past_week", EMPTY_OBJECT), 15 | PAST_MONTH("past_month", EMPTY_OBJECT), 16 | PAST_YEAR("past_year", EMPTY_OBJECT), 17 | THIS_WEEK("this_week", EMPTY_OBJECT), 18 | NEXT_WEEK("next_week", EMPTY_OBJECT), 19 | NEXT_MONTH("next_month", EMPTY_OBJECT), 20 | NEXT_YEAR("next_year", EMPTY_OBJECT); 21 | 22 | private final String method; 23 | private final int valueType; 24 | 25 | DateFilterMethodEnum(String method, int valueType) { 26 | this.method = method; 27 | this.valueType = valueType; 28 | } 29 | 30 | @Override 31 | public String getMethod() { 32 | return method; 33 | } 34 | 35 | @Override 36 | public int getValueType() { 37 | return valueType; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/LanguageEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum LanguageEnum { 7 | ABAP("abap"), 8 | ARDUINO("arduino"), 9 | BASH("bash"), 10 | BASIC("basic"), 11 | C("c"), 12 | CLOJURE("clojure"), 13 | COFFEESCRIPT("coffeescript"), 14 | CPP("c++"), 15 | CS("c#"), 16 | CSS("css"), 17 | DART("dart"), 18 | DIFF("diff"), 19 | DOCKER("docker"), 20 | ELIXIR("elixir"), 21 | ELM("elm"), 22 | ERLANG("erlang"), 23 | FLOW("flow"), 24 | FORTRAN("fortran"), 25 | FSHARP("f#"), 26 | GHERKIN("gherkin"), 27 | GLSL("glsl"), 28 | GO("go"), 29 | GRAPHQL("graphql"), 30 | GROOVY("groovy"), 31 | HASKELL("haskell"), 32 | HTML("html"), 33 | JAVA("java"), 34 | JAVASCRIPT("javascript"), 35 | JSON("json"), 36 | JULIA("julia"), 37 | KOTLIN("kotlin"), 38 | LATEX("latex"), 39 | LESS("less"), 40 | LISP("lisp"), 41 | LIVESCRIPT("livescript"), 42 | LUA("lua"), 43 | MAKEFILE("makefile"), 44 | MARKDOWN("markdown"), 45 | MARKUP("markup"), 46 | MATLAB("matlab"), 47 | MERMAID("mermaid"), 48 | NIX("nix"), 49 | OBJECTIVE_C("objective-c"), 50 | OCAML("ocaml"), 51 | PASCAL("pascal"), 52 | PERL("perl"), 53 | PHP("php"), 54 | PLAIN_TEXT("plain text"), 55 | POWERSHELL("powershell"), 56 | PROLOG("prolog"), 57 | PROTOBUF("protobuf"), 58 | PYTHON("python"), 59 | R("r"), 60 | REASON("reason"), 61 | RUBY("ruby"), 62 | RUST("rust"), 63 | SASS("sass"), 64 | SCALA("scala"), 65 | SCHEME("scheme"), 66 | SCSS("scss"), 67 | SHELL("shell"), 68 | SQL("sql"), 69 | SWIFT("swift"), 70 | TYPESCRIPT("typescript"), 71 | VBNET("vb.net"), 72 | VERILOG("verilog"), 73 | VHDL("vhdl"), 74 | VISUAL_BASIC("visual basic"), 75 | WEBASSEMBLY("webassembly"), 76 | XML("xml"), 77 | YAML("yaml"), 78 | JAVACC("java/c/c++/c#"); 79 | 80 | private final String language; 81 | 82 | @JsonCreator 83 | LanguageEnum(String language) { 84 | this.language = language; 85 | } 86 | 87 | @JsonValue 88 | public String toString() { 89 | return language; 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/NumberFormatEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | // Disable spell checking for this file 7 | @SuppressWarnings("all") 8 | public enum NumberFormatEnum { 9 | NUMBER("number"), 10 | NUMBER_WITH_COMMAS("number_with_commas"), 11 | PERCENT("percent"), 12 | DOLLAR("dollar"), 13 | CANADIAN_DOLLAR("canadian_dollar"), 14 | EURO("euro"), 15 | POUND("pound"), 16 | YEN("yen"), 17 | RUBLE("ruble"), 18 | RUPEE("rupee"), 19 | WON("won"), 20 | YUAN("yuan"), 21 | REAL("real"), 22 | LIRA("lira"), 23 | RUPIAH("rupiah"), 24 | FRANC("franc"), 25 | HONG_KONG_DOLLAR("hong_kong_dollar"), 26 | NEW_ZEALAND_DOLLAR("new_zealand_dollar"), 27 | KRONA("krona"), 28 | NORWEGIAN_KRONE("norwegian_krone"), 29 | MEXICAN_PESO("mexican_peso"), 30 | RAND("rand"), 31 | NEW_TAIWAN_DOLLAR("new_taiwan_dollar"), 32 | DANISH_KRONE("danish_krone"), 33 | ZLOTY("zloty"), 34 | BAHT("baht"), 35 | FORINT("forint"), 36 | KORUNA("koruna"), 37 | SHEKEL("shekel"), 38 | CHILEAN_PESO("chilean_peso"), 39 | PHILIPPINE_PESO("philippine_peso"), 40 | DIRHAM("dirham"), 41 | COLOMBIAN_PESO("colombian_peso"), 42 | RIYAL("riyal"), 43 | RINGGIT("ringgit"), 44 | LEU("leu"), 45 | ARGENTINE_PESO("argentine_peso"), 46 | URUGUAYAN_PESO("uruguayan_peso"), 47 | SINGAPORE_DOLLAR("singapore_dollar"); 48 | 49 | private 50 | final String format; 51 | 52 | @JsonCreator 53 | NumberFormatEnum(String format) { 54 | this.format = format; 55 | } 56 | 57 | @JsonValue 58 | @Override 59 | public String toString() { 60 | return format; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/ObjectEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum ObjectEnum { 7 | DATABASE("database"), 8 | USER("user"), 9 | PAGE("page"), 10 | BLOCK("block"), 11 | COMMENTS("comments"), 12 | LIST("list"), 13 | PROPERTY_ITEM("property_item"); 14 | 15 | final String type; 16 | 17 | @JsonCreator 18 | ObjectEnum(String type) { 19 | this.type = type; 20 | } 21 | 22 | @Override 23 | @JsonValue 24 | public String toString() { 25 | return type; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/RollupFunctionEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum RollupFunctionEnum { 7 | AVERAGE("average"), 8 | CHECKED("checked"), 9 | COUNT("count"), 10 | COUNT_PER_GROUP("count_per_group"), 11 | COUNT_VALUES("count_values"), 12 | DATE_RANGE("date_range"), 13 | EARLIEST_DATE("earliest_date"), 14 | EMPTY("empty"), 15 | LATEST_DATE("latest_date"), 16 | MAX("max"), 17 | MEDIAN("median"), 18 | MIN("min"), 19 | NOT_EMPTY("not_empty"), 20 | PERCENT_CHECKED("percent_checked"), 21 | PERCENT_EMPTY("percent_empty"), 22 | PERCENT_NOT_EMPTY("percent_not_empty"), 23 | PERCENT_PER_GROUP("percent_per_group"), 24 | PERCENT_UNCHECKED("percent_unchecked"), 25 | RANGE("range"), 26 | SHOW_ORIGINAL("show_original"), 27 | SHOW_UNIQUE("show_unique"), 28 | SUM("sum"), 29 | UNCHECKED("unchecked"), 30 | UNIQUE("unique"); 31 | 32 | final String function; 33 | 34 | @JsonCreator 35 | RollupFunctionEnum(String function) { 36 | this.function = function; 37 | } 38 | 39 | @JsonValue 40 | @Override 41 | public String toString() { 42 | return function; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/SortDirectionEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum SortDirectionEnum { 7 | ASCENDING("ascending"), 8 | DESCENDING("descending"); 9 | 10 | final String direction; 11 | 12 | @JsonCreator 13 | SortDirectionEnum(String direction) { 14 | this.direction = direction; 15 | } 16 | 17 | @Override 18 | @JsonValue 19 | public String toString() { 20 | return direction; 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/TemplateMentionEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum TemplateMentionEnum { 7 | DATE("template_mention_date"), 8 | USER("template_mention_user"); 9 | 10 | final String type; 11 | 12 | 13 | @JsonCreator 14 | TemplateMentionEnum(String type) { 15 | this.type = type; 16 | } 17 | 18 | @Override 19 | @JsonValue 20 | public String toString() { 21 | return type; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/TemplateMentionValueEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum TemplateMentionValueEnum { 7 | TODAY("template_mention_date"), 8 | NOW("template_mention_user"), 9 | ME("me"); 10 | 11 | final String type; 12 | 13 | @JsonCreator 14 | TemplateMentionValueEnum(String type) { 15 | this.type = type; 16 | } 17 | 18 | @Override 19 | @JsonValue 20 | public String toString() { 21 | return type; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/TimeStampEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum TimeStampEnum { 7 | CREATED_TIME("created_time"), 8 | LAST_EDITED_TIME("last_edited_time"); 9 | 10 | final String value; 11 | 12 | @JsonCreator 13 | TimeStampEnum(String value) { 14 | this.value = value; 15 | } 16 | 17 | @Override 18 | @JsonValue 19 | public String toString() { 20 | return value; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/type/BlockTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration.type; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum BlockTypeEnum { 7 | PARAGRAPH("paragraph"), 8 | BULLETED_LIST_ITEM("bulleted_list_item"), 9 | NUMBERED_LIST_ITEM("numbered_list_item"), 10 | TOGGLE("toggle"), 11 | TO_DO("to_do"), 12 | QUOTE("quote"), 13 | CALLOUT("callout"), 14 | SYNCED_BLOCK("synced_block"), 15 | TEMPLATE("template"), 16 | COLUMN("column"), 17 | CODE("code"), 18 | CHILD_PAGE("child_page"), 19 | CHILD_DATABASE("child_database"), 20 | TABLE("table"), 21 | HEADING_1("heading_1"), 22 | HEADING_2("heading_2"), 23 | HEADING_3("heading_3"), 24 | EMBED("embed"), 25 | IMAGE("image"), 26 | VIDEO("video"), 27 | FILE("file"), 28 | PDF("pdf"), 29 | BOOKMARK("bookmark"), 30 | LINK("link"), 31 | EQUATION("equation"), 32 | DIVIDER("divider"), 33 | TABLE_OF_CONTENTS("table_of_contents"), 34 | BREADCRUMB("breadcrumb"), 35 | COLUMN_LIST("column_list"), 36 | LINK_PREVIEW("link_preview"), 37 | LINK_TO_PAGE("link_to_page"), 38 | TABLE_ROW("table_row"); 39 | 40 | final String type; 41 | 42 | @JsonCreator 43 | BlockTypeEnum(String type) { 44 | this.type = type; 45 | } 46 | 47 | @Override 48 | @JsonValue 49 | public String toString() { 50 | return type; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/type/FileTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration.type; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum FileTypeEnum { 7 | EXTERNAL("external"), 8 | FILE("file"); 9 | 10 | final String type; 11 | 12 | @JsonCreator 13 | FileTypeEnum(String type) { 14 | this.type = type; 15 | } 16 | 17 | @Override 18 | @JsonValue 19 | public String toString() { 20 | return type; 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/type/FormulaTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration.type; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum FormulaTypeEnum { 7 | STRING("string"), 8 | NUMBER("number"), 9 | BOOLEAN("boolean"), 10 | DATE("date"); 11 | 12 | final String type; 13 | 14 | @JsonCreator 15 | FormulaTypeEnum(String type) { 16 | this.type = type; 17 | } 18 | 19 | @Override 20 | @JsonValue 21 | public String toString() { 22 | return type; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/type/IconTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration.type; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum IconTypeEnum { 7 | EMOJI("emoji"), 8 | EXTERNAL("external"); 9 | 10 | private final String type; 11 | 12 | @JsonCreator 13 | IconTypeEnum(String type) { 14 | this.type = type; 15 | } 16 | 17 | @Override 18 | @JsonValue 19 | public String toString() { 20 | return type; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/type/MentionTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration.type; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum MentionTypeEnum { 7 | DATABASE("database"), 8 | DATE("date"), 9 | LINK_PREVIEW("link_preview"), 10 | PAGE("page"), 11 | TEMPLATE_MENTION("template_mention"), 12 | USER("user"); 13 | 14 | 15 | final String type; 16 | 17 | @JsonCreator 18 | MentionTypeEnum(String type) { 19 | this.type = type; 20 | } 21 | 22 | @Override 23 | @JsonValue 24 | public String toString() { 25 | return type; 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/type/ParentTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration.type; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum ParentTypeEnum { 7 | DATABASE_ID("database_id"), 8 | PAGE_ID("page_id"), 9 | WORKSPACE("workspace"), 10 | BLOCK_ID("block_id"); 11 | 12 | final String type; 13 | 14 | @JsonCreator 15 | ParentTypeEnum(String type) { 16 | this.type = type; 17 | } 18 | 19 | @Override 20 | @JsonValue 21 | public String toString() { 22 | return type; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/type/PropertyTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration.type; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum PropertyTypeEnum { 7 | RICH_TEXT("rich_text"), 8 | NUMBER("number"), 9 | SELECT("select"), 10 | MULTI_SELECT("multi_select"), 11 | STATUS("status"), 12 | DATE("date"), 13 | FORMULA("formula"), 14 | RELATION("relation"), 15 | ROLLUP("rollup"), 16 | TITLE("title"), 17 | PEOPLE("people"), 18 | FILES("files"), 19 | CHECKBOX("checkbox"), 20 | URL("url"), 21 | EMAIL("email"), 22 | PHONE_NUMBER("phone_number"), 23 | CREATED_TIME("created_time"), 24 | CREATED_BY("created_by"), 25 | LAST_EDITED_TIME("last_edited_time"), 26 | LAST_EDITED_BY("last_edited_by"); 27 | 28 | final String type; 29 | 30 | @JsonCreator 31 | PropertyTypeEnum(String type) { 32 | this.type = type; 33 | } 34 | 35 | @JsonValue 36 | public String toString() { 37 | return type; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/type/RelationTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration.type; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum RelationTypeEnum { 7 | SINGLE_PROPERTY("single_property"), 8 | DUAL_PROPERTY("dual_property"); 9 | 10 | private final String type; 11 | 12 | @JsonCreator 13 | RelationTypeEnum(String type) { 14 | this.type = type; 15 | } 16 | 17 | @JsonValue 18 | public String toString() { 19 | return type; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/type/RollupTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration.type; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum RollupTypeEnum { 7 | ARRAY("array"), 8 | DATE("date"), 9 | NUMBER("number"), 10 | INCOMPLETE("incomplete"), 11 | UNSUPPORTED("unsupported"); 12 | 13 | final String type; 14 | 15 | @JsonCreator 16 | RollupTypeEnum(String type) { 17 | this.type = type; 18 | } 19 | 20 | @JsonValue 21 | @Override 22 | public String toString() { 23 | return type; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/type/TextTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration.type; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum TextTypeEnum { 7 | TEXT("text"), 8 | MENTION("mention"), 9 | EQUATION("equation"); 10 | 11 | final String type; 12 | 13 | @JsonCreator 14 | TextTypeEnum(String type) { 15 | this.type = type; 16 | } 17 | 18 | @Override 19 | @JsonValue 20 | public String toString() { 21 | return type; 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/enumeration/type/UserTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.enumeration.type; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum UserTypeEnum { 7 | PERSON("person"), 8 | BOT("bot"); 9 | 10 | final String type; 11 | 12 | @JsonCreator 13 | UserTypeEnum (String type) { 14 | this.type = type; 15 | } 16 | 17 | @Override 18 | @JsonValue 19 | public String toString() { 20 | return type; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/exception/ExceptionCodeEnum.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.exception; 2 | 3 | public enum ExceptionCodeEnum { 4 | INVALID_JSON("invalid_json", 400), 5 | INVALID_REQUEST_URL("invalid_request_url", 400), 6 | INVALID_REQUEST("invalid_request", 400), 7 | VALIDATION_ERROR("validation_error", 400), 8 | MISSING_VERSION("missing_version", 400), 9 | UNAUTHORIZED("unauthorized", 401), 10 | RESTRICTED_RESOURCE("restricted_resource", 403), 11 | OBJECT_NOT_FOUND("object_not_found", 404), 12 | CONFLICT_ERROR("conflict_error", 409), 13 | RATE_LIMITED("rate_limited", 429), 14 | INTERNAL_SERVER_ERROR("internal_server_error", 500), 15 | SERVICE_UNAVAILABLE("service_unavailable", 503), 16 | DATABASE_CONNECTION_UNAVAILABLE("database_connection_unavailable", 503), 17 | GATEWAY_TIMEOUT("gateway_timeout", 504); 18 | 19 | private final String code; 20 | private final int statusCode; 21 | 22 | ExceptionCodeEnum(String code, int statusCode) { 23 | this.code = code; 24 | this.statusCode = statusCode; 25 | } 26 | 27 | public String getCode() { 28 | return code; 29 | } 30 | 31 | public int getStatusCode() { 32 | return statusCode; 33 | } 34 | 35 | public static ExceptionCodeEnum getByCode(String code) { 36 | for (ExceptionCodeEnum exceptionCodeEnum : values()) { 37 | if (exceptionCodeEnum.getCode().equals(code)) { 38 | return exceptionCodeEnum; 39 | } 40 | } 41 | return null; 42 | } 43 | 44 | public static ExceptionCodeEnum getByStatusCode(int statusCode) { 45 | for (ExceptionCodeEnum exceptionCodeEnum : values()) { 46 | if (exceptionCodeEnum.getStatusCode() == statusCode) { 47 | return exceptionCodeEnum; 48 | } 49 | } 50 | return null; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/exception/NotionException.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.exception; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | 6 | @JsonIgnoreProperties(ignoreUnknown = true) 7 | public class NotionException extends RuntimeException { 8 | private final String object = "error"; 9 | private int status; 10 | private String code; 11 | @JsonProperty("message") 12 | protected String message; 13 | 14 | 15 | public NotionException() { 16 | } 17 | 18 | public int getStatus() { 19 | return status; 20 | } 21 | 22 | public NotionException setStatus(int status) { 23 | this.status = status; 24 | return this; 25 | } 26 | 27 | public String getCode() { 28 | return code; 29 | } 30 | 31 | public NotionException setCode(String code) { 32 | this.code = code; 33 | return this; 34 | } 35 | 36 | public String getObject() { 37 | return object; 38 | } 39 | 40 | @Override 41 | public String getMessage() { 42 | return """ 43 | 44 | NotionException: 45 | Code %d: %s 46 | ================================= 47 | %s 48 | """.formatted(status, code, message); 49 | } 50 | 51 | public NotionException setMessage(String message) { 52 | this.message = message; 53 | return this; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/AbstractProperty.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 5 | 6 | @JsonIgnoreProperties 7 | public abstract class AbstractProperty { 8 | private String id; 9 | protected PropertyTypeEnum type; 10 | 11 | public String getId() { 12 | return id; 13 | } 14 | 15 | public PropertyTypeEnum getType() { 16 | return type; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/AbstractDatabaseProperty.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.ObjectEnum; 4 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 5 | import com._2lazy2name.notion.property.AbstractProperty; 6 | import com.fasterxml.jackson.annotation.*; 7 | 8 | @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) 9 | @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", include = JsonTypeInfo.As.EXISTING_PROPERTY) 10 | @JsonInclude(JsonInclude.Include.NON_NULL) 11 | @JsonSubTypes({ 12 | @JsonSubTypes.Type(value = CheckboxConfiguration.class, name = "checkbox"), 13 | @JsonSubTypes.Type(value = CreatedByConfiguration.class, name = "created_by"), 14 | @JsonSubTypes.Type(value = CreatedTimeConfiguration.class, name = "created_time"), 15 | @JsonSubTypes.Type(value = DateConfiguration.class, name = "date"), 16 | @JsonSubTypes.Type(value = EmailConfiguration.class, name = "email"), 17 | @JsonSubTypes.Type(value = FileConfiguration.class, name = "files"), 18 | @JsonSubTypes.Type(value = FormulaConfiguration.class, name = "formula"), 19 | @JsonSubTypes.Type(value = LastEditedByConfiguration.class, name = "last_edited_by"), 20 | @JsonSubTypes.Type(value = LastEditedTimeConfiguration.class, name = "last_edited_time"), 21 | @JsonSubTypes.Type(value = MultiSelectConfiguration.class, name = "multi_select"), 22 | @JsonSubTypes.Type(value = NumberConfiguration.class, name = "number"), 23 | @JsonSubTypes.Type(value = PeopleConfiguration.class, name = "people"), 24 | @JsonSubTypes.Type(value = PhoneNumberConfiguration.class, name = "phone_number"), 25 | @JsonSubTypes.Type(value = RelationConfiguration.class, name = "relation"), 26 | @JsonSubTypes.Type(value = RichTextConfiguration.class, name = "rich_text"), 27 | @JsonSubTypes.Type(value = RollupConfiguration.class, name = "rollup"), 28 | @JsonSubTypes.Type(value = SelectConfiguration.class, name = "select"), 29 | @JsonSubTypes.Type(value = StatusConfiguration.class, name = "status"), 30 | @JsonSubTypes.Type(value = TitleConfiguration.class, name = "title"), 31 | @JsonSubTypes.Type(value = UrlConfiguration.class, name = "url"), 32 | }) 33 | public abstract class AbstractDatabaseProperty extends AbstractProperty { 34 | private ObjectEnum object; 35 | protected PropertyTypeEnum type; 36 | private String name; 37 | private String nextUrl; 38 | 39 | public ObjectEnum getObject() { 40 | return object; 41 | } 42 | 43 | public PropertyTypeEnum getType() { 44 | return type; 45 | } 46 | 47 | public String getName() { 48 | return name; 49 | } 50 | 51 | public String getNextUrl() { 52 | return nextUrl; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/CheckboxConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.serializer.NullToEmptyObjectSerializer; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 7 | 8 | /*** 9 | * @author Yi 10 | * @since 1.0 11 | * @version 1.0 12 | * @see Checkbox Configuration 13 | */ 14 | 15 | public class CheckboxConfiguration extends AbstractDatabaseProperty { 16 | private final PropertyTypeEnum type = PropertyTypeEnum.CHECKBOX; 17 | @JsonSerialize(nullsUsing = NullToEmptyObjectSerializer.class) 18 | private final Object checkbox = null; 19 | @JsonIgnore 20 | private static final CheckboxConfiguration INSTANCE = new CheckboxConfiguration(); 21 | 22 | private CheckboxConfiguration() { 23 | } 24 | 25 | public static CheckboxConfiguration getInstance() { 26 | return INSTANCE; 27 | } 28 | 29 | @Override 30 | public PropertyTypeEnum getType() { 31 | return type; 32 | } 33 | 34 | private Object getCheckbox() { 35 | return null; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/CreatedByConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.serializer.NullToEmptyObjectSerializer; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 7 | 8 | 9 | /*** 10 | * @author Yi 11 | * @since 1.0 12 | * @version 1.0 13 | * @see Created By Configuration 14 | */ 15 | 16 | public class CreatedByConfiguration extends AbstractDatabaseProperty { 17 | private final PropertyTypeEnum type = PropertyTypeEnum.CREATED_BY; 18 | @JsonSerialize(nullsUsing = NullToEmptyObjectSerializer.class) 19 | private final Object createdBy = null; 20 | @JsonIgnore 21 | private static final CreatedByConfiguration INSTANCE = new CreatedByConfiguration(); 22 | 23 | private CreatedByConfiguration() { 24 | } 25 | 26 | public static CreatedByConfiguration getInstance() { 27 | return INSTANCE; 28 | } 29 | 30 | @Override 31 | public PropertyTypeEnum getType() { 32 | return type; 33 | } 34 | 35 | private Object getCreatedBy() { 36 | return null; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/CreatedTimeConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.serializer.NullToEmptyObjectSerializer; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 7 | 8 | 9 | /*** 10 | * @author Yi 11 | * @since 1.0 12 | * @version 1.0 13 | * @see Created Time Configuration 14 | */ 15 | 16 | public class CreatedTimeConfiguration extends AbstractDatabaseProperty{ 17 | private final PropertyTypeEnum type = PropertyTypeEnum.CREATED_TIME; 18 | @JsonSerialize(nullsUsing = NullToEmptyObjectSerializer.class) 19 | private final Object createdTime = null; 20 | @JsonIgnore 21 | private static final CreatedTimeConfiguration INSTANCE = new CreatedTimeConfiguration(); 22 | 23 | private CreatedTimeConfiguration() { 24 | } 25 | 26 | public static CreatedTimeConfiguration getInstance() { 27 | return INSTANCE; 28 | } 29 | 30 | @Override 31 | public PropertyTypeEnum getType() { 32 | return type; 33 | } 34 | 35 | private Object getCreatedTime() { 36 | return null; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/DateConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.serializer.NullToEmptyObjectSerializer; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 7 | 8 | /*** 9 | * @author Yi 10 | * @since 1.0 11 | * @version 1.0 12 | * @see Date Configuration 13 | */ 14 | public class DateConfiguration extends AbstractDatabaseProperty { 15 | private PropertyTypeEnum type = PropertyTypeEnum.DATE; 16 | @JsonSerialize(nullsUsing = NullToEmptyObjectSerializer.class) 17 | private final Object date = null; 18 | @JsonIgnore 19 | private static final DateConfiguration INSTANCE = new DateConfiguration(); 20 | 21 | private DateConfiguration() { 22 | } 23 | 24 | public static DateConfiguration getInstance() { 25 | return INSTANCE; 26 | } 27 | 28 | @Override 29 | public PropertyTypeEnum getType() { 30 | return type; 31 | } 32 | 33 | public DateConfiguration setType(PropertyTypeEnum type) { 34 | this.type = type; 35 | return this; 36 | } 37 | 38 | private Object getDate() { 39 | return null; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/EmailConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.serializer.NullToEmptyObjectSerializer; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 7 | 8 | /*** 9 | * @author Yi 10 | * @since 1.0 11 | * @version 1.0 12 | * @see Email Configuration 13 | */ 14 | public class EmailConfiguration extends AbstractDatabaseProperty { 15 | private final PropertyTypeEnum type = PropertyTypeEnum.EMAIL; 16 | @JsonSerialize(nullsUsing = NullToEmptyObjectSerializer.class) 17 | private final Object email = null; 18 | @JsonIgnore 19 | private static final EmailConfiguration INSTANCE = new EmailConfiguration(); 20 | 21 | private EmailConfiguration() { 22 | } 23 | 24 | public static EmailConfiguration getInstance() { 25 | return INSTANCE; 26 | } 27 | 28 | @Override 29 | public PropertyTypeEnum getType() { 30 | return type; 31 | } 32 | 33 | private Object getEmail() { 34 | return null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/FileConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.serializer.NullToEmptyObjectSerializer; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 7 | 8 | 9 | /*** 10 | * @author Yi 11 | * @since 1.0 12 | * @version 1.0 13 | * @see Files Configuration 14 | */ 15 | public class FileConfiguration extends AbstractDatabaseProperty { 16 | private final PropertyTypeEnum type = PropertyTypeEnum.FILES; 17 | @JsonSerialize(nullsUsing = NullToEmptyObjectSerializer.class) 18 | private final Object files = null; 19 | @JsonIgnore 20 | private static final FileConfiguration INSTANCE = new FileConfiguration(); 21 | 22 | private FileConfiguration() { 23 | } 24 | 25 | public static FileConfiguration getInstance() { 26 | return INSTANCE; 27 | } 28 | 29 | @Override 30 | public PropertyTypeEnum getType() { 31 | return type; 32 | } 33 | 34 | private Object getFiles() { 35 | return null; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/FormulaConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | 6 | /*** 7 | * TODO: Not work 8 | * @author Yi 9 | * @since 1.0 10 | * @version 1.0 11 | * @see Formula Configuration 12 | */ 13 | public class FormulaConfiguration extends AbstractDatabaseProperty { 14 | private final PropertyTypeEnum type = PropertyTypeEnum.FORMULA; 15 | private Formula formula; 16 | 17 | 18 | private static class Formula { 19 | private String expression; 20 | 21 | public String getExpression() { 22 | return expression; 23 | } 24 | 25 | public Formula setExpression(String expression) { 26 | this.expression = expression; 27 | return this; 28 | } 29 | } 30 | 31 | private FormulaConfiguration() { 32 | } 33 | 34 | public FormulaConfiguration(String expression) { 35 | this.formula = new Formula(); 36 | this.formula.setExpression(expression); 37 | } 38 | 39 | @JsonIgnore 40 | public String getExpression() { 41 | return this.formula.getExpression(); 42 | } 43 | 44 | public void setExpression(String expression) { 45 | this.formula.setExpression(expression); 46 | } 47 | 48 | @Override 49 | public PropertyTypeEnum getType() { 50 | return type; 51 | } 52 | 53 | public Formula getFormula() { 54 | return formula; 55 | } 56 | 57 | public FormulaConfiguration setFormula(Formula formula) { 58 | this.formula = formula; 59 | return this; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/LastEditedByConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.serializer.NullToEmptyObjectSerializer; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 7 | 8 | 9 | /*** 10 | * @author Yi 11 | * @since 1.0 12 | * @version 1.0 13 | * @see Last Edited By Configuration 14 | */ 15 | public class LastEditedByConfiguration extends AbstractDatabaseProperty { 16 | private final PropertyTypeEnum type = PropertyTypeEnum.LAST_EDITED_BY; 17 | @JsonSerialize(nullsUsing = NullToEmptyObjectSerializer.class) 18 | private final Object lastEditedBy = null; 19 | @JsonIgnore 20 | private static final LastEditedByConfiguration INSTANCE = new LastEditedByConfiguration(); 21 | 22 | private LastEditedByConfiguration() { 23 | } 24 | 25 | public static LastEditedByConfiguration getInstance() { 26 | return INSTANCE; 27 | } 28 | 29 | @Override 30 | public PropertyTypeEnum getType() { 31 | return type; 32 | } 33 | 34 | private Object getLastEditedBy() { 35 | return null; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/LastEditedTimeConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.serializer.NullToEmptyObjectSerializer; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 7 | 8 | 9 | /*** 10 | * @author Yi 11 | * @since 1.0 12 | * @version 1.0 13 | * @see Last Edited Time Configuration 14 | */ 15 | 16 | public class LastEditedTimeConfiguration extends AbstractDatabaseProperty { 17 | private final PropertyTypeEnum type = PropertyTypeEnum.LAST_EDITED_TIME; 18 | @JsonSerialize(nullsUsing = NullToEmptyObjectSerializer.class) 19 | private final Object lastEditedTime = null; 20 | @JsonIgnore 21 | private static final LastEditedTimeConfiguration INSTANCE = new LastEditedTimeConfiguration(); 22 | 23 | private LastEditedTimeConfiguration() { 24 | } 25 | 26 | public static LastEditedTimeConfiguration getInstance() { 27 | return INSTANCE; 28 | } 29 | 30 | @Override 31 | public PropertyTypeEnum getType() { 32 | return type; 33 | } 34 | 35 | private Object getLastEditedTime() { 36 | return null; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/MultiSelectConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | 6 | import java.util.List; 7 | 8 | /*** 9 | * @author Yi 10 | * @since 1.0 11 | * @version 1.0 12 | * @see Multiselect Configuration 13 | */ 14 | public class MultiSelectConfiguration extends AbstractDatabaseProperty { 15 | private PropertyTypeEnum type = PropertyTypeEnum.MULTI_SELECT; 16 | private Multiselect multiSelect; 17 | 18 | private static class Multiselect { 19 | private List options; 20 | 21 | public List getOptions() { 22 | return options; 23 | } 24 | 25 | public Multiselect setOptions(List options) { 26 | this.options = options; 27 | return this; 28 | } 29 | } 30 | 31 | private MultiSelectConfiguration() { 32 | } 33 | 34 | public MultiSelectConfiguration(List options) { 35 | this.multiSelect = new MultiSelectConfiguration.Multiselect(); 36 | this.multiSelect.setOptions(options); 37 | } 38 | 39 | @JsonIgnore 40 | public List getOptions() { 41 | return this.multiSelect.getOptions(); 42 | } 43 | 44 | public void setOptions(List options) { 45 | this.multiSelect.setOptions(options); 46 | } 47 | 48 | @Override 49 | public PropertyTypeEnum getType() { 50 | return type; 51 | } 52 | 53 | public MultiSelectConfiguration setType(PropertyTypeEnum type) { 54 | this.type = type; 55 | return this; 56 | } 57 | 58 | public Multiselect getMultiSelect() { 59 | return multiSelect; 60 | } 61 | 62 | public MultiSelectConfiguration setMultiSelect(Multiselect multiSelect) { 63 | this.multiSelect = multiSelect; 64 | return this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/NumberConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.NumberFormatEnum; 4 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | 7 | /*** 8 | * @author Yi 9 | * @since 1.0 10 | * @version 1.0 11 | * @see Number Configuration 12 | */ 13 | public class NumberConfiguration extends AbstractDatabaseProperty { 14 | private final PropertyTypeEnum type = PropertyTypeEnum.NUMBER; 15 | private Number number; 16 | 17 | private static class Number { 18 | private NumberFormatEnum format; 19 | 20 | public NumberFormatEnum getFormat() { 21 | return format; 22 | } 23 | 24 | public Number setFormat(NumberFormatEnum format) { 25 | this.format = format; 26 | return this; 27 | } 28 | } 29 | 30 | private NumberConfiguration() { 31 | } 32 | 33 | public NumberConfiguration(NumberFormatEnum format) { 34 | this.number = new Number(); 35 | this.number.setFormat(format); 36 | } 37 | 38 | @JsonIgnore 39 | public NumberFormatEnum getFormat() { 40 | return this.number.getFormat(); 41 | } 42 | 43 | public void setFormat(NumberFormatEnum format) { 44 | this.number.setFormat(format); 45 | } 46 | 47 | @Override 48 | public PropertyTypeEnum getType() { 49 | return type; 50 | } 51 | 52 | public Number getNumber() { 53 | return number; 54 | } 55 | 56 | public NumberConfiguration setNumber(Number number) { 57 | this.number = number; 58 | return this; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/PeopleConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.serializer.NullToEmptyObjectSerializer; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 7 | 8 | 9 | /*** 10 | * @author Yi 11 | * @since 1.0 12 | * @version 1.0 13 | * @see People configuration 14 | */ 15 | public class PeopleConfiguration extends AbstractDatabaseProperty{ 16 | private final PropertyTypeEnum type = PropertyTypeEnum.PEOPLE; 17 | @JsonSerialize(nullsUsing = NullToEmptyObjectSerializer.class) 18 | private final Object people = null; 19 | @JsonIgnore 20 | private static final PeopleConfiguration INSTANCE = new PeopleConfiguration(); 21 | 22 | private PeopleConfiguration() { 23 | } 24 | 25 | public static PeopleConfiguration getInstance() { 26 | return INSTANCE; 27 | } 28 | 29 | @Override 30 | public PropertyTypeEnum getType() { 31 | return type; 32 | } 33 | 34 | public Object getPeople() { 35 | return people; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/PhoneNumberConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.serializer.NullToEmptyObjectSerializer; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 7 | 8 | /*** 9 | * @author Yi 10 | * @since 1.0 11 | * @version 1.0 12 | * @see Phone Number Configuration 13 | */ 14 | 15 | public class PhoneNumberConfiguration extends AbstractDatabaseProperty { 16 | private final PropertyTypeEnum type = PropertyTypeEnum.PHONE_NUMBER; 17 | @JsonSerialize(nullsUsing = NullToEmptyObjectSerializer.class) 18 | private final Object phoneNumber = null; 19 | @JsonIgnore 20 | private static final PhoneNumberConfiguration INSTANCE = new PhoneNumberConfiguration(); 21 | 22 | private PhoneNumberConfiguration() { 23 | } 24 | 25 | public static PhoneNumberConfiguration getInstance() { 26 | return INSTANCE; 27 | } 28 | 29 | @Override 30 | public PropertyTypeEnum getType() { 31 | return type; 32 | } 33 | 34 | private Object getPhoneNumber() { 35 | return null; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/RelationConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.property.database.relation.AbstractRelation; 5 | 6 | 7 | /*** 8 | * @author Yi 9 | * @since 1.0 10 | * @version 1.0 11 | * @see Relaiton 12 | */ 13 | 14 | public class RelationConfiguration extends AbstractDatabaseProperty { 15 | private final PropertyTypeEnum type = PropertyTypeEnum.RELATION; 16 | private AbstractRelation relation; 17 | 18 | @Override 19 | public PropertyTypeEnum getType() { 20 | return type; 21 | } 22 | 23 | public AbstractRelation getRelation() { 24 | return relation; 25 | } 26 | 27 | public RelationConfiguration setRelation(AbstractRelation relation) { 28 | this.relation = relation; 29 | return this; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/RenamingProperty.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | public class RenamingProperty extends AbstractDatabaseProperty { 4 | private String name; 5 | 6 | public String getName() { 7 | return name; 8 | } 9 | 10 | private RenamingProperty() { 11 | } 12 | 13 | public RenamingProperty(String name) { 14 | this.name = name; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/RichTextConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.serializer.NullToEmptyObjectSerializer; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 7 | 8 | 9 | /*** 10 | * @author Yi 11 | * @since 1.0 12 | * @version 1.0 13 | * @see Rich Text Configuration 14 | */ 15 | 16 | public class RichTextConfiguration extends AbstractDatabaseProperty { 17 | private final PropertyTypeEnum type = PropertyTypeEnum.RICH_TEXT; 18 | @JsonSerialize(nullsUsing = NullToEmptyObjectSerializer.class) 19 | private final Object richText = null; 20 | @JsonIgnore 21 | private static final RichTextConfiguration INSTANCE = new RichTextConfiguration(); 22 | 23 | private RichTextConfiguration() { 24 | } 25 | 26 | public static RichTextConfiguration getInstance() { 27 | return INSTANCE; 28 | } 29 | 30 | @Override 31 | public PropertyTypeEnum getType() { 32 | return type; 33 | } 34 | 35 | private Object getRichText() { 36 | return null; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/RollupConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.RollupFunctionEnum; 4 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 5 | 6 | 7 | /*** 8 | * Rollup is not supported by Notion API yet. 9 | * @author Yi 10 | * @since 1.0 11 | * @version 1.0 12 | * @see Rollup Configuration 13 | */ 14 | 15 | public class RollupConfiguration extends AbstractDatabaseProperty{ 16 | private final PropertyTypeEnum type = PropertyTypeEnum.ROLLUP; 17 | private Rollup rollup; 18 | 19 | private static class Rollup { 20 | private RollupFunctionEnum function; 21 | private String relationPropertyName; 22 | private String relationPropertyId; 23 | private String rollupPropertyName; 24 | private String rollupPropertyId; 25 | 26 | public RollupFunctionEnum getFunction() { 27 | return function; 28 | } 29 | 30 | public Rollup setFunction(RollupFunctionEnum function) { 31 | this.function = function; 32 | return this; 33 | } 34 | 35 | public String getRelationPropertyName() { 36 | return relationPropertyName; 37 | } 38 | 39 | public Rollup setRelationPropertyName(String relationPropertyName) { 40 | this.relationPropertyName = relationPropertyName; 41 | return this; 42 | } 43 | 44 | public String getRelationPropertyId() { 45 | return relationPropertyId; 46 | } 47 | 48 | public Rollup setRelationPropertyId(String relationPropertyId) { 49 | this.relationPropertyId = relationPropertyId; 50 | return this; 51 | } 52 | 53 | public String getRollupPropertyName() { 54 | return rollupPropertyName; 55 | } 56 | 57 | public Rollup setRollupPropertyName(String rollupPropertyName) { 58 | this.rollupPropertyName = rollupPropertyName; 59 | return this; 60 | } 61 | 62 | public String getRollupPropertyId() { 63 | return rollupPropertyId; 64 | } 65 | 66 | public Rollup setRollupPropertyId(String rollupPropertyId) { 67 | this.rollupPropertyId = rollupPropertyId; 68 | return this; 69 | } 70 | } 71 | 72 | @Override 73 | public PropertyTypeEnum getType() { 74 | return type; 75 | } 76 | 77 | public Rollup getRollup() { 78 | return rollup; 79 | } 80 | 81 | public RollupConfiguration setRollup(Rollup rollup) { 82 | this.rollup = rollup; 83 | return this; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/SelectConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /*** 11 | * @author Yi 12 | * @since 1.0 13 | * @version 1.0 14 | * @see Select Configuration 15 | */ 16 | public class SelectConfiguration extends AbstractDatabaseProperty { 17 | private final PropertyTypeEnum type = PropertyTypeEnum.SELECT; 18 | private Select select; 19 | 20 | 21 | private static class Select { 22 | private List options = new ArrayList<>(); 23 | 24 | public List getOptions() { 25 | return options; 26 | } 27 | 28 | public Select setOptions(List options) { 29 | this.options = options; 30 | return this; 31 | } 32 | } 33 | 34 | private SelectConfiguration() { 35 | } 36 | 37 | public SelectConfiguration(List options) { 38 | this.select = new Select(); 39 | this.select.setOptions(options); 40 | } 41 | 42 | @JsonIgnore 43 | public List getOptions() { 44 | return this.select.getOptions(); 45 | } 46 | 47 | public void setOptions(List options) { 48 | this.select.setOptions(options); 49 | } 50 | 51 | @Override 52 | public PropertyTypeEnum getType() { 53 | return type; 54 | } 55 | 56 | public Select getSelect() { 57 | return select; 58 | } 59 | 60 | public SelectConfiguration setSelect(Select select) { 61 | this.select = select; 62 | return this; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/SelectOption.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.ColorEnum; 4 | import com.fasterxml.jackson.annotation.JsonInclude; 5 | 6 | 7 | 8 | /*** 9 | * @author Yi 10 | * @since 1.0 11 | * @version 1.0 12 | * @see Select Options 13 | */ 14 | @JsonInclude(JsonInclude.Include.NON_NULL) 15 | public class SelectOption { 16 | private String name; 17 | private String id; 18 | private ColorEnum color; 19 | 20 | private SelectOption() { 21 | } 22 | 23 | public SelectOption(String name, ColorEnum color) { 24 | this.name = name; 25 | this.color = color; 26 | } 27 | 28 | public SelectOption(String name) { 29 | this.name = name; 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | public SelectOption setName(String name) { 37 | this.name = name; 38 | return this; 39 | } 40 | 41 | public String getId() { 42 | return id; 43 | } 44 | 45 | public SelectOption setId(String id) { 46 | this.id = id; 47 | return this; 48 | } 49 | 50 | public ColorEnum getColor() { 51 | return color; 52 | } 53 | 54 | public SelectOption setColor(ColorEnum color) { 55 | this.color = color; 56 | return this; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/StatusConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /*** 10 | * TODO: find out whether this class is able to modify. 11 | * @author Yi 12 | * @since 1.0 13 | * @version 1.0 14 | * @see Status Configuration 15 | */ 16 | 17 | public class StatusConfiguration extends AbstractDatabaseProperty { 18 | private final PropertyTypeEnum type = PropertyTypeEnum.STATUS; 19 | private Status status; 20 | 21 | 22 | private static class Status { 23 | private List options = new ArrayList<>(); 24 | private List groups = new ArrayList<>(); 25 | 26 | public List getOptions() { 27 | return options; 28 | } 29 | 30 | public Status setOptions(List options) { 31 | this.options = options; 32 | return this; 33 | } 34 | 35 | public List getGroups() { 36 | return groups; 37 | } 38 | 39 | public Status setGroups(List groups) { 40 | this.groups = groups; 41 | return this; 42 | } 43 | } 44 | 45 | @Override 46 | public PropertyTypeEnum getType() { 47 | return type; 48 | } 49 | 50 | public Status getStatus() { 51 | return status; 52 | } 53 | 54 | public StatusConfiguration setStatus(Status status) { 55 | this.status = status; 56 | return this; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/StatusGroup.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.ColorEnum; 4 | 5 | 6 | import java.util.List; 7 | 8 | /*** 9 | * @author Yi 10 | * @since 1.0 11 | * @version 1.0 12 | * @see Status Group 13 | */ 14 | 15 | public class StatusGroup { 16 | private String id; 17 | private String name; 18 | private ColorEnum color; 19 | private List optionIds; 20 | 21 | public String getId() { 22 | return id; 23 | } 24 | 25 | public StatusGroup setId(String id) { 26 | this.id = id; 27 | return this; 28 | } 29 | 30 | public String getName() { 31 | return name; 32 | } 33 | 34 | public StatusGroup setName(String name) { 35 | this.name = name; 36 | return this; 37 | } 38 | 39 | public ColorEnum getColor() { 40 | return color; 41 | } 42 | 43 | public StatusGroup setColor(ColorEnum color) { 44 | this.color = color; 45 | return this; 46 | } 47 | 48 | public List getOptionIds() { 49 | return optionIds; 50 | } 51 | 52 | public StatusGroup setOptionIds(List optionIds) { 53 | this.optionIds = optionIds; 54 | return this; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/TitleConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.serializer.NullToEmptyObjectSerializer; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 7 | 8 | /*** 9 | * @author Yi 10 | * @since 1.0 11 | * @version 1.0 12 | * @see Title Configuration 13 | */ 14 | public class TitleConfiguration extends AbstractDatabaseProperty { 15 | private final PropertyTypeEnum type = PropertyTypeEnum.TITLE; 16 | @JsonSerialize(nullsUsing = NullToEmptyObjectSerializer.class) 17 | private final Object title = null; 18 | @JsonIgnore 19 | private static final TitleConfiguration INSTANCE = new TitleConfiguration(); 20 | 21 | private TitleConfiguration() { 22 | } 23 | 24 | public static TitleConfiguration getInstance() { 25 | return INSTANCE; 26 | } 27 | 28 | @Override 29 | public PropertyTypeEnum getType() { 30 | return type; 31 | } 32 | 33 | private Object getTitle() { 34 | return null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/UrlConfiguration.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.serializer.NullToEmptyObjectSerializer; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 7 | 8 | /*** 9 | * @author Yi 10 | * @since 1.0 11 | * @version 1.0 12 | * @see URL Configuration 13 | */ 14 | public class UrlConfiguration extends AbstractDatabaseProperty { 15 | private final PropertyTypeEnum type = PropertyTypeEnum.URL; 16 | @JsonSerialize(nullsUsing = NullToEmptyObjectSerializer.class) 17 | private final Object url = null; 18 | @JsonIgnore 19 | private static final UrlConfiguration INSTANCE = new UrlConfiguration(); 20 | 21 | private UrlConfiguration() { 22 | } 23 | 24 | public static UrlConfiguration getInstance() { 25 | return INSTANCE; 26 | } 27 | 28 | @Override 29 | public PropertyTypeEnum getType() { 30 | return type; 31 | } 32 | 33 | private Object getUrl() { 34 | return null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/relation/AbstractRelation.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database.relation; 2 | 3 | import com._2lazy2name.notion.enumeration.type.RelationTypeEnum; 4 | import com.fasterxml.jackson.annotation.JsonInclude; 5 | import com.fasterxml.jackson.annotation.JsonSubTypes; 6 | import com.fasterxml.jackson.annotation.JsonTypeInfo; 7 | 8 | 9 | /*** 10 | * TODO: Implement this class. 11 | * This is an update in version 2022-06-28 and can be found in the "Versioning - Changes by version" section. 12 | * @author Yi 13 | * @since 1.0 14 | * @version 1.0 15 | * @see Changes by version 16 | */ 17 | @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") 18 | @JsonSubTypes({ 19 | @JsonSubTypes.Type(value = SinglePropertyRelation.class, name = "single_property"), 20 | @JsonSubTypes.Type(value = DualPropertyRelation.class, name = "dual_property") 21 | }) 22 | public abstract class AbstractRelation { 23 | protected RelationTypeEnum type; 24 | private String databaseId; 25 | 26 | public RelationTypeEnum getType() { 27 | return type; 28 | } 29 | 30 | public String getDatabaseId() { 31 | return databaseId; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/relation/DualPropertyRelation.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database.relation; 2 | 3 | import com._2lazy2name.notion.enumeration.type.RelationTypeEnum; 4 | 5 | public class DualPropertyRelation extends AbstractRelation { 6 | private RelationTypeEnum type = RelationTypeEnum.DUAL_PROPERTY; 7 | private DualProperty dualProperty; 8 | 9 | private static class DualProperty { 10 | private String syncedPropertyName; 11 | private String syncedPropertyId; 12 | 13 | public String getSyncedPropertyName() { 14 | return syncedPropertyName; 15 | } 16 | 17 | public DualProperty setSyncedPropertyName(String syncedPropertyName) { 18 | this.syncedPropertyName = syncedPropertyName; 19 | return this; 20 | } 21 | 22 | public String getSyncedPropertyId() { 23 | return syncedPropertyId; 24 | } 25 | 26 | public DualProperty setSyncedPropertyId(String syncedPropertyId) { 27 | this.syncedPropertyId = syncedPropertyId; 28 | return this; 29 | } 30 | } 31 | 32 | @Override 33 | public RelationTypeEnum getType() { 34 | return type; 35 | } 36 | 37 | public DualPropertyRelation setType(RelationTypeEnum type) { 38 | this.type = type; 39 | return this; 40 | } 41 | 42 | public DualProperty getDualProperty() { 43 | return dualProperty; 44 | } 45 | 46 | public DualPropertyRelation setDualProperty(DualProperty dualProperty) { 47 | this.dualProperty = dualProperty; 48 | return this; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/database/relation/SinglePropertyRelation.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database.relation; 2 | 3 | import com._2lazy2name.notion.enumeration.type.RelationTypeEnum; 4 | import com._2lazy2name.notion.serializer.NullToEmptyObjectSerializer; 5 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 6 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 7 | 8 | @JsonIgnoreProperties(ignoreUnknown = true) 9 | public class SinglePropertyRelation extends AbstractRelation { 10 | private RelationTypeEnum type = RelationTypeEnum.SINGLE_PROPERTY; 11 | @JsonSerialize(nullsUsing = NullToEmptyObjectSerializer.class) 12 | private final Object singleProperty = null; 13 | 14 | @Override 15 | public RelationTypeEnum getType() { 16 | return type; 17 | } 18 | 19 | public SinglePropertyRelation setType(RelationTypeEnum type) { 20 | this.type = type; 21 | return this; 22 | } 23 | 24 | private Object getSingleProperty() { 25 | return null; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/page/AbstractPagePropertyValue.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.page; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.property.AbstractProperty; 5 | import com.fasterxml.jackson.annotation.*; 6 | 7 | /*** 8 | * @author Yi 9 | * @since 1.0 10 | * @version 1.0 11 | * @see Page Property Value 12 | */ 13 | @JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION, property = "type") 14 | @JsonSubTypes({ 15 | @JsonSubTypes.Type(value = CheckboxValue.class, name = "checkbox"), 16 | @JsonSubTypes.Type(value = CreatedByValue.class, name = "created_by"), 17 | @JsonSubTypes.Type(value = CreatedTimeValue.class, name = "created_time"), 18 | @JsonSubTypes.Type(value = DateValue.class, name = "date"), 19 | @JsonSubTypes.Type(value = EmailValue.class, name = "email"), 20 | @JsonSubTypes.Type(value = FilesValue.class, name = "files"), 21 | @JsonSubTypes.Type(value = FormulaValue.class, name = "formula"), 22 | @JsonSubTypes.Type(value = LastEditedByValue.class, name = "last_edited_by"), 23 | @JsonSubTypes.Type(value = LastEditedTimeValue.class, name = "last_edited_time"), 24 | @JsonSubTypes.Type(value = MultiselectValue.class, name = "multi_select"), 25 | @JsonSubTypes.Type(value = NumberValue.class, name = "number"), 26 | @JsonSubTypes.Type(value = PeopleValue.class, name = "people"), 27 | @JsonSubTypes.Type(value = PhoneNumberValue.class, name = "phone_number"), 28 | @JsonSubTypes.Type(value = RelationValue.class, name = "relation"), 29 | @JsonSubTypes.Type(value = RichTextValue.class, name = "rich_text"), 30 | @JsonSubTypes.Type(value = RollupValue.class, name = "rollup"), 31 | @JsonSubTypes.Type(value = SelectValue.class, name = "select"), 32 | @JsonSubTypes.Type(value = StatusValue.class, name = "status"), 33 | @JsonSubTypes.Type(value = TitleValue.class, name = "title"), 34 | @JsonSubTypes.Type(value = UrlValue.class, name = "url") 35 | }) 36 | @JsonInclude(JsonInclude.Include.NON_NULL) 37 | @JsonIgnoreProperties(ignoreUnknown = true) 38 | public class AbstractPagePropertyValue extends AbstractProperty { 39 | private String id; 40 | protected PropertyTypeEnum type; 41 | 42 | @Override 43 | public String getId() { 44 | return id; 45 | } 46 | 47 | public AbstractPagePropertyValue setId(String id) { 48 | this.id = id; 49 | return this; 50 | } 51 | 52 | @Override 53 | public PropertyTypeEnum getType() { 54 | return type; 55 | } 56 | 57 | public AbstractPagePropertyValue setType(PropertyTypeEnum type) { 58 | this.type = type; 59 | return this; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/page/CheckboxValue.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.page; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | 5 | /** 6 | * @author Yi 7 | * @since 1.0 8 | * @version 1.0 9 | * @see Checkbox 10 | */ 11 | 12 | public class CheckboxValue extends AbstractPagePropertyValue { 13 | private final PropertyTypeEnum type = PropertyTypeEnum.CHECKBOX; 14 | private Boolean checkbox; 15 | 16 | private CheckboxValue() { 17 | } 18 | 19 | public CheckboxValue(Boolean checkbox) { 20 | this.checkbox = checkbox; 21 | } 22 | 23 | public Boolean toggle() { 24 | this.checkbox = !this.checkbox; 25 | return this.checkbox; 26 | } 27 | 28 | @Override 29 | public PropertyTypeEnum getType() { 30 | return type; 31 | } 32 | 33 | public Boolean getCheckbox() { 34 | return checkbox; 35 | } 36 | 37 | public CheckboxValue setCheckbox(Boolean checkbox) { 38 | this.checkbox = checkbox; 39 | return this; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/page/CreatedByValue.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.page; 2 | 3 | import com._2lazy2name.notion.entity.User; 4 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 5 | 6 | 7 | /** 8 | * This object cannot be updated. 9 | * @author Yi 10 | * @since 1.0 11 | * @version 1.0 12 | * @see Created By 13 | */ 14 | public class CreatedByValue extends AbstractPagePropertyValue { 15 | private final PropertyTypeEnum type = PropertyTypeEnum.CREATED_BY; 16 | private User createdBy; 17 | 18 | private CreatedByValue() { 19 | } 20 | 21 | @Override 22 | public PropertyTypeEnum getType() { 23 | return type; 24 | } 25 | 26 | public User getCreatedBy() { 27 | return createdBy; 28 | } 29 | 30 | public CreatedByValue setCreatedBy(User createdBy) { 31 | this.createdBy = createdBy; 32 | return this; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/page/CreatedTimeValue.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.page; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * This object cannot be updated. 9 | * @author Yi 10 | * @since 1.0 11 | * @version 1.0 12 | * @see Created Time 13 | */ 14 | 15 | public class CreatedTimeValue extends AbstractPagePropertyValue { 16 | private final PropertyTypeEnum type = PropertyTypeEnum.CREATED_TIME; 17 | private Date createdTime; 18 | 19 | private CreatedTimeValue() { 20 | } 21 | 22 | @Override 23 | public PropertyTypeEnum getType() { 24 | return type; 25 | } 26 | 27 | public Date getCreatedTime() { 28 | return createdTime; 29 | } 30 | 31 | public CreatedTimeValue setCreatedTime(Date createdTime) { 32 | this.createdTime = createdTime; 33 | return this; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/page/DateValue.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.page; 2 | 3 | import com._2lazy2name.notion.entity.common.Date; 4 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 5 | /** 6 | * @author Yi 7 | * @since 1.0 8 | * @version 1.0 9 | * @see Date 10 | */ 11 | public class DateValue extends AbstractPagePropertyValue { 12 | private final PropertyTypeEnum type = PropertyTypeEnum.DATE; 13 | private Date date; 14 | 15 | private DateValue() { 16 | } 17 | 18 | public DateValue(Date date) { 19 | this.date = date; 20 | } 21 | 22 | public DateValue(java.util.Date date) { 23 | this.date = new Date(date); 24 | } 25 | 26 | @Override 27 | public PropertyTypeEnum getType() { 28 | return type; 29 | } 30 | 31 | public Date getDate() { 32 | return date; 33 | } 34 | 35 | public DateValue setDate(Date date) { 36 | this.date = date; 37 | return this; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/page/EmailValue.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.page; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | 5 | /** 6 | * @author Yi 7 | * @since 1.0 8 | * @version 1.0 9 | * @see Email 10 | */ 11 | public class EmailValue extends AbstractPagePropertyValue { 12 | private final PropertyTypeEnum type = PropertyTypeEnum.EMAIL; 13 | private String email; 14 | 15 | private EmailValue() { 16 | } 17 | 18 | public EmailValue(String email) { 19 | this.email = email; 20 | } 21 | 22 | @Override 23 | public PropertyTypeEnum getType() { 24 | return type; 25 | } 26 | 27 | public String getEmail() { 28 | return email; 29 | } 30 | 31 | public EmailValue setEmail(String email) { 32 | this.email = email; 33 | return this; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/page/FilesValue.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.page; 2 | 3 | import com._2lazy2name.notion.entity.common.file.AbstractFile; 4 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 5 | import com.fasterxml.jackson.annotation.JsonFormat; 6 | 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author Yi 12 | * @since 1.0 13 | * @version 1.0 14 | * @see Files 15 | */ 16 | public class FilesValue extends AbstractPagePropertyValue { 17 | private final PropertyTypeEnum type = PropertyTypeEnum.FILES; 18 | @JsonFormat(shape = JsonFormat.Shape.OBJECT, with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY) 19 | private List files; 20 | 21 | private FilesValue() { 22 | } 23 | 24 | public FilesValue(List files) { 25 | this.files = files; 26 | } 27 | 28 | @Override 29 | public PropertyTypeEnum getType() { 30 | return type; 31 | } 32 | 33 | public List getFiles() { 34 | return files; 35 | } 36 | 37 | public FilesValue setFiles(List files) { 38 | this.files = files; 39 | return this; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/page/LastEditedByValue.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.page; 2 | 3 | import com._2lazy2name.notion.entity.User; 4 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 5 | 6 | 7 | /** 8 | * This object cannot be updated. 9 | * @author Yi 10 | * @since 1.0 11 | * @version 1.0 12 | * @see Last Edited By 13 | */ 14 | public class LastEditedByValue extends AbstractPagePropertyValue { 15 | private final PropertyTypeEnum type = PropertyTypeEnum.LAST_EDITED_BY; 16 | private User lastEditedBy; 17 | 18 | @Override 19 | public PropertyTypeEnum getType() { 20 | return type; 21 | } 22 | 23 | public User getLastEditedBy() { 24 | return lastEditedBy; 25 | } 26 | 27 | public LastEditedByValue setLastEditedBy(User lastEditedBy) { 28 | this.lastEditedBy = lastEditedBy; 29 | return this; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/page/LastEditedTimeValue.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.page; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * This object cannot be updated. 9 | * @author Yi 10 | * @since 1.0 11 | * @version 1.0 12 | * @see Last Edited Time 13 | */ 14 | public class LastEditedTimeValue extends AbstractPagePropertyValue { 15 | private final PropertyTypeEnum type = PropertyTypeEnum.LAST_EDITED_TIME; 16 | private Date lastEditedTime; 17 | 18 | @Override 19 | public PropertyTypeEnum getType() { 20 | return type; 21 | } 22 | 23 | public Date getLastEditedTime() { 24 | return lastEditedTime; 25 | } 26 | 27 | public LastEditedTimeValue setLastEditedTime(Date lastEditedTime) { 28 | this.lastEditedTime = lastEditedTime; 29 | return this; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/page/MultiselectValue.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.page; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.property.database.SelectOption; 5 | 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * I strongly recommend you to directly use the result of Database Retrieve as the parameter of this class. 11 | * Attempt to create SelectOption is not a wise choice. 12 | * @author Yi 13 | * @since 1.0 14 | * @version 1.0 15 | * @see Multi-select 16 | */ 17 | public class MultiselectValue extends AbstractPagePropertyValue { 18 | private final PropertyTypeEnum type = PropertyTypeEnum.MULTI_SELECT; 19 | private List multiSelect; 20 | 21 | private MultiselectValue() { 22 | } 23 | 24 | public MultiselectValue(List multiSelect) { 25 | this.multiSelect = multiSelect; 26 | } 27 | 28 | public MultiselectValue(SelectOption multiSelect) { 29 | this.multiSelect = List.of(multiSelect); 30 | } 31 | 32 | @Override 33 | public PropertyTypeEnum getType() { 34 | return type; 35 | } 36 | 37 | public List getMultiSelect() { 38 | return multiSelect; 39 | } 40 | 41 | public MultiselectValue setMultiSelect(List multiSelect) { 42 | this.multiSelect = multiSelect; 43 | return this; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/page/NumberValue.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.page; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | 5 | /** 6 | * @author Yi 7 | * @since 1.0 8 | * @version 1.0 9 | * @see Number 10 | */ 11 | public class NumberValue extends AbstractPagePropertyValue { 12 | private final PropertyTypeEnum type = PropertyTypeEnum.NUMBER; 13 | private Double number; 14 | 15 | private NumberValue() { 16 | } 17 | 18 | public NumberValue(Double number) { 19 | this.number = number; 20 | } 21 | 22 | public NumberValue(Integer number) { 23 | this.number = number.doubleValue(); 24 | } 25 | 26 | @Override 27 | public PropertyTypeEnum getType() { 28 | return type; 29 | } 30 | 31 | public Double getNumber() { 32 | return number; 33 | } 34 | 35 | public NumberValue setNumber(Double number) { 36 | this.number = number; 37 | return this; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/page/PeopleValue.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.page; 2 | 3 | import com._2lazy2name.notion.entity.User; 4 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 5 | import com.fasterxml.jackson.annotation.JsonFormat; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author Yi 11 | * @since 1.0 12 | * @version 1.0 13 | * @see People 14 | */ 15 | public class PeopleValue extends AbstractPagePropertyValue { 16 | private final PropertyTypeEnum type = PropertyTypeEnum.PEOPLE; 17 | @JsonFormat(shape = JsonFormat.Shape.OBJECT, with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY) 18 | private List people; 19 | 20 | private PeopleValue() { 21 | } 22 | 23 | public PeopleValue(List people) { 24 | this.people = people; 25 | } 26 | 27 | @Override 28 | public PropertyTypeEnum getType() { 29 | return type; 30 | } 31 | 32 | public List getPeople() { 33 | return people; 34 | } 35 | 36 | public PeopleValue setPeople(List people) { 37 | this.people = people; 38 | return this; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/page/PhoneNumberValue.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.page; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | 5 | /** 6 | * @author Yi 7 | * @since 1.0 8 | * @version 1.0 9 | * @see Phone Number 10 | */ 11 | public class PhoneNumberValue extends AbstractPagePropertyValue { 12 | private final PropertyTypeEnum type = PropertyTypeEnum.PHONE_NUMBER; 13 | private String phoneNumber; 14 | 15 | private PhoneNumberValue() { 16 | } 17 | 18 | public PhoneNumberValue(String phoneNumber) { 19 | this.phoneNumber = phoneNumber; 20 | } 21 | 22 | @Override 23 | public PropertyTypeEnum getType() { 24 | return type; 25 | } 26 | 27 | public String getPhoneNumber() { 28 | return phoneNumber; 29 | } 30 | 31 | public PhoneNumberValue setPhoneNumber(String phoneNumber) { 32 | this.phoneNumber = phoneNumber; 33 | return this; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/page/RichTextValue.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.page; 2 | 3 | import com._2lazy2name.notion.entity.common.richText.AbstractRichText; 4 | import com._2lazy2name.notion.entity.common.richText.TextText; 5 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 6 | import com.fasterxml.jackson.annotation.JsonFormat; 7 | 8 | 9 | import java.util.List; 10 | 11 | /*** 12 | * @author Yi 13 | * @since 1.0 14 | * @version 1.0 15 | * @see Rich Text 16 | */ 17 | public class RichTextValue extends AbstractPagePropertyValue { 18 | private final PropertyTypeEnum type = PropertyTypeEnum.RICH_TEXT; 19 | @JsonFormat(shape = JsonFormat.Shape.OBJECT, with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY) 20 | private List richText; 21 | 22 | private RichTextValue() { 23 | } 24 | 25 | public RichTextValue(List richText) { 26 | this.richText = richText; 27 | } 28 | 29 | public RichTextValue(AbstractRichText richText) { 30 | this.richText = List.of(richText); 31 | } 32 | 33 | public RichTextValue(String text) { 34 | this.richText = List.of(new TextText(text)); 35 | } 36 | 37 | @Override 38 | public PropertyTypeEnum getType() { 39 | return type; 40 | } 41 | 42 | public List getRichText() { 43 | return richText; 44 | } 45 | 46 | public RichTextValue setRichText(List richText) { 47 | this.richText = richText; 48 | return this; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/page/SelectValue.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.page; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.property.database.SelectOption; 5 | 6 | /** 7 | * @author Yi 8 | * @since 1.0 9 | * @version 1.0 10 | * @see Select 11 | */ 12 | public class SelectValue extends AbstractPagePropertyValue { 13 | private final PropertyTypeEnum type = PropertyTypeEnum.SELECT; 14 | private SelectOption select; 15 | 16 | private SelectValue() { 17 | } 18 | 19 | public SelectValue(SelectOption select) { 20 | this.select = select; 21 | } 22 | 23 | @Override 24 | public PropertyTypeEnum getType() { 25 | return type; 26 | } 27 | 28 | public SelectOption getSelect() { 29 | return select; 30 | } 31 | 32 | public SelectValue setSelect(SelectOption select) { 33 | this.select = select; 34 | return this; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/page/StatusValue.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.page; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | import com._2lazy2name.notion.property.database.SelectOption; 5 | 6 | /*** 7 | * @author Yi 8 | * @since 1.0 9 | * @version 1.0 10 | * @see Status 11 | */ 12 | public class StatusValue extends AbstractPagePropertyValue { 13 | private final PropertyTypeEnum type = PropertyTypeEnum.STATUS; 14 | private SelectOption status; 15 | 16 | private StatusValue() { 17 | } 18 | 19 | public StatusValue(SelectOption status) { 20 | this.status = status; 21 | } 22 | 23 | @Override 24 | public PropertyTypeEnum getType() { 25 | return type; 26 | } 27 | 28 | public SelectOption getStatus() { 29 | return status; 30 | } 31 | 32 | public StatusValue setStatus(SelectOption status) { 33 | this.status = status; 34 | return this; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/page/TitleValue.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.page; 2 | 3 | import com._2lazy2name.notion.entity.common.richText.AbstractRichText; 4 | import com._2lazy2name.notion.entity.common.richText.TextText; 5 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 6 | import com.fasterxml.jackson.annotation.JsonFormat; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author Yi 12 | * @since 1.0 13 | * @version 1.0 14 | * @see Title 15 | */ 16 | public class TitleValue extends AbstractPagePropertyValue { 17 | private final PropertyTypeEnum type = PropertyTypeEnum.TITLE; 18 | @JsonFormat(shape = JsonFormat.Shape.OBJECT, with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY) 19 | private List title; 20 | 21 | private TitleValue() { 22 | } 23 | 24 | public TitleValue(List title) { 25 | this.title = title; 26 | } 27 | 28 | public TitleValue(String title) { 29 | this.title = List.of(new TextText(title)); 30 | } 31 | 32 | public TitleValue(AbstractRichText title) { 33 | this.title = List.of(title); 34 | } 35 | 36 | @Override 37 | public PropertyTypeEnum getType() { 38 | return type; 39 | } 40 | 41 | public List getTitle() { 42 | return title; 43 | } 44 | 45 | public TitleValue setTitle(List title) { 46 | this.title = title; 47 | return this; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/property/page/UrlValue.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.page; 2 | 3 | import com._2lazy2name.notion.enumeration.type.PropertyTypeEnum; 4 | 5 | 6 | /*** 7 | * @author Yi 8 | * @since 1.0 9 | * @version 1.0 10 | * @see URL 11 | */ 12 | 13 | public class UrlValue extends AbstractPagePropertyValue { 14 | private final PropertyTypeEnum type = PropertyTypeEnum.URL; 15 | private String url; 16 | 17 | private UrlValue() { 18 | } 19 | 20 | public UrlValue(String url) { 21 | this.url = url; 22 | } 23 | 24 | @Override 25 | public PropertyTypeEnum getType() { 26 | return type; 27 | } 28 | 29 | public String getUrl() { 30 | return url; 31 | } 32 | 33 | public UrlValue setUrl(String url) { 34 | this.url = url; 35 | return this; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/notion/serializer/NullToEmptyObjectSerializer.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.serializer; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | 7 | import java.io.IOException; 8 | 9 | public class NullToEmptyObjectSerializer extends JsonSerializer { 10 | @Override 11 | public void serialize(Object value, JsonGenerator gen, SerializerProvider serializers) throws IOException { 12 | gen.writeStartObject(); 13 | gen.writeEndObject(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/util/NotionHttpUtil.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.util; 2 | 3 | import com._2lazy2name.notion.exception.NotionException; 4 | import com.fasterxml.jackson.core.JsonProcessingException; 5 | import com.fasterxml.jackson.databind.ObjectMapper; 6 | 7 | public class NotionHttpUtil extends HttpUtil { 8 | private static final ObjectMapper objectMapper = new ObjectMapper(); 9 | 10 | @Override 11 | public void checkAndWrapHttpError(Response response) { 12 | { 13 | if (!(response.getStatusCode() >= 400)) { 14 | return; 15 | } 16 | String message = response.getBody(); 17 | try { 18 | throw objectMapper.readValue(message, NotionException.class); 19 | } catch (JsonProcessingException e) { 20 | throw new RuntimeException(e); 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/_2lazy2name/util/StringUtil.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.util; 2 | 3 | public class StringUtil { 4 | public static boolean isNullOrEmpty(String str) { 5 | return str == null || str.isEmpty() || str.isBlank(); 6 | } 7 | 8 | public static boolean isUUID(String str) { 9 | if (str == null) { 10 | return false; 11 | } 12 | str = str.replace("-", ""); 13 | if (str.length() != 32) { 14 | return false; 15 | } 16 | return str.matches("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/test/java/com/_2lazy2name/notion/NotionBlockTest.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | public class NotionBlockTest extends NotionTest { 6 | @Test 7 | void testAppendBlockChildren() { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/test/java/com/_2lazy2name/notion/NotionTest.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 6 | import org.junit.jupiter.api.AfterAll; 7 | 8 | import java.io.IOException; 9 | import java.text.SimpleDateFormat; 10 | import java.util.ArrayList; 11 | import java.util.Date; 12 | import java.util.Objects; 13 | import java.util.Properties; 14 | 15 | public class NotionTest { 16 | public static final ObjectMapper objectMapper; 17 | protected final static Notion notion ; 18 | protected static final ArrayList createdBlock = new ArrayList<>(); 19 | protected static final boolean AUTO_DELETE = true; 20 | protected final static int SLEEP_TIME = 2000; 21 | 22 | 23 | static { 24 | objectMapper = new ObjectMapper(); 25 | objectMapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE); 26 | objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")); 27 | Properties properties = new Properties(); 28 | try { 29 | properties.load(NotionTest.class.getClassLoader().getResourceAsStream("test.properties")); 30 | } catch (IOException e) { 31 | throw new RuntimeException(e); 32 | } 33 | String token = properties.getProperty("token"); 34 | notion = new Notion(token); 35 | } 36 | 37 | @AfterAll 38 | public static void deleteAll() throws InterruptedException, IOException { 39 | Thread.sleep(SLEEP_TIME); 40 | if (AUTO_DELETE) { 41 | for (String s : createdBlock) { 42 | if (s != null) { 43 | notion.deleteBlock(s); 44 | } 45 | } 46 | } 47 | createdBlock.clear(); 48 | } 49 | 50 | // Compare two Json is equals without order 51 | public static boolean isEquals(String json1, String json2) { 52 | try { 53 | Object obj1 = objectMapper.readValue(json1, Object.class); 54 | Object obj2 = objectMapper.readValue(json2, Object.class); 55 | return Objects.equals(obj1, obj2); 56 | } catch (JsonProcessingException e) { 57 | return false; 58 | } 59 | } 60 | 61 | public static Date formatDate(String date) { 62 | try { 63 | return objectMapper.getDateFormat().parse(date); 64 | } catch (Exception e) { 65 | throw new RuntimeException(e); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/test/java/com/_2lazy2name/notion/entity/block/BookmarkTest.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.NotionTest; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import java.io.IOException; 7 | 8 | class BookmarkTest extends NotionTest { 9 | private final String testPageId = "63e4778008934c61b3f0cf6c07fe7c3e"; 10 | private final static int SLEEP_TIME = 1000; 11 | 12 | @Test 13 | public void testCreate() throws IOException { 14 | BookmarkBlock bookmark = new BookmarkBlock.Builder() 15 | .url("https://www.google.com") 16 | .caption("Google") 17 | .build(); 18 | createdBlock.add(notion.appendBlockChild(testPageId, bookmark).getResult().getId()); 19 | } 20 | 21 | @Test 22 | public void testUpdate() throws IOException { 23 | BookmarkBlock bookmark = new BookmarkBlock.Builder() 24 | .url("https://www.google.com") 25 | .caption("Google") 26 | .build(); 27 | String id = notion.appendBlockChild(testPageId, bookmark).getResult().getId(); 28 | createdBlock.add(id); 29 | notion.updateBlock(id, bookmark.setUrl("https://www.bing.com").setCaption("Bing")); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/com/_2lazy2name/notion/entity/block/BreadcrumbTest.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.NotionTest; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import java.io.IOException; 7 | 8 | class BreadcrumbTest extends NotionTest { 9 | private final String testPageId = "f0dd27733f7d4f3bac21efb6f53a1326"; 10 | 11 | @Test 12 | public void testCreate() throws IOException { 13 | BreadcrumbBlock breadcrumb = BreadcrumbBlock.getInstance(); 14 | createdBlock.add(notion.appendBlockChild(testPageId, breadcrumb).getResult().getId()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/com/_2lazy2name/notion/entity/block/CalloutTest.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.NotionTest; 4 | import com._2lazy2name.notion.enumeration.ColorEnum; 5 | import org.junit.jupiter.api.Test; 6 | 7 | import java.io.IOException; 8 | 9 | class CalloutTest extends NotionTest { 10 | private final String testPageId = "66e8a3fbdedf4f13912efbc0eafa10fe"; 11 | 12 | @Test 13 | public void testCreate() throws IOException { 14 | CalloutBlock calloutBlock = new CalloutBlock.Builder() 15 | .richText("Test") 16 | .color(ColorEnum.RED) 17 | .build(); 18 | createdBlock.add(notion.appendBlockChild(testPageId, calloutBlock).getResult().getId()); 19 | } 20 | 21 | @Test 22 | public void testUpdate() throws IOException { 23 | CalloutBlock calloutBlock = new CalloutBlock.Builder() 24 | .richText("Test") 25 | .color(ColorEnum.RED) 26 | .build(); 27 | String id = notion.appendBlockChild(testPageId, calloutBlock).getResult().getId(); 28 | createdBlock.add(id); 29 | notion.updateBlock(id, calloutBlock.setRichText("Test2").setColor(ColorEnum.getRandomColorBackground())); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/com/_2lazy2name/notion/entity/block/CodeTest.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.NotionTest; 4 | import com._2lazy2name.notion.enumeration.LanguageEnum; 5 | import org.junit.jupiter.api.Test; 6 | 7 | import java.io.IOException; 8 | 9 | class CodeTest extends NotionTest { 10 | private final String testPageId = "fa26bc15ba0b4e2eac73ff6db7fda283"; 11 | 12 | @Test 13 | public void testCreate() throws IOException { 14 | CodeBlock codeBlock = new CodeBlock.Builder() 15 | .language(LanguageEnum.JAVA) 16 | .caption("This is a caption") 17 | .richText("This is a text") 18 | .build(); 19 | createdBlock.add(notion.appendBlockChild(testPageId, codeBlock).getResult().getId()); 20 | } 21 | 22 | @Test 23 | public void testUpdate() throws IOException { 24 | CodeBlock codeBlock = new CodeBlock.Builder() 25 | .language(LanguageEnum.JAVA) 26 | .caption("This is a caption") 27 | .richText("This is a text") 28 | .build(); 29 | String id = notion.appendBlockChild(testPageId, codeBlock).getResult().getId(); 30 | createdBlock.add(id); 31 | notion.updateBlock(id, codeBlock.setRichText("System.out.println(\"Hello World!\");")); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/com/_2lazy2name/notion/entity/block/ColumnListTest.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.NotionTest; 4 | import com._2lazy2name.notion.entity.block.heading.HeadingOneBlock; 5 | import org.junit.jupiter.api.Test; 6 | 7 | import java.io.IOException; 8 | 9 | public class ColumnListTest extends NotionTest { 10 | private final String testPageId = "6588177ff34448fca47de8fffe8851fd"; 11 | 12 | @Test 13 | public void testCreate() throws IOException { 14 | ColumnBlock columnBlock = new ColumnBlock( 15 | new HeadingOneBlock.Builder().richText("This is a text").build(), 16 | new HeadingOneBlock.Builder().richText("This is a text").build(), 17 | new HeadingOneBlock.Builder().richText("This is a text").build() 18 | ); 19 | ColumnListBlock columnListBlock = new ColumnListBlock(columnBlock, columnBlock); 20 | createdBlock.add(notion.appendBlockChild(testPageId, columnListBlock).getResult().getId()); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/_2lazy2name/notion/entity/block/DividerTest.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.NotionTest; 4 | import org.junit.jupiter.api.Disabled; 5 | import org.junit.jupiter.api.Test; 6 | 7 | import java.io.IOException; 8 | 9 | @Disabled 10 | public class DividerTest extends NotionTest { 11 | private final String testPageId = "325ba04e40d345d390a7f02b835a196c"; 12 | 13 | @Test 14 | public void testCreate() throws IOException { 15 | DividerBlock dividerBlock = DividerBlock.getInstance(); 16 | createdBlock.add(notion.appendBlockChild(testPageId, dividerBlock).getResult().getId()); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/com/_2lazy2name/notion/entity/block/EmbedTest.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.NotionTest; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import java.io.IOException; 7 | 8 | public class EmbedTest extends NotionTest { 9 | private final String testPageId = "668627061669445daa11d8a933f86de1"; 10 | 11 | @Test 12 | public void testCreate() throws IOException { 13 | EmbedBlock embedBlock = new EmbedBlock("google.com"); 14 | createdBlock.add(notion.appendBlockChild(testPageId, embedBlock).getResult().getId()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/com/_2lazy2name/notion/entity/block/EquationTest.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.NotionTest; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import java.io.IOException; 7 | 8 | class EquationTest extends NotionTest { 9 | private final String testPageId = "3b6a43673a004b1dba99adbeb2728c63"; 10 | 11 | @Test 12 | public void testCreate() throws IOException { 13 | EquationBlock equationBlock = new EquationBlock("2+2"); 14 | createdBlock.add(notion.appendBlockChild(testPageId, equationBlock).getResult().getId()); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/com/_2lazy2name/notion/entity/block/FileTest.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.NotionTest; 4 | import com._2lazy2name.notion.entity.block.fileRelated.FileBlock; 5 | import com._2lazy2name.notion.entity.block.fileRelated.ImageBlock; 6 | import com._2lazy2name.notion.entity.block.fileRelated.PdfBlock; 7 | import com._2lazy2name.notion.entity.block.fileRelated.VideoBlock; 8 | import com._2lazy2name.notion.entity.common.file.AbstractFile; 9 | import com._2lazy2name.notion.entity.common.file.ExternalFile; 10 | import com._2lazy2name.notion.entity.common.richText.TextText; 11 | import org.junit.jupiter.api.Test; 12 | 13 | import java.io.IOException; 14 | import java.util.List; 15 | 16 | class FileTest extends NotionTest { 17 | private final String testPageId = "a7f112c726c9459cbade461e625bad6b"; 18 | 19 | @Test 20 | public void testCreateFileBlock() throws IOException { 21 | AbstractFile file = new ExternalFile(List.of(new TextText("test")), "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"); 22 | FileBlock fileBlock = new FileBlock(file); 23 | createdBlock.add(notion.appendBlockChild(testPageId, fileBlock).getResult().getId()); 24 | } 25 | 26 | @Test 27 | public void testCreateImageBlock() throws IOException { 28 | AbstractFile file = new ExternalFile(List.of(new TextText("test")), "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"); 29 | ImageBlock fileBlock = new ImageBlock(file); 30 | createdBlock.add(notion.appendBlockChild(testPageId, fileBlock).getResult().getId()); 31 | } 32 | 33 | @Test 34 | public void testCreatePdfBlock() throws IOException { 35 | AbstractFile file = new ExternalFile("https://www.phocos.com/wp-content/uploads/2021/05/Any-Bridge_chinese-datasheet_2022-08-26.pdf"); 36 | PdfBlock fileBlock = new PdfBlock(file); 37 | createdBlock.add(notion.appendBlockChild(testPageId, fileBlock).getResult().getId()); 38 | } 39 | 40 | @Test 41 | public void testCreateVideoBlock() throws IOException { 42 | AbstractFile file = new ExternalFile("https://a.com/0.mp4"); 43 | VideoBlock fileBlock = new VideoBlock(file); 44 | createdBlock.add(notion.appendBlockChild(testPageId, fileBlock).getResult().getId()); 45 | } 46 | 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/com/_2lazy2name/notion/entity/block/LinkToPageTest.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.block; 2 | 3 | import com._2lazy2name.notion.NotionTest; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import java.io.IOException; 7 | 8 | public class LinkToPageTest extends NotionTest { 9 | private final String testPageId = "d9581058bf214821822ae1c07c193198"; 10 | 11 | @Test 12 | public void testCreate() throws IOException { 13 | LinkToPageBlock linkToPageBlock = LinkToPageBlock.toPage(testPageId); 14 | createdBlock.add(notion.appendBlockChild(testPageId, linkToPageBlock).getResult().getId()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/com/_2lazy2name/notion/entity/common/file/AbstractFileTest.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.file; 2 | 3 | import com._2lazy2name.notion.NotionTest; 4 | import com.fasterxml.jackson.core.JsonProcessingException; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.Test; 7 | 8 | class AbstractFileTest extends NotionTest { 9 | 10 | private final String externalFileJson = """ 11 | { 12 | "type": "external", 13 | "external": { 14 | "url": "https://images.unsplash.com/photo-1525310072745-f49212b5ac6d?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1065&q=80" 15 | } 16 | } 17 | """; 18 | private final String externalFileUrl = "https://images.unsplash.com/photo-1525310072745-f49212b5ac6d?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1065&q=80"; 19 | 20 | private final String notionHostedFileJson = """ 21 | { 22 | "type": "file", 23 | "file": { 24 | "url": "https://s3.us-west-2.amazonaws.com/secure.notion-static.com/7b8b0713-dbd4-4962-b38b-955b6c49a573/My_test_image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45EIPT3X45%2F20221024%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20221024T205211Z&X-Amz-Expires=3600&X-Amz-Signature=208aa971577ff05e75e68354e8a9488697288ff3fb3879c2d599433a7625bf90&X-Amz-SignedHeaders=host&x-id=GetObject", 25 | "expiry_time": "2022-10-24T22:49:22.765Z" 26 | } 27 | } 28 | """; 29 | 30 | private final String notionHostedFileUrl = "https://s3.us-west-2.amazonaws.com/secure.notion-static.com/7b8b0713-dbd4-4962-b38b-955b6c49a573/My_test_image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45EIPT3X45%2F20221024%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20221024T205211Z&X-Amz-Expires=3600&X-Amz-Signature=208aa971577ff05e75e68354e8a9488697288ff3fb3879c2d599433a7625bf90&X-Amz-SignedHeaders=host&x-id=GetObject"; 31 | private final String notionHostedFileExpiryTime = "2022-10-24T22:49:22.765Z"; 32 | 33 | @Test 34 | public void testExternalFile() throws JsonProcessingException { 35 | AbstractFile file = new ExternalFile(externalFileUrl); 36 | Assertions.assertTrue(isEquals(objectMapper.writeValueAsString(file), externalFileJson)); 37 | } 38 | 39 | @Test 40 | public void testNotionHostedFile() throws JsonProcessingException { 41 | NotionHostedFile file = objectMapper.readValue(notionHostedFileJson, NotionHostedFile.class); 42 | Assertions.assertEquals(notionHostedFileUrl, file.getUrl()); 43 | Assertions.assertEquals(formatDate(notionHostedFileExpiryTime), file.getExpiryTime()); 44 | } 45 | 46 | 47 | 48 | } -------------------------------------------------------------------------------- /src/test/java/com/_2lazy2name/notion/entity/common/sort/PropertyValueSortTest.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.entity.common.sort; 2 | 3 | import com._2lazy2name.notion.NotionTest; 4 | import com._2lazy2name.notion.enumeration.SortDirectionEnum; 5 | import com.fasterxml.jackson.core.JsonProcessingException; 6 | 7 | import static org.junit.jupiter.api.Assertions.*; 8 | 9 | class PropertyValueSortTest extends NotionTest { 10 | 11 | @org.junit.jupiter.api.Test 12 | void getProperty() throws JsonProcessingException { 13 | PropertyValueSort sort = AbstractSort.buildPropertyValueSort("Created time", SortDirectionEnum.DESCENDING); 14 | String s = objectMapper.writeValueAsString(sort); 15 | System.out.println(s); 16 | 17 | } 18 | 19 | @org.junit.jupiter.api.Test 20 | void setProperty() { 21 | } 22 | } -------------------------------------------------------------------------------- /src/test/java/com/_2lazy2name/notion/exception/ExceptionTest.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.exception; 2 | 3 | import com._2lazy2name.notion.NotionTest; 4 | import com._2lazy2name.notion.entity.block.DividerBlock; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.Test; 7 | 8 | public class ExceptionTest extends NotionTest { 9 | 10 | @Test 11 | public void testExceptionCreation() { 12 | Assertions.assertThrows(NotionException.class, () -> notion.appendBlockChild("asda", DividerBlock.getInstance())); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/com/_2lazy2name/notion/property/database/LastEditedByConfigurationTest.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.database; 2 | 3 | import com._2lazy2name.notion.NotionTest; 4 | import com.fasterxml.jackson.core.JsonProcessingException; 5 | import org.junit.jupiter.api.Test; 6 | 7 | class LastEditedByConfigurationTest extends NotionTest { 8 | @Test 9 | public void test() throws JsonProcessingException { 10 | LastEditedByConfiguration configuration = LastEditedByConfiguration.getInstance(); 11 | System.out.println(objectMapper.writeValueAsString(configuration)); 12 | } 13 | } -------------------------------------------------------------------------------- /src/test/java/com/_2lazy2name/notion/property/page/CreatedByValueTest.java: -------------------------------------------------------------------------------- 1 | package com._2lazy2name.notion.property.page; 2 | 3 | import com._2lazy2name.notion.NotionTest; 4 | import com._2lazy2name.notion.entity.Page; 5 | import com.fasterxml.jackson.core.JsonProcessingException; 6 | import com.fasterxml.jackson.databind.ObjectMapper; 7 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 8 | import org.junit.jupiter.api.Test; 9 | 10 | import java.text.SimpleDateFormat; 11 | 12 | class CreatedByValueTest extends NotionTest { 13 | 14 | String json = """ 15 | { 16 | "object": "page", 17 | "id": "62008259-e0fa-4f45-bdd0-eb0ea3920cc5", 18 | "created_time": "2023-04-06T16:03:00.000Z", 19 | "last_edited_time": "2023-04-06T16:03:00.000Z", 20 | "created_by": { 21 | "object": "user", 22 | "id": "a943b83f-a892-4886-93c8-8391161c58c4" 23 | }, 24 | "last_edited_by": { 25 | "object": "user", 26 | "id": "a943b83f-a892-4886-93c8-8391161c58c4" 27 | }, 28 | "cover": null, 29 | "icon": null, 30 | "parent": { 31 | "type": "database_id", 32 | "database_id": "d4916ab4-f18b-488c-b780-4fea423afd85" 33 | } 34 | } 35 | """; 36 | @Test 37 | public void test() throws JsonProcessingException { 38 | ObjectMapper objectMapper = new ObjectMapper(); 39 | objectMapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE); 40 | objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")); 41 | System.out.println(objectMapper.readValue(json, Page.class)); 42 | } 43 | } -------------------------------------------------------------------------------- /src/test/resources/test.properties: -------------------------------------------------------------------------------- 1 | token=secret_T5dSWItaAp1GfpXPRnI4uNVVpxpcvWb1zo0gDbFRP3i --------------------------------------------------------------------------------