gotion

package module
v0.0.0-...-219f826 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2022 License: MIT Imports: 11 Imported by: 0

README

gotion

Not implemented at all

Strange cases

  • Can't create page under another page with parent block like this:
"parent": {
        "type": "page_id",
        "page_id": "02e0fefa-38e6-47fb-99b1-ac066ac1cd86"
    }

Need to test

  • Create page with properties: rollup, relation

Need to add

  • Page can be settled under parent with type=block. Now only database, page and workspace possible
  • Block types which support children are "paragraph", "bulleted_list_item", "numbered_list_item", "toggle", "to_do", "quote", "callout", "synced_block", "template", "column", "child_page", "child_database", and "table". - Add validation

Think about

Documentation

Index

Constants

View Source
const (
	NoBlockParentType = iota
	PageBlockParentType
	DatabaseBlockParentType
	BlockBlockParentType
)
View Source
const (
	NoBlockType = iota
	ParagraphBlockType
	H1BlockType
	H2BlockType
	H3BlockType
	BulletedListBlockType
	NumberedListBlockType
	ToDoBlockType
	ToggleBlockType
	CodeBlockType
	ChildPageBlockType
	ChildDatabaseBlockType
	EmbedBlockType
	ImageBlockType
	VideoBlockType
	FileBlockType
	PDFBlockType
	BookmarkBlockType
	CalloutBlockType
	QuoteBlockType
	EquationBlockType
	DividerBlockType
	TableOfContentsBlockType
	BreadCrumbBlockType
	ColumnBlockType
	ColumnListBlockType
	LinkPreviewBlockType
	SuncedBlockBlockType
	TemplateBlockType
	LinkToPageBlockType
	TableBlockType
	TableRowBlockType
	UnsupportedBlockType
)
View Source
const BaseUrl = "https://api.notion.com"
View Source
const V1 = "v1"

Variables

