README

notionapi

GitHub tag (latest SemVer) Go Reference Test

An API client for the Notion API implemented in Golang

Supported APIs

It supports all APIs for Notion API version 2021-05-13

  • Databases
  • Pages
  • Blocks
  • Users
  • Search

Installation

$ go get github.com/jomei/notionapi

Getting started

Follow Notion’s getting started guide to obtain an Integration Token.

Example

Make a new Client

import "github.com/jomei/notionapi"


client := notionapi.NewClient("your-integration-token")

Then, use client's methods to retrieve or update your content

page, err := client.Page.Get(context.Background(), "your-page-id")
if err != nil {
	// do something
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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 AppendBlockChildrenRequest

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

type Block

type Block interface {
	GetType() BlockType
}

type BlockClient

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

func (*BlockClient) AppendChildren

func (bc *BlockClient) AppendChildren(ctx context.Context, id BlockID, requestBody *AppendBlockChildrenRequest) (Block, error)

AppendChildren https://developers.notion.com/reference/patch-block-children

func (*BlockClient) GetChildren

func (bc *BlockClient) GetChildren(ctx context.Context, id BlockID, pagination *Pagination) (*GetChildrenResponse, error)

GetChildren https://developers.notion.com/reference/get-block-children

type BlockID

type BlockID string

func (BlockID) String

func (bID BlockID) String() string

type BlockService

type BlockService interface {
	GetChildren(context.Context, BlockID, *Pagination) (*GetChildrenResponse, error)
	AppendChildren(context.Context, BlockID, *AppendBlockChildrenRequest) (Block, error)
}

type BlockType

type BlockType string
const (
	BlockTypeParagraph BlockType = "paragraph"
	BlockTypeHeading1  BlockType = "heading_1"
	BlockTypeHeading2  BlockType = "heading_2"
	BlockTypeHeading3  BlockType = "heading_3"

	BlockTypeBulletedListItem BlockType = "bulleted_list_item"
	BlockTypeNumberedListItem BlockType = "numbered_list_item"

	BlockTypeToDo        BlockType = "to_do"
	BlockTypeToggle      BlockType = "toggle"
	BlockTypeChildPage   BlockType = "child_page"
	BlockTypeUnsupported BlockType = "unsupported"
)

func (BlockType) String

func (bt BlockType) String() string

type Bot

type Bot struct{}

type BulletedListItemBlock

type BulletedListItemBlock struct {
	Object           ObjectType `json:"object"`
	ID               BlockID    `json:"id,omitempty"`
	Type             BlockType  `json:"type"`
	CreatedTime      *time.Time `json:"created_time,omitempty"`
	LastEditedTime   *time.Time `json:"last_edited_time,omitempty"`
	HasChildren      bool       `json:"has_children,omitempty"`
	BulletedListItem struct {
		Text     Paragraph `json:"text"`
		Children []Block   `json:"children"`
	} `json:"bulleted_list_item"`
}

func (*BulletedListItemBlock) GetType

func (b *BulletedListItemBlock) GetType() BlockType

type CheckboxProperty

type CheckboxProperty struct {
	ID       ObjectID     `json:"id,omitempty"`
	Type     PropertyType `json:"type"`
	Checkbox interface{}  `json:"checkbox"`
}

func (CheckboxProperty) GetType

func (p CheckboxProperty) GetType() PropertyType

type ChildPageBlock

type ChildPageBlock struct {
	Object         ObjectType `json:"object"`
	ID             BlockID    `json:"id,omitempty"`
	Type           BlockType  `json:"type"`
	CreatedTime    *time.Time `json:"created_time,omitempty"`
	LastEditedTime *time.Time `json:"last_edited_time,omitempty"`
	HasChildren    bool       `json:"has_children,omitempty"`
	ChildPage      struct {
		Title string `json:"title"`
	} `json:"child_page"`
}

func (*ChildPageBlock) GetType

func (b *ChildPageBlock) GetType() BlockType

type Client

type Client struct {
	Token Token

	Database DatabaseService
	Block    BlockService
	Page     PageService
	User     UserService
	Search   SearchService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(token Token, opts ...ClientOption) *Client

type ClientOption

type ClientOption func(*Client)

ClientOption to configure API client

func WithHTTPClient

func WithHTTPClient(client *http.Client) ClientOption

WithHTTPClient overrides the default http.Client

func WithVersion

func WithVersion(version string) ClientOption

WithVersion overrides the Notion API version

type Color

type Color string
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"
)

func (Color) String

func (c Color) String() string

type CompoundFilter

type CompoundFilter map[FilterOperator]Filter

type Condition

type Condition string
const (
	ConditionEquals         Condition = "equals"
	ConditionDoesNotEqual   Condition = "does_not_equal"
	ConditionContains       Condition = "contains"
	ConditionDoesNotContain Condition = "does_not_contain"
	ConditionDoesStartsWith Condition = "starts_with"
	ConditionDoesEndsWith   Condition = "ends_with"
	ConditionDoesIsEmpty    Condition = "is_empty"
	ConditionGreaterThan    Condition = "greater_than"
	ConditionLessThan       Condition = "less_than"

	ConditionGreaterThanOrEqualTo Condition = "greater_than_or_equal_to"
	ConditionLessThanOrEqualTo    Condition = "greater_than_or_equal_to"

	ConditionBefore     Condition = "before"
	ConditionAfter      Condition = "after"
	ConditionOnOrBefore Condition = "on_or_before"
	ConditionOnOrAfter  Condition = "on_or_after"
	ConditionPastWeek   Condition = "past_week"
	ConditionPastMonth  Condition = "past_month"
	ConditionPastYear   Condition = "past_year"
	ConditionNextWeek   Condition = "next_week"
	ConditionNextMonth  Condition = "next_month"
	ConditionNextYear   Condition = "next_year"

	ConditionText     Condition = "text"
	ConditionCheckbox Condition = "checkbox"
	ConditionNumber   Condition = "number"
	ConditionDate     Condition = "date"
)

type CreatedByProperty

type CreatedByProperty struct {
	ID        ObjectID     `json:"id"`
	Type      PropertyType `json:"type"`
	CreatedBy interface{}  `json:"created_by"`
}

func (CreatedByProperty) GetType

func (p CreatedByProperty) GetType() PropertyType

type CreatedTimeProperty

type CreatedTimeProperty struct {
	ID          ObjectID     `json:"id,omitempty"`
	Type        PropertyType `json:"type"`
	CreatedTime interface{}  `json:"created_time"`
}

func (CreatedTimeProperty) GetType

func (p CreatedTimeProperty) GetType() PropertyType

type Cursor

type Cursor string

func (Cursor) String

func (c Cursor) String() string

type Database

type Database struct {
	Object         ObjectType `json:"object"`
	ID             ObjectID   `json:"id"`
	CreatedTime    time.Time  `json:"created_time"`
	LastEditedTime time.Time  `json:"last_edited_time"`
	Title          Paragraph  `json:"title"`
	Properties     Properties `json:"properties"`
}

func (*Database) GetObject

func (db *Database) GetObject() ObjectType

type DatabaseClient

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

type DatabaseID

type DatabaseID string

func (DatabaseID) String

func (dID DatabaseID) String() string

type DatabaseListResponse

type DatabaseListResponse struct {
	Object     ObjectType `json:"object"`
	Results    []Database `json:"results"`
	NextCursor string     `json:"next_cursor"`
	HasMore    bool       `json:"has_more"`
}

type DatabaseQueryRequest

type DatabaseQueryRequest struct {
	Filter      Filter       `json:"filter,omitempty"`
	Sorts       []SortObject `json:"sorts"`
	StartCursor Cursor       `json:"start_cursor,omitempty"`
	PageSize    int          `json:"page_size,omitempty"`
}

type DatabaseQueryResponse

type DatabaseQueryResponse struct {
	Object     ObjectType `json:"object"`
	Results    []Page     `json:"results"`
	HasMore    bool       `json:"has_more"`
	NextCursor Cursor     `json:"next_cursor"`
}

type DatabaseTitleProperty

type DatabaseTitleProperty struct {
	ID    PropertyID   `json:"id,omitempty"`
	Type  PropertyType `json:"type"`
	Title RichText     `json:"title"`
}

func (DatabaseTitleProperty) GetType

func (p DatabaseTitleProperty) GetType() PropertyType

type DateProperty

type DateProperty struct {
	ID   ObjectID     `json:"id,omitempty"`
	Type PropertyType `json:"type"`
	Date interface{}  `json:"date"`
}

func (DateProperty) GetType

func (p DateProperty) GetType() PropertyType

type EmailProperty

type EmailProperty struct {
	ID    PropertyID   `json:"id,omitempty"`
	Type  PropertyType `json:"type"`
	Email interface{}  `json:"email"`
}

func (EmailProperty) GetType

func (p EmailProperty) GetType() PropertyType

type EmptyRichTextProperty

type EmptyRichTextProperty struct {
	ID       PropertyID   `json:"id,omitempty"`
	Type     PropertyType `json:"type"`
	RichText struct{}     `json:"rich_text"`
}

func (EmptyRichTextProperty) GetType

func (p EmptyRichTextProperty) GetType() PropertyType

type Error

type Error struct {
	Object  ObjectType `json:"object"`
	Status  int        `json:"status"`
	Code    ErrorCode  `json:"code"`
	Message string     `json:"message"`
}

func (*Error) Error

func (e *Error) Error() string

type ErrorCode

type ErrorCode string

type FileProperty

type FileProperty struct {
	ID   ObjectID     `json:"id,omitempty"`
	Type PropertyType `json:"type"`
	File interface{}  `json:"file"`
}

func (FileProperty) GetType

func (p FileProperty) GetType() PropertyType

type Filter

type Filter interface{}

type FilterOperator

type FilterOperator string
const (
	FilterOperatorAND FilterOperator = "and"
	FilterOperatorOR  FilterOperator = "or"
)

type FormatType

type FormatType string
const (
	FormatNumber           FormatType = "number"
	FormatNumberWithCommas FormatType = "number_with_commas"
	FormatPercent          FormatType = "percent"
	FormatDollar           FormatType = "dollar"
	FormatEuro             FormatType = "euro"
	FormatPound            FormatType = "pound"
	FormatYen              FormatType = "yen"
	FormatRuble            FormatType = "ruble"
	FormatRupee            FormatType = "rupee"
	FormatYuan             FormatType = "yuan"
)

func (FormatType) String

func (ft FormatType) String() string

type FormulaObject

type FormulaObject struct {
	Value string `json:"value"`
}

type FormulaProperty

type FormulaProperty struct {
	ID         ObjectID     `json:"id,omitempty"`
	Type       PropertyType `json:"type"`
	Expression string       `json:"expression"`
}

func (FormulaProperty) GetType

func (p FormulaProperty) GetType() PropertyType

type FunctionType

type FunctionType string
const (
	FunctionCountAll          FunctionType = "count_all"
	FunctionCountValues       FunctionType = "count_values"
	FunctionCountUniqueValues FunctionType = "count_unique_values"
	FunctionCountEmpty        FunctionType = "count_empty"
	FunctionCountNotEmpty     FunctionType = "count_not_empty"
	FunctionPercentEmpty      FunctionType = "percent_empty"
	FunctionPercentNotEmpty   FunctionType = "percent_not_empty"
	FunctionSum               FunctionType = "sum"
	FunctionAverage           FunctionType = "average"
	FunctionMedian            FunctionType = "median"
	FunctionMin               FunctionType = "min"
	FunctionMax               FunctionType = "max"
	FunctionRange             FunctionType = "range"
)

func (FunctionType) String

func (ft FunctionType) String() string

type GetChildrenResponse

type GetChildrenResponse struct {
	Object  ObjectType `json:"object"`
	Results []Block    `json:"results"`
}

type Heading1Block

type Heading1Block struct {
	Object         ObjectType `json:"object"`
	ID             BlockID    `json:"id,omitempty"`
	Type           BlockType  `json:"type"`
	CreatedTime    *time.Time `json:"created_time,omitempty"`
	LastEditedTime *time.Time `json:"last_edited_time,omitempty"`
	HasChildren    bool       `json:"has_children,omitempty"`
	Heading1       struct {
		Text Paragraph `json:"text"`
	} `json:"heading_1"`
}

func (*Heading1Block) GetType

func (b *Heading1Block) GetType() BlockType

type Heading2Block

type Heading2Block struct {
	Object         ObjectType `json:"object"`
	ID             BlockID    `json:"id,omitempty"`
	Type           BlockType  `json:"type"`
	CreatedTime    *time.Time `json:"created_time,omitempty"`
	LastEditedTime *time.Time `json:"last_edited_time,omitempty"`
	HasChildren    bool       `json:"has_children,omitempty"`
	Heading2       struct {
		Text Paragraph `json:"text"`
	} `json:"heading_2"`
}

func (*Heading2Block) GetType

func (b *Heading2Block) GetType() BlockType

type Heading3Block

type Heading3Block struct {
	Object         ObjectType `json:"object"`
	ID             BlockID    `json:"id,omitempty"`
	Type           BlockType  `json:"type"`
	CreatedTime    *time.Time `json:"created_time,omitempty"`
	LastEditedTime *time.Time `json:"last_edited_time,omitempty"`
	HasChildren    bool       `json:"has_children,omitempty"`
	Heading3       struct {
		Text Paragraph `json:"text"`
	} `json:"heading_3"`
}

func (*Heading3Block) GetType

func (b *Heading3Block) GetType() BlockType

type LastEditedByProperty

type LastEditedByProperty struct {
	ID           ObjectID     `json:"id"`
	Type         PropertyType `json:"type"`
	LastEditedBy interface{}  `json:"last_edited_by"`
}

func (LastEditedByProperty) GetType

func (p LastEditedByProperty) GetType() PropertyType

type LastEditedTimeProperty

type LastEditedTimeProperty struct {
	ID             ObjectID     `json:"id"`
	Type           PropertyType `json:"type"`
	LastEditedTime interface{}  `json:"last_edited_time"`
}

func (LastEditedTimeProperty) GetType

type MultiSelectOptionsProperty

type MultiSelectOptionsProperty struct {
	ID          ObjectID     `json:"id,omitempty"`
	Type        PropertyType `json:"type"`
	MultiSelect []Option     `json:"multi_select"`
}

func (MultiSelectOptionsProperty) GetType

type MultiSelectProperty

type MultiSelectProperty struct {
	ID          ObjectID     `json:"id,omitempty"`
	Type        PropertyType `json:"type"`
	MultiSelect Select       `json:"multi_select"`
}

func (MultiSelectProperty) GetType

func (p MultiSelectProperty) GetType() PropertyType

type NumberProperty

type NumberProperty struct {
	ID     ObjectID     `json:"id,omitempty"`
	Type   PropertyType `json:"type"`
	Format FormatType   `json:"format"`
}

func (NumberProperty) GetType

func (p NumberProperty) GetType() PropertyType

type NumberedListItemBlock

type NumberedListItemBlock struct {
	Object           ObjectType `json:"object"`
	ID               BlockID    `json:"id,omitempty"`
	Type             BlockType  `json:"type"`
	CreatedTime      *time.Time `json:"created_time,omitempty"`
	LastEditedTime   *time.Time `json:"last_edited_time,omitempty"`
	HasChildren      bool       `json:"has_children,omitempty"`
	NumberedListItem struct {
		Text     Paragraph `json:"text"`
		Children []Block   `json:"children"`
	} `json:"numbered_list_item"`
}

func (*NumberedListItemBlock) GetType

func (b *NumberedListItemBlock) GetType() BlockType

type Object

type Object interface {
	GetObject() ObjectType
}

type ObjectID

type ObjectID string

func (ObjectID) String

func (oID ObjectID) String() string

type ObjectType

type ObjectType string
const (
	ObjectTypeDatabase ObjectType = "database"
	ObjectTypeBlock    ObjectType = "block"
	ObjectTypePage     ObjectType = "page"
	ObjectTypeList     ObjectType = "list"
	ObjectTypeText     ObjectType = "text"
	ObjectTypeUser     ObjectType = "user"
	ObjectTypeError    ObjectType = "error"
)

func (ObjectType) String

func (ot ObjectType) String() string

type Option

type Option struct {
	ID    PropertyID
	Name  string `json:"name"`
	Color Color  `json:"color"`
}

type Page

type Page struct {
	Object         ObjectType `json:"object"`
	ID             ObjectID   `json:"id"`
	CreatedTime    time.Time  `json:"created_time"`
	LastEditedTime time.Time  `json:"last_edited_time"`
	Archived       bool       `json:"archived"`
	Properties     Properties `json:"properties"`
	Parent         Parent     `json:"parent"`
}

func (*Page) GetObject

func (p *Page) GetObject() ObjectType

type PageClient

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

func (*PageClient) Create

func (pc *PageClient) Create(ctx context.Context, requestBody *PageCreateRequest) (*Page, error)

Create https://developers.notion.com/reference/post-page

func (*PageClient) Update

func (pc *PageClient) Update(ctx context.Context, id PageID, request *PageUpdateRequest) (*Page, error)

Update https://developers.notion.com/reference/patch-page

type PageCreateRequest

type PageCreateRequest struct {
	Parent     Parent     `json:"parent"`
	Properties Properties `json:"properties"`
	Children   []Block    `json:"children,omitempty"`
}

type PageID

type PageID string

func (PageID) String

func (pID PageID) String() string

type PageService

type PageService interface {
	Get(context.Context, PageID) (*Page, error)
	Create(context.Context, *PageCreateRequest) (*Page, error)
	Update(context.Context, PageID, *PageUpdateRequest) (*Page, error)
}

type PageTitleProperty

type PageTitleProperty struct {
	ID    PropertyID   `json:"id,omitempty"`
	Type  PropertyType `json:"type,omitempty"`
	Title Paragraph    `json:"title"`
}

func (PageTitleProperty) GetType

func (p PageTitleProperty) GetType() PropertyType

type PageUpdateRequest

type PageUpdateRequest struct {
	Properties Properties `json:"properties"`
}

type Pagination

type Pagination struct {
	StartCursor Cursor
	PageSize    int
}

func (*Pagination) ToQuery

func (p *Pagination) ToQuery() map[string]string

type Paragraph

type Paragraph []RichText

type ParagraphBlock

type ParagraphBlock struct {
	Object         ObjectType `json:"object"`
	ID             BlockID    `json:"id,omitempty"`
	Type           BlockType  `json:"type"`
	CreatedTime    *time.Time `json:"created_time,omitempty"`
	LastEditedTime *time.Time `json:"last_edited_time,omitempty"`
	HasChildren    bool       `json:"has_children,omitempty"`
	Paragraph      struct {
		Text Paragraph `json:"text"`
	} `json:"paragraph"`
}

func (*ParagraphBlock) GetType

func (b *ParagraphBlock) GetType() BlockType

type Parent

type Parent struct {
	Type       ParentType `json:"type"`
	PageID     PageID     `json:"page_id,omitempty"`
	DatabaseID DatabaseID `json:"database_id,omitempty"`
}

type ParentType

type ParentType string
const (
	ParentTypeDatabaseID ParentType = "database_id"
	ParentTypePageID     ParentType = "page_id"
)

type PeopleProperty

type PeopleProperty struct {
	ID     ObjectID     `json:"id,omitempty"`
	Type   PropertyType `json:"type"`
	People interface{}  `json:"people"`
}

func (PeopleProperty) GetType

func (p PeopleProperty) GetType() PropertyType

type Person

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

type PhoneNumberProperty

type PhoneNumberProperty struct {
	ID          ObjectID     `json:"id,omitempty"`
	Type        PropertyType `json:"type"`
	PhoneNumber interface{}  `json:"phone_number"`
}

func (PhoneNumberProperty) GetType

func (p PhoneNumberProperty) GetType() PropertyType

type Properties

type Properties map[string]Property

func (*Properties) UnmarshalJSON

func (p *Properties) UnmarshalJSON(data []byte) error

type Property

type Property interface {
	GetType() PropertyType
}

type PropertyFilter

type PropertyFilter struct {
	Property    PropertyType                    `json:"property"`
	Text        map[Condition]string            `json:"text,omitempty"`
	Number      map[Condition]float64           `json:"number,omitempty"`
	Checkbox    map[Condition]bool              `json:"checkbox,omitempty"`
	Select      map[Condition]interface{}       `json:"select,omitempty"`
	MultiSelect map[Condition]interface{}       `json:"multi_select,omitempty"`
	Date        map[Condition]time.Time         `json:"date,omitempty"`
	People      map[Condition]interface{}       `json:"people,omitempty"`
	Files       map[Condition]bool              `json:"files,omitempty"`
	Relation    map[Condition]interface{}       `json:"relation,omitempty"`
	Formula     map[PropertyType]PropertyFilter `json:"formula,omitempty"`
}

type PropertyID

type PropertyID string

func (PropertyID) String

func (pID PropertyID) String() string

type PropertyType

type PropertyType string
const (
	PropertyTypeTitle          PropertyType = "title"
	PropertyTypeRichText       PropertyType = "rich_text"
	PropertyTypeSelect         PropertyType = "select"
	PropertyTypeMultiSelect    PropertyType = "multi_select"
	PropertyTypeNumber         PropertyType = "number"
	PropertyTypeCheckbox       PropertyType = "checkbox"
	PropertyTypeEmail          PropertyType = "email"
	PropertyTypeURL            PropertyType = "url"
	PropertyTypeFile           PropertyType = "file"
	PropertyTypePhoneNumber    PropertyType = "phone_number"
	PropertyTypeFormula        PropertyType = "formula"
	PropertyTypeDate           PropertyType = "date"
	PropertyTypeRelation       PropertyType = "relation"
	PropertyTypeRollup         PropertyType = "rollup"
	PropertyTypePeople         PropertyType = "people"
	PropertyTypeCreatedTime    PropertyType = "created_time"
	PropertyTypeCreatedBy      PropertyType = "created_by"
	PropertyTypeLastEditedTime PropertyType = "last_edited_time"
	PropertyTypeLastEditedBy   PropertyType = "last_edited_by"
)

type Relation

type Relation struct {
	DatabaseID         DatabaseID `json:"database_id"`
	SyncedPropertyID   PropertyID `json:"synced_property_id"`
	SyncedPropertyName string     `json:"synced_property_name"`
}

type RelationObject

type RelationObject struct {
	Database           DatabaseID `json:"database"`
	SyncedPropertyName string     `json:"synced_property_name"`
}

type RelationProperty

type RelationProperty struct {
	Type     PropertyType `json:"type"`
	Relation Relation     `json:"relation"`
}

func (RelationProperty) GetType

func (p RelationProperty) GetType() PropertyType

type RichText

type RichText struct {
	Type        ObjectType   `json:"type,omitempty"`
	Text        Text         `json:"text"`
	Annotations *Annotations `json:"annotations,omitempty"`
	PlainText   string       `json:"plain_text,omitempty"`
	Href        string       `json:"href,omitempty"`
}

type RichTextProperty

type RichTextProperty struct {
	ID       PropertyID   `json:"id,omitempty"`
	Type     PropertyType `json:"type"`
	RichText []RichText   `json:"rich_text"`
}

func (RichTextProperty) GetType

func (p RichTextProperty) GetType() PropertyType

type Rollup

type Rollup struct {
	RelationPropertyName string       `json:"relation_property_name"`
	RelationPropertyID   PropertyID   `json:"relation_property_id"`
	RollupPropertyName   string       `json:"rollup_property_name"`
	RollupPropertyID     PropertyID   `json:"rollup_property_id"`
	Function             FunctionType `json:"function"`
}

type RollupProperty

type RollupProperty struct {
	ID     ObjectID     `json:"id,omitempty"`
	Type   PropertyType `json:"type"`
	Rollup Rollup       `json:"rollup"`
}

func (RollupProperty) GetType

func (p RollupProperty) GetType() PropertyType

type SearchClient

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

type SearchRequest

type SearchRequest struct {
	Query       string      `json:"query,omitempty"`
	Sort        *SortObject `json:"sort,omitempty"`
	Filter      Filter      `json:"filter,omitempty"`
	StartCursor Cursor      `json:"start_cursor,omitempty"`
	PageSize    int         `json:"page_size"`
}

type SearchResponse

type SearchResponse struct {
	Object     ObjectType `json:"object"`
	Results    []Object   `json:"results"`
	HasMore    bool       `json:"has_more"`
	NextCursor Cursor     `json:"next_cursor"`
}

func (*SearchResponse) UnmarshalJSON

func (sr *SearchResponse) UnmarshalJSON(data []byte) error

type SearchService

type SearchService interface {
	Do(context.Context, *SearchRequest) (*SearchResponse, error)
}

type Select

type Select struct {
	Options []Option `json:"options"`
}

type SelectProperty

type SelectProperty struct {
	ID     ObjectID     `json:"id,omitempty"`
	Type   PropertyType `json:"type"`
	Select Select       `json:"select"`
}

func (SelectProperty) GetType

func (p SelectProperty) GetType() PropertyType

type SortObject

type SortObject struct {
	Property  string        `json:"property,omitempty"`
	Timestamp TimestampType `json:"timestamp"`
	Direction SortOrder     `json:"direction"`
}

type SortOrder

type SortOrder string
const (
	SortOrderASC  SortOrder = "ascending"
	SortOrderDESC SortOrder = "descending"
)

type Text

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

type TextProperty

type TextProperty struct {
	ID    PropertyID   `json:"id,omitempty"`
	Type  PropertyType `json:"type"`
	Title []RichText   `json:"title"`
}

func (TextProperty) GetType

func (p TextProperty) GetType() PropertyType

type TimestampType

type TimestampType string
const (
	TimestampCreated    TimestampType = "created_time"
	TimestampLastEdited TimestampType = "last_edited_time"
)

type ToDoBlock

type ToDoBlock struct {
	Object         ObjectType `json:"object"`
	ID             BlockID    `json:"id,omitempty"`
	Type           BlockType  `json:"type"`
	CreatedTime    *time.Time `json:"created_time,omitempty"`
	LastEditedTime *time.Time `json:"last_edited_time,omitempty"`
	HasChildren    bool       `json:"has_children"`
	ToDo           struct {
		Text     Paragraph `json:"text"`
		Children []Block   `json:"children"`
		Checked  bool      `json:"checked"`
	} `json:"to_do"`
}

func (*ToDoBlock) GetType

func (b *ToDoBlock) GetType() BlockType

type ToggleBlock

type ToggleBlock struct {
	Object         ObjectType `json:"object"`
	ID             BlockID    `json:"id,omitempty"`
	Type           BlockType  `json:"type"`
	CreatedTime    *time.Time `json:"created_time,omitempty"`
	LastEditedTime *time.Time `json:"last_edited_time,omitempty"`
	HasChildren    bool       `json:"has_children,omitempty"`
	Text           Paragraph  `json:"text"`
	Children       []Block    `json:"children"`
	Toggle         struct {
		Text     Paragraph `json:"text"`
		Children []Block   `json:"children"`
	} `json:"toggle"`
}

func (*ToggleBlock) GetType

func (b *ToggleBlock) GetType() BlockType

type Token

type Token string

func (Token) String

func (it Token) String() string

type URLProperty

type URLProperty struct {
	ID   ObjectID     `json:"id,omitempty"`
	Type PropertyType `json:"type"`
	URL  interface{}  `json:"url"`
}

func (URLProperty) GetType

func (p URLProperty) GetType() PropertyType

type User

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

type UserClient

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

type UserID

type UserID string

func (UserID) String

func (uID UserID) String() string

type UserService

type UserService interface {
	Get(context.Context, UserID) (*User, error)
	List(context.Context, *Pagination) (*UsersListResponse, error)
}

type UserType

type UserType string
const (
	UserTypePerson UserType = "person"
	UserTypeBot    UserType = "bot"
)

type UsersListResponse

type UsersListResponse struct {
	Object     ObjectType `json:"object"`
	Results    []User     `json:"results"`
	HasMore    bool       `json:"has_more"`
	NextCursor Cursor     `json:"next_cursor"`
}