notion

package
v0.0.0-...-9aa71bc Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockTypeEnumParagraph        = "paragraph"
	BlockTypeEnumHeading1         = "heading_1"
	BlockTypeEnumHeading2         = "heading_2"
	BlockTypeEnumHeading3         = "heading_3"
	BlockTypeEnumBulletedListItem = "bulleted_list_item"
	BlockTypeEnumNumberedListItem = "numbered_list_item"
	BlockTypeEnumToDo             = "to_do"
	BlockTypeEnumToggle           = "toggle"
	BlockTypeEnumChildPage        = "child_page"
	BlockTypeEnumUnsupported      = "unsupported"
)

These constants represent the valid type enums for a block type

View Source
const (
	DatabasePropertyTypeEnumTitle          = "title"
	DatabasePropertyTypeEnumRichText       = "rich_text"
	DatabasePropertyTypeEnumNumber         = "number"
	DatabasePropertyTypeEnumSelect         = "select"
	DatabasePropertyTypeEnumMultiSelect    = "multi_select"
	DatabasePropertyTypeEnumDate           = "date"
	DatabasePropertyTypeEnumPeople         = "people"
	DatabasePropertyTypeEnumFile           = "file"
	DatabasePropertyTypeEnumCheckbox       = "checkbox"
	DatabasePropertyTypeEnumURL            = "url"
	DatabasePropertyTypeEnumEmail          = "email"
	DatabasePropertyTypeEnumPhoneNumber    = "phone_number"
	DatabasePropertyTypeEnumFormula        = "formula"
	DatabasePropertyTypeEnumRelation       = "relation"
	DatabasePropertyTypeEnumRollup         = "rollup"
	DatabasePropertyTypeEnumCreatedTime    = "created_time"
	DatabasePropertyTypeEnumLastEditedTime = "last_edited_time"
	DatabasePropertyTypeEnumLastEditedBy   = "last_edited_by"

	SelectColorEnumDefault = "default"
	SelectColorEnumGray    = "gray"
	SelectColorEnumBrown   = "brown"
	SelectColorEnumOrange  = "orange"
	SelectColorEnumYellow  = "yellow"
	SelectColorEnumGreen   = "green"
	SelectColorEnumBlue    = "blue"
	SelectColorEnumPurple  = "purple"
	SelectColorEnumPink    = "pink"
	SelectColorEnumRed     = "red"

	RollupFunctionEnumCountAll          = "count_all"
	RollupFunctionEnumCountValues       = "count_values"
	RollupFunctionEnumCountUniqueValues = "count_unique_values"
	RollupFunctionEnumCountEmpty        = "count_empty"
	RollupFunctionEnumCountNotEmpty     = "count_not_empty"
	RollupFunctionEnumPercentEmpty      = "percent_empty"
	RollupFunctionEnumPercentNotEmpty   = "percent_not_empty"
	RollupFunctionEnumSum               = "sum"
	RollupFunctionEnumAverage           = "average"
	RollupFunctionEnumMedian            = "median"
	RollupFunctionEnumMin               = "min"
	RollupFunctionEnumMax               = "max"
	RollupFunctionEnumRange             = "range"
	RollupFunctionEnumShowOriginal      = "show_original"

	NumberConfigurationTypeEnumNumber           = "number"
	NumberConfigurationTypeEnumNumberWithCommas = "number_with_commas"
	NumberConfigurationTypeEnumPercent          = "percent"
	NumberConfigurationTypeEnumDollar           = "dollar"
	NumberConfigurationTypeEnumEuro             = "euro"
	NumberConfigurationTypeEnumPound            = "pound"
	NumberConfigurationTypeEnumYen              = "yen"
	NumberConfigurationTypeEnumRuble            = "ruble"
	NumberConfigurationTypeEnumRupee            = "rupee"
	NumberConfigurationTypeEnumWon              = "won"
	NumberConfigurationTypeEnumYuan             = "yuan"
)

These represent the valid enums for database properties int the Notion API

View Source
const (
	ErrorCodeInvalidJSON        = "invalid_json"
	ErrorCodeInvalidRequestURL  = "invalid_request_url"
	ErrorCodeInvalidRequest     = "invalid_request"
	ErrorCodeValidationError    = "validation_error"
	ErrorCodeUnauthorized       = "unauthorized"
	ErrorCodeRestrictedResource = "restricted_resource"
	ErrorCodeObjectNotFound     = "object_not_found"
	ErrorCodeConflict           = "conflict_error"
	ErrorCodeRateLimited        = "rate_limited"
	ErrorCodeInternalError      = "internal_server_error"
	ErrorCodeServiceUnavailable = "service_unavailable"
)

These constants represent the error codes one can get from the Notion API.