View Source
var BlockParentTypeToString = map[BlockParentType]string{
	PageBlockParentType:     "page_id",
	DatabaseBlockParentType: "database_id",
	BlockBlockParentType:    "block_id",
}
View Source
var BlockTypeToString = map[BlockType]string{
	ParagraphBlockType:       "paragraph",
	H1BlockType:              "heading_1",
	H2BlockType:              "heading_2",
	H3BlockType:              "heading_3",
	BulletedListBlockType:    "bulleted_list_item",
	NumberedListBlockType:    "numbered_list_item",
	ToDoBlockType:            "to_do",
	ToggleBlockType:          "toggle",
	CodeBlockType:            "code",
	ChildPageBlockType:       "child_page",
	ChildDatabaseBlockType:   "child_database",
	EmbedBlockType:           "embed",
	ImageBlockType:           "image",
	VideoBlockType:           "video",
	FileBlockType:            "file",
	PDFBlockType:             "pdf",
	BookmarkBlockType:        "bookmark",
	CalloutBlockType:         "callout",
	QuoteBlockType:           "quote",
	EquationBlockType:        "equation",
	DividerBlockType:         "divider",
	TableOfContentsBlockType: "table_of_contents",
	BreadCrumbBlockType:      "breadcrumb",
	ColumnBlockType:          "column",
	ColumnListBlockType:      "column_list",
	LinkPreviewBlockType:     "link_preview",
	SuncedBlockBlockType:     "synced_block",
	TemplateBlockType:        "template",
	LinkToPageBlockType:      "link_to_page",
	TableBlockType:           "table",
	TableRowBlockType:        "table_row",
	UnsupportedBlockType:     "unsupported",
}
View Source
var ColorToString = map[Color]string{
	DefaultColor:     "default",
	Gray:             "gray",
	Brown:            "brown",
	Orange:           "orange",
	Yellow:           "yellow",
	Green:            "green",
	Blue:             "blue",
	Purple:           "purple",
	Pink:             "pink",
	Red:              "red",
	GrayBackground:   "gray_background",
	BrownBackground:  "brown_background",
	OrangeBackground: "orange_background",
	YellowBackground: "yellow_background",
	GreenBackground:  "green_background",
	BlueBackground:   "blue_background",
	PurpleBackground: "purple_background",
	PinkBackground:   "pink_background",
	RedBackground:    "red_background",
}
View Source
var DBParentTypeToString = map[DBParentType]string{
	PageDBParentType:      "page_id",
	WorksapceDBParentType: "workspace",
}
View Source
var FileDescriptorTypeToString = map[FileDescriptorType]string{
	NotionFileDescriptorType:   "file",
	ExternalFileDescriptorType: "external",
}
View Source
var IconTypeToString = map[IconType]string{
	EmojiIconType:    "emoji",
	FileIconType:     "file",
	ExternalIconType: "external",
}
View Source
var LanguageToString = map[Language]string{
	ABAP:         "abap",
	Arduino:      "arduino",
	Bash:         "bash",
	Basic:        "basic",
	C:            "c",
	Clojure:      "clojure",
	CoffeeScript: "coffeescript",
	CPlusPlus:    "c++",
	CSharp:       "c#",
	CSS:          "css",
	Dart:         "dart",
	Diff:         "diff",
	Docker:       "docker",
	Elixir:       "elixir",
	Elm:          "elm",
	Erlang:       "erlang",
	Flow:         "flow",
	Fortran:      "fortran",
	FSharp:       "f#",
	Gherkin:      "gherkin",
	Glsl:         "glsl",
	Go:           "go",
	GraphQL:      "graphql",
	Groovy:       "groovy",
	Haskell:      "haskell",
	HTML:         "html",
	Java:         "java",
	JavaScript:   "javascript",
	JSON:         "json",
	Julia:        "julia",
	Kotlin:       "kotlin",
	LaTeX:        "latex",
	LESS:         "less",
	Lisp:         "lisp",
	LiveScript:   "livescript",
	Lua:          "lua",
	Makefile:     "makefile",
	Markdown:     "markdown",
	Markup:       "markup",
	Matlab:       "matlab",
	Mermaid:      "mermaid",

	ObjectiveC:  "objective-c",
	OCaml:       "ocaml",
	Pascal:      "pascal",
	Perl:        "perl",
	PHP:         "php",
	PlainText:   "plain text",
	PowerShell:  "powershell",
	Prolog:      "prolog",
	Protobuf:    "protobuf",
	Python:      "python",
	R:           "r",
	Reason:      "reason",
	Ruby:        "ruby",
	Rust:        "rust",
	SASS:        "sass",
	Scala:       "scala",
	Scheme:      "scheme",
	SCSS:        "scss",
	Shell:       "shell",
	SQL:         "sql",
	Swift:       "swift",
	TypeScript:  "typescript",
	VBNet:       "vb.net",
	Verilog:     "verilog",
	VHDL:        "vhdl",
	VisualBasic: "visual basic",
	Webassembly: "webassembly",
	XML:         "xml",
	YAML:        "yaml",
	// contains filtered or unexported fields
}
View Source
var MentionTypeToString = map[MentionType]string{
	UserMentionType:        "user",
	PageMentionType:        "page",
	DatabaseMentionType:    "database",
	DateMentionType:        "date",
	LinkPriviewMentionType: "link_preview",
}
View Source
var NumberFormatToString = map[NumberPropertyFormat]string{
	Number:           "number",
	NumberWithCommas: "number_with_commas",
	Percent:          "percent",
	Dollar:           "dollar",
	CanadianDollar:   "canadian_dollar",
	Euro:             "euro",
	Pound:            "pound",
	Yen:              "yen",
	Ruble:            "ruble",
	Rupee:            "rupee",
	Won:              "won",
	Yuan:             "yuan",
	Real:             "real",
	Lira:             "lira",
	Rupiah:           "rupiah",
	Franc:            "franc",
	HongKondDollar:   "hong_kong_dollar",
	NewZellanDollar:  "new_zealand_dollar",
	Krona:            "krona",
	NorwegianKrone:   "norwegian_krone",
	MexicanPeso:      "mexican_peso",
	Rand:             "rand",
	NewTaiwanDollar:  "new_taiwan_dollar",
	DanishKrone:      "danish_krone",
	Zloty:            "zloty",
	Baht:             "baht",
	Forint:           "forint",
	Koruna:           "koruna",
	Shekel:           "shekel",
	ChileanPeso:      "chilean_peso",
	PhilippinePeso:   "philippine_peso",
	Dirham:           "dirham",
	ColumbianPeso:    "colombian_peso",
	Riyal:            "riyal",
	Ringgit:          "ringgit",
	Leu:              "leu",
	ArgentinePeso:    "argentine_peso",
	UruguayanPeso:    "uruguayan_peso",
}
View Source
var PageParentToString = map[PageParentType]string{
	PageParentDB:        "database_id",
	PageParentWorkspace: "workspace",
	PageParentPage:      "page_id",
}
View Source
var PagePropertyFormulaTypeToString = map[PagePropertyFormulaType]string{
	StringFormulaType: "string",
	NumberFormulaType: "number",
	BoolFormulaType:   "boolean",
	DateFormuleType:   "date",
}
View Source
var PropTypeToString = map[DBPropertyType]string{
	DBPropTypeTitle:          "title",
	DBPropTypeRichText:       "rich_text",
	DBPropTypeNumber:         "number",
	DBPropTypeSelect:         "select",
	DBPropTypeMultiSelect:    "multi_select",
	DBPropTypeDate:           "date",
	DBPropTypePeople:         "people",
	DBPropTypeFiles:          "files",
	DBPropTypeCheckbox:       "checkbox",
	DBPropTypeURL:            "url",
	DBPropTypeEmail:          "email",
	DBPropTypePhoneNumber:    "phone_number",
	DBPropTypeFormula:        "formula",
	DBPropTypeRelation:       "relation",
	DBPropTypeRollup:         "rollup",
	DBPropTypeCreatedTime:    "created_time",
	DBPropTypeCreatedBy:      "created_by",
	DBPropTypeLastEditedTime: "last_edited_time",
	DBPropTypeLastEditedBy:   "last_edited_by",
}
View Source
var RichTextTypeToString = map[RichTextType]string{
	TextRichTextType:     "text",
	MentionRichTextType:  "mention",
	EquationRichTextType: "equation",
}
View Source
var RollupFunctionToString = map[RollupFunction]string{
	Count:             "count",
	CountAll:          "count_all",
	CountValues:       "count_values",
	CountUniqueValues: "count_unique_values",
	CountEmpty:        "count_empty",
	CountNotEmpty:     "count_not_empty",
	PercentEmpty:      "percent_empty",
	PercentNotEmpty:   "percent_not_empty",
	Sum:               "sum",
	Average:           "average",
	Median:            "median",
	Min:               "min",
	Max:               "max",
	Range:             "range",
	ShowOriginal:      "show_original",
	EarliestDate:      "earliest_date",
	LatestDate:        "latest_date",
	DateRange:         "date_range",
}
View Source
var RollupPropertyTypeToString = map[RollupPropertyType]string{
	NumberRollupPropertyType:      "number",
	DateRollupPropertyType:        "date",
	ArrayRollupPropertyType:       "array",
	UnsupportedRollupPropertyType: "unsupported",
	IncompleteRollupPropertyType:  "incomplete",
}
View Source
var SortDirectionToString = map[SortDirection]string{
	Ascending:  "ascending",
	Descending: "descending",
}
View Source
var StringToBlockParentType = map[string]BlockParentType{
	"page_id":     PageBlockParentType,
	"database_id": DatabaseBlockParentType,
	"block_id":    BlockBlockParentType,
}
View Source
var StringToBlockType = map[string]BlockType{
	"paragraph":          ParagraphBlockType,
	"heading_1":          H1BlockType,
	"heading_2":          H2BlockType,
	"heading_3":          H3BlockType,
	"bulleted_list_item": BulletedListBlockType,
	"numbered_list_item": NumberedListBlockType,
	"to_do":              ToDoBlockType,
	"toggle":             ToggleBlockType,
	"code":               CodeBlockType,
	"child_page":         ChildPageBlockType,
	"child_database":     ChildDatabaseBlockType,
	"embed":              EmbedBlockType,
	"image":              ImageBlockType,
	"video":              VideoBlockType,
	"file":               FileBlockType,
	"pdf":                PDFBlockType,
	"bookmark":           BookmarkBlockType,
	"callout":            CalloutBlockType,
	"quote":              QuoteBlockType,
	"equation":           EquationBlockType,
	"divider":            DividerBlockType,
	"table_of_contents":  TableOfContentsBlockType,
	"breadcrumb":         BreadCrumbBlockType,
	"column":             ColumnBlockType,
	"column_list":        ColumnListBlockType,
	"link_preview":       LinkPreviewBlockType,
	"synced_block":       SuncedBlockBlockType,
	"template":           TemplateBlockType,
	"link_to_page":       LinkToPageBlockType,
	"table":              TableBlockType,
	"table_row":          TableRowBlockType,
	"unsupported":        UnsupportedBlockType,
}
View Source
var StringToColor = map[string]Color{
	"default":           DefaultColor,
	"gray":              Gray,
	"brown":             Brown,
	"orange":            Orange,
	"yellow":            Yellow,
	"green":             Green,
	"blue":              Blue,
	"purple":            Purple,
	"pink":              Pink,
	"red":               Red,
	"gray_background":   GrayBackground,
	"brown_background":  BrownBackground,
	"orange_background": OrangeBackground,
	"yellow_background": YellowBackground,
	"green_background":  GreenBackground,
	"blue_background":   BlueBackground,
	"purple_background": PurpleBackground,
	"pink_background":   PinkBackground,
	"red_background":    RedBackground,
}
View Source
var StringToDBParentType = map[string]DBParentType{
	"page_id":   PageDBParentType,
	"workspace": WorksapceDBParentType,
}
View Source
var StringToFileDescriptorType = map[string]FileDescriptorType{
	"file":     NotionFileDescriptorType,
	"external": ExternalFileDescriptorType,
}
View Source
var StringToIconType = map[string]IconType{
	"emoji":    EmojiIconType,
	"file":     FileIconType,
	"external": ExternalIconType,
}
View Source
var StringToLanguage = map[string]Language{
	"abap":         ABAP,
	"arduino":      Arduino,
	"bash":         Bash,
	"basic":        Basic,
	"c":            C,
	"clojure":      Clojure,
	"coffeescript": CoffeeScript,
	"c++":          CPlusPlus,
	"c#":           CSharp,
	"css":          CSS,
	"dart":         Dart,
	"diff":         Diff,
	"docker":       Docker,
	"elixir":       Elixir,
	"elm":          Elm,
	"erlang":       Erlang,
	"flow":         Flow,
	"fortran":      Fortran,
	"f#":           FSharp,
	"gherkin":      Gherkin,
	"glsl":         Glsl,
	"go":           Go,
	"graphql":      GraphQL,
	"groovy":       Groovy,
	"haskell":      Haskell,
	"html":         HTML,
	"java":         Java,
	"javascript":   JavaScript,
	"json":         JSON,
	"julia":        Julia,
	"kotlin":       Kotlin,
	"latex":        LaTeX,
	"less":         LESS,
	"lisp":         Lisp,
	"livescript":   LiveScript,
	"lua":          Lua,
	"makefile":     Makefile,
	"markdown":     Markdown,
	"markup":       Markup,
	"matlab":       Matlab,
	"mermaid":      Mermaid,
	"nix":          nix,
	"objective-c":  ObjectiveC,
	"ocaml":        OCaml,
	"pascal":       Pascal,
	"perl":         Perl,
	"php":          PHP,
	"plain text":   PlainText,
	"powershell":   PowerShell,
	"prolog":       Prolog,
	"protobuf":     Protobuf,
	"python":       Python,
	"r":            R,
	"reason":       Reason,
	"ruby":         Ruby,
	"rust":         Rust,
	"sass":         SASS,
	"scala":        Scala,
	"scheme":       Scheme,
	"scss":         SCSS,
	"shell":        Shell,
	"sql":          SQL,
	"swift":        Swift,
	"typescript":   TypeScript,
	"vb.net":       VBNet,
	"verilog":      Verilog,
	"vhdl":         VHDL,
	"visual basic": VisualBasic,
	"webassembly":  Webassembly,
	"xml":          XML,
	"yaml":         YAML,
}
View Source
var StringToMentionType = map[string]MentionType{
	"user":        UserMentionType,
	"page":        PageMentionType,
	"database":    DatabaseMentionType,
	"date":        DateMentionType,
	"link_privew": LinkPriviewMentionType,
}
View Source
var StringToNumberFormat = map[string]NumberPropertyFormat{
	"number":             Number,
	"number_with_commas": NumberWithCommas,
	"percent":            Percent,
	"dollar":             Dollar,
	"canadian_dollar":    CanadianDollar,
	"euro":               Euro,
	"pound":              Pound,
	"yen":                Yen,
	"ruble":              Ruble,
	"rupee":              Rupee,
	"won":                Won,
	"yuan":               Yuan,
	"real":               Real,
	"lira":               Lira,
	"rupiah":             Rupiah,
	"franc":              Franc,
	"hong_kong_dollar":   HongKondDollar,
	"new_zealand_dollar": NewZellanDollar,
	"krona":              Krona,
	"norwegian_krone":    NorwegianKrone,
	"mexican_peso":       MexicanPeso,
	"rand":               Rand,
	"new_taiwan_dollar":  NewTaiwanDollar,
	"danish_krone":       DanishKrone,
	"zloty":              Zloty,
	"baht":               Baht,
	"forint":             Forint,
	"koruna":             Koruna,
	"shekel":             Shekel,
	"chilean_peso":       ChileanPeso,
	"philippine_peso":    PhilippinePeso,
	"dirham":             Dirham,
	"colombian_peso":     ColumbianPeso,
	"riyal":              Riyal,
	"ringgit":            Ringgit,
	"leu":                Leu,
	"argentine_peso":     ArgentinePeso,
	"uruguayan_peso":     UruguayanPeso,
}
View Source
var StringToPageParent = map[string]PageParentType{
	"database_id": PageParentDB,
	"workspace":   PageParentWorkspace,
	"page_id":     PageParentPage,
}
View Source
var StringToPagePropertyFormulaType = map[string]PagePropertyFormulaType{
	"string":  StringFormulaType,
	"number":  NumberFormulaType,
	"boolean": BoolFormulaType,
	"date":    DateFormuleType,
}
View Source
var StringToPropType = map[string]DBPropertyType{
	"title":            DBPropTypeTitle,
	"rich_text":        DBPropTypeRichText,
	"number":           DBPropTypeNumber,
	"select":           DBPropTypeSelect,
	"multi_select":     DBPropTypeMultiSelect,
	"date":             DBPropTypeDate,
	"people":           DBPropTypePeople,
	"files":            DBPropTypeFiles,
	"checkbox":         DBPropTypeCheckbox,
	"url":              DBPropTypeURL,
	"email":            DBPropTypeEmail,
	"phone_number":     DBPropTypePhoneNumber,
	"formula":          DBPropTypeFormula,
	"relation":         DBPropTypeRelation,
	"rollup":           DBPropTypeRollup,
	"created_time":     DBPropTypeCreatedTime,
	"created_by":       DBPropTypeCreatedBy,
	"last_edited_time": DBPropTypeLastEditedTime,
	"last_edited_by":   DBPropTypeLastEditedBy,
}
View Source
var StringToRichTextType = map[string]RichTextType{
	"text":     TextRichTextType,
	"mention":  MentionRichTextType,
	"equation": EquationRichTextType,
}
View Source
var StringToRollupFunction = map[string]RollupFunction{
	"count":               Count,
	"count_all":           CountAll,
	"count_values":        CountValues,
	"count_unique_values": CountUniqueValues,
	"count_empty":         CountEmpty,
	"count_not_empty":     CountNotEmpty,
	"percent_empty":       PercentEmpty,
	"percent_not_empty":   PercentNotEmpty,
	"sum":                 Sum,
	"average":             Average,
	"median":              Median,
	"min":                 Min,
	"max":                 Max,
	"range":               Range,
	"show_original":       ShowOriginal,
	"earliest_date":       EarliestDate,
	"latest_date":         LatestDate,
	"date_range":          DateRange,
}
View Source
var StringToRollupPropertyType = map[string]RollupPropertyType{
	"number":      NumberRollupPropertyType,
	"date":        DateRollupPropertyType,
	"array":       ArrayRollupPropertyType,
	"unsupported": UnsupportedRollupPropertyType,
	"incomplete":  IncompleteRollupPropertyType,
}
View Source
var StringToSortDirection = map[string]SortDirection{
	"ascending":  Ascending,
	"descending": Descending,
}
View Source
var StringToTimestampFilterType = map[string]TimestampConditionType{
	"created_time":     CreatedTime,
	"last_edited_time": LastEditedTime,
}
View Source
var StringToUserType = map[string]UserType{
	"person": PersonType,
	"bot":    BotType,
}
View Source
var TimestampFilterTypeToString = map[TimestampConditionType]string{
	CreatedTime:    "created_time",
	LastEditedTime: "last_edited_time",
}
View Source
var UserTypeToString = map[UserType]string{
	PersonType: "person",
	BotType:    "bot",
}

