notion

package module
v0.0.0-...-b81cf9d Latest Latest
Warning

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

Go to latest
Published: May 31, 2021 License: MIT Imports: 7 Imported by: 0

README

Supported Go versions

Feature Overview

  • Wrapper of Notion API from Developers Beta(https://developers.notion.com/)
  • Support Databases API
  • Support Pages API
  • Support Blocks API
  • Support Users API
  • Support Search API

Guide

Installation

go get github.com/hunydev/notion

Example

package main

import (
	"fmt"
	"os"
	"time"

	"github.com/hunydev/notion"
	api "github.com/hunydev/notion/api/v20210513"
)

func main() {
	//token := "secret_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
	token := os.Getenv("NOTION_AUTHORIZATION")

	nt := notion.New(api.New(token, &api.Option{
		Timeout: time.Second * 3,
	}))

	fmt.Println(nt.APIVersion())
}
Databases

List Databases

//List Databases
resp, err := nt.ListDatabases(&notion.PaginationRequest{}) // can use nil pointer
if err != nil {
    panic(err)
}

databases, err := resp.Databases()
if err != nil {
    panic(err)
}

for _, database := range databases {
    fmt.Println("ID:", database.ID())
}

License

MIT

Documentation

Index

Constants

View Source
const (
	TypeBlockParagraph        = "paragraph"
	TypeBlockHeading1         = "heading_1"
	TypeBlockHeading2         = "heading_2"
	TypeBlockHeading3         = "heading_3"
	TypeBlockBulletedListItem = "bulleted_list_item"
	TypeBlockNumberedListItem = "numbered_list_item"
	TypeBlockTodo             = "to_do"
	TypeBlockToggle           = "toggle"
	TypeBlockChildPage        = "child_page"
	TypeBlockUnsupported      = "unsupported"
)
View Source
const (
	ColorDefault          = Color("default")
	ColorGray             = Color("gray")
	ColorBrown            = Color("brown")
	ColorOrange           = Color("orange")
	ColorYellow           = Color("yellow")
	ColorGreen            = Color("green")
	ColorBlue             = Color("blue")
	ColorPurple           = Color("purple")
	ColorPink             = Color("pink")
	ColorRed              = Color("red")
	ColorGrayBackground   = Color("gray_background")
	ColorBrownBackground  = Color("brown_background")
	ColorOrangeBackground = Color("orange_background")
	ColorYellowBackground = Color("yellow_background")
	ColorGreenBackground  = Color("green_background")
	ColorBlueBackground   = Color("blue_background")
	ColorPurpleBackground = Color("purple_background")
	ColorPinkBackground   = Color("pink_background")
	ColorRedBackground    = Color("red_background")
)
View Source
const (
	ObjectUser     = Object("user")
	ObjectDatabase = Object("database")
	ObjectPage     = Object("page")
	ObjectBlock    = Object("block")
)
View Source
const (
	TypeParentDatabase  = "database_id"
	TypeParentPage      = "page_id"
	TypeParentWorkspace = "workspace"
)
View Source
const (
	TypePropertyTitle       = "title"
	TypePropertyRichText    = "rich_text"
	TypePropertyNumber      = "number"
	TypePropertySelect      = "select"
	TypePropertyMultiSelect = "multi_select"
	TypePropertyDate        = "date"
	TypePropertyFormula     = "formula"
	TypePropertyPeople      = "people"
	TypePropertyFiles       = "files"
	TypePropertyCheckbox    = "checkbox"
	TypePropertyURL         = "url"
	TypePropertyEmail       = "email"
	TypePropertyPhoneNumber = "phone_number"
)
View Source
const (
	FilterOperationOR  = FilterOperation("or")
	FilterOperationAND = FilterOperation("and")
)
View Source
const (
	CreatedTime    = Timestamp("created_time")
	LastEditedTime = Timestamp("last_edited_time")
)
View Source
const (
	Ascending  = Direction("ascending")
	Descending = Direction("descending")
)
View Source
const (
	UserTypePerson = "pserson"
	UserTypeBot    = "bot"
)

Variables

View Source
var FilterCheckbox = &ConditionCheckbox{
	Equals:       func(value bool) Condition { return NewCondition("checkbox", "equals", value) },
	DoesNotEqual: func(value bool) Condition { return NewCondition("checkbox", "does_not_equal", value) },
}
View Source
var FilterDate = &ConditionDate{
	Equals:     func(value string) Condition { return NewCondition("date", "equals", value) },
	Before:     func(value string) Condition { return NewCondition("date", "before", value) },
	After:      func(value string) Condition { return NewCondition("date", "after", value) },
	OnOrBefore: func(value string) Condition { return NewCondition("date", "on_or_before", value) },
	IsEmpty:    func(value bool) Condition { return NewCondition("date", "is_empty", true) },
	IsNotEmpty: func(value bool) Condition { return NewCondition("date", "is_not_empty", true) },
	OnOrAfter:  func(value string) Condition { return NewCondition("date", "on_or_after", value) },
	PastWeek:   func(value interface{}) Condition { return NewCondition("date", "past_week", JSON{}) },
	PastMonth:  func(value interface{}) Condition { return NewCondition("date", "past_month", JSON{}) },
	PastYear:   func(value interface{}) Condition { return NewCondition("date", "past_year", JSON{}) },
	NextWeek:   func(value interface{}) Condition { return NewCondition("date", "next_week", JSON{}) },
	NextMonth:  func(value interface{}) Condition { return NewCondition("date", "next_month", JSON{}) },
	NextYear:   func(value interface{}) Condition { return NewCondition("date", "next_year", JSON{}) },
}
View Source
var FilterFiles = &ConditionFiles{
	IsEmpty:    func(value bool) Condition { return NewCondition("files", "is_empty", true) },
	IsNotEmpty: func(value bool) Condition { return NewCondition("files", "is_not_empty", true) },
}
View Source
var FilterFormula = &ConditionFormula{
	Text:     FilterText,
	Checkbox: FilterCheckbox,
	Number:   FilterNumber,
	Date:     FilterDate,
}
View Source
var FilterMultiSelect = &ConditionMultiSelect{
	Contains:       func(value string) Condition { return NewCondition("multi_select", "contains", value) },
	DoesNotContain: func(value string) Condition { return NewCondition("multi_select", "doeS_not_contain", value) },
	IsEmpty:        func(value bool) Condition { return NewCondition("multi_select", "is_empty", true) },
	IsNotEmpty:     func(value bool) Condition { return NewCondition("multi_select", "is_not_empty", true) },
}
View Source
var FilterNumber = &ConditionNumber{
	Equals:               func(value int) Condition { return NewCondition("number", "equals", value) },
	DoesNotEqual:         func(value int) Condition { return NewCondition("number", "does_not_equal", value) },
	GreaterThan:          func(value int) Condition { return NewCondition("number", "greater_than", value) },
	LessThan:             func(value int) Condition { return NewCondition("number", "less_than", value) },
	GreaterThanOrEqualTo: func(value int) Condition { return NewCondition("number", "greater_than_or_equal_to", value) },
	LessThanOrEqualTo:    func(value int) Condition { return NewCondition("number", "less_than_or_equal_to", value) },
	IsEmpty:              func(value bool) Condition { return NewCondition("number", "is_empty", true) },
	IsNotEmpty:           func(value bool) Condition { return NewCondition("number", "is_not_empty", true) },
}
View Source
var FilterPeople = &ConditionPeople{
	Contains:       func(value string) Condition { return NewCondition("people", "contains", value) },
	DoesNotContain: func(value string) Condition { return NewCondition("people", "does_not_contain", value) },
	IsEmpty:        func(value bool) Condition { return NewCondition("people", "is_empty", true) },
	IsNotEmpty:     func(value bool) Condition { return NewCondition("people", "is_not_empty", true) },
}
View Source
var FilterSelect = &ConditionSelect{
	Equals:       func(value string) Condition { return NewCondition("select", "equals", value) },
	DoesNotEqual: func(value string) Condition { return NewCondition("select", "does_not_equal", value) },
	IsEmpty:      func(value bool) Condition { return NewCondition("select", "is_empty", true) },
	IsNotEmpty:   func(value bool) Condition { return NewCondition("select", "is_not_empty", true) },
}
View Source
var FilterText = &ConditionText{
	Equals:         func(value string) Condition { return NewCondition("text", "equals", value) },
	DoesNotEqual:   func(value string) Condition { return NewCondition("text", "does_not_equal", value) },
	Contains:       func(value string) Condition { return NewCondition("text", "contains", value) },
	DoesNotContain: func(value string) Condition { return NewCondition("text", "does_not_contain", value) },
	StartsWith:     func(value string) Condition { return NewCondition("text", "starts_with", value) },
	EndsWith:       func(value string) Condition { return NewCondition("text", "ends_with", value) },
	IsEmpty:        func(value bool) Condition { return NewCondition("text", "is_empty", true) },
	IsNotEmpty:     func(value bool) Condition { return NewCondition("text", "is_not_empty", true) },
}

Functions

func ParseTime

func ParseTime(t string) (time.Time, error)

func TimeFormat

func TimeFormat(t time.Time) string

Types

type API

type API interface {
	ListAllUsers(pagination *PaginationRequest) (*PaginationResponse, error)
	RetrieveUser(UserID string) (*User, error)

	RetrieveBlockChildren(BlockID string, pagination *PaginationRequest) (*PaginationResponse, error)
	AppendBlockChildren(BlockID string, Children []Block) (Block, error)

	RetrievePage(PageID string) (*Page, error)
	CreatePage(Parent *Parent, Properties []Property, Children ...Block) (*Page, error)
	UpdatePageProperties(PageID string, Properties ...Property) (*Page, error)

	RetrieveDatabase(DatabaseID string) (*Database, error)
	QueryDatabase(DatabaseID string, Pagination *PaginationRequest, Filter Filter, Sorts []Sort) (*PaginationResponse, error)
	ListDatabases(Pagination *PaginationRequest) (*PaginationResponse, error)

	Search(Query string, Pagination *PaginationRequest, Filter Object, Sort *Sort) (*PaginationResponse, error)

	Version() string
}

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

func NewAnnotations

func NewAnnotations() *Annotations

NewAnnotations Create Annotations Struct, set color with "default"

type BaseConfiguration

type BaseConfiguration struct {
	*BaseProperty
}

type BaseProperty

type BaseProperty struct {
	JSON JSON
	// contains filtered or unexported fields
}

func (*BaseProperty) ID

func (property *BaseProperty) ID() string

func (*BaseProperty) Interface

func (property *BaseProperty) Interface() interface{}

func (*BaseProperty) Json

func (property *BaseProperty) Json() JSON

func (*BaseProperty) Name

func (property *BaseProperty) Name() string

func (*BaseProperty) Type

func (property *BaseProperty) Type() string

type Block

type Block interface {
	Object() string
	ID() string
	CreatedTime() string
	LastEditedTime() string
	HasChildren() bool
	Type() string

	Interface() interface{}

	Json() JSON
}

func AssignBlock

func AssignBlock(json JSON) (Block, error)

func NewBlock

func NewBlock(j JSON) Block

func NewBlockBulletedListItem

func NewBlockBulletedListItem(Text []RichText, Children ...Block) Block

func NewBlockChildPage

func NewBlockChildPage(PageID string) Block

func NewBlockHeading1

func NewBlockHeading1(Text []RichText) Block

func NewBlockHeading2

func NewBlockHeading2(Text []RichText) Block

func NewBlockHeading3

func NewBlockHeading3(Text []RichText) Block

func NewBlockNumberedListItem

func NewBlockNumberedListItem(Text []RichText, Children ...Block) Block

func NewBlockParagraph

func NewBlockParagraph(Text []RichText) Block

func NewBlockTodo

func NewBlockTodo(Checked bool, Text []RichText, Children ...Block) Block

func NewBlockToggle

func NewBlockToggle(Text []RichText, Children ...Block) Block

type BlockBulletedListItem

type BlockBulletedListItem struct {
	*ChildrenBlock
}

func (*BlockBulletedListItem) Interface

func (block *BlockBulletedListItem) Interface() interface{}

type BlockChildPage

type BlockChildPage struct {
	*CustomBlock
}

func (*BlockChildPage) Interface

func (block *BlockChildPage) Interface() interface{}

type BlockHeading1

type BlockHeading1 struct {
	*RichTextBlock
}

func (*BlockHeading1) Interface

func (block *BlockHeading1) Interface() interface{}

type BlockHeading2

type BlockHeading2 struct {
	*RichTextBlock
}

func (*BlockHeading2) Interface

func (block *BlockHeading2) Interface() interface{}

type BlockHeading3

type BlockHeading3 struct {
	*RichTextBlock
}

func (*BlockHeading3) Interface

func (block *BlockHeading3) Interface() interface{}

type BlockNumberedListItem

type BlockNumberedListItem struct {
	*ChildrenBlock
}

func (*BlockNumberedListItem) Interface

func (block *BlockNumberedListItem) Interface() interface{}

type BlockParagraph

type BlockParagraph struct {
	*RichTextBlock
}

func (*BlockParagraph) Interface

func (block *BlockParagraph) Interface() interface{}

type BlockTodo

type BlockTodo struct {
	*ChildrenBlock
}

func (*BlockTodo) Checked

func (block *BlockTodo) Checked()

func (*BlockTodo) Interface

func (block *BlockTodo) Interface() interface{}

func (*BlockTodo) IsChecked

func (block *BlockTodo) IsChecked() bool

func (*BlockTodo) Unchecked

func (block *BlockTodo) Unchecked()

type BlockToggle

type BlockToggle struct {
	*ChildrenBlock
}

func (*BlockToggle) Interface

func (block *BlockToggle) Interface() interface{}

type BlockUnsupported

type BlockUnsupported struct {
	*CustomBlock
}

func (*BlockUnsupported) Interface

func (block *BlockUnsupported) Interface() interface{}

type ChildrenBlock

type ChildrenBlock struct {
	*RichTextBlock
}

func (*ChildrenBlock) AddChildren

func (block *ChildrenBlock) AddChildren(children []Block) error

func (*ChildrenBlock) Children

func (block *ChildrenBlock) Children() ([]Block, error)

func (*ChildrenBlock) Interface

func (block *ChildrenBlock) Interface() interface{}

type Color

type Color string

type CompoundFilter

type CompoundFilter struct {
	JSON JSON
	// contains filtered or unexported fields
}

func (*CompoundFilter) Json

func (filter *CompoundFilter) Json() JSON

func (*CompoundFilter) Operation

func (filter *CompoundFilter) Operation() FilterOperation

type Condition

type Condition interface {
	Type() string
	Key() string
	Value() interface{}
}

func NewCondition

func NewCondition(Type, Key string, Value interface{}) Condition

type ConditionCheckbox

type ConditionCheckbox struct {
	Equals       ConditionFuncBoolean
	DoesNotEqual ConditionFuncBoolean
}

type ConditionFiles

type ConditionFiles struct {
	IsEmpty    ConditionFuncBoolean
	IsNotEmpty ConditionFuncBoolean
}

type ConditionFormula

type ConditionFormula struct {
	Text     *ConditionText
	Checkbox *ConditionCheckbox
	Number   *ConditionNumber
	Date     *ConditionDate
}

type ConditionFuncBoolean

type ConditionFuncBoolean func(value bool) Condition

type ConditionFuncNumber

type ConditionFuncNumber func(value int) Condition

type ConditionFuncObject

type ConditionFuncObject func(value interface{}) Condition

type ConditionFuncString

type ConditionFuncString func(value string) Condition

type ConditionMultiSelect

type ConditionMultiSelect struct {
	Contains       ConditionFuncString
	DoesNotContain ConditionFuncString
	IsEmpty        ConditionFuncBoolean
	IsNotEmpty     ConditionFuncBoolean
}

type ConditionNumber

type ConditionNumber struct {
	Equals               ConditionFuncNumber
	DoesNotEqual         ConditionFuncNumber
	GreaterThan          ConditionFuncNumber
	LessThan             ConditionFuncNumber
	GreaterThanOrEqualTo ConditionFuncNumber
	LessThanOrEqualTo    ConditionFuncNumber
	IsEmpty              ConditionFuncBoolean
	IsNotEmpty           ConditionFuncBoolean
}

type ConditionPeople

type ConditionPeople struct {
	Contains       ConditionFuncString
	DoesNotContain ConditionFuncString
	IsEmpty        ConditionFuncBoolean
	IsNotEmpty     ConditionFuncBoolean
}

type ConditionSelect

type ConditionSelect struct {
	Equals       ConditionFuncString
	DoesNotEqual ConditionFuncString
	IsEmpty      ConditionFuncBoolean
	IsNotEmpty   ConditionFuncBoolean
}

type ConditionText

type ConditionText struct {
	Equals         ConditionFuncString
	DoesNotEqual   ConditionFuncString
	Contains       ConditionFuncString
	DoesNotContain ConditionFuncString
	StartsWith     ConditionFuncString
	EndsWith       ConditionFuncString
	IsEmpty        ConditionFuncBoolean
	IsNotEmpty     ConditionFuncBoolean
}

type Conditioner

type Conditioner struct {
	// contains filtered or unexported fields
}

func (*Conditioner) Key

func (c *Conditioner) Key() string

func (*Conditioner) Type

func (c *Conditioner) Type() string

func (*Conditioner) Value

func (c *Conditioner) Value() interface{}

type Configuration

type Configuration interface {
	Name() string
	ID() string
	Type() string

	Json() JSON
	Interface() interface{}
}

func AssignConfiguration

func AssignConfiguration(name string, json JSON) (Configuration, error)

type ConfigurationCheckbox

type ConfigurationCheckbox struct {
	*BaseConfiguration
}

type ConfigurationDate

type ConfigurationDate struct {
	*BaseConfiguration
}

type ConfigurationEmail

type ConfigurationEmail struct {
	*BaseConfiguration
}

type ConfigurationFile

type ConfigurationFile struct {
	*BaseConfiguration
}

type ConfigurationFormula

type ConfigurationFormula struct {
	*BaseConfiguration
}

func (*ConfigurationFormula) Expression

func (configuration *ConfigurationFormula) Expression() string

type ConfigurationMultiSelect

type ConfigurationMultiSelect struct {
	*SelectOptionsConfiguration
}

type ConfigurationNumber

type ConfigurationNumber struct {
	*BaseConfiguration
}

func (*ConfigurationNumber) Format

func (configuration *ConfigurationNumber) Format() string

type ConfigurationPeople

type ConfigurationPeople struct {
	*BaseConfiguration
}

type ConfigurationPhoneNumber

type ConfigurationPhoneNumber struct {
	*BaseConfiguration
}

type ConfigurationSelect

type ConfigurationSelect struct {
	*SelectOptionsConfiguration
}

type ConfigurationText

type ConfigurationText struct {
	*BaseConfiguration
}

type ConfigurationTitle

type ConfigurationTitle struct {
	*BaseConfiguration
}

type ConfigurationURL

type ConfigurationURL struct {
	*BaseConfiguration
}

type CustomBlock

type CustomBlock struct {
	JSON JSON
	// contains filtered or unexported fields
}

func (*CustomBlock) CreatedTime

func (block *CustomBlock) CreatedTime() string

func (*CustomBlock) HasChildren

func (block *CustomBlock) HasChildren() bool

func (*CustomBlock) ID

func (block *CustomBlock) ID() string

func (*CustomBlock) Interface

func (block *CustomBlock) Interface() interface{}

func (*CustomBlock) Json

func (block *CustomBlock) Json() JSON

func (*CustomBlock) LastEditedTime

func (block *CustomBlock) LastEditedTime() string

func (*CustomBlock) Object

func (block *CustomBlock) Object() string

func (*CustomBlock) Type

func (block *CustomBlock) Type() string

type Database

type Database struct {
	JSON JSON
}

func (*Database) CreatedTime

func (database *Database) CreatedTime() string

func (*Database) ID

func (database *Database) ID() string

func (*Database) LastEditedTime

func (database *Database) LastEditedTime() string

func (*Database) Object

func (database *Database) Object() string

func (*Database) Properties

func (database *Database) Properties() []Configuration

func (*Database) Title

func (database *Database) Title() []RichText

type DatabasePropertyFilter

type DatabasePropertyFilter struct {
	JSON JSON
	// contains filtered or unexported fields
}

func (*DatabasePropertyFilter) Condition

func (filter *DatabasePropertyFilter) Condition() Condition

func (*DatabasePropertyFilter) Json

func (filter *DatabasePropertyFilter) Json() JSON

func (*DatabasePropertyFilter) Property

func (filter *DatabasePropertyFilter) Property() string

type Date

type Date struct {
	Start string `json:"start"`
	End   string `json:"end"`
}

type Direction

type Direction string

type Equation

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

type File

type File struct {
	Name string `json:"name"`
}

type Filter

type Filter interface {
	Json() JSON
}

func NewCompoundFilter

func NewCompoundFilter(Operation FilterOperation, Filters ...Filter) Filter

func NewFilter

func NewFilter(Property string, Condition Condition) Filter

type FilterOperation

type FilterOperation string

func (FilterOperation) String

func (operation FilterOperation) String() string

type JSON

type JSON map[string]interface{}

func (JSON) Append

func (j JSON) Append(name string, v interface{})

func (JSON) Get

func (j JSON) Get(name string) interface{}

func (JSON) GetBool

func (j JSON) GetBool(name string) bool

func (JSON) GetFloat

func (j JSON) GetFloat(name string) float64

func (JSON) GetInt

func (j JSON) GetInt(name string) int

func (JSON) GetJSON

func (j JSON) GetJSON(name string) (JSON, bool)

func (JSON) GetJSONList

func (j JSON) GetJSONList(name string) ([]JSON, bool)

func (JSON) GetString

func (j JSON) GetString(name string) string

func (JSON) Marshal

func (j JSON) Marshal(v interface{}) error

func (JSON) Set

func (j JSON) Set(name string, v interface{})

func (JSON) String

func (j JSON) String() string

func (JSON) Unmarshal

func (j JSON) Unmarshal(v interface{}) error
type Link struct {
	URL string `json:"url"`
}

type Notion

type Notion struct {
	// contains filtered or unexported fields
}

func New

func New(API API) *Notion

func (*Notion) APIVersion

func (notion *Notion) APIVersion() string

func (*Notion) AppendBlockChildren

func (notion *Notion) AppendBlockChildren(BlockID string, Children []Block) (Block, error)

func (*Notion) CreatePage

func (notion *Notion) CreatePage(Parent *Parent, Properties []Property, Children ...Block) (*Page, error)

func (*Notion) ListAllUsers

func (notion *Notion) ListAllUsers(pagination *PaginationRequest) (*PaginationResponse, error)

func (*Notion) ListDatabases

func (notion *Notion) ListDatabases(Pagination *PaginationRequest) (*PaginationResponse, error)

func (*Notion) QueryDatabase

func (notion *Notion) QueryDatabase(DatabaseID string, Pagination *PaginationRequest, Filter Filter, Sorts []Sort) (*PaginationResponse, error)

func (*Notion) RetrieveBlockChildren

func (notion *Notion) RetrieveBlockChildren(BlockID string, pagination *PaginationRequest) (*PaginationResponse, error)

func (*Notion) RetrieveDatabase

func (notion *Notion) RetrieveDatabase(DatabaseID string) (*Database, error)

func (*Notion) RetrievePage

func (notion *Notion) RetrievePage(PageID string) (*Page, error)

func (*Notion) RetrieveUser

func (notion *Notion) RetrieveUser(UserID string) (*User, error)

func (*Notion) Search

func (notion *Notion) Search(Query string, Pagination *PaginationRequest, Filter Object, Sort *Sort) (*PaginationResponse, error)

func (*Notion) UpdatePageProperties

func (notion *Notion) UpdatePageProperties(PageID string, Properties ...Property) (*Page, error)

type Object

type Object string

func (Object) String

func (object Object) String() string

type Page

type Page struct {
	JSON JSON
}

func NewPage

func NewPage(parent *Parent) *Page

func (*Page) Archived

func (page *Page) Archived() bool

func (*Page) CreatedTime

func (page *Page) CreatedTime() string

func (*Page) ID

func (page *Page) ID() string

func (*Page) LastEditedTime

func (page *Page) LastEditedTime() string

func (*Page) Object

func (page *Page) Object() string

func (*Page) Parent

func (page *Page) Parent() *Parent

func (*Page) Properties

func (page *Page) Properties() []Property

type PaginationRequest

type PaginationRequest struct {
	StartCursor string `json:"start_cursor"`
	PageSize    int    `json:"page_size"`
}

func (*PaginationRequest) Json

func (request *PaginationRequest) Json() JSON

func (*PaginationRequest) QueryString

func (request *PaginationRequest) QueryString() string

type PaginationResponse

type PaginationResponse struct {
	HasMore    bool   `json:"has_more"`
	NextCursor string `json:"next_cursor"`
	Object     string `json:"object"` //always 'list'

	Results []interface{} `json:"results"`
}

func (*PaginationResponse) Blocks

func (response *PaginationResponse) Blocks() ([]Block, error)

func (*PaginationResponse) Databases

func (response *PaginationResponse) Databases() ([]Database, error)

func (*PaginationResponse) Pages

func (response *PaginationResponse) Pages() ([]Page, error)

func (*PaginationResponse) Unmarshal

func (response *PaginationResponse) Unmarshal(v interface{}) error

func (*PaginationResponse) Users

func (response *PaginationResponse) Users() ([]User, error)

type Parent

type Parent struct {
	ID string

	JSON JSON
}

func NewParentDatabase

func NewParentDatabase(ID string) *Parent

func NewParentPage

func NewParentPage(ID string) *Parent

func NewParentWorkspace

func NewParentWorkspace() *Parent

type Property

type Property interface {
	Name() string
	ID() string
	Type() string

	Json() JSON
	Interface() interface{}
}

func AssignProperty

func AssignProperty(name string, json JSON) (Property, error)

func NewProperty

func NewProperty(j JSON) Property

func NewPropertyCheckbox

func NewPropertyCheckbox(Name string, checked bool) Property

func NewPropertyDate

func NewPropertyDate(Name string, Date *Date) Property

func NewPropertyEmail

func NewPropertyEmail(Name string, Email string) Property

func NewPropertyFiles

func NewPropertyFiles(Name string, Files ...File) Property

func NewPropertyFormula

func NewPropertyFormula(Name string, v interface{}) Property

func NewPropertyMultiSelect

func NewPropertyMultiSelect(Name string, Select ...SelectOption) Property

func NewPropertyNumber

func NewPropertyNumber(Name string, Number int) Property

func NewPropertyPeople

func NewPropertyPeople(Name string, User ...User) Property

func NewPropertyPhoneNumber

func NewPropertyPhoneNumber(Name string, PhoneNumber string) Property

func NewPropertyRichText

func NewPropertyRichText(Name string, text []RichText) Property

func NewPropertySelect

func NewPropertySelect(Name string, Select *SelectOption) Property

func NewPropertyTitle

func NewPropertyTitle(Name string, text []RichText) Property

func NewPropertyURL

func NewPropertyURL(Name string, URL string) Property

type PropertyCheckbox

type PropertyCheckbox struct {
	*BaseProperty
}

func (*PropertyCheckbox) Checked

func (property *PropertyCheckbox) Checked() bool

func (*PropertyCheckbox) Interface

func (property *PropertyCheckbox) Interface() interface{}

type PropertyDate

type PropertyDate struct {
	*BaseProperty
}

func (*PropertyDate) Date

func (property *PropertyDate) Date() *Date

func (*PropertyDate) Interface

func (property *PropertyDate) Interface() interface{}

type PropertyEmail

type PropertyEmail struct {
	*BaseProperty
}

func (*PropertyEmail) Email

func (property *PropertyEmail) Email() string

func (*PropertyEmail) Interface

func (property *PropertyEmail) Interface() interface{}

type PropertyFiles

type PropertyFiles struct {
	*BaseProperty
}

func (*PropertyFiles) Files

func (property *PropertyFiles) Files() []File

func (*PropertyFiles) Interface

func (property *PropertyFiles) Interface() interface{}

type PropertyFormula

type PropertyFormula struct {
	*BaseProperty
}

func (*PropertyFormula) Formula

func (property *PropertyFormula) Formula() (Type string, v interface{})

func (*PropertyFormula) Interface

func (property *PropertyFormula) Interface() interface{}

type PropertyMultiSelect

type PropertyMultiSelect struct {
	*BaseProperty
}

func (*PropertyMultiSelect) Interface

func (property *PropertyMultiSelect) Interface() interface{}

func (*PropertyMultiSelect) Options

func (property *PropertyMultiSelect) Options() []SelectOption

type PropertyNumber

type PropertyNumber struct {
	*BaseProperty
}

func (*PropertyNumber) Interface

func (property *PropertyNumber) Interface() interface{}

func (*PropertyNumber) Number

func (property *PropertyNumber) Number() (int, error)

type PropertyPeople

type PropertyPeople struct {
	*BaseProperty
}

func (*PropertyPeople) Interface

func (property *PropertyPeople) Interface() interface{}

func (*PropertyPeople) Users

func (property *PropertyPeople) Users() []User

type PropertyPhoneNumber

type PropertyPhoneNumber struct {
	*BaseProperty
}

func (*PropertyPhoneNumber) Interface

func (property *PropertyPhoneNumber) Interface() interface{}

func (*PropertyPhoneNumber) PhoneNumber

func (property *PropertyPhoneNumber) PhoneNumber() string

type PropertyRichText

type PropertyRichText struct {
	*RichTextProperty
}

func (*PropertyRichText) Interface

func (property *PropertyRichText) Interface() interface{}

type PropertySelect

type PropertySelect struct {
	*BaseProperty
}

func (*PropertySelect) Interface

func (property *PropertySelect) Interface() interface{}

func (*PropertySelect) Option

func (property *PropertySelect) Option() *SelectOption

type PropertyTitle

type PropertyTitle struct {
	*RichTextProperty
}

func (*PropertyTitle) Interface

func (property *PropertyTitle) Interface() interface{}

type PropertyURL

type PropertyURL struct {
	*BaseProperty
}

func (*PropertyURL) Interface

func (property *PropertyURL) Interface() interface{}

func (*PropertyURL) URL

func (property *PropertyURL) URL() string

type RichText

type RichText struct {
	JSON JSON
}

func NewRichText

func NewRichText(PlainText string) *RichText

func (*RichText) GetAnnotations

func (rt *RichText) GetAnnotations() (*Annotations, error)

func (*RichText) GetEquation

func (rt *RichText) GetEquation() (*Equation, error)

func (*RichText) GetMentionDatabase

func (rt *RichText) GetMentionDatabase() (*Database, error)

func (*RichText) GetMentionDate

func (rt *RichText) GetMentionDate() (*Date, error)

func (*RichText) GetMentionPage

func (rt *RichText) GetMentionPage() (*Page, error)

func (*RichText) GetMentionUser

func (rt *RichText) GetMentionUser() (*User, error)

func (*RichText) GetText

func (rt *RichText) GetText() (*Text, error)

func (*RichText) Href

func (rt *RichText) Href() string

func (*RichText) PlainText

func (rt *RichText) PlainText() string

func (*RichText) SetAnnotations

func (rt *RichText) SetAnnotations(annotations *Annotations)

func (*RichText) SetEquation

func (rt *RichText) SetEquation(equation *Equation)

func (*RichText) SetMentionDatabase

func (rt *RichText) SetMentionDatabase(database *Database) error

func (*RichText) SetMentionDate

func (rt *RichText) SetMentionDate(date *Date) error

func (*RichText) SetMentionPage

func (rt *RichText) SetMentionPage(page *Page) error

func (*RichText) SetMentionUser

func (rt *RichText) SetMentionUser(user *User) error

func (*RichText) SetText

func (rt *RichText) SetText(text *Text)

func (*RichText) Type

func (rt *RichText) Type() string

type RichTextBlock

type RichTextBlock struct {
	*CustomBlock
}

func (*RichTextBlock) AddText

func (block *RichTextBlock) AddText(text []RichText) error

func (*RichTextBlock) Interface

func (block *RichTextBlock) Interface() interface{}

func (*RichTextBlock) ListText

func (block *RichTextBlock) ListText() ([]RichText, error)

type RichTextProperty

type RichTextProperty struct {
	*BaseProperty
}

func (*RichTextProperty) Interface

func (property *RichTextProperty) Interface() interface{}

func (*RichTextProperty) RichText

func (property *RichTextProperty) RichText() []RichText

type SelectOption

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

type SelectOptionsConfiguration

type SelectOptionsConfiguration struct {
	*BaseConfiguration
}

func (*SelectOptionsConfiguration) Options

func (configuration *SelectOptionsConfiguration) Options() []SelectOption

type Sort

type Sort struct {
	Property  string
	Timestamp Timestamp
	Direction Direction
}

type Text

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

type Timestamp

type Timestamp string

type User

type User struct {
	ID string

	JSON JSON
}

func NewUser

func NewUser(ID string) *User

func (*User) AvatarURL

func (user *User) AvatarURL() string

func (*User) Email

func (user *User) Email() string

func (*User) IsBot

func (user *User) IsBot() bool

func (*User) IsPerson

func (user *User) IsPerson() bool

func (*User) Name

func (user *User) Name() string

func (*User) Object

func (user *User) Object() string

func (*User) String

func (user *User) String() string

func (*User) Type

func (user *User) Type() (string, error)

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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