View Source
const (
	FilterConditionTypeEnumText        = "text"
	FilterConditionTypeEnumNumber      = "number"
	FilterConditionTypeEnumCheckbox    = "checkbox"
	FilterConditionTypeEnumSelect      = "select"
	FilterConditionTypeEnumMultiSelect = "multi_select"
	FilterConditionTypeEnumDate        = "date"
	FilterConditionTypeEnumPeople      = "people"
	FilterConditionTypeEnumFiles       = "files"
	FilterConditionTypeEnumRelation    = "relation"
	FilterConditionTypeEnumFormula     = "formula"
	FilterConditionTypeEnumObject      = "object"

	FilterTextConditionEnumEquals         = "equals"
	FilterTextConditionEnumDoesNotEqual   = "does_not_equal"
	FilterTextConditionEnumContains       = "contains"
	FilterTextConditionEnumDoesNotContain = "does_not_contain"
	FilterTextConditionEnumStartsWith     = "starts_with"
	FilterTextConditionEnumEndWith        = "ends_with"
	FilterTextConditionEnumIsEmpty        = "is_empty"
	FilterTextConditionEnumIsNotEmpty     = "is_not_empty"

	FilterNumberConditionEnumEquals               = "equals"
	FilterNumberConditionEnumDoesNotEqual         = "does_not_equal"
	FilterNumberConditionEnumGreaterThan          = "greater_than"
	FilterNumberConditionEnumLessThan             = "less_than"
	FilterNumberConditionEnumGreaterThanOrEqualTo = "greater_than_or_equal_to"
	FilterNumberConditionEnumLessThanOrEqualTo    = "less_than_or_equal_to"
	FilterNumberConditionEnumIsEmpty              = "is_empty"
	FilterNumberConditionEnumIsNotEmpty           = "is_not_empty"

	FilterCheckboxConditionEnumEquals       = "equals"
	FilterCheckboxConditionEnumDoesNotEqual = "does_not_equal"

	FilterSelectConditionEnumEquals       = "equals"
	FilterSelectConditionEnumDoesNotEqual = "does_not_equal"
	FilterSelectConditionEnumIsEmpty      = "is_empty"
	FilterSelectConditionEnumIsNotEmpty   = "is_not_empty"

	FilterMultiSelectConditionEnumContains       = "contains"
	FilterMultiSelectConditionEnumDoesNotContain = "does_not_contain"
	FilterMultiSelectConditionEnumIsEmpty        = "is_empty"
	FilterMultiSelectConditionEnumIsNotEmpty     = "is_not_empty"

	FilterDateConditionEnumEquals     = "equals"
	FilterDateConditionEnumBefore     = "before"
	FilterDateConditionEnumAfter      = "after"
	FilterDateConditionEnumOnOrBefore = "on_or_before"
	FilterDateConditionEnumOnOrAfter  = "on_or_after"
	FilterDateConditionEnumIsEmpty    = "is_empty"
	FilterDateConditionEnumIsNotEmpty = "is_not_empty"
	FilterDateConditionEnumPastWeek   = "past_week"
	FilterDateConditionEnumPastMonth  = "past_month"
	FilterDateConditionEnumPastYear   = "past_year"
	FilterDateConditionEnumNextWeek   = "next_week"
	FilterDateConditionEnumNextMonth  = "next_month"
	FilterDateConditionEnumNextYear   = "next_year"

	FilterPeopleConditionEnumContains       = "contains"
	FilterPeopleConditionEnumDoesNotContain = "does_not_contain"
	FilterPeopleConditionEnumIsEmpty        = "is_empty"
	FilterPeopleConditionEnumIsNotEmpty     = "is_not_empty"

	FilterFilesConditionEnumIsEmpty    = "is_empty"
	FilterFilesConditionEnumIsNotEmpty = "is_not_empty"

	FilterRelationConditionEnumContains       = "contains"
	FilterRelationConditionEnumDoesNotContain = "does_not_contain"
	FilterRelationConditionEnumIsEmpty        = "is_empty"
	FilterRelationConditionEnumIsNotEmpty     = "is_not_empty"

	FilterFormulaConditionEnumText     = "text"
	FilterFormulaConditionEnumCheckbox = "checkbox"
	FilterFormulaConditionEnumNumber   = "number"
	FilterFormulaConditionEnumDate     = "date"

	FilterObjectConditionEnumPage     = "page"
	FilterObjectConditionEnumDatabase = "database"
)

These constants represent valid enum values for filter objects in the Notion API.

View Source
const (
	IconTypeEnumFile  = "file"
	IconTypeEnumEmoji = "emoji"
)
View Source
const (
	ParentTypeEnumWorkspace = "workspace"
	ParentTypeEnumPage      = "page_id"
	ParentTypeEnumDatabase  = "database_id"

	FormulaTypeEnumString  = "string"
	FormulaTypeEnumNumber  = "number"
	FormulaTypeEnumBoolean = "boolean"
	FormulaTypeEnumDate    = "date"

	RollupValueTypeEnumNumber = "number"
	RollupValueTypeEnumDate   = "date"
	RollupValueTypeEnumArray  = "array"

	FileTypeEnumFile     = "file"
	FileTypeEnumExternal = "external"
)

These represent the enum types for pages in the Notion API.

View Source
const (
	RichTextTypeEnumText     = "text"
	RichTextTypeEnumMention  = "mention"
	RichTextTypeEnumEquation = "equation"

	AnnotationColorEnumDefault          = "default"
	AnnotationColorEnumGray             = "gray"
	AnnotationColorEnumBrown            = "brown"
	AnnotationColorEnumOrange           = "orange"
	AnnotationColorEnumYellow           = "yellow"
	AnnotationColorEnumGreen            = "green"
	AnnotationColorEnumBlue             = "blue"
	AnnotationColorEnumPurple           = "purple"
	AnnotationColorEnumPink             = "pink"
	AnnotationColorEnumRed              = "red"
	AnnotationColorEnumGrayBackground   = "gray_background"
	AnnotationColorEnumBrownBackground  = "brown_background"
	AnnotationColorEnumOrangeBackground = "orange_background"
	AnnotationColorEnumYellowBackground = "yellow_background"
	AnnotationColorEnumGreenBackground  = "green_background"
	AnnotationColorEnumBlueBackground   = "blue_background"
	AnnotationColorEnumPurpleBackground = "purple_background"
	AnnotationColorEnumPinkBackground   = "pink_background"
	AnnotationColorEnumRedBackground    = "red_background"

	MentionTypeEnumUser     = "user"
	MentionTypeEnumPage     = "page"
	MentionTypeEnumDatabase = "database"
	MentionTypeEnumData     = "date"
)

These constants represent the enums in the Notion API for rich_text objects

View Source
const (
	SortTimestampEnumCreatedTime    = "created_time"
	SortTimestampEnumLastEditedTime = "last_edited_time"

	SortDirectionEnumAscending  = "ascending"
	SortDirectionEnumDescending = "descending"
)

These represent valid enum values for sort objects in the Notion API.

View Source
const (
	UserTypeEnumPerson = "person"
	UserTypeEnumBot    = "bot"
)

These constants represent the valid enum types for users in the Notion API.

Variables

View Source
var Versions = []string{
	"2021-05-13",
	"2021-08-16",
}

Versions holds a list of all valid versions of the Notion API.

Functions

func IsAPIErrorWithCode

func IsAPIErrorWithCode(err error, code string) bool

IsAPIErrorWithCode returns true if the error is a Notion APIError and has the given code

func IsConflictError

func IsConflictError(err error) bool

IsConflictError returns true if the error is an APIError and has the "conflict_error" code

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the error is an APIError and has the "object_not_found" code

func IsRateLimitError

func IsRateLimitError(err error) bool

IsRateLimitError returns true if the error is an APIError and has the "rate_limited" code

Types

type APIError

type APIError struct {
	Status  int    `json:"status"`
	Code    string `json:"code"`
	Message string `json:"message"`
}

APIError is an error from the Notion API

func (APIError) Error

func (a APIError) Error() string

Error implements the error interface for APIError

type AnnotationColorEnum

type AnnotationColorEnum string

AnnotationColorEnum represents the colors of a rich_text object in the Notion API.

func (*AnnotationColorEnum) IsValidEnum

func (ace *AnnotationColorEnum) IsValidEnum() bool

IsValidEnum returns true if the provided string represents a valid color in the Notion API.

func (*AnnotationColorEnum) SetValue

func (ace *AnnotationColorEnum) SetValue(s string)

SetValue sets the AnnotationColorEnum to the given string

func (*AnnotationColorEnum) UnmarshalJSON