Functions

This section is empty.

Types

type Annotations

type Annotations struct {
	Bold          bool  `json:"bold"`
	Italic        bool  `json:"italic"`
	Strikethrough bool  `json:"strikethrough"`
	Underline     bool  `json:"underline"`
	Code          bool  `json:"code"`
	Color         Color `json:"color"`
}

type Block

type Block struct {
	Object         string       `json:"object,omitempty"`
	ID             string       `json:"id"`
	Parent         BlockParent  `json:"parent"`
	Type           BlockType    `json:"type"`
	CreatedTime    DateTimeWrap `json:"created_time"`
	CreatedBy      User         `json:"created_by"`
	LastEditedTime DateTimeWrap `json:"last_edited_time"`
	LastEditedBy   User         `json:"last_edited_by"`
	Archived       *bool        `json:"archived,omitempty"`     //TODO value instead pointer?
	HasChildren    *bool        `json:"has_children,omitempty"` //TODO value instead pointer?

	Paragraph        *TextBlock            `json:"paragraph,omitempty"`
	Heading_1        *HeadingBlock         `json:"heading_1,omitempty"`
	Heading_2        *HeadingBlock         `json:"heading_2,omitempty"`
	Heading_3        *HeadingBlock         `json:"heading_3,omitempty"`
	Callout          *CalloutBlock         `json:"callout,omitempty"`
	Quote            *TextBlock            `json:"quote,omitempty"`
	BulletedListItem *TextBlock            `json:"bulleted_list_item,omitempty"`
	NumberedListItem *TextBlock            `json:"numbered_list_item,omitempty"`
	ToDo             *TodoBlock            `json:"to_do,omitempty"`
	Toggle           *TextBlock            `json:"toggle,omitempty"`
	Code             *CodeBlock            `json:"code,omitempty"` //WTF
	ChildPage        *ChildBlock           `json:"child_page,omitempty"`
	ChildDatabase    *ChildBlock           `json:"child_database,omitempty"`
	Embed            *EmbedBlock           `json:"embed,omitempty"`
	Image            *FileDescriptor       `json:"image,omitempty"`
	Video            *FileDescriptor       `json:"video,omitempty"`
	File             *FileDescriptor       `json:"file,omitempty"`
	PDF              *FileDescriptor       `json:"pdf,omitempty"`
	Bookmark         *BookmarkBlock        `json:"bookmark,omitempty"`
	Equation         *EquationBlock        `json:"equation,omitempty"`
	Divider          *DividerBlock         `json:"divider,omitempty"`
	TableOfContents  *TableOfContentsBlock `json:"table_of_contents,omitempty"` // Table of contents block?
	BreadCrumb       *BreadCrumbBlock      `json:"breadcrumb,omitempty"`
	ColumnList       *ColumnListBlock      `json:"column_list,omitempty"`  //Column Block?
	Column           *ColumnBlock          `json:"column,omitempty"`       //row?
	LinkPreview      *LinkPreviewBlock     `json:"link_preview,omitempty"` //Link Privew blocks?
	Template         *TemplateBlock        `json:"template,omitempty"`     //Tempalte Blocks?
	LinkToPage       *LinkToPageBlock      `json:"link_to_page,omitempty"` //Link To page BlocK?
	SyncedBlock      *SyncedBlock          `json:"synced_block,omitempty"`
	Table            *TableBlock           `json:"table,omitempty"`
	TableRow         *TableRowBlock        `json:"table_row,omitempty"`
}

