Documentation
¶
Index ¶
- type API
- type Annotation
- type Block
- type BlockType
- type CheckboxFilterCondition
- type ChildPage
- type Client
- func (c *Client) AppendBlockChildren(ctx context.Context, blockID string, children ...*Block) error
- func (c *Client) CreatePage(ctx context.Context, parent Parent, properties map[string]*PropertyValue, ...) (*Page, error)
- func (c *Client) ListAllUsers(ctx context.Context, pageSize int32, startCursor string) ([]*User, string, bool, error)
- func (c *Client) ListDatabases(ctx context.Context, pageSize int32, startCursor string) ([]*Database, string, bool, error)
- func (c *Client) QueryDatabase(ctx context.Context, databaseID string, param QueryDatabaseParam) ([]*Page, string, bool, error)
- func (c *Client) RetrieveBlockChildren(ctx context.Context, blockID string, pageSize int32, startCursor string) ([]*Block, string, bool, error)
- func (c *Client) RetrieveDatabase(ctx context.Context, databaseID string) (*Database, error)
- func (c *Client) RetrievePage(ctx context.Context, pageID string) (*Page, error)
- func (c *Client) RetrieveUser(ctx context.Context, userID string) (*User, error)
- func (c *Client) Search(ctx context.Context, param SearchParam) ([]*Object, string, bool, error)
- func (c *Client) UpdatePageProperties(ctx context.Context, pageID string, properties map[string]*PropertyValue) (*Page, error)
- type Color
- type CreatePageBody
- type CreatePageRequest
- type Database
- type Date
- type DateFilterCondition
- type Equation
- type ErrCode
- type Error
- type File
- type FilesFilterCondition
- type Filter
- type FormulaFilterCondition
- type FormulaValue
- type FormulaValueType
- type Heading
- type Link
- type List
- type ListItem
- type Mention
- type MentionType
- type MultiSelectFilterCondition
- type NumberFilterCondition
- type NumberFormat
- type OAuthAccessToken
- type OAuthClient
- type Object
- type ObjectReference
- type ObjectType
- type Objects
- type Page
- type Paragraph
- type Parent
- type ParentType
- type PeopleFilterCondition
- type Property
- type PropertyType
- type PropertyValue
- func NewCheckboxPropertyValue(check bool) *PropertyValue
- func NewDatePropertyValue(date *Date) *PropertyValue
- func NewEmailPropertyValue(email string) *PropertyValue
- func NewFilesPropertyValue(files ...*File) *PropertyValue
- func NewMultiSelectPropertyValue(options ...*SelectOption) *PropertyValue
- func NewNumberPropertyValue(number float64) *PropertyValue
- func NewPeoplePropertyValue(people ...*User) *PropertyValue
- func NewPhoneNumberPropertyValue(phoneNumber string) *PropertyValue
- func NewRelationPropertyValue(relation ...*ObjectReference) *PropertyValue
- func NewRichTextPropertyValue(texts ...*RichText) *PropertyValue
- func NewSelectPropertyValue(option *SelectOption) *PropertyValue
- func NewTitlePropertyValue(texts ...*RichText) *PropertyValue
- func NewURLPropertyValue(url string) *PropertyValue
- type QueryDatabaseParam
- type RelationFilterCondition
- type RichText
- type RichTextType
- type RollupValue
- type RollupValueType
- type SearchFilter
- type SearchParam
- type SelectFilterCondition
- type SelectOption
- type Settings
- type Sort
- type SortDirection
- type Text
- type TextFilterCondition
- type ToDo
- type Toggle
- type User
- type UserType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface { // RetrieveDatabase retrieves a database. RetrieveDatabase(ctx context.Context, databaseID string) (*Database, error) // QueryDatabase queries a database. QueryDatabase(ctx context.Context, databaseID string, param QueryDatabaseParam) (results []*Page, nextCursor string, hasMore bool, err error) // ListDatabases lists databases. ListDatabases(ctx context.Context, pageSize int32, startCursor string) (results []*Database, nextCursor string, hasMore bool, err error) // RetrievePage retrieves a page. RetrievePage(ctx context.Context, pageID string) (*Page, error) // CreatePage creates a new page. CreatePage(ctx context.Context, parent Parent, properties map[string]*PropertyValue, children ...*Block) (*Page, error) // UpdatePageProperties updates pages' properties. // The keys of properties are the names or IDs of the property and the values are property values. UpdatePageProperties(ctx context.Context, pageID string, properties map[string]*PropertyValue) (*Page, error) // RetrieveBlockChildren retrieves child blocks of block. RetrieveBlockChildren(ctx context.Context, blockID string, pageSize int32, startCursor string) (results []*Block, nextCursor string, hasMore bool, err error) // AppendBlockChildren creates new child blocks. AppendBlockChildren(ctx context.Context, blockID string, children ...*Block) error // RetrieveUser retrieves user. RetrieveUser(ctx context.Context, userID string) (*User, error) // ListAllUsers lists all users. ListAllUsers(ctx context.Context, pageSize int32, startCursor string) (results []*User, nextCursor string, hasMore bool, err error) // Search searches objects. Search(ctx context.Context, param SearchParam) (results []*Object, nextCursor string, hasMore bool, err error) }
API is declaration of Notion.so APIs.
type Annotation ¶
type Annotation struct { // Whether the text is bolded. Bold bool `json:"bold,omitempty"` // Whether the text is italicized. Italic bool `json:"italic,omitempty"` // Whether the text is struck through. Strikethrough bool `json:"strikethrough,omitempty"` // Whether the text is underlined. Underline bool `json:"underline,omitempty"` // Whether the text is code style. Code bool `json:"code,omitempty"` // Color of the text. Color Color `json:"color,omitempty"` }
Annotation is style information which applies to the whole rich text object.
type Block ¶
type Block struct { Object ObjectType `json:"object,omitempty"` ID string `json:"id,omitempty"` CreatedTime time.Time `json:"created_time,omitempty"` LastEditedTime time.Time `json:"last_edited_time,omitempty"` HasChildren bool `json:"has_children,omitempty"` Type BlockType `json:"type,omitempty"` Heading1 *Heading `json:"heading_1,omitempty"` Heading2 *Heading `json:"heading_2,omitempty"` Heading3 *Heading `json:"heading_3,omitempty"` Paragraph *Paragraph `json:"paragraph,omitempty"` BulletedListItem *ListItem `json:"bulleted_list_item,omitempty"` NumberedListItem *ListItem `json:"numbered_list_item,omitempty"` ToDo *ToDo `json:"to_do,omitempty"` Toggle *Toggle `json:"toggle,omitempty"` ChildPage *ChildPage `json:"child_page,omitempty"` }
Block object represents content within Notion.
func (*Block) MarshalJSON ¶
MarshalJSON marshal Block to json and set Object to "block" automatically.
type BlockType ¶
type BlockType string
BlockType is type of Block.
const ( BlockParagraph BlockType = "paragraph" BlockHeading1 BlockType = "heading_1" BlockHeading2 BlockType = "heading_2" BlockHeading3 BlockType = "heading_3" BlockBulletedListItem BlockType = "bulleted_list_item" BlockNumberedListItem BlockType = "numbered_list_item" BlockToDo BlockType = "to_do" BlockToggle BlockType = "toggle" // BlockChildPage is not support appending currently. BlockChildPage BlockType = "child_page" BlockUnsupported BlockType = "unsupported" )
BlockType enums.
type CheckboxFilterCondition ¶
type CheckboxFilterCondition struct { Equals bool `json:"equals,omitempty"` DoesNotEqual bool `json:"does_not_equal,omitempty"` }
CheckboxFilterCondition applies to database properties of type "checkbox".
type ChildPage ¶
type ChildPage struct {
Title string `json:"title,omitempty"`
}
ChildPage contains information of child page.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is implement of API.
func (*Client) AppendBlockChildren ¶
AppendBlockChildren implements API.AppendBlockChildren.
func (*Client) CreatePage ¶
func (c *Client) CreatePage(ctx context.Context, parent Parent, properties map[string]*PropertyValue, children ...*Block) (*Page, error)
CreatePage implements API.CreatePage.
func (*Client) ListAllUsers ¶
func (c *Client) ListAllUsers(ctx context.Context, pageSize int32, startCursor string) ([]*User, string, bool, error)
ListAllUsers implements API.ListAllUsers.
func (*Client) ListDatabases ¶
func (c *Client) ListDatabases(ctx context.Context, pageSize int32, startCursor string) ([]*Database, string, bool, error)
ListDatabases implements API.ListDatabases.
func (*Client) QueryDatabase ¶
func (c *Client) QueryDatabase(ctx context.Context, databaseID string, param QueryDatabaseParam) ([]*Page, string, bool, error)
QueryDatabase implements API.QueryDatabase.
func (*Client) RetrieveBlockChildren ¶
func (c *Client) RetrieveBlockChildren(ctx context.Context, blockID string, pageSize int32, startCursor string) ([]*Block, string, bool, error)
RetrieveBlockChildren implements API.RetrieveBlockChildren.
func (*Client) RetrieveDatabase ¶
RetrieveDatabase implements API.RetrieveDatabase.
func (*Client) RetrievePage ¶
RetrievePage implements API.RetrievePage.
func (*Client) RetrieveUser ¶
RetrieveUser implements API.RetrieveUser.
func (*Client) UpdatePageProperties ¶
func (c *Client) UpdatePageProperties(ctx context.Context, pageID string, properties map[string]*PropertyValue) (*Page, error)
UpdatePageProperties implements API.UpdatePageProperties.
type Color ¶
type Color string
Color is color definition of Notion.
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" )
Color enums.
type CreatePageBody ¶
type CreatePageBody struct { Parent Parent `json:"parent,omitempty"` Properties map[string]*PropertyValue `json:"properties"` Children []*Block `json:"children,omitempty"` }
type CreatePageRequest ¶
type CreatePageRequest struct {
Body CreatePageBody `json:"body"`
}
type Database ¶
type Database struct { Object ObjectType `json:"object,omitempty"` ID string `json:"id,omitempty"` CreatedTime time.Time `json:"created_time,omitempty"` LastEditedTime time.Time `json:"last_edited_time,omitempty"` Title []*RichText `json:"title,omitempty"` Properties map[string]Property `json:"properties,omitempty"` }
Database objects describe the property schema of a database in Notion. Page are the items (or children) in a database. Page property values must conform to the property objects laid out in the parent database object.
type Date ¶
type Date struct { Start time.Time // If null, this property's date value is not a range. End *time.Time }
Date represents a datetime or time range.
type DateFilterCondition ¶
type DateFilterCondition struct { Equals *time.Time `json:"equals,omitempty"` Before *time.Time `json:"before,omitempty"` After *time.Time `json:"after,omitempty"` OnOrBefore *time.Time `json:"on_or_before,omitempty"` OnOrAfter *time.Time `json:"on_or_after,omitempty"` IsEmpty bool `json:"is_empty,omitempty"` IsNotEmpty bool `json:"is_not_empty,omitempty"` PassWeek *struct{} `json:"pass_week,omitempty"` PastYear *struct{} `json:"past_year,omitempty"` NextWeek *struct{} `json:"next_week,omitempty"` NextMonth *struct{} `json:"next_month,omitempty"` NextYear *struct{} `json:"next_year,omitempty"` }
DateFilterCondition applies to database properties of types "date", "created_time", and "last_edited_time".
type Equation ¶
type Equation struct { // Expression The LaTeX string representing this inline equation. Expression string `json:"expression,omitempty"` }
Equation .
type ErrCode ¶
type ErrCode string
ErrCode is the "code" field in Notion error
const ( // ErrCodeInvalidJSON The request body could not be decoded as JSON. ErrCodeInvalidJSON ErrCode = "invalid_json" // ErrCodeInvalidRequestURL The request URL is not valid. ErrCodeInvalidRequestURL ErrCode = "invalid_request_url" // ErrCodeInvalidRequest This request is not supported. ErrCodeInvalidRequest ErrCode = "invalid_request" // ErrCodeValidationError The request body does not match the schema for the expected parameters. // Check the "message" property for more details. ErrCodeValidationError ErrCode = "validation_error" ErrCodeUnauthorized ErrCode = "unauthorized" // ErrCodeRestrictedResource Given the bearer token used, the client doesn't have permission to perform this operation. ErrCodeRestrictedResource ErrCode = "restricted_resource" // ErrCodeObjectNotFound Given the bearer token used, the resource does not exist. // This error can also indicate that the resource has not been shared with owner of the bearer token. ErrCodeObjectNotFound ErrCode = "object_not_found" // ErrCodeConflictError The transaction could not be completed, potentially due to a data collision. // Make sure the parameters are up to date and try again. ErrCodeConflictError ErrCode = "conflict_error" // ErrCodeRateLimited This request exceeds the number of requests allowed. // Slow down and try again.More details on rate limits ErrCodeRateLimited ErrCode = "rate_limited" // ErrCodeInternalServerError An unexpected error occurred.Reach out to Notion support. ErrCodeInternalServerError ErrCode = "internal_server_error" // This can occur when the time to respond to a request takes longer than 60 seconds, the maximum request timeout. ErrCodeServiceUnavailable ErrCode = "service_unavailable" )
type Error ¶
type Error struct { Status int `json:"status,omitempty"` Code ErrCode `json:"code,omitempty"` Message string `json:"message,omitempty"` }
Error is Notion error response body.
type File ¶
type File struct {
Name string `json:"name,omitempty"`
}
File reference is an object with an name property, with a string value corresponding to a filename of the original file upload (i.e. "Whole_Earth_Catalog.jpg").
type FilesFilterCondition ¶
type FilesFilterCondition struct { IsEmpty bool `json:"is_empty,omitempty"` IsNotEmpty bool `json:"is_not_empty,omitempty"` }
FilesFilterCondition applies to database properties of type "files".
type Filter ¶
type Filter struct { Property string `json:"property,omitempty"` Text *TextFilterCondition `json:"text,omitempty"` Number *NumberFilterCondition `json:"number,omitempty"` Checkbox *CheckboxFilterCondition `json:"checkbox,omitempty"` Select *SelectFilterCondition `json:"select,omitempty"` MultiSelect *MultiSelectFilterCondition `json:"multi_select,omitempty"` Date *DateFilterCondition `json:"date,omitempty"` People *PeopleFilterCondition `json:"people,omitempty"` Files *FilesFilterCondition `json:"files,omitempty"` Relation *RelationFilterCondition `json:"relation,omitempty"` Formula *FormulaFilterCondition `json:"formula,omitempty"` // And is Compound filter. And []*Filter `json:"and,omitempty"` // Or is Compound filter. Or []*Filter `json:"or,omitempty"` }
Filter is mix type of database query filter.
type FormulaFilterCondition ¶
type FormulaFilterCondition struct { Text *TextFilterCondition `json:"text,omitempty"` Checkbox *CheckboxFilterCondition `json:"checkbox,omitempty"` Number *NumberFilterCondition `json:"number,omitempty"` Date *DateFilterCondition `json:"date,omitempty"` }
FormulaFilterCondition applies to database properties of type "formula".
type FormulaValue ¶
type FormulaValue struct { Type FormulaValueType `json:"type,omitempty"` String string `json:"string,omitempty"` Number float64 `json:"number,omitempty"` Boolean bool `json:"boolean,omitempty"` Date *Date `json:"date,omitempty"` }
FormulaValue represents the result of evaluating a formula described in the database's properties. These objects contain a type key and a key corresponding with the value of type.
type FormulaValueType ¶
type FormulaValueType string
FormulaValueType is type of formula value.
const ( FormulaValueString FormulaValueType = "string" FormulaValueNumber FormulaValueType = "number" FormulaValueBoolen FormulaValueType = "boolean" FormulaValueDate FormulaValueType = "date" )
FormulaValueType enums.
type Heading ¶
type Heading struct {
Text []*RichText `json:"text,omitempty"`
}
Heading is the common type of Heading1, Heading2, Heading3.
type Link ¶
type Link struct { URL string `json:"url,omitempty"` // Type is always be "url". Type string `json:"type,omitempty"` }
Link objects contain a type key whose value is always "url" and a url key whose value is a web address.
type List ¶
type List struct { Object ObjectType `json:"object,omitempty"` Results Objects `json:"results,omitempty"` NextCursor string `json:"next_cursor,omitempty"` HasMore bool `json:"has_more,omitempty"` }
List is Pagination response type.
type ListItem ¶
type ListItem struct { Text []*RichText `json:"text"` Children []*Block `json:"children,omitempty"` }
ListItem is the common type of BulletedListItem and NumberedListItem.
type Mention ¶
type Mention struct { // Type of the inline mention. Type MentionType `json:"type,omitempty"` // User mentions contain a user object within the user property. User *User `json:"user,omitempty"` // Page mentions contain a page reference within the page property. // A page reference is an object with an id property, with a string value (UUIDv4) corresponding to a page ID. Page *ObjectReference `json:"page,omitempty"` // Database mentions contain a database reference within the database property. // A database reference is an object with an id property, with a string value (UUIDv4) corresponding to a database ID. Database *ObjectReference `json:"database,omitempty"` // Date mentions contain a date property value object within the date property. Date *Date `json:"date,omitempty"` }
Mention objects represent an inline mention of a user, page, database, or date. In the app these are created by typing @ followed by the name of a user, page, database, or a date.
Mention objects contain a type key. In addition, mention objects contain a key corresponding with the value of type. The value is an object containing type-specific configuration. The type-specific configurations are described in the sections below.
type MentionType ¶
type MentionType string
MentionType is type of Mention.
const ( MentionUser MentionType = "user" MentionPage MentionType = "page" MentionDatabase MentionType = "database" MentionDate MentionType = "date" )
MentionType enums.
type MultiSelectFilterCondition ¶
type MultiSelectFilterCondition struct { Contains string `json:"contains,omitempty"` DoesNotContain string `json:"does_not_contain,omitempty"` IsEmpty bool `json:"is_empty,omitempty"` IsNotEmpty bool `json:"is_not_empty,omitempty"` }
MultiSelectFilterCondition applies to database properties of type "multi_select".
type NumberFilterCondition ¶
type NumberFilterCondition struct { Equals float64 `json:"equals,omitempty"` DoesNotEqual float64 `json:"does_not_equal,omitempty"` GreaterThan float64 `json:"greater_than,omitempty"` LessThan float64 `json:"less_than,omitempty"` GreaterThanOrEqualTo float64 `json:"greater_than_or_equal_to,omitempty"` LessThanOrEqualTo float64 `json:"less_than_or_equal_to,omitempty"` IsEmpty bool `json:"is_empty,omitempty"` IsNotEmpty bool `json:"is_not_empty,omitempty"` }
NumberFilterCondition applies to database properties of type "number".
type NumberFormat ¶
type NumberFormat string
NumberFormat is format of number property value.
const ( NumberFormatNumber NumberFormat = "number" NumberFormatNumberWithCommas NumberFormat = "number_with_commas" NumberFormatPercent NumberFormat = "percent" NumberFormatDollar NumberFormat = "dollar" NumberFormatEuro NumberFormat = "euro" NumberFormatPound NumberFormat = "pound" NumberFormatYen NumberFormat = "yen" NumberFormatRuble NumberFormat = "ruble" NumberFormatRupee NumberFormat = "rupee" NumberFormatWon NumberFormat = "won" NumberFormatYuan NumberFormat = "yuan" )
NumberFormat enums.
type OAuthAccessToken ¶
type OAuthAccessToken struct { AccessToken string `json:"access_token,omitempty"` WorkspaceName string `json:"workspace_name,omitempty"` WorkspaceIcon string `json:"workspace_icon,omitempty"` BotID string `json:"bot_id,omitempty"` }
OAuthAccessToken is the response of OAuth token exchanging. You can use AccessToken as Client token to access normal Notion api.
type OAuthClient ¶
type OAuthClient struct {
// contains filtered or unexported fields
}
OAuthClient is client to exchange OAuth token.
func NewOAuthClient ¶
func NewOAuthClient(clientID, clientSecret, redirectURI string) *OAuthClient
NewOAuthClient creates a OAuthClient.
func (*OAuthClient) ExchangeAccessToken ¶
func (c *OAuthClient) ExchangeAccessToken(ctx context.Context, code string) (*OAuthAccessToken, error)
ExchangeAccessToken exchanges the auth code to api token.
type Object ¶
type Object struct { Type ObjectType // contains filtered or unexported fields }
Object is the mix type of Top-level resources.
func (*Object) MarshalJSON ¶
MarshalJSON picks the value field for JSON marshalling.
func (*Object) UnmarshalJSON ¶
UnmarshalJSON unmarshalls bytes to the correct Object field according to "object" type field.
type ObjectReference ¶
type ObjectReference struct { // Object may be empty in some cases. Object ObjectType `json:"object,omitempty"` ID string `json:"id,omitempty"` }
ObjectReference is simple type of Object that just contains id and type.
type ObjectType ¶
type ObjectType string
ObjectType is enum of Notion top level resource types.
const ( ObjectList ObjectType = "list" ObjectDatabase ObjectType = "database" ObjectPage ObjectType = "page" ObjectUser ObjectType = "user" ObjectBlock ObjectType = "block" )
ObjectType enums.
type Objects ¶
type Objects []*Object
Objects is wrapper of Object list.
type Page ¶
type Page struct { Object ObjectType `json:"object,omitempty"` ID string `json:"id,omitempty"` Title string `json:"title,omitempty"` CreatedTime time.Time `json:"created_time"` LastEditedTime time.Time `json:"last_edited_time"` Archived bool `json:"archived,omitempty"` Properties map[string]PropertyValue `json:"properties,omitempty"` Parent Parent `json:"parent,omitempty"` }
Page object contains the property values of a single Notion page. All pages have a parent. If the parent is a database, the property values conform to the schema laid out database's properties. Otherwise, the only property value is the title. Page content is available as blocks. The content can be read using retrieve block children and appended using append block children.
func (*Page) MarshalJSON ¶
MarshalJSON marshal Page to json and set Object to "page" automatically.
type Paragraph ¶
type Paragraph struct { Text []*RichText `json:"text"` Children []*Block `json:"children,omitempty"` }
Paragraph is paragraph block.
type Parent ¶
type Parent struct { Type ParentType `json:"type,omitempty"` PageID string `json:"page_id,omitempty"` DatabaseID string `json:"database_id,omitempty"` Workspace bool `json:"workspace,omitempty"` }
Parent represents the Page parent.
func NewDatabaseParent ¶
NewDatabaseParent creates a database parent.
func NewWorkspaceParent ¶
func NewWorkspaceParent() Parent
NewWorkspaceParent creates a workspace parent.
type ParentType ¶
type ParentType string
ParentType is type of Parent.
const ( ParentDatabase ParentType = "database_id" ParentPage ParentType = "page_id" ParentWorkspace ParentType = "workspace" )
ParentType enums.
type PeopleFilterCondition ¶
type PeopleFilterCondition struct { Contains string `json:"contains,omitempty"` DoesNotContain string `json:"does_not_contain,omitempty"` IsEmpty string `json:"is_empty,omitempty"` IsNotEmpty string `json:"is_not_empty,omitempty"` }
PeopleFilterCondition applies to database properties of types "date", "created_by", and "last_edited_by".
type Property ¶
type Property struct { ID string `json:"id,omitempty"` Type PropertyType `json:"type,omitempty"` Title *struct{} `json:"title,omitempty"` RichText *struct{} `json:"rich_text,omitempty"` Number *struct { Format NumberFormat `json:"format,omitempty"` } `json:"number,omitempty"` Select *struct { Options []*SelectOption `json:"options,omitempty"` } `json:"select,omitempty"` MultiSelect *struct { Options []*SelectOption `json:"options,omitempty"` } `json:"multi_select,omitempty"` Checkbox *struct{} `json:"checkbox,omitempty"` URL *struct{} `json:"url,omitempty"` Email *struct{} `json:"email,omitempty"` PhoneNumber *struct{} `json:"phone_number,omitempty"` Formula *struct { Expression string `json:"expression,omitempty"` } `json:"formula,omitempty"` Relation *struct { DatabaseID string `json:"database_id,omitempty"` SyncedPropertyName string `json:"synced_property_name,omitempty"` SyncedPropertyID string `json:"synced_property_id,omitempty"` } `json:"relation,omitempty"` Rollup *struct { RelationPropertyName string `json:"relation_property_name,omitempty"` RelationPropertyID string `json:"relation_property_id,omitempty"` RollupPropertyName string `json:"rollup_property_name,omitempty"` RollupPropertyID string `json:"rollup_property_id,omitempty"` Function string `json:"function,omitempty"` } `json:"rollup,omitempty"` People *struct{} `json:"people,omitempty"` Date *struct{} `json:"date,omitempty"` File *struct{} `json:"files,omitempty"` CreatedTime *struct{} `json:"created_time,omitempty"` CreatedBy *struct{} `json:"created_by,omitempty"` LastEditedTime *struct{} `json:"last_edited_time,omitempty"` LastEditedBy *struct{} `json:"last_edited_by,omitempty"` }
Property is mix type of database property.
type PropertyType ¶
type PropertyType string
PropertyType is type of database Property.
const ( PropertyTitle PropertyType = "title" PropertyRichText PropertyType = "rich_text" PropertyNumber PropertyType = "number" PropertySelect PropertyType = "select" PropertyMultiSelect PropertyType = "multi_select" PropertyDate PropertyType = "date" PropertyPeople PropertyType = "people" PropertyFile PropertyType = "file" PropertyCheckbox PropertyType = "checkbox" PropertyURL PropertyType = "url" PropertyEmail PropertyType = "email" PropertyPhoneNumber PropertyType = "phone_number" PropertyFormula PropertyType = "formula" PropertyRelation PropertyType = "relation" PropertyRollup PropertyType = "rollup" PropertyCreatedTime PropertyType = "created_time" PropertyCreatedBy PropertyType = "created_by" PropertyLastEditedTime PropertyType = "last_edited_time" PropertyLastEditedBy PropertyType = "last_edited_by" )
PropertyType enums.
type PropertyValue ¶
type PropertyValue struct { ID string `json:"id,omitempty"` Type PropertyType `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 *FormulaValue `json:"formula,omitempty"` // Relation is an array of page references. Relation []*ObjectReference `json:"relation,omitempty"` Rollup *RollupValue `json:"rollup,omitempty"` // People is an array of user objects. People []*User `json:"people,omitempty"` // Files is an array of file references. Files []*File `json:"files,omitempty"` Checkbox bool `json:"checkbox,omitempty"` // URL describes a web address (i.e. "http://worrydream.com/EarlyHistoryOfSmalltalk/"). URL string `json:"url,omitempty"` // Email describes an email address (i.e. "hello@example.org"). Email string `json:"email,omitempty"` // PhoneNumber describes a phone number. No structure is enforced. PhoneNumber string `json:"phone_number,omitempty"` // CreatedBy describes the user who created this page. CreatedBy *User `json:"created_by,omitempty"` // LastEditedBy describes the user who last updated this page. LastEditedBy *User `json:"last_edited_by,omitempty"` // CreatedTime contains the date and time when this page was created. CreatedTime *time.Time `json:"created_time,omitempty"` // LastEditedTime contains the date and time when this page was last updated. LastEditedTime *time.Time `json:"last_edited_time,omitempty"` }
PropertyValue is the property value of Page. It must contain a key corresponding with the value of type. The value is an object containing type-specific data.
func NewCheckboxPropertyValue ¶
func NewCheckboxPropertyValue(check bool) *PropertyValue
NewCheckboxPropertyValue creates a CheckboxPropertyValue.
func NewDatePropertyValue ¶
func NewDatePropertyValue(date *Date) *PropertyValue
NewDatePropertyValue creates a DatePropertyValue.
func NewEmailPropertyValue ¶
func NewEmailPropertyValue(email string) *PropertyValue
NewEmailPropertyValue creates a EmailPropertyValue.
func NewFilesPropertyValue ¶
func NewFilesPropertyValue(files ...*File) *PropertyValue
NewFilesPropertyValue creates a FilesPropertyValue.
func NewMultiSelectPropertyValue ¶
func NewMultiSelectPropertyValue(options ...*SelectOption) *PropertyValue
NewMultiSelectPropertyValue creates a MultiSelectPropertyValue.
func NewNumberPropertyValue ¶
func NewNumberPropertyValue(number float64) *PropertyValue
NewNumberPropertyValue creates a NumberPropertyValue.
func NewPeoplePropertyValue ¶
func NewPeoplePropertyValue(people ...*User) *PropertyValue
NewPeoplePropertyValue creates a PeoplePropertyValue.
func NewPhoneNumberPropertyValue ¶
func NewPhoneNumberPropertyValue(phoneNumber string) *PropertyValue
NewPhoneNumberPropertyValue creates a PhonePropertyValue.
func NewRelationPropertyValue ¶
func NewRelationPropertyValue(relation ...*ObjectReference) *PropertyValue
NewRelationPropertyValue creates a RelationPropertyValue.
func NewRichTextPropertyValue ¶
func NewRichTextPropertyValue(texts ...*RichText) *PropertyValue
NewRichTextPropertyValue creates a RichTextPropertyValue.
func NewSelectPropertyValue ¶
func NewSelectPropertyValue(option *SelectOption) *PropertyValue
NewSelectPropertyValue creates a SelectPropertyValue.
func NewTitlePropertyValue ¶
func NewTitlePropertyValue(texts ...*RichText) *PropertyValue
NewTitlePropertyValue creates a TitlePropertyValue.
func NewURLPropertyValue ¶
func NewURLPropertyValue(url string) *PropertyValue
NewURLPropertyValue creates a URLPropertyValue.
type QueryDatabaseParam ¶
type QueryDatabaseParam struct { Filter *Filter `json:"filter,omitempty"` Sorts []*Sort `json:"sorts,omitempty"` StartCursor string `json:"start_cursor,omitempty"` PageSize int32 `json:"page_size,omitempty"` }
QueryDatabaseParam is the param of QueryDatabase.
type RelationFilterCondition ¶
type RelationFilterCondition struct { Contains string `json:"contains,omitempty"` DoesNotContain string `json:"does_not_contain,omitempty"` IsEmpty bool `json:"is_empty,omitempty"` IsNotEmpty bool `json:"is_not_empty,omitempty"` }
RelationFilterCondition applies to database properties of type "relation".
type RichText ¶
type RichText struct { // The plain text without annotations. PlainText string `json:"plain_text,omitempty"` // The URL of any link or internal Notion mention in this text, if any. Href string `json:"href,omitempty"` // All annotations that apply to this rich text. // Annotations include colors and bold/italics/underline/strikethrough. Annotations Annotation `json:"annotations"` // Type of this rich text object. Type RichTextType `json:"type,omitempty"` Text *Text `json:"text,omitempty"` Mention *Mention `json:"mention,omitempty"` Equation *Equation `json:"equation,omitempty"` }
RichText objects contain data for displaying formatted text, mentions, and equations. RichText object also contains annotations for style information. Arrays of rich text objects are used within property objects and property value objects to create what a user sees as a single text value in Notion.
type RichTextType ¶
type RichTextType string
RichTextType is type of RichText.
const ( RichTextText RichTextType = "text" RichTextMention RichTextType = "mention" RichTextEquation RichTextType = "equation" )
RichTextType enums.
type RollupValue ¶
type RollupValue struct { Type RollupValueType `json:"type,omitempty"` Number float64 `json:"number,omitempty"` Date *Date `json:"date,omitempty"` // The element is exactly like property value object, but without the "id" key. Array []*PropertyValue `json:"array,omitempty"` }
RollupValue represent the result of evaluating a rollup described in the database's properties. These objects contain a type key and a key corresponding with the value of type. The value is an object containing type-specific data.
type RollupValueType ¶
type RollupValueType string
RollupValueType is type of rollup value.
const ( RollupValueString RollupValueType = "string" RolluoValueDate RollupValueType = "date" RolluoValueArray RollupValueType = "array" )
RollupValueType enums.
type SearchFilter ¶
type SearchFilter struct { // The value of the property to filter the results by. // Possible values for object type include page or database. // Limitation: Currently the only filter allowed is object which will filter by type of object (either page or database) Value string `json:"value,omitempty"` // The name of the property to filter by. Currently the only property you can filter by is the object type. // Possible values include object. // Limitation: Currently the only filter allowed is object which will filter by type of object (either page or database) Property string `json:"property,omitempty"` }
SearchFilter when supplied, filters the results based on the provided criteria.
type SearchParam ¶
type SearchParam struct { // The query parameter matches against the page titles. // When supplied, limits which pages are returned by comparing the query to the page title. // If the query parameter is not provided, the response will contain all pages (and child pages) in the results. Query string `json:"query,omitempty"` // When supplied, sorts the results based on the provided criteria. // Limitation: Currently only a single sort is allowed and is limited to last_edited_time. Sort *Sort `json:"sort,omitempty"` // The filter parameter can be used to query specifically for only pages or only databases. // When supplied, filters the results based on the provided criteria. // Limitation: Currently only a single sort is allowed and is limited to last_edited_time. Filter *SearchFilter `json:"filter,omitempty"` StartCursor string `json:"start_cursor,omitempty"` PageSize int32 `json:"page_size,omitempty"` }
SearchParam is param of Search.
type SelectFilterCondition ¶
type SelectFilterCondition struct { Equals string `json:"equals,omitempty"` DoesNotEqual string `json:"does_not_equal,omitempty"` IsEmpty bool `json:"is_empty,omitempty"` IsNotEmpty bool `json:"is_not_empty,omitempty"` }
SelectFilterCondition applies to database properties of type "select".
type SelectOption ¶
type SelectOption struct { Name string `json:"name,omitempty"` ID string `json:"id,omitempty"` Color Color `json:"color,omitempty"` }
SelectOption is the option value of single selector and multi selector.
type Sort ¶
type Sort struct { // The direction to sort. Direction SortDirection `json:"direction,omitempty"` // The name of the timestamp to sort against. Possible values include "created_time" and "last_edited_time". Timestamp string `json:"timestamp,omitempty"` // The name of the property to sort against. Property string `json:"property,omitempty"` }
Sort sorts the results based on the provided criteria.
func SortByCreatedTime ¶
func SortByCreatedTime(direction SortDirection) *Sort
SortByCreatedTime creates Sort to sort database by "created_time".
func SortByLastEditedTime ¶
func SortByLastEditedTime(direction SortDirection) *Sort
SortByLastEditedTime creates Sort to sort database by "last_edited_time".
func SortByProperty ¶
func SortByProperty(property string, direction SortDirection) *Sort
SortByProperty creates Sort to sort database by specified property.
type SortDirection ¶
type SortDirection string
SortDirection query result order.
const ( DirectionAscending SortDirection = "ascending" DirectionDescending SortDirection = "descending" )
SortDirection enums.
type Text ¶
type Text struct { // Text content. This field contains the actual content of your text and is probably the field you'll use most often. Content string `json:"content,omitempty"` // Any inline link in this text. Link *Link `json:"link,omitempty"` }
Text is the content of rich text.
type TextFilterCondition ¶
type TextFilterCondition struct { Equals string `json:"equals,omitempty"` DoesNotEqual string `json:"does_not_equal,omitempty"` Contains string `json:"contains,omitempty"` DoesNotContain string `json:"does_not_contain,omitempty"` StartsWith string `json:"starts_with,omitempty"` EndsWith string `json:"ends_with,omitempty"` IsEmpty bool `json:"is_empty,omitempty"` IsNotEmpty bool `json:"is_not_empty,omitempty"` }
TextFilterCondition applies to database properties of types "title", "rich_text", "url", "email", and "phone".
type ToDo ¶
type ToDo struct { Text []*RichText `json:"text"` Children []*Block `json:"children,omitempty"` Checked bool `json:"checked,omitempty"` }
ToDo is todo item.
type User ¶
type User struct { // Always "user" Object ObjectType `json:"object,omitempty"` ID string `json:"id,omitempty"` Type UserType `json:"type,omitempty"` // Properties only present for non-bot users. Person *struct { Email string `json:"email,omitempty"` } `json:"person,omitempty"` // Properties only present for bot users. Bot *struct{} `json:"bot,omitempty"` Name string `json:"name,omitempty"` AvatarURL string `json:"avatar_url,omitempty"` }
The User object represents a user in a Notion workspace.