func (ace *AnnotationColorEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the provided string is not a valid AnnotationColorEnum

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         AnnotationColorEnum `json:"color"`
}

Annotations are the annotations on a rich_text object in the Notion API.

type Block

type Block struct {
	Object
	Editable
	Type        BlockTypeEnum `json:"type"`
	HasChildren bool          `json:"has_children"`
	Archived    bool          `json:"archived"`
	Text        []*RichText   `json:"text,omitempty"`
	Children    []*Block      `json:"children,omitempty"`
	// Only valid for To Do blocks
	Checked *bool `json:"checked,omitempty"`
	// Only valid for Child Page blocks
	Title *string `json:"title,omitempty"`
}

Block represents the common fields in a "block" in Notion (i.e. text, headings, list, etc)

func (*Block) GetTitle

func (b *Block) GetTitle() string

GetTitle returns the title of the Block if the Block is a child_page Block, and returns the empty string otherwise

func (*Block) IsChecked

func (b *Block) IsChecked() bool

IsChecked returns true if the Block is a To Do block and it is checked, and returns false otherwise

func (*Block) MarshalJSON

func (b *Block) MarshalJSON() ([]byte, error)

MarshalJSON returns a marshaled version of the Block that is compatible with the Notion API.

func (*Block) UnmarshalJSON

func (b *Block) UnmarshalJSON(bt []byte) error

UnmarshalJSON sets the JSON object based on the Type of the Block object. Text and Children are set based on the Type of the Block.

type BlockTypeEnum

type BlockTypeEnum string

A BlockTypeEnum represents a type of a block in the Notion API.

func (*BlockTypeEnum) IsValidEnum