type BlockParent

type BlockParent struct {
	Type       string `json:"type"`
	BlockId    string `json:"block_id,omitempty"`
	PageId     string `json:"page_id,omitempty"`
	DatabaseId string `json:"database_id,omitempty"`
}

type BlockParentType

type BlockParentType int

func (BlockParentType) MarshalJSON

func (p BlockParentType) MarshalJSON() ([]byte, error)

func (*BlockParentType) UnmarshalJSON

func (p *BlockParentType) UnmarshalJSON(b []byte) error

type BlockType

type BlockType int

func (BlockType) MarshalJSON

func (p BlockType) MarshalJSON() ([]byte, error)

func (*BlockType) UnmarshalJSON

func (p *BlockType) UnmarshalJSON(b []byte) error

type BookmarkBlock

type BookmarkBlock struct {
	URL     string     `json:"url"`
	Caption []RichText `json:"caption"`
}

type Bot

type Bot struct {
	Bot   string   `json:"bot,omitempty"`
	Owner BotOwner `json:"owner"`
}

type BotOwner

type BotOwner struct {
	Owner     string `json:"owner,omitempty"`
	Type      string `json:"type"`
	Workspace bool   `json:"workspace"`
	OwnerUser User   `json:"user"`
}
type BreadCrumbBlock struct{}

type CalloutBlock

type CalloutBlock struct {
	RichText []RichText      `json:"rich_text"`
	Icon     *IconDescriptor `json:"icon,omitempty"`
	Color    Color           `json:"color,omitempty"`
	Children []Block         `json:"children,omitempty"`
}

type CheckboxCondition

type CheckboxCondition struct {
	Equals      *bool `json:"equals,omitempty"`
	DoesntEqual *bool `json:"does_not_equal,omitempty"`
}

by default go treats bool_field=false as empty and if tag omitempty is present, bool_field=false will be erased from result json that's why I use *bool hre, instead bool. https://github.com/golang/go/issues/13284

type ChildBlock

type ChildBlock struct {
	Title string `json:"title"`
}

type CodeBlock

type CodeBlock struct {
	RichText []RichText `json:"rich_text"`
	Caption  []RichText `json:"caption"`
	Language Language   `json:"language,omitempty"`
}

type Color

type Color int
const (
	DefaultColor Color = iota
	Gray
	Brown
	Orange
	Yellow
	Green
	Blue
	Purple
	Pink
	Red
	GrayBackground
	BrownBackground
	OrangeBackground
	YellowBackground
	GreenBackground
	BlueBackground
	PurpleBackground
	PinkBackground
	RedBackground
)

func (Color) MarshalJSON

func (p Color) MarshalJSON() ([]byte, error)

func (*Color) UnmarshalJSON

func (p *Color) UnmarshalJSON(b []byte) error

type ColumnBlock

type ColumnBlock struct {
	Children []Block `json:"children"`
}

Can contains any block type itself "column", need validation

type ColumnListBlock

type ColumnListBlock struct {
	Children []ColumnBlock `json:"children"`
}

TODO need to test ColumnListBlock and ColumnBlock carefuly https://developers.notion.com/reference/block#column-list-and-column-blocks

type CreateDBRq

type CreateDBRq struct {
	PageId     string
	Title      []RichText
	Properties DBProperties
	Icon       *IconDescriptor
	Cover      *FileDescriptor
}

func (CreateDBRq) MarshalJSON

func (cdb CreateDBRq) MarshalJSON() ([]byte, error)

func (CreateDBRq) ValidateRequest

func (cdb CreateDBRq) ValidateRequest() error

type CreatePageRq

type CreatePageRq struct {
	ID         string // You can create page only with database as parent. Looks like bug, might need to be fixed later
	Properties PageProperties
	// TODO children
	Icon  *IconDescriptor
	Cover *FileDescriptor
}

If pass empty value for text, like

gotion.CreatePageRq{
		ID: "7fb5f8a059eb45a585fa71ba40fd7a0f",
		Properties: gotion.PageProperties{
			"Name": gotion.PageProperty{
				Title: []gotion.RichText{
				},
			},
		},
	}

title will be omitted and error will be returned from notion need fix this

func (CreatePageRq) MarshalJSON

func (rq CreatePageRq) MarshalJSON() ([]byte, error)

func (CreatePageRq) ValidateRequest

func (rq CreatePageRq) ValidateRequest() error

type DB

type DB struct {
	Object         string       `json:"object"`
	ID             string       `json:"id"`
	CreatedTime    DateTimeWrap `json:"created_time"`
	CreatedBy      User         `json:"created_by"`
	LastEditedTime DateTimeWrap `json:"last_edited_time"`
	LastEditedBy   User         `json:"last_edited_by"`
	Title          []RichText   `json:"title"`
	//Doesn't exist in doc, but exists in response
	Description []RichText      `json:"description"`
	Icon        *IconDescriptor `json:"icon,omitempty"`
	Cover       *FileDescriptor `json:"cover,omitempty"`
	Properties  DBProperties    `json:"properties"`
	Parent      DBParent        `json:"parent"`
	URL         string          `json:"url"`
	Archived    bool            `json:"archived"`
}

type DBDefaultProperty

type DBDefaultProperty struct{}

type DBFormulatProperty

type DBFormulatProperty struct {
	Expression string `json:"expression"`
}

type DBNumberProperty

type DBNumberProperty struct {
	Format NumberPropertyFormat `json:"format"`
}

type DBParent

type DBParent struct {
	Type      DBParentType `json:"type"`
	PageID    string       `json:"page_id,omitempty"`
	Workspace bool         `json:"workspace,omitempty"`
}

func (DBParent) ValidateRequest

func (dbp DBParent) ValidateRequest() error

type DBParentType

type DBParentType int
const (
	NoDBParentType DBParentType = iota
	PageDBParentType
	WorksapceDBParentType
)

func (DBParentType) MarshalJSON

func (p DBParentType) MarshalJSON() ([]byte, error)

func (*DBParentType) UnmarshalJSON

func (p *DBParentType) UnmarshalJSON(b []byte) error

type DBProperties

type DBProperties map[string]DBProperty

type DBProperty