func (bte *BlockTypeEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid type of a block object in the Notion API.

func (*BlockTypeEnum) SetValue

func (bte *BlockTypeEnum) SetValue(s string)

SetValue sets the BlockTypeEnum to the given string

func (*BlockTypeEnum) UnmarshalJSON

func (bte *BlockTypeEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the provided string is not a valid BlockTypeEnum in the Notion API.

type Blocks

type Blocks []*Block

Blocks represents a list of users from the Notion API.

func (*Blocks) Len

func (bs *Blocks) Len() int

Len returns the number of blocks in the the slice.

func (*Blocks) UnmarshalJSON

func (bs *Blocks) UnmarshalJSON(bt []byte) error

UnmarshalJSON appends the unmarshaled Blocks to the slice.

type CheckboxFilter

type CheckboxFilter struct {
	EmptyFilter
	Type  FilterCheckboxConditionEnum
	Value *bool
}

A CheckboxFilter represents a filter object with which to query a database in the Notion API.

func (*CheckboxFilter) MarshalJSON

func (cf *CheckboxFilter) MarshalJSON() ([]byte, error)

MarshalJSON prepares the filter to be compatible with the Notion API.

type CompoundFilter

type CompoundFilter struct {
	Or  []*Filter `json:"or,omitempty"`
	And []*Filter `json:"and,omitempty"`
}

A CompoundFilter represents a compound filter object with which to query a database in the Notion API. TODO: nested compound filters are not yet implemented.

type Database

type Database struct {
	Object
	Editable
	Icons
	Title      []RichText         `json:"title"`
	Properties DatabaseProperties `json:"properties"`
	Children   Blocks             `json:"-"`
	Parent     Parent             `json:"parent"`
	URL        *jsonURL           `json:"url"`
}

A Database represents a database object in the Notion API

type DatabaseProperties

type DatabaseProperties []*DatabaseProperty

DatabaseProperties is a short-hand type for a slice of DatabaseProperty, used for (un)marshaling purposes

func (*DatabaseProperties) MarshalJSON

func (dbps *DatabaseProperties) MarshalJSON() ([]byte, error)

MarshalJSON marshals the database properties into a form that is compatible with the Notion API.

func (*DatabaseProperties) UnmarshalJSON

func (dbps *DatabaseProperties) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the database properties from a "javascript" style to a more "go" style

type DatabaseProperty

type DatabaseProperty struct {
	Name              string
	ID                string                       `json:"id"`
	Type              DatabasePropertyTypeEnum     `json:"type"`
	NumberFormat      *NumberConfigurationTypeEnum `json:"format,omitempty"`
	SelectOptions     []SelectOption               `json:"options,omitempty"`
	FormulaExpression *string                      `json:"expression,omitempty"`
	Relation          *Relation                    `json:"relation,omitempty"`
	Rollup            *Rollup                      `json:"rollup_configuration,omitempty"`
}

DatabaseProperty represents the properties of the items in a database

func (*DatabaseProperty) GetName

func (dp *DatabaseProperty) GetName() string

GetName returns the name of the database property

func (*DatabaseProperty) MarshalJSON

func (dp *DatabaseProperty) MarshalJSON() ([]byte, error)

MarshalJSON returns a marshaled version of the Block that is compatible with the Notion API.

func (*DatabaseProperty) UnmarshalJSON

func (dp *DatabaseProperty) UnmarshalJSON(bt []byte) error

UnmarshalJSON sets the JSON object based on the Type of the DatabaseProperty object.

type DatabasePropertyTypeEnum

type DatabasePropertyTypeEnum string

A DatabasePropertyTypeEnum represents a valid database property type in the Notion API.

func (*DatabasePropertyTypeEnum) IsValidEnum

func (dbte *DatabasePropertyTypeEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid DatabasePropertyTypeEnum in the Notion API.

func (*DatabasePropertyTypeEnum) SetValue

func (dbte *DatabasePropertyTypeEnum) SetValue(s string)

SetValue sets the DatabasePropertyTypeEnum to the given string

func (*DatabasePropertyTypeEnum) UnmarshalJSON

func (dbte *DatabasePropertyTypeEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON verifies that the string is a valid DatabasePropertyTypeEnum for the Notion API.

type Databases

type Databases []*Database

Databases represents a list of users from the Notion API.

func (*Databases) Len

func (dbs *Databases) Len() int

Len returns the number of blocks in the the slice.

func (*Databases) UnmarshalJSON

func (dbs *Databases) UnmarshalJSON(b []byte) error

UnmarshalJSON appends the unmarshaled Databases to the slice.

type Date

type Date struct {
	Start   time.Time `json:"start"`
	End     time.Time `json:"end,omitempty"`
	HasTime bool      `json:"-"`
}

A Date object represents a date with a start and end date/time in the Notion API.

func (*Date) MarshalJSON

func (d *Date) MarshalJSON() ([]byte, error)

MarshalJSON marshals the date and time to one compatible with the Notion API.

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the date based on whether or not it has a time associated.

type DateFilter

type DateFilter struct {
	EmptyFilter
	Type  FilterDateConditionEnum
	Value time.Time
}

A DateFilter represents a filter object with which to query a database in the Notion API.

func (*DateFilter) MarshalJSON

func (df *DateFilter) MarshalJSON() ([]byte, error)

MarshalJSON prepares the filter to be compatible with the Notion API.

type Editable

type Editable struct {
	CreatedTime    time.Time `json:"created_time,omitempty"`
	LastEditedTime time.Time `json:"last_edited_time,omitempty"`
}

An Editable represents all objects in the Notion API that have a "created" and "last updated" time.

func (*Editable) MarshalJSON

func (e *Editable) MarshalJSON() ([]byte, error)

MarshalJSON marshals the date and time to one compatible with the Notion API.

type EmptyFilter

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

The EmptyFilter is one where a property can be filter on whether or not it is empty.

type Equation

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

An Equation represents an equation in a rich_text object in the Notion API.

type File

type File struct {
	Name       string       `json:"name"`
	Type       FileTypeEnum `json:"type"`
	URL        *jsonURL     `json:"url"`
	ExpiryTime time.Time    `json:"expiry_time,omitempty"`
}

A File represents a file property of a page in a database in the Notion API.

func (*File) MarshalJSON

func (f *File) MarshalJSON() ([]byte, error)

MarshalJSON marshals the File to be compatible with the Notion API.

func (*File) UnmarshalJSON

func (f *File) UnmarshalJSON(b []byte) error

UnmarshalJSON flattens the page property by its type

type FileTypeEnum

type FileTypeEnum string

FileTypeEnum represents a file type in the Notion API.

func (*FileTypeEnum) IsValidEnum

func (pte *FileTypeEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid FileTypeEnum in the Notion API.

func (*FileTypeEnum) SetValue

func (pte *FileTypeEnum) SetValue(s string)

SetValue sets the FileTypeEnum to the given string

func (*FileTypeEnum) UnmarshalJSON

func (pte *FileTypeEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the type is not a valid enum in the Notion API.

type FilesFilter

type FilesFilter struct {
	EmptyFilter
	Type FilterFilesConditionEnum
}

A FilesFilter represents a filter object with which to query a database in the Notion API.

func (*FilesFilter) MarshalJSON

func (ff *FilesFilter) MarshalJSON() ([]byte, error)

MarshalJSON prepares the filter to be compatible with the Notion API.

type Filter

type Filter struct {
	// All that is required for the "property" field is the name or id of the property,
	// but allowing to pass the whole property is more flexible. Just requires custom (un)marshaling.
	Property    DatabaseProperty
	Type        FilterConditionTypeEnum `json:"type"`
	Text        *TextFilter             `json:"text,omitempty"`
	Number      *NumberFilter           `json:"number,omitempty"`
	Checkbox    *CheckboxFilter         `json:"checkbox,omitempty"`
	Select      *SelectFilter           `json:"select,omitempty"`
	MultiSelect *MultiSelectFilter      `json:"multi_select,omitempty"`
	Date        *DateFilter             `json:"date,omitempty"`
	People      *PeopleFilter           `json:"people,omitempty"`
	Files       *FilesFilter            `json:"files,omitempty"`
	Relation    *RelationFilter         `json:"relation,omitempty"`
	Formula     *FormulaFilter          `json:"formula,omitempty"`
}

A Filter represents a filter object with which to query a database in the Notion API.

func (*Filter) MarshalJSON

func (f *Filter) MarshalJSON() ([]byte, error)

MarshalJSON prepares the filter to be compatible with the Notion API.

type FilterCheckboxConditionEnum

type FilterCheckboxConditionEnum string

A FilterCheckboxConditionEnum represents a valid text filter in the Notion API.

func (*FilterCheckboxConditionEnum) IsValidEnum

func (fcce *FilterCheckboxConditionEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid FilterCheckboxConditionEnum in the Notion API.

func (*FilterCheckboxConditionEnum) SetValue

func (fcce *FilterCheckboxConditionEnum) SetValue(s string)

SetValue sets the FilterCheckboxConditionEnum to the given string

func (*FilterCheckboxConditionEnum) UnmarshalJSON

func (fcce *FilterCheckboxConditionEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the string is not a valid FilterCheckboxConditionEnum in the Notion API.

type FilterConditionTypeEnum

type FilterConditionTypeEnum string

A FilterConditionTypeEnum represents the valid filter types in the Notion API.

func (*FilterConditionTypeEnum) IsValidEnum

func (fcte *FilterConditionTypeEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid FilterConditionTypeEnum in the Notion API.

func (*FilterConditionTypeEnum) SetValue

func (fcte *FilterConditionTypeEnum) SetValue(s string)

SetValue sets the FilterConditionTypeEnum to the given string

func (*FilterConditionTypeEnum) UnmarshalJSON

func (fcte *FilterConditionTypeEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the string is not a valid FilterConditionTypeEnum in the Notion API.

type FilterDateConditionEnum

type FilterDateConditionEnum string

A FilterDateConditionEnum represents a valid text filter in the Notion API.

func (*FilterDateConditionEnum) IsValidEnum

func (fdce *FilterDateConditionEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid FilterDateConditionEnum in the Notion API.

func (*FilterDateConditionEnum) SetValue

func (fdce *FilterDateConditionEnum) SetValue(s string)

SetValue sets the FilterDateConditionEnum to the given string

func (*FilterDateConditionEnum) UnmarshalJSON

func (fdce *FilterDateConditionEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the string is not a valid FilterDateConditionEnum in the Notion API.

type FilterFilesConditionEnum

type FilterFilesConditionEnum string

A FilterFilesConditionEnum represents a valid text filter in the Notion API.

func (*FilterFilesConditionEnum) IsValidEnum

func (ffce *FilterFilesConditionEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid FilterFilesConditionEnum in the Notion API.

func (*FilterFilesConditionEnum) SetValue

func (ffce *FilterFilesConditionEnum) SetValue(s string)

SetValue sets the FilterFilesConditionEnum to the given string

func (*FilterFilesConditionEnum) UnmarshalJSON

func (ffce *FilterFilesConditionEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the string is not a valid FilterFilesConditionEnum in the Notion API.

type FilterFormulaConditionEnum

type FilterFormulaConditionEnum string

A FilterFormulaConditionEnum represents a valid text filter in the Notion API.

func (*FilterFormulaConditionEnum) IsValidEnum

func (ffce *FilterFormulaConditionEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid FilterFormulaConditionEnum in the Notion API.

func (*FilterFormulaConditionEnum) SetValue

func (ffce *FilterFormulaConditionEnum) SetValue(s string)

SetValue sets the FilterFormulaConditionEnum to the given string

func (*FilterFormulaConditionEnum) UnmarshalJSON

func (ffce *FilterFormulaConditionEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the string is not a valid FilterFormulaConditionEnum in the Notion API.

type FilterMultiSelectConditionEnum

type FilterMultiSelectConditionEnum string

A FilterMultiSelectConditionEnum represents a valid text filter in the Notion API.

func (*FilterMultiSelectConditionEnum) IsValidEnum

func (fmce *FilterMultiSelectConditionEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid FilterMultiSelectConditionEnum in the Notion API.

func (*FilterMultiSelectConditionEnum) SetValue

func (fmce *FilterMultiSelectConditionEnum) SetValue(s string)

SetValue sets the FilterMultiSelectConditionEnum to the given string

func (*FilterMultiSelectConditionEnum) UnmarshalJSON

func (fmce *FilterMultiSelectConditionEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the string is not a valid FilterMultiSelectConditionEnum in the Notion API.

type FilterNumberConditionEnum

type FilterNumberConditionEnum string

A FilterNumberConditionEnum represents a valid text filter in the Notion API.

func (*FilterNumberConditionEnum) IsValidEnum

func (fnce *FilterNumberConditionEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid FilterNumberConditionEnum in the Notion API.

func (*FilterNumberConditionEnum) SetValue

func (fnce *FilterNumberConditionEnum) SetValue(s string)

SetValue sets the FilterNumberConditionEnum to the given string

func (*FilterNumberConditionEnum) UnmarshalJSON

func (fnce *FilterNumberConditionEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the string is not a valid FilterNumberConditionEnum in the Notion API.

type FilterObjectConditionEnum

type FilterObjectConditionEnum string

A FilterObjectConditionEnum represents a valid text filter in the Notion API.

func (*FilterObjectConditionEnum) IsValidEnum

func (ofce *FilterObjectConditionEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid FilterObjectConditionEnum in the Notion API.

func (*FilterObjectConditionEnum) SetValue

func (ofce *FilterObjectConditionEnum) SetValue(s string)

SetValue sets the FilterObjectConditionEnum to the given string

func (*FilterObjectConditionEnum) UnmarshalJSON

func (ofce *FilterObjectConditionEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the string is not a valid FilterObjectConditionEnum in the Notion API.

type FilterPeopleConditionEnum

type FilterPeopleConditionEnum string

A FilterPeopleConditionEnum represents a valid text filter in the Notion API.

func (*FilterPeopleConditionEnum) IsValidEnum

func (fpce *FilterPeopleConditionEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid FilterPeopleConditionEnum in the Notion API.

func (*FilterPeopleConditionEnum) SetValue

func (fpce *FilterPeopleConditionEnum) SetValue(s string)

SetValue sets the FilterPeopleConditionEnum to the given string

func (*FilterPeopleConditionEnum) UnmarshalJSON

func (fpce *FilterPeopleConditionEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the string is not a valid FilterPeopleConditionEnum in the Notion API.

type FilterRelationConditionEnum

type FilterRelationConditionEnum string

A FilterRelationConditionEnum represents a valid text filter in the Notion API.

func (*FilterRelationConditionEnum) IsValidEnum

func (frce *FilterRelationConditionEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid FilterRelationConditionEnum in the Notion API.

func (*FilterRelationConditionEnum) SetValue

func (frce *FilterRelationConditionEnum) SetValue(s string)

SetValue sets the FilterRelationConditionEnum to the given string

func (*FilterRelationConditionEnum) UnmarshalJSON

func (frce *FilterRelationConditionEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the string is not a valid FilterRelationConditionEnum in the Notion API.

type FilterSelectConditionEnum

type FilterSelectConditionEnum string

A FilterSelectConditionEnum represents a valid text filter in the Notion API.

func (*FilterSelectConditionEnum) IsValidEnum

func (fsce *FilterSelectConditionEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid FilterSelectConditionEnum in the Notion API.

func (*FilterSelectConditionEnum) SetValue

func (fsce *FilterSelectConditionEnum) SetValue(s string)

SetValue sets the FilterSelectConditionEnum to the given string

func (*FilterSelectConditionEnum) UnmarshalJSON

func (fsce *FilterSelectConditionEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the string is not a valid FilterSelectConditionEnum in the Notion API.

type FilterTextConditionEnum

type FilterTextConditionEnum string

A FilterTextConditionEnum represents a valid text filter in the Notion API.

func (*FilterTextConditionEnum) IsValidEnum

func (ftce *FilterTextConditionEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid FilterTextConditionEnum in the Notion API.

func (*FilterTextConditionEnum) SetValue

func (ftce *FilterTextConditionEnum) SetValue(s string)

SetValue sets the FilterTextConditionEnum to the given string

func (*FilterTextConditionEnum) UnmarshalJSON

func (ftce *FilterTextConditionEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the string is not a valid FilterTextConditionEnum in the Notion API.

type Formula

type Formula struct {
	Type    FormulaTypeEnum `json:"type"`
	String  *string         `json:"string,omitempty"`
	Number  *float64        `json:"number,omitempty"`
	Boolean *bool           `json:"boolean,omitempty"`
	Date    *Date           `json:"date,omitempty"`
}

Formula represents a formula entry in a page in the Notion API.

func (*Formula) MarshalJSON

func (f *Formula) MarshalJSON() ([]byte, error)

MarshalJSON expands the formula by its type to be compatible with the Notion API.

type FormulaFilter

type FormulaFilter struct {
	Type     FilterFormulaConditionEnum `json:"-"`
	Text     *TextFilter                `json:"text,omitempty"`
	Checkbox *CheckboxFilter            `json:"checkbox,omitempty"`
	Number   *NumberFilter              `json:"number,omitempty"`
	Date     *DateFilter                `json:"date,omitempty"`
}

A FormulaFilter represents a filter object with which to query a database in the Notion API.

type FormulaTypeEnum

type FormulaTypeEnum string

FormulaTypeEnum represents the parent type in the Notion API.

func (*FormulaTypeEnum) IsValidEnum

func (fte *FormulaTypeEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid FormulaTypeEnum in the Notion API.

func (*FormulaTypeEnum) SetValue

func (fte *FormulaTypeEnum) SetValue(s string)

SetValue sets the FormulaTypeEnum to the given string

func (*FormulaTypeEnum) UnmarshalJSON

func (fte *FormulaTypeEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the type is not a valid enum in the Notion API.

type Icon

type Icon struct {
	Type  IconTypeEnum `json:"type"`
	Emoji string       `json:"emoji,omitempty"`
	File  File         `json:"file,omitempty"`
}

An Icon represents a page or database icon in the Notion API

func (*Icon) MarshalJSON

func (i *Icon) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Icon to be compatible with the Notion API.

func (*Icon) UnmarshalJSON

func (i *Icon) UnmarshalJSON(b []byte) error

UnmarshalJSON flattens the icon by its type

type IconTypeEnum

type IconTypeEnum string

IconTypeEnum represents an icon type in the Notion API.

func (*IconTypeEnum) IsValidEnum

func (ite *IconTypeEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid IconTypeEnum in the Notion API.

func (*IconTypeEnum) SetValue

func (ite *IconTypeEnum) SetValue(s string)

SetValue sets the IconTypeEnum to the given string

func (*IconTypeEnum) UnmarshalJSON

func (ite *IconTypeEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the type is not a valid enum in the Notion API.

type Icons

type Icons struct {
	Cover File `json:"cover,omitempty"`
	Icon  Icon `json:"icon,omitempty"`
}

Icons represents the icon and cover icon for pages and databases in the Notion API

type InvalidEnumError

type InvalidEnumError struct {
	Enum, InvalidValue string
}

InvalidEnumError represents an invalid enum value for a given enum

func NewInvalidEnumError

func NewInvalidEnumError(enum, invalidValue string) *InvalidEnumError

NewInvalidEnumError returns an error value representing an invalid value for the given enum.

func (*InvalidEnumError) Error

func (i *InvalidEnumError) Error() string

Error turns an InvalidEnumError into an error

type Link struct {
	URL jsonURL `json:"url"`
}

Link type represents a link in a rich_text object in the Notion API.

func (*Link) MarshalJSON

func (l *Link) MarshalJSON() ([]byte, error)

MarshalJSON marshals a Link object, always setting the `type` parameter to "url"

type Mention

type Mention struct {
	Type MentionTypeEnum `json:"type"`
	User *User           `json:"user,omitempty"`
	Ref  *UUID4          `json:"id,omitempty"`
	Date *Date           `json:"date,omitempty"`
}

A Mention represents a mention object in a rich_text object in the Notion API.

func (*Mention) MarshalJSON

func (m *Mention) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Mention object to be compatible with the Notion API.

func (*Mention) UnmarshalJSON

func (m *Mention) UnmarshalJSON(b []byte) error

UnmarshalJSON parses the Mention object, flattening the page or database reference into the Ref parameter

type MentionTypeEnum

type MentionTypeEnum string

MentionTypeEnum represents the valid mention types in the Notion API.

func (*MentionTypeEnum) IsValidEnum

func (mte *MentionTypeEnum) IsValidEnum() bool

IsValidEnum returns true if the provided string represents a valid mention type in the Notion API.

func (*MentionTypeEnum) SetValue

func (mte *MentionTypeEnum) SetValue(s string)

SetValue sets the MentionTypeEnum to the given string

func (*MentionTypeEnum) UnmarshalJSON

func (mte *MentionTypeEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the provided string is not a valid MentionTypeEnum

type MultiSelectFilter

type MultiSelectFilter struct {
	EmptyFilter
	Type  FilterMultiSelectConditionEnum
	Value *string
}

A MultiSelectFilter represents a filter object with which to query a database in the Notion API.

func (*MultiSelectFilter) MarshalJSON

func (mf *MultiSelectFilter) MarshalJSON() ([]byte, error)

MarshalJSON prepares the filter to be compatible with the Notion API.

type NumberConfigurationTypeEnum

type NumberConfigurationTypeEnum string

NumberConfigurationTypeEnum represents a number type in a database in the Notion API.

func (*NumberConfigurationTypeEnum) IsValidEnum

func (ncte *NumberConfigurationTypeEnum) IsValidEnum() bool

IsValidEnum returns true if the string is a valid NumberConfigurationTypeEnum in the Notion API.

func (*NumberConfigurationTypeEnum) SetValue

func (ncte *NumberConfigurationTypeEnum) SetValue(s string)

SetValue sets the NumberConfigurationTypeEnum to the given string

func (*NumberConfigurationTypeEnum) UnmarshalJSON

func (ncte *NumberConfigurationTypeEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON verifies that the string is a valid NumberConfigurationTypeEnum in the Notion API

type NumberFilter

type NumberFilter struct {
	EmptyFilter
	Type  FilterNumberConditionEnum
	Value *float64
}

A NumberFilter represents a filter object with which to query a database in the Notion API.

func (*NumberFilter) MarshalJSON

func (nf *NumberFilter) MarshalJSON() ([]byte, error)

MarshalJSON prepares the filter to be compatible with the Notion API.

type Object

type Object struct {
	ID     UUID4  `json:"id,omitempty"`
	Object string `json:"object,omitempty"`
}

An Object represents all the fields that are common to all objects in the Notion API.

type ObjectFilter

type ObjectFilter struct {
	Type  FilterObjectConditionEnum
	Value *string
}

A ObjectFilter represents a filter object with which to query a database in the Notion API.

func (*ObjectFilter) MarshalJSON

func (of *ObjectFilter) MarshalJSON() ([]byte, error)

MarshalJSON prepares the filter to be compatible with the Notion API.

type Page

type Page struct {
	Object
	Editable
	Icons
	Archived   bool           `json:"archived"`
	Parent     Parent         `json:"parent"`
	Properties PageProperties `json:"properties"`
	Children   Blocks         `json:"children,omitempty"`
	URL        *jsonURL       `json:"url"`
}

A Page represents a page object in the Notion API.

type PageProperties

type PageProperties []*PageProperty

PageProperties represents the properties of a page in a database in the Notion API.

func (*PageProperties) MarshalJSON

func (pps *PageProperties) MarshalJSON() ([]byte, error)

MarshalJSON marshals the database properties into a form that is compatible with the Notion API.

func (*PageProperties) UnmarshalJSON

func (pps *PageProperties) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the page properties from a "javascript" style to a more "go" style

type PageProperty

type PageProperty struct {
	Editable
	Name         string                   `json:"-"`
	ID           string                   `json:"id,omitempty"`
	Type         DatabasePropertyTypeEnum `json:"type,omitempty"`
	Title        []RichText               `json:"title,omitempty"`
	RichText     []RichText               `json:"rich_text,omitempty"`
	Number       *float64                 `json:"number,omitempty"`
	Select       *SelectOption            `json:"select,omitempty"`
	MultiSelect  []SelectOption           `json:"multi_select,omitempty"`
	Date         *Date                    `json:"date,omitempty"`
	Formula      *Formula                 `json:"formula,omitempty"`
	Relations    Relations                `json:"relation,omitempty"`
	People       []*User                  `json:"people,omitempty"`
	Files        []*File                  `json:"files,omitempty"`
	Checkbox     *bool                    `json:"checkbox,omitempty"`
	URL          *jsonURL                 `json:"url,omitempty"`
	Email        *jsonEmail               `json:"email,omitempty"`
	PhoneNumber  *string                  `json:"phone_number,omitempty"`
	CreatedBy    *User                    `json:"created_by,omitempty"`
	LastEditedBy *User                    `json:"last_edited_by,omitempty"`
}

PageProperty represents a property of a page in a database in the Notion API.

func (*PageProperty) MarshalJSON

func (pp *PageProperty) MarshalJSON() ([]byte, error)

MarshalJSON marshals the page property to be compatible with the Notion API.

func (*PageProperty) UnmarshalJSON

func (pp *PageProperty) UnmarshalJSON(b []byte) error

UnmarshalJSON flattens the page property by its type

type Pages

type Pages []*Page

Pages is a slice of pages from the Notion API.

func (*Pages) Len

func (pgs *Pages) Len() int

Len returns the number of pages in the slice.

func (*Pages) UnmarshalJSON

func (pgs *Pages) UnmarshalJSON(b []byte) error

UnmarshalJSON appends the unmarshaled Users to the slice.

type Parent

type Parent struct {
	Type ParentTypeEnum `json:"type"`
	ID   string
}

Parent represents the parent object of a page in the Notion API.

func (*Parent) MarshalJSON

func (p *Parent) MarshalJSON() ([]byte, error)

MarshalJSON sets the correct type id based on the type.

func (*Parent) UnmarshalJSON

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

UnmarshalJSON sets the ID field based on the parent type

type ParentTypeEnum

type ParentTypeEnum string

ParentTypeEnum represents the parent type in the Notion API.

func (*ParentTypeEnum) IsValidEnum

func (pte *ParentTypeEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid ParentTypeEnum in the Notion API.

func (*ParentTypeEnum) SetValue

func (pte *ParentTypeEnum) SetValue(s string)

SetValue sets the ParentTypeEnum to the given string

func (*ParentTypeEnum) UnmarshalJSON

func (pte *ParentTypeEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the type is not a valid enum in the Notion API.

type PeopleFilter

type PeopleFilter struct {
	EmptyFilter
	Type  FilterPeopleConditionEnum
	Value *UUID4
}

A PeopleFilter represents a filter object with which to query a database in the Notion API.

func (*PeopleFilter) MarshalJSON

func (pf *PeopleFilter) MarshalJSON() ([]byte, error)

MarshalJSON prepares the filter to be compatible with the Notion API.

type Relation

type Relation struct {
	DatabaseID         UUID4   `json:"database_id"`
	SyncedPropertyName *string `json:"synced_property_name,omitempty"`
	SyncedPropertyID   *string `json:"synced_property_id,omitempty"`
}

Relation represents a database relation in the Notion API.

type RelationFilter

type RelationFilter struct {
	EmptyFilter
	Type  FilterRelationConditionEnum
	Value *UUID4
}

A RelationFilter represents a filter object with which to query a database in the Notion API.

func (*RelationFilter) MarshalJSON

func (rf *RelationFilter) MarshalJSON() ([]byte, error)

MarshalJSON prepares the filter to be compatible with the Notion API.

type RelationID

type RelationID UUID4

A RelationID represents a single relation in a page in a database in the Notion API.

func (*RelationID) MarshalJSON

func (rid *RelationID) MarshalJSON() ([]byte, error)

MarshalJSON expands a RelationID to be compatible with the Notion API.

func (*RelationID) UnmarshalJSON

func (rid *RelationID) UnmarshalJSON(b []byte) error

UnmarshalJSON flattens a relation reference for a page in a database in the Notion API.

type Relations

type Relations []*RelationID

Relations represent a set of relations for a page in a database in the Notion API.

type RichText

type RichText struct {
	Type        RichTextTypeEnum `json:"type"`
	HRef        string           `json:"href,omitempty"`
	Annotations Annotations      `json:"annotations"`
	PlainText   string           `json:"plain_text"`
	Text        *Text            `json:"text,omitempty"`
	Mention     *Mention         `json:"mention,omitempty"`
	Equation    *Equation        `json:"equation,omitempty"`
}

RichText represents the common fields in a rich text object in Notion.

type RichTextTypeEnum

type RichTextTypeEnum string

RichTextTypeEnum represents the different types of a rich_text object in the Notion API.

func (*RichTextTypeEnum) IsValidEnum

func (rtte *RichTextTypeEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid rich_text type in the Notion API.

func (*RichTextTypeEnum) SetValue

func (rtte *RichTextTypeEnum) SetValue(s string)

SetValue sets the RichTextTypeEnum to the given string

func (*RichTextTypeEnum) UnmarshalJSON

func (rtte *RichTextTypeEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the provided string is not a valid RichTextTypeEnum

type Rollup

type Rollup 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             RollupFunctionEnumType `json:"function"`
}

Rollup represents a rollup configuration in the Notion API.

type RollupFunctionEnumType

type RollupFunctionEnumType string

RollupFunctionEnumType represents a valid rollup function in a database in the Notion API.

func (*RollupFunctionEnumType) IsValidEnum

func (rfet *RollupFunctionEnumType) IsValidEnum() bool

IsValidEnum returns true if the string is a valid RollupFunctionEnumType in the Notion API.

func (*RollupFunctionEnumType) SetValue

func (rfet *RollupFunctionEnumType) SetValue(s string)

SetValue sets the RollupFunctionEnumType to the given string

func (*RollupFunctionEnumType) UnmarshalJSON

func (rfet *RollupFunctionEnumType) UnmarshalJSON(b []byte) error

UnmarshalJSON verifies that the string is a valid RollupFunctionEnumType for the Notion API.

type RollupValue

type RollupValue struct {
	Type   RollupValueTypeEnum `json:"type"`
	Number *float64            `json:"number,omitempty"`
	Date   *Date               `json:"date,omitempty"`
	Array  []*PageProperty     `json:"array,omitempty"`
}

RollupValue represents the value of a rollup property of a page in a database in the Notion API.

type RollupValueTypeEnum

type RollupValueTypeEnum string

RollupValueTypeEnum represents a valid rollup value type for a page in a database in the Notion API.

func (*RollupValueTypeEnum) IsValidEnum

func (rvte *RollupValueTypeEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid RollupValueTypeEnum in the Notion API.

func (*RollupValueTypeEnum) SetValue

func (rvte *RollupValueTypeEnum) SetValue(s string)

SetValue sets the RollupValueTypeEnum to the given string

func (*RollupValueTypeEnum) UnmarshalJSON

func (rvte *RollupValueTypeEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the type is not a valid enum in the Notion API.

type SelectColorEnum

type SelectColorEnum string

SelectColorEnum represents the valid select colors in the Notion API

func (*SelectColorEnum) IsValidEnum

func (sce *SelectColorEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid SelectColorEnum in the Notion API.

func (*SelectColorEnum) SetValue

func (sce *SelectColorEnum) SetValue(s string)

SetValue sets the SelectColorEnum to the given string

func (*SelectColorEnum) UnmarshalJSON

func (sce *SelectColorEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON verifies that the string is a valid DatabasePropertyTypeEnum for the Notion API.

type SelectFilter

type SelectFilter struct {
	EmptyFilter
	Type  FilterSelectConditionEnum
	Value *string
}

A SelectFilter represents a filter object with which to query a database in the Notion API.

func (*SelectFilter) MarshalJSON

func (sf *SelectFilter) MarshalJSON() ([]byte, error)

MarshalJSON prepares the filter to be compatible with the Notion API.

type SelectOption

type SelectOption struct {
	Name  string          `json:"name"`
	ID    string          `json:"id"`
	Color SelectColorEnum `json:"color"`
}

SelectOption represents the (multi)select options for database properties in the Notion API.

type Settings

type Settings struct {
	APIKey, Version, UserAgent string
}

Settings represents the settings needed to use the Notion API.

func LatestWithAPIKey

func LatestWithAPIKey(apiKey string) *Settings

LatestWithAPIKey returns a Settings struct using the provided API key and the latest version of the Notion API.

func (*Settings) ToHeaders

func (s *Settings) ToHeaders(req *http.Request)

ToHeaders attaches the appropriate header information to the request.

type Sort

type Sort struct {
	Property  *string            `json:"property,omitempty"`
	Timestamp *SortTimestampEnum `json:"timestamp,omitempty"`
	Direction *SortDirectionEnum `json:"direction,omitempty"`
}

A Sort object represents a sort used to query a database in the Notion API.

func NewPropertySort

func NewPropertySort(s string, d SortDirectionEnum) (*Sort, error)

NewPropertySort returns a new Sort object with the provided property as name and the given sort direction

func NewTimestampSort

func NewTimestampSort(t SortTimestampEnum, d SortDirectionEnum) (*Sort, error)

NewTimestampSort returns a new Sort object with the provided timestamp and the given sort direction

type SortDirectionEnum

type SortDirectionEnum string

SortDirectionEnum represents a valid timestamp sort type in the Notion API.

func (*SortDirectionEnum) IsValidEnum

func (sde *SortDirectionEnum) IsValidEnum() bool

IsValidEnum returns true if the provide string represents a valid SortDirectionEnum in the Notion API.

func (*SortDirectionEnum) SetValue

func (sde *SortDirectionEnum) SetValue(s string)

SetValue sets the SortDirectionEnum to the given string

func (*SortDirectionEnum) UnmarshalJSON

func (sde *SortDirectionEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the string does not represent a valid SortDirectionEnum in the Notion API.

type SortTimestampEnum

type SortTimestampEnum string

SortTimestampEnum represents a valid timestamp sort type in the Notion API.

func (*SortTimestampEnum) IsValidEnum

func (ste *SortTimestampEnum) IsValidEnum() bool

IsValidEnum returns true if the provide string represents a valid SortTimestampEnum in the Notion API.

func (*SortTimestampEnum) SetValue

func (ste *SortTimestampEnum) SetValue(s string)

SetValue sets the SortTimestampEnum to the given string

func (*SortTimestampEnum) UnmarshalJSON

func (ste *SortTimestampEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the string does not represent a valid SortTimestampEnum in the Notion API.

type StringEnum

type StringEnum interface {
	SetValue(v string)
	IsValidEnum() bool
}

StringEnum interface are the methods needed to unmarshal string enums.

type Text

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

Text type represents a text rich_text object in the Notion API.

func (*Text) GetURL

func (t *Text) GetURL() *url.URL

GetURL returns a pointer to the URL of the Link of the Text object, if it exists, and returns nil otherwise.

type TextFilter

type TextFilter struct {
	EmptyFilter
	Type  FilterTextConditionEnum
	Value *string
}

A TextFilter represents a filter object with which to query a database in the Notion API.

func (*TextFilter) MarshalJSON

func (tf *TextFilter) MarshalJSON() ([]byte, error)

MarshalJSON prepares the filter to be compatible with the Notion API.

type UUID4

type UUID4 uuid.UUID

UUID4 represents the UUIDs used as "id" in the Notion API. It is not actually a UUID4, but that is the type used in the Notion API.

func (*UUID4) MarshalJSON

func (u *UUID4) MarshalJSON() ([]byte, error)

MarshalJSON marshals the UUID as a string

func (*UUID4) String

func (u *UUID4) String() string

String returns the UUID4 as a string

func (*UUID4) UnmarshalJSON

func (u *UUID4) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the provide string is not a valid UUID

type User

type User struct {
	Object
	Type      UserTypeEnum `json:"type,omitempty"`
	Name      string       `json:"name,omitempty"`
	AvatarURL jsonURL      `json:"avatar_url,omitempty"`
	// Only set if the Type is "person"
	Email string `json:"email"`
}

A User represents a user object in the Notion API.

func (*User) MarshalJSON

func (u *User) MarshalJSON() ([]byte, error)

MarshalJSON marshals the User object to be compatible with the Notion API.

func (*User) UnmarshalJSON

func (u *User) UnmarshalJSON(b []byte) error

UnmarshalJSON parses the user object from the Notion API, flattening the "person" or "bot" attributes.

type UserTypeEnum

type UserTypeEnum string

UserTypeEnum represents a valid type for a user object in the Notion API.

func (*UserTypeEnum) IsValidEnum

func (ute *UserTypeEnum) IsValidEnum() bool

IsValidEnum returns true if the string represents a valid user type in the Notion API.

func (*UserTypeEnum) SetValue

func (ute *UserTypeEnum) SetValue(s string)

SetValue sets the UserTypeEnum to the given string

func (*UserTypeEnum) UnmarshalJSON

func (ute *UserTypeEnum) UnmarshalJSON(b []byte) error

UnmarshalJSON returns an error if the provided string is not a valid UserTypeEnum in the Notion API.

type Users

type Users []*User

Users represents a list of users from the Notion API.

func (*Users) Len

func (us *Users) Len() int

Len returns the number of users in the the slice.

func (*Users) UnmarshalJSON

func (us *Users) UnmarshalJSON(b []byte) error

UnmarshalJSON appends the unmarshaled Users to the slice.

Jump to

Keyboard shortcuts

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