type DBProperty struct {
	ID   string         `json:"id,omitempty"`
	Type DBPropertyType `json:"type,omitempty"`
	Name string         `json:"name,omitempty"`

	Title          *DBDefaultProperty  `json:"title,omitempty"`
	RichText       *DBDefaultProperty  `json:"rich_text,omitempty"`
	Number         *DBNumberProperty   `json:"number,omitempty"`
	Select         *DBSelectProperties `json:"select,omitempty"`
	MultiSelect    *DBSelectProperties `json:"multi_select,omitempty"`
	Date           *DBDefaultProperty  `json:"date,omitempty"`
	People         *DBDefaultProperty  `json:"people,omitempty"`
	Files          *DBDefaultProperty  `json:"files,omitempty"`
	Checkbox       *DBDefaultProperty  `json:"checkbox,omitempty"`
	URL            *DBDefaultProperty  `json:"url,omitempty"`
	Email          *DBDefaultProperty  `json:"email,omitempty"`
	PhoneNumber    *DBDefaultProperty  `json:"phone_number,omitempty"`
	Formula        *DBFormulatProperty `json:"formula,omitempty"`
	Relation       *DBRelationProperty `json:"relation,omitempty"`
	Rollup         *RollupProperty     `json:"rollup,omitempty"` // TODO need fix this
	CreatedTime    *DBDefaultProperty  `json:"created_time,omitempty"`
	CreatedBy      *DBDefaultProperty  `json:"created_by,omitempty"`
	LastEditedTime *DBDefaultProperty  `json:"last_edited_time,omitempty"`
	LastEditedBy   *DBDefaultProperty  `json:"last_edited_by,omitempty"`
}

type DBPropertyType

type DBPropertyType int
const (
	NoDBPropType DBPropertyType = iota
	DBPropTypeTitle
	DBPropTypeRichText
	DBPropTypeNumber
	DBPropTypeSelect
	DBPropTypeMultiSelect
	DBPropTypeDate
	DBPropTypePeople
	DBPropTypeFiles
	DBPropTypeCheckbox
	DBPropTypeURL
	DBPropTypeEmail
	DBPropTypePhoneNumber
	DBPropTypeFormula
	DBPropTypeRelation
	DBPropTypeRollup
	DBPropTypeCreatedTime
	DBPropTypeCreatedBy
	DBPropTypeLastEditedTime
	DBPropTypeLastEditedBy
)

func (DBPropertyType) MarshalJSON

func (p DBPropertyType) MarshalJSON() ([]byte, error)

func (*DBPropertyType) UnmarshalJSON

func (p *DBPropertyType) UnmarshalJSON(b []byte) error

type DBRelationProperty

type DBRelationProperty struct {
	DBId               string `json:"database_id"`
	SyncedPropertyName string `json:"synced_property_name,omitempty"`
	SyncedPropertyId   string `json:"synced_property_id,omitempty"`
}

type DBRollupProperty

type DBRollupProperty struct {
	RelationPropertyName string `json:"relation_property_name"`
	RelationPropertyId   string `json:"relation_property_id"`
	RollupPropertyName   string `json:"rollup_property_name"`
	RollupPropertyId     string `json:"rollup_property_id"`
	Function             string `json:"function"`
}

type DBSelectProperties

type DBSelectProperties struct {
	Options []DBSelectProperty `json:"options"`
}

type DBSelectProperty

type DBSelectProperty struct {
	Name  string `json:"name"`
	ID    string `json:"id,omitempty"`
	Color Color  `json:"color"`
}

type DateCondition

type DateCondition struct {
	Equals     *DateTimeWrap      `json:"equals,omitempty"`
	Before     *DateTimeWrap      `json:"before,omitempty"`
	After      *DateTimeWrap      `json:"after,omitempty"`
	OnOrBefore *DateTimeWrap      `json:"on_or_before,omitempty"`
	OnOrAfter  *DateTimeWrap      `json:"on_or_after,omitempty"`
	PastWeek   *DateTimeEmptyWrap `json:"past_week,omitempty"`
	PastMonth  *DateTimeEmptyWrap `json:"past_month,omitempty"`
	PastYear   *DateTimeEmptyWrap `json:"past_year,omitempty"`
	NextWeek   *DateTimeEmptyWrap `json:"next_week,omitempty"`
	NextMonth  *DateTimeEmptyWrap `json:"next_month,omitempty"`
	NextYear   *DateTimeEmptyWrap `json:"next_year,omitempty"`
	IsEmpty    bool               `json:"is_empty,omitempty"`
	IsNotEmpty bool               `json:"is_not_empty,omitempty"`
}

type DatePageProperty

type DatePageProperty struct {
	Start    DateTimeWrap  `json:"start"`
	End      *DateTimeWrap `json:"end,omitempty"`
	TimeZone *string       `json:"time_zone,omitempty"`
}

type DateTimeEmptyWrap

type DateTimeEmptyWrap struct{}

type DateTimeWrap

type DateTimeWrap struct {
	Datetime time.Time
}

func (DateTimeWrap) MarshalJSON

func (dt DateTimeWrap) MarshalJSON() ([]byte, error)

func (*DateTimeWrap) UnmarshalJSON

func (dt *DateTimeWrap) UnmarshalJSON(b []byte) error

type DividerBlock

type DividerBlock struct{}

type EmbedBlock

type EmbedBlock struct {
	Url string `json:"url"`
}

Embed blocks created via Notion API may differ of embed blocks created via UI Details: https://developers.notion.com/reference/block#embed-blocks Can it be returned in request? Because after inserting embed link into page its type transforming to another For isntace to bookmark. Example: https://{{notion-host}}/v1/blocks/74552d4f1c01447a8c7edd560e161520

type Emoji

type Emoji struct {
	Type  string `json:"type"`
	Emoji string `json:"emoji"`
}

type Equation

type Equation struct {
	Expression string `json:"expression"`
}

type EquationBlock

type EquationBlock struct {
	Expression string `json:"expression"`
}

type ExternalFile

type ExternalFile struct {
	URL string `json:"url"`
}

type FileBlock

type FileBlock struct {
	File FileDescriptor `json:"file"`
}

type FileCondition

type FileCondition struct {
	IsEmpty    bool `json:"is_empty,omitempty"`
	IsNotEmpty bool `json:"is_not_empty,omitempty"`
}

type FileDescriptor

type FileDescriptor struct {
	Type         FileDescriptorType `json:"type"`
	Name         string             `json:"name,omitempty"`
	ExternalFile *ExternalFile      `json:"external,omitempty"`
	NotionFile   *NotionFile        `json:"file,omitempty"`
	//This field isn't documented, but it's appeared in blocks
	Caption []RichText `json:"caption,omitempty"`
}

func (FileDescriptor) ValidateRequest

func (fdt FileDescriptor) ValidateRequest() error

type FileDescriptorType

type FileDescriptorType int
const (
	NoFileDescriptorType FileDescriptorType = iota
	NotionFileDescriptorType
	ExternalFileDescriptorType
)

func (FileDescriptorType) MarshalJSON

func (p FileDescriptorType) MarshalJSON() ([]byte, error)

func (*FileDescriptorType) UnmarshalJSON

func (p *FileDescriptorType) UnmarshalJSON(b []byte) error

type Filter

type Filter struct {
	Property  string                 `json:"property,omitempty"`
	Timestamp TimestampConditionType `json:"timestamp,omitempty"`

	RichText     *TextCondition        `json:"rich_text,omitempty"`
	Title        *TextCondition        `json:"title,omitempty"`
	URL          *TextCondition        `json:"url,omitempty"`
	Email        *TextCondition        `json:"email,omitempty"`
	PhoneNumber  *TextCondition        `json:"phone_number,omitempty"`
	Number       *NumberCondition      `json:"number,omitempty"`
	Checkbox     *CheckboxCondition    `json:"checkbox,omitempty"`
	Select       *SelectCondition      `json:"select,omitempty"`
	MultiSelect  *MultiSelectCondition `json:"multi_select,omitempty"`
	File         *FileCondition        `json:"files,omitempty"`
	Relation     *RelationCondition    `json:"relation,omitempty"`
	Date         *DateCondition        `json:"date,omitempty"`
	People       *PeopleCondition      `json:"people,omitempty"`
	CreatedBy    *PeopleCondition      `json:"created_by,omitempty"`
	LastEditedBy *PeopleCondition      `json:"last_edited_by,omitempty"`
	Formula      *FormulaCondition     `json:"formula,omitempty"`
	Rollup       *RollupCondition      `json:"rollup,omitempty"`

	And []Filter `json:"and,omitempty"`
	Or  []Filter `json:"or,omitempty"`
}

Add filter terst with timestamp

type FormulaCondition

type FormulaCondition struct {
	String   *TextCondition     `json:"string,omitempty"`
	Checkbox *CheckboxCondition `json:"checkbox,omitempty"`
	Number   *NumberCondition   `json:"number,omitempty"`
	Date     *DateCondition     `json:"date,omitempty"`
}

type FormulaPageProperty

type FormulaPageProperty struct {
	Type           PagePropertyFormulaType `json:"type"`
	StringFormula  *string                 `json:"string,omitempty"`
	BooleanFormula *bool                   `json:"boolean,omitempty"`
	NumberFormula  *float64                `json:"number,omitempty"`
	DateFormula    *DatePageProperty       `json:"date,omitempty"`
}

type HeadingBlock

type HeadingBlock struct {
	RichText []RichText `json:"rich_text"`
	Color    Color      `json:"color,omitempty"`
}

type IDWrap

type IDWrap struct {
	ID string `json:"id"`
}

type IconDescriptor

type IconDescriptor struct {
	Type     IconType      `json:"type"`
	Emoji    string        `json:"emoji,omitempty"`
	External *ExternalFile `json:"external,omitempty"`
	File     *NotionFile   `json:"file,omitempty"`
}

func (IconDescriptor) ValidateRequest

func (id IconDescriptor) ValidateRequest() error

Notion supports icon as a notion file and this can be returned with response. But in request supports only emoji and external types

type IconType

type IconType int
const (
	NoIconType IconType = iota
	EmojiIconType
	FileIconType
	ExternalIconType
)

func (IconType) MarshalJSON

func (p IconType) MarshalJSON() ([]byte, error)

func (*IconType) UnmarshalJSON

func (p *IconType) UnmarshalJSON(b []byte) error

type ImageBlock

type ImageBlock struct {
	Image FileDescriptor `json:"image"`
}

type Language

type Language int
const (
	NoLanguage Language = iota
	ABAP
	Arduino
	Bash
	Basic
	C
	Clojure
	CoffeeScript
	CPlusPlus
	CSharp
	CSS
	Dart
	Diff
	Docker
	Elixir
	Elm
	Erlang
	Flow
	Fortran
	FSharp
	Gherkin
	Glsl
	Go
	GraphQL
	Groovy
	Haskell
	HTML
	Java
	JavaScript
	JSON
	Julia
	Kotlin
	LaTeX
	LESS
	Lisp
	LiveScript
	Lua
	Makefile
	Markdown
	Markup
	Matlab
	Mermaid

	ObjectiveC
	OCaml
	Pascal
	Perl
	PHP
	PlainText
	PowerShell
	Prolog
	Protobuf
	Python
	R
	Reason
	Ruby
	Rust
	SASS
	Scala
	Scheme
	SCSS
	Shell
	SQL
	Swift
	TypeScript
	VBNet
	Verilog
	VHDL
	VisualBasic
	Webassembly
	XML
	YAML
)

func (Language) MarshalJSON

func (l Language) MarshalJSON() ([]byte, error)

func (*Language) UnmarshalJSON

func (l *Language) UnmarshalJSON(b []byte) error
type Link struct {
	URL string `json:"url"`
}

type LinkPreviewBlock

type LinkPreviewBlock struct {
	URL string `json:"link_preview"`
}

Link Preview block objects return the originally pasted url. NOTE: The link_preview block will only be returned as part of a response. It cannot be created via the API. https://developers.notion.com/reference/block#link-preview-blocks

type LinkToPageBlock

type LinkToPageBlock struct {
	Type       string `json:"type"` //TODO need to create enum
	PageID     string `json:"page_id,omitempty"`
	DatabaseID string `json:"database_id,omitempty"`
}

type Mention

type Mention struct {
	Type MentionType `json:"type,omitempty"`

	User     *User             `json:"user,omitempty"`
	Page     *IDWrap           `json:"page,omitempty"`
	Database *IDWrap           `json:"database,omitempty"`
	Date     *DatePageProperty `json:"date,omitempty"`
	Template *Template         `json:"template_mention,omitempty"`
}

type MentionType

type MentionType int
const (
	NoMentionType MentionType = iota
	UserMentionType
	PageMentionType
	DatabaseMentionType
	DateMentionType
	LinkPriviewMentionType
)

func (MentionType) MarshalJSON

func (p MentionType) MarshalJSON() ([]byte, error)

func (*MentionType) UnmarshalJSON

func (p *MentionType) UnmarshalJSON(b []byte) error

type MultiSelectCondition

type MultiSelectCondition struct {
	Contains      string `json:"contains,omitempty"`
	DoesntContain string `json:"does_not_contain,omitempty"`
	IsEmpty       bool   `json:"is_empty,omitempty"`
	IsNotEmpty    bool   `json:"is_not_empty,omitempty"`
}

type NotionClient

type NotionClient struct {
	BaseURL       string
	ApiVersion    string
	NotionVersion string

	HttpClient *http.Client
	// contains filtered or unexported fields
}

func CreateNotionClient

func CreateNotionClient(apiKey string) NotionClient

func (*NotionClient) QueryDatabase

func (nc *NotionClient) QueryDatabase(ctx context.Context, query QueryDBRq, database string) (Page, error)

func (*NotionClient) UpdatePage

func (nc *NotionClient) UpdatePage(ctx context.Context, properties Page, pageId string) (Page, error)

type NotionFile

type NotionFile struct {
	URL        string        `json:"url"`
	ExpiryTime *DateTimeWrap `json:"expiry_time,omitempty"`
}

type NumberCondition

type NumberCondition struct {
	Equals               float64 `json:"equals,omitempty"`
	DoesntEqual          float64 `json:"does_not_equal,omitempty"`
	GreaterThan          float64 `json:"greater_than,omitempty"`
	LessThan             float64 `json:"less_than,omitempty"`
	GreaterThanOrEqualTo float64 `json:"greater_than_or_equal_to,omitempty"`
	LessThanOrEqualTo    float64 `json:"less_than_or_equal_to,omitempty"`
	IsEmpty              bool    `json:"is_empty,omitempty"`
	IsNotEmpty           bool    `json:"is_not_empty,omitempty"`
}

If we pass 0 as value, fields will be erased completely from result json.

type NumberPropertyFormat

type NumberPropertyFormat int
const (
	NoNumberFormat NumberPropertyFormat = iota
	Number
	NumberWithCommas
	Percent
	Dollar
	CanadianDollar
	Euro
	Pound
	Yen
	Ruble
	Rupee
	Won
	Yuan
	Real
	Lira
	Rupiah
	Franc
	HongKondDollar
	NewZellanDollar
	Krona
	NorwegianKrone
	MexicanPeso
	Rand
	NewTaiwanDollar
	DanishKrone
	Zloty
	Baht
	Forint
	Koruna
	Shekel
	ChileanPeso
	PhilippinePeso
	Dirham
	ColumbianPeso
	Riyal
	Ringgit
	Leu
	ArgentinePeso
	UruguayanPeso
)

func (NumberPropertyFormat) MarshalJSON

func (p NumberPropertyFormat) MarshalJSON() ([]byte, error)

func (*NumberPropertyFormat) UnmarshalJSON

func (p *NumberPropertyFormat) UnmarshalJSON(b []byte) error

type PDFBlock

type PDFBlock struct {
	PDF FileDescriptor `json:"pdf"`
}

type Page

type Page struct {
	Object         string
	ID             string          `json:"id"`
	CreatedTime    DateTimeWrap    `json:"created_time"`
	CreatedBy      User            `json:"created_by"`
	LastEditedTime DateTimeWrap    `json:"last_edited_time"`
	LastEditedBy   User            `json:"last_edited_by"`
	Parent         PageParent      `json:"parent"`
	Icon           *IconDescriptor `json:"icon,omitempty"`
	Cover          *FileDescriptor `json:"cover,omitempty"`
	Archived       bool            `json:"archived"`
	Properties     PageProperties  `json:"properties"`
	URL            string          `json:"url"`
}

type PageParent

type PageParent struct {
	Type       PageParentType `json:"type"`
	DatabaseID string         `json:"database_id,omitempty"`
	PageID     string         `json:"page_id,omitempty"`
	Workspace  bool           `json:"workspace,omitempty"`
}

type PageParentType

type PageParentType int
const (
	NoPageParentType PageParentType = iota
	PageParentDB
	PageParentWorkspace
	PageParentPage
)

func (PageParentType) MarshalJSON

func (pt PageParentType) MarshalJSON() ([]byte, error)

func (*PageParentType) UnmarshalJSON

func (pt *PageParentType) UnmarshalJSON(b []byte) error

type PageProperties

type PageProperties map[string]PageProperty

type PageProperty

type PageProperty struct {
	ID   string         `json:"id,omitempty"`
	Type DBPropertyType `json:"type,omitempty"`

	Title          []RichText           `json:"title,omitempty"`
	RichText       []RichText           `json:"rich_text,omitempty"`
	Number         *float64             `json:"number,omitempty"`
	Select         *SelectPageProperty  `json:"select,omitempty"`
	MultiSelect    []SelectPageProperty `json:"multi_select,omitempty"`
	Date           *DatePageProperty    `json:"date,omitempty"`
	People         []User               `json:"people,omitempty"`
	Files          []FileDescriptor     `json:"files,omitempty"`
	Checkbox       *bool                `json:"checkbox,omitempty"`
	URL            *string              `json:"url,omitempty"`
	Email          *string              `json:"email,omitempty"`
	PhoneNumber    *string              `json:"phone_number,omitempty"`
	Formula        *FormulaPageProperty `json:"formula,omitempty"`
	Relation       []IDWrap             `json:"relation,omitempty"`
	Rollup         *RollupPageProperty  `json:"rollup,omitempty"`
	CreatedTime    *DateTimeWrap        `json:"created_time,omitempty"`
	CreatedBy      *User                `json:"created_by,omitempty"`
	LastEditedTime *DateTimeWrap        `json:"last_edited_time,omitempty"`
	LastEditedBy   *User                `json:"last_edited_by,omitempty"`
}

type PagePropertyFormulaType

type PagePropertyFormulaType int
const (
	NoFormulaType PagePropertyFormulaType = iota
	StringFormulaType
	NumberFormulaType
	BoolFormulaType
	DateFormuleType
)

func (PagePropertyFormulaType) MarshalJSON

func (p PagePropertyFormulaType) MarshalJSON() ([]byte, error)

func (*PagePropertyFormulaType) UnmarshalJSON

func (p *PagePropertyFormulaType) UnmarshalJSON(b []byte) error

type PeopleCondition

type PeopleCondition struct {
	IsEmpty    bool `json:"is_empty,omitempty"`
	IsNotEmpty bool `json:"is_not_empty,omitempty"`
	//Should be valid uuid
	Contains string `json:"contains,omitempty"`
	//Should be valid uuid
	DoesntContains string `json:"does_not_contain,omitempty"`
}

type Person

type Person struct {
	Person string `json:"person,omitempty"`
	Email  string `json:"email"`
}

type QueryDBRq

type QueryDBRq struct {
	Filter      *Filter `json:"filter,omitempty"`
	Sorts       []Sort  `json:"sorts,omitempty"`
	StartCursor string  `json:"start_cursor,omitempty"`
	PageSize    int     `json:"page_size,omitempty"`
}

type QueryDBRs

type QueryDBRs struct {
	Object     string  `json:"object"`
	Results    []Page  `json:"results"`
	NextCursor *string `json:"next_cursor"`
	HasMore    bool    `json:"has_more"`
}

type RelationCondition

type RelationCondition struct {
	IsEmpty    bool `json:"is_empty,omitempty"`
	IsNotEmpty bool `json:"is_not_empty,omitempty"`
	//Should be valid uuid
	Contains string `json:"contains,omitempty"`
	//Should be valid uuid
	DoesntContains string `json:"does_not_contain,omitempty"`
}

type RichText

type RichText struct {
	Type        RichTextType `json:"type,omitempty"`
	PlainText   string       `json:"plain_text,omitempty"`
	Href        string       `json:"href,omitempty"`
	Annotations *Annotations `json:"annotations,omitempty"`
	//One of followings should be define
	Text     *Text     `json:"text,omitempty"`
	Mention  *Mention  `json:"mention,omitempty"`
	Equation *Equation `json:"equation,omitempty"`
}

type RichTextType

type RichTextType int
const (
	NoRichTextType RichTextType = iota
	TextRichTextType
	MentionRichTextType
	EquationRichTextType
)

func (RichTextType) MarshalJSON

func (p RichTextType) MarshalJSON() ([]byte, error)

func (*RichTextType) UnmarshalJSON

func (p *RichTextType) UnmarshalJSON(b []byte) error

type RollupArrayValue

type RollupArrayValue struct {
	Type DBPropertyType `json:"type"`

	Title          []RichText           `json:"title,omitempty"`
	RichText       []RichText           `json:"rich_text,omitempty"`
	Number         *float64             `json:"number,omitempty"`
	Select         *SelectPageProperty  `json:"select,omitempty"`
	MultiSelect    []SelectPageProperty `json:"multi_select,omitempty"`
	Date           *DatePageProperty    `json:"date,omitempty"`
	People         []User               `json:"people,omitempty"`
	Files          []FileDescriptor     `json:"files,omitempty"`
	Checkbox       *bool                `json:"checkbox,omitempty"`
	URL            *string              `json:"url,omitempty"`
	Email          *string              `json:"email,omitempty"`
	PhoneNumber    *string              `json:"phone_number,omitempty"`
	Formula        *FormulaPageProperty `json:"formula,omitempty"`
	Relation       []IDWrap             `json:"relation,omitempty"`
	CreatedTime    *DateTimeWrap        `json:"created_time,omitempty"`
	CreatedBy      *User                `json:"created_by,omitempty"`
	LastEditedTime *DateTimeWrap        `json:"last_edited_time,omitempty"`
	LastEditedBy   *User                `json:"last_edited_by,omitempty"`
}

type RollupCondition

type RollupCondition struct {
	Any   *RollupProperty `json:"any,omitempty"`
	Every *RollupProperty `json:"every,omitempty"`
	None  *RollupProperty `json:"none,omitempty"`

	Number *NumberCondition `json:"number,omitempty"`
	Date   *DateCondition   `json:"date,omitempty"`
}

type RollupFunction

type RollupFunction int
const (
	NoRollupFunc RollupFunction = iota
	Count
	CountAll
	CountValues
	CountUniqueValues
	CountEmpty
	CountNotEmpty
	PercentEmpty
	PercentNotEmpty
	Sum
	Average
	Median
	Min
	Max
	Range
	ShowOriginal
	EarliestDate
	LatestDate
	DateRange
)

func (RollupFunction) MarshalJSON

func (p RollupFunction) MarshalJSON() ([]byte, error)

func (*RollupFunction) UnmarshalJSON

func (p *RollupFunction) UnmarshalJSON(b []byte) error

type RollupPageProperty

type RollupPageProperty struct {
	Type     RollupPropertyType `json:"type"`
	Number   *float64           `json:"number,omitempty"`
	Date     *DatePageProperty  `json:"date,omitempty"`
	String   *string            `json:"string,omitempty"`
	Array    []RollupArrayValue `json:"array,omitempty"`
	Function RollupFunction     `json:"function"`
}

type RollupProperty

type RollupProperty struct {
	RichText    *TextCondition        `json:"rich_text,omitempty"`
	Title       *TextCondition        `json:"title,omitempty"`
	URL         *TextCondition        `json:"url,omitempty"`
	Email       *TextCondition        `json:"email,omitempty"`
	PhoneNumber *TextCondition        `json:"phone_number,omitempty"`
	Number      *NumberCondition      `json:"number,omitempty"`
	CheckBox    *CheckboxCondition    `json:"checkbox,omitempty"`
	Select      *SelectCondition      `json:"select,omitempty"`
	MultiSelect *MultiSelectCondition `json:"multi_select,omitempty"`
	File        *FileCondition        `json:"files,omitempty"`
	Relation    *RelationCondition    `json:"relation,omitempty"`
	Date        *DateCondition        `json:"date,omitempty"`
}

type RollupPropertyType

type RollupPropertyType int
const (
	NoRollupPropertyType RollupPropertyType = iota
	NumberRollupPropertyType
	DateRollupPropertyType
	ArrayRollupPropertyType
	UnsupportedRollupPropertyType
	IncompleteRollupPropertyType
)

func (RollupPropertyType) MarshalJSON

func (p RollupPropertyType) MarshalJSON() ([]byte, error)

func (*RollupPropertyType) UnmarshalJSON

func (p *RollupPropertyType) UnmarshalJSON(b []byte) error

type SelectCondition

type SelectCondition struct {
	Equals      string `json:"equals,omitempty"`
	DoesntEqual string `json:"does_not_equal,omitempty"`
	IsEmpty     bool   `json:"is_empty,omitempty"`
	IsNotEmpty  bool   `json:"is_not_empty,omitempty"`
}

type SelectPageProperty

type SelectPageProperty struct {
	Name string  `json:"name"`
	ID   *string `json:"id,omitempty"`
	//Color works strange while creating pages. Looks like it doesn't have any effect on creating tag. Need test more.
	//https://developers.notion.com/reference/property-value-object#multi-select-property-values
	Color *Color `json:"color,omitempty"`
}

type Sort

type Sort struct {
	Property string `json:"property,omitempty"`
	/*
		If you will pass both timestamp and property in one sort object
		like this:

		{
			"sorts": [
				{
					"timestamp": "created_time",
					"property": "title",
					"direction": "ascending"
				}
			]
		}

		Notiion will accept it, but behaviour unpredictable(need to test)
		TODO Think about validtion on exactly one of this
	*/
	Timestamp TimestampConditionType `json:"timestamp,omitempty"`
	Direction SortDirection          `json:"direction"`
}

type SortDirection

type SortDirection int
const (
	Ascending SortDirection = iota
	Descending
)

func (SortDirection) MarshalJSON

func (p SortDirection) MarshalJSON() ([]byte, error)

func (*SortDirection) UnmarshalJSON

func (p *SortDirection) UnmarshalJSON(b []byte) error

type SyncedBlock

type SyncedBlock struct {
	SyncedFrom *SyncedFrom `json:"synced_from,omitempty"`
	Children   []Block     `json:"children"`
}

Need validations to prevent creating original synced block with filled SyncedFrom and visa verse Details: https://developers.notion.com/reference/block#synced-block-blocks

type SyncedFrom

type SyncedFrom struct {
	Type    string `json:"type"` //TODO the only possible value now is block, but might need to create enum
	BlockID string `json:"block_id"`
}

type TableBlock

type TableBlock struct {
	//Note that this cannot be changed via the public API once a table is created.
	TableWidth      int             `json:"table_width"`
	HasColumnHeader bool            `json:"has_column_header"`
	HasRowHeader    bool            `json:"has_row_header"`
	Children        []TableRowBlock `json:"children"`
}

type TableOfContentsBlock

type TableOfContentsBlock struct {
	Color Color `json:"color,omitempty"`
}

type TableRowBlock

type TableRowBlock struct {
	Cells []RichText `json:"cells"`
}

type Template

type Template struct {
	TemplateMentionDate *string `json:"template_mention_date"`
	TemplateMentionUser *string `json:"template_mention_user"`
}

type TemplateBlock

type TemplateBlock struct {
	RichText []RichText `json:"rich_text"`
	Children []Block    `json:"children"`
}

type Text

type Text struct {
	Content string `json:"content"`
	Link    *Link  `json:"link,omitempty"`
}

type TextBlock

type TextBlock struct {
	RichText []RichText `json:"rich_text"`
	Color    Color      `json:"color"`
	Children []Block    `json:"children,omitempty"`
}

type TextCondition

type TextCondition struct {
	Equals        string `json:"equals,omitempty"`
	DoesntEqual   string `json:"does_not_equal,omitempty"`
	Contains      string `json:"contains,omitempty"`
	DoesntContain string `json:"does_not_contain,omitempty"`
	StartsWith    string `json:"starts_with,omitempty"`
	EndsWith      string `json:"ends_with,omitempty"`
	IsEmpty       bool   `json:"is_empty,omitempty"`     //In doc written "only true", test what happened if false will be passed here
	IsNotEmpty    bool   `json:"is_not_empty,omitempty"` //In doc written "only true", test what happened if false will be passed here
}

type TimestampConditionType

type TimestampConditionType int
const (
	NoTimestampFilterType TimestampConditionType = iota
	CreatedTime
	LastEditedTime
)

func (TimestampConditionType) MarshalJSON

func (p TimestampConditionType) MarshalJSON() ([]byte, error)

func (*TimestampConditionType) UnmarshalJSON

func (p *TimestampConditionType) UnmarshalJSON(b []byte) error

type TodoBlock

type TodoBlock struct {
	RichText []RichText `json:"rich_text"`
	Checked  bool       `json:"checked"`
	Color    Color      `json:"color,omitempty"`
	Children []Block    `json:"children,omitempty"`
}

type UpdateDBRq

type UpdateDBRq struct {
	Title      []RichText      `json:"title,omitempty"`
	Properties DBProperties    `json:"properties,omitempty"`
	Icon       *IconDescriptor `json:"icon,omitempty"`
	Cover      *FileDescriptor `json:"cover,omitempty"`
}

type UpdatePageRq

type UpdatePageRq struct {
	Archived   *bool           `json:"archived,omitempty"`
	Properties PageProperties  `json:"properties,omitempty"`
	Icon       *IconDescriptor `json:"icon,omitempty"`
	Cover      *FileDescriptor `json:"cover,omitempty"`
}

type User

type User struct {
	Object    string   `json:"object,omitempty"`
	ID        string   `json:"id"`
	Type      UserType `json:"type,omitempty"`
	Name      string   `json:"name,omitempty"`
	AvatarUrl *string  `json:"avatar_url,omitempty"`
	Person    *Person  `json:"person,omitempty"`
	Bot       *Bot     `json:"bot,omitempty"`
}

* https://developers.notion.com/reference/user#where-user-objects-appear-in-the-api

User objects will always contain object and id keys, as described below. The remaining properties may appear if the user is being rendered in a rich text or page property context, and the bot has the correct capabilities to access those properties. *

type UserType

type UserType int
const (
	PersonType UserType = iota
	BotType
)

func (UserType) MarshalJSON

func (p UserType) MarshalJSON() ([]byte, error)

func (*UserType) UnmarshalJSON

func (p *UserType) UnmarshalJSON(b []byte) error

type VideoBlock

type VideoBlock struct {
	Video FileDescriptor `json:"image"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL