mirror of
https://github.com/dstotijn/go-notion.git
synced 2025-06-15 00:05:04 +02:00
Handle changes introduced in version 2022-02-22
(#29)
Ref: https://developers.notion.com/changelog/releasing-notion-version-2022-02-22
This commit is contained in:
24
block.go
24
block.go
@ -97,7 +97,7 @@ func (b baseBlock) Parent() Parent {
|
|||||||
type ParagraphBlock struct {
|
type ParagraphBlock struct {
|
||||||
baseBlock
|
baseBlock
|
||||||
|
|
||||||
Text []RichText `json:"text"`
|
RichText []RichText `json:"rich_text"`
|
||||||
Children []Block `json:"children,omitempty"`
|
Children []Block `json:"children,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ func (b ParagraphBlock) MarshalJSON() ([]byte, error) {
|
|||||||
type BulletedListItemBlock struct {
|
type BulletedListItemBlock struct {
|
||||||
baseBlock
|
baseBlock
|
||||||
|
|
||||||
Text []RichText `json:"text"`
|
RichText []RichText `json:"rich_text"`
|
||||||
Children []Block `json:"children,omitempty"`
|
Children []Block `json:"children,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ func (b BulletedListItemBlock) MarshalJSON() ([]byte, error) {
|
|||||||
type NumberedListItemBlock struct {
|
type NumberedListItemBlock struct {
|
||||||
baseBlock
|
baseBlock
|
||||||
|
|
||||||
Text []RichText `json:"text"`
|
RichText []RichText `json:"rich_text"`
|
||||||
Children []Block `json:"children,omitempty"`
|
Children []Block `json:"children,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ func (b NumberedListItemBlock) MarshalJSON() ([]byte, error) {
|
|||||||
type QuoteBlock struct {
|
type QuoteBlock struct {
|
||||||
baseBlock
|
baseBlock
|
||||||
|
|
||||||
Text []RichText `json:"text"`
|
RichText []RichText `json:"rich_text"`
|
||||||
Children []Block `json:"children,omitempty"`
|
Children []Block `json:"children,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ func (b QuoteBlock) MarshalJSON() ([]byte, error) {
|
|||||||
type ToggleBlock struct {
|
type ToggleBlock struct {
|
||||||
baseBlock
|
baseBlock
|
||||||
|
|
||||||
Text []RichText `json:"text"`
|
RichText []RichText `json:"rich_text"`
|
||||||
Children []Block `json:"children,omitempty"`
|
Children []Block `json:"children,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ func (b ToggleBlock) MarshalJSON() ([]byte, error) {
|
|||||||
type TemplateBlock struct {
|
type TemplateBlock struct {
|
||||||
baseBlock
|
baseBlock
|
||||||
|
|
||||||
Text []RichText `json:"text"`
|
RichText []RichText `json:"rich_text"`
|
||||||
Children []Block `json:"children,omitempty"`
|
Children []Block `json:"children,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ func (b TemplateBlock) MarshalJSON() ([]byte, error) {
|
|||||||
type Heading1Block struct {
|
type Heading1Block struct {
|
||||||
baseBlock
|
baseBlock
|
||||||
|
|
||||||
Text []RichText `json:"text"`
|
RichText []RichText `json:"rich_text"`
|
||||||
Children []Block `json:"children,omitempty"`
|
Children []Block `json:"children,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ func (b Heading1Block) MarshalJSON() ([]byte, error) {
|
|||||||
type Heading2Block struct {
|
type Heading2Block struct {
|
||||||
baseBlock
|
baseBlock
|
||||||
|
|
||||||
Text []RichText `json:"text"`
|
RichText []RichText `json:"rich_text"`
|
||||||
Children []Block `json:"children,omitempty"`
|
Children []Block `json:"children,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ func (b Heading2Block) MarshalJSON() ([]byte, error) {
|
|||||||
type Heading3Block struct {
|
type Heading3Block struct {
|
||||||
baseBlock
|
baseBlock
|
||||||
|
|
||||||
Text []RichText `json:"text"`
|
RichText []RichText `json:"rich_text"`
|
||||||
Children []Block `json:"children,omitempty"`
|
Children []Block `json:"children,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ func (b Heading3Block) MarshalJSON() ([]byte, error) {
|
|||||||
type ToDoBlock struct {
|
type ToDoBlock struct {
|
||||||
baseBlock
|
baseBlock
|
||||||
|
|
||||||
Text []RichText `json:"text"`
|
RichText []RichText `json:"rich_text"`
|
||||||
Children []Block `json:"children,omitempty"`
|
Children []Block `json:"children,omitempty"`
|
||||||
Checked *bool `json:"checked,omitempty"`
|
Checked *bool `json:"checked,omitempty"`
|
||||||
}
|
}
|
||||||
@ -348,7 +348,7 @@ func (b ChildDatabaseBlock) MarshalJSON() ([]byte, error) {
|
|||||||
type CalloutBlock struct {
|
type CalloutBlock struct {
|
||||||
baseBlock
|
baseBlock
|
||||||
|
|
||||||
Text []RichText `json:"text"`
|
RichText []RichText `json:"rich_text"`
|
||||||
Children []Block `json:"children,omitempty"`
|
Children []Block `json:"children,omitempty"`
|
||||||
Icon *Icon `json:"icon,omitempty"`
|
Icon *Icon `json:"icon,omitempty"`
|
||||||
}
|
}
|
||||||
@ -370,7 +370,7 @@ func (b CalloutBlock) MarshalJSON() ([]byte, error) {
|
|||||||
type CodeBlock struct {
|
type CodeBlock struct {
|
||||||
baseBlock
|
baseBlock
|
||||||
|
|
||||||
Text []RichText `json:"text"`
|
RichText []RichText `json:"rich_text"`
|
||||||
Children []Block `json:"children,omitempty"`
|
Children []Block `json:"children,omitempty"`
|
||||||
Caption []RichText `json:"caption,omitempty"`
|
Caption []RichText `json:"caption,omitempty"`
|
||||||
Language *string `json:"language,omitempty"`
|
Language *string `json:"language,omitempty"`
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
baseURL = "https://api.notion.com/v1"
|
baseURL = "https://api.notion.com/v1"
|
||||||
apiVersion = "2021-08-16"
|
apiVersion = "2022-02-22"
|
||||||
clientVersion = "0.0.0"
|
clientVersion = "0.0.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -433,8 +433,10 @@ func TestQueryDatabase(t *testing.T) {
|
|||||||
query: ¬ion.DatabaseQuery{
|
query: ¬ion.DatabaseQuery{
|
||||||
Filter: ¬ion.DatabaseQueryFilter{
|
Filter: ¬ion.DatabaseQueryFilter{
|
||||||
Property: "Name",
|
Property: "Name",
|
||||||
Text: ¬ion.TextDatabaseQueryFilter{
|
DatabaseQueryPropertyFilter: notion.DatabaseQueryPropertyFilter{
|
||||||
Contains: "foobar",
|
RichText: ¬ion.TextPropertyFilter{
|
||||||
|
Contains: "foobar",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Sorts: []notion.DatabaseQuerySort{
|
Sorts: []notion.DatabaseQuerySort{
|
||||||
@ -641,7 +643,7 @@ func TestQueryDatabase(t *testing.T) {
|
|||||||
expPostBody: map[string]interface{}{
|
expPostBody: map[string]interface{}{
|
||||||
"filter": map[string]interface{}{
|
"filter": map[string]interface{}{
|
||||||
"property": "Name",
|
"property": "Name",
|
||||||
"text": map[string]interface{}{
|
"rich_text": map[string]interface{}{
|
||||||
"contains": "foobar",
|
"contains": "foobar",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1669,7 +1671,7 @@ func TestCreatePage(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Children: []notion.Block{
|
Children: []notion.Block{
|
||||||
¬ion.ParagraphBlock{
|
¬ion.ParagraphBlock{
|
||||||
Text: []notion.RichText{
|
RichText: []notion.RichText{
|
||||||
{
|
{
|
||||||
Text: ¬ion.Text{
|
Text: ¬ion.Text{
|
||||||
Content: "Lorem ipsum dolor sit amet.",
|
Content: "Lorem ipsum dolor sit amet.",
|
||||||
@ -1761,7 +1763,7 @@ func TestCreatePage(t *testing.T) {
|
|||||||
"children": []interface{}{
|
"children": []interface{}{
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"paragraph": map[string]interface{}{
|
"paragraph": map[string]interface{}{
|
||||||
"text": []interface{}{
|
"rich_text": []interface{}{
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"text": map[string]interface{}{
|
"text": map[string]interface{}{
|
||||||
"content": "Lorem ipsum dolor sit amet.",
|
"content": "Lorem ipsum dolor sit amet.",
|
||||||
@ -1842,7 +1844,7 @@ func TestCreatePage(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Children: []notion.Block{
|
Children: []notion.Block{
|
||||||
¬ion.ParagraphBlock{
|
¬ion.ParagraphBlock{
|
||||||
Text: []notion.RichText{
|
RichText: []notion.RichText{
|
||||||
{
|
{
|
||||||
Text: ¬ion.Text{
|
Text: ¬ion.Text{
|
||||||
Content: "Lorem ipsum dolor sit amet.",
|
Content: "Lorem ipsum dolor sit amet.",
|
||||||
@ -1908,7 +1910,7 @@ func TestCreatePage(t *testing.T) {
|
|||||||
"children": []interface{}{
|
"children": []interface{}{
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"paragraph": map[string]interface{}{
|
"paragraph": map[string]interface{}{
|
||||||
"text": []interface{}{
|
"rich_text": []interface{}{
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"text": map[string]interface{}{
|
"text": map[string]interface{}{
|
||||||
"content": "Lorem ipsum dolor sit amet.",
|
"content": "Lorem ipsum dolor sit amet.",
|
||||||
@ -2747,15 +2749,20 @@ func TestFindPagePropertyByID(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"has_more": false,
|
"has_more": true,
|
||||||
"type": "rollup",
|
"type": "property_item",
|
||||||
"rollup": {
|
"property_item": {
|
||||||
"type": "date",
|
"id": "aBcD123",
|
||||||
"date": {
|
"next_url": "https://api.notion.com/v1/pages/b55c9c91-384d-452b-81db-d1ef79372b75/properties/aBcD123?start_cursor=some-next-cursor-value",
|
||||||
"start": "2021-10-07T14:42:00.000+00:00",
|
"type": "rollup",
|
||||||
"end": null
|
"rollup": {
|
||||||
},
|
"type": "date",
|
||||||
"function": "latest_date"
|
"date": {
|
||||||
|
"start": "2021-10-07T14:42:00.000+00:00",
|
||||||
|
"end": null
|
||||||
|
},
|
||||||
|
"function": "latest_date"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
)
|
)
|
||||||
@ -2764,6 +2771,10 @@ func TestFindPagePropertyByID(t *testing.T) {
|
|||||||
expQueryParams: nil,
|
expQueryParams: nil,
|
||||||
expResponse: notion.PagePropResponse{
|
expResponse: notion.PagePropResponse{
|
||||||
PagePropItem: notion.PagePropItem{
|
PagePropItem: notion.PagePropItem{
|
||||||
|
Type: notion.DBPropTypePropertyItem,
|
||||||
|
},
|
||||||
|
PropertyItem: notion.PagePropListItem{
|
||||||
|
ID: "aBcD123",
|
||||||
Type: notion.DBPropTypeRollup,
|
Type: notion.DBPropTypeRollup,
|
||||||
Rollup: notion.RollupResult{
|
Rollup: notion.RollupResult{
|
||||||
Type: notion.RollupResultTypeDate,
|
Type: notion.RollupResultTypeDate,
|
||||||
@ -2771,7 +2782,9 @@ func TestFindPagePropertyByID(t *testing.T) {
|
|||||||
Start: mustParseDateTime("2021-10-07T14:42:00.000+00:00"),
|
Start: mustParseDateTime("2021-10-07T14:42:00.000+00:00"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
NextURL: "https://api.notion.com/v1/pages/b55c9c91-384d-452b-81db-d1ef79372b75/properties/aBcD123?start_cursor=some-next-cursor-value",
|
||||||
},
|
},
|
||||||
|
HasMore: true,
|
||||||
Results: []notion.PagePropItem{
|
Results: []notion.PagePropItem{
|
||||||
{
|
{
|
||||||
Type: notion.DBPropTypeRelation,
|
Type: notion.DBPropTypeRelation,
|
||||||
@ -2903,7 +2916,7 @@ func TestFindBlockChildrenById(t *testing.T) {
|
|||||||
"has_children": false,
|
"has_children": false,
|
||||||
"type": "paragraph",
|
"type": "paragraph",
|
||||||
"paragraph": {
|
"paragraph": {
|
||||||
"text": [
|
"rich_text": [
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"text": {
|
"text": {
|
||||||
@ -2938,7 +2951,7 @@ func TestFindBlockChildrenById(t *testing.T) {
|
|||||||
expResponse: notion.BlockChildrenResponse{
|
expResponse: notion.BlockChildrenResponse{
|
||||||
Results: []notion.Block{
|
Results: []notion.Block{
|
||||||
¬ion.ParagraphBlock{
|
¬ion.ParagraphBlock{
|
||||||
Text: []notion.RichText{
|
RichText: []notion.RichText{
|
||||||
{
|
{
|
||||||
Type: notion.RichTextTypeText,
|
Type: notion.RichTextTypeText,
|
||||||
Text: ¬ion.Text{
|
Text: ¬ion.Text{
|
||||||
@ -3107,7 +3120,7 @@ func TestAppendBlockChildren(t *testing.T) {
|
|||||||
name: "successful response",
|
name: "successful response",
|
||||||
children: []notion.Block{
|
children: []notion.Block{
|
||||||
¬ion.ParagraphBlock{
|
¬ion.ParagraphBlock{
|
||||||
Text: []notion.RichText{
|
RichText: []notion.RichText{
|
||||||
{
|
{
|
||||||
Text: ¬ion.Text{
|
Text: ¬ion.Text{
|
||||||
Content: "Lorem ipsum dolor sit amet.",
|
Content: "Lorem ipsum dolor sit amet.",
|
||||||
@ -3129,7 +3142,7 @@ func TestAppendBlockChildren(t *testing.T) {
|
|||||||
"has_children": false,
|
"has_children": false,
|
||||||
"type": "paragraph",
|
"type": "paragraph",
|
||||||
"paragraph": {
|
"paragraph": {
|
||||||
"text": [
|
"rich_text": [
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"text": {
|
"text": {
|
||||||
@ -3161,7 +3174,7 @@ func TestAppendBlockChildren(t *testing.T) {
|
|||||||
"children": []interface{}{
|
"children": []interface{}{
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"paragraph": map[string]interface{}{
|
"paragraph": map[string]interface{}{
|
||||||
"text": []interface{}{
|
"rich_text": []interface{}{
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"text": map[string]interface{}{
|
"text": map[string]interface{}{
|
||||||
"content": "Lorem ipsum dolor sit amet.",
|
"content": "Lorem ipsum dolor sit amet.",
|
||||||
@ -3175,7 +3188,7 @@ func TestAppendBlockChildren(t *testing.T) {
|
|||||||
expResponse: notion.BlockChildrenResponse{
|
expResponse: notion.BlockChildrenResponse{
|
||||||
Results: []notion.Block{
|
Results: []notion.Block{
|
||||||
¬ion.ParagraphBlock{
|
¬ion.ParagraphBlock{
|
||||||
Text: []notion.RichText{
|
RichText: []notion.RichText{
|
||||||
{
|
{
|
||||||
Type: notion.RichTextTypeText,
|
Type: notion.RichTextTypeText,
|
||||||
Text: ¬ion.Text{
|
Text: ¬ion.Text{
|
||||||
@ -3207,7 +3220,7 @@ func TestAppendBlockChildren(t *testing.T) {
|
|||||||
name: "error response",
|
name: "error response",
|
||||||
children: []notion.Block{
|
children: []notion.Block{
|
||||||
¬ion.ParagraphBlock{
|
¬ion.ParagraphBlock{
|
||||||
Text: []notion.RichText{
|
RichText: []notion.RichText{
|
||||||
{
|
{
|
||||||
Text: ¬ion.Text{
|
Text: ¬ion.Text{
|
||||||
Content: "Lorem ipsum dolor sit amet.",
|
Content: "Lorem ipsum dolor sit amet.",
|
||||||
@ -3231,7 +3244,7 @@ func TestAppendBlockChildren(t *testing.T) {
|
|||||||
"children": []interface{}{
|
"children": []interface{}{
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"paragraph": map[string]interface{}{
|
"paragraph": map[string]interface{}{
|
||||||
"text": []interface{}{
|
"rich_text": []interface{}{
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"text": map[string]interface{}{
|
"text": map[string]interface{}{
|
||||||
"content": "Lorem ipsum dolor sit amet.",
|
"content": "Lorem ipsum dolor sit amet.",
|
||||||
@ -4141,7 +4154,7 @@ func TestUpdateBlock(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "successful response",
|
name: "successful response",
|
||||||
block: ¬ion.ParagraphBlock{
|
block: ¬ion.ParagraphBlock{
|
||||||
Text: []notion.RichText{
|
RichText: []notion.RichText{
|
||||||
{
|
{
|
||||||
Text: ¬ion.Text{
|
Text: ¬ion.Text{
|
||||||
Content: "Foobar",
|
Content: "Foobar",
|
||||||
@ -4160,7 +4173,7 @@ func TestUpdateBlock(t *testing.T) {
|
|||||||
"archived": false,
|
"archived": false,
|
||||||
"type": "paragraph",
|
"type": "paragraph",
|
||||||
"paragraph": {
|
"paragraph": {
|
||||||
"text": [
|
"rich_text": [
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"text": {
|
"text": {
|
||||||
@ -4186,7 +4199,7 @@ func TestUpdateBlock(t *testing.T) {
|
|||||||
respStatusCode: http.StatusOK,
|
respStatusCode: http.StatusOK,
|
||||||
expPostBody: map[string]interface{}{
|
expPostBody: map[string]interface{}{
|
||||||
"paragraph": map[string]interface{}{
|
"paragraph": map[string]interface{}{
|
||||||
"text": []interface{}{
|
"rich_text": []interface{}{
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"text": map[string]interface{}{
|
"text": map[string]interface{}{
|
||||||
"content": "Foobar",
|
"content": "Foobar",
|
||||||
@ -4196,7 +4209,7 @@ func TestUpdateBlock(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
expResponse: ¬ion.ParagraphBlock{
|
expResponse: ¬ion.ParagraphBlock{
|
||||||
Text: []notion.RichText{
|
RichText: []notion.RichText{
|
||||||
{
|
{
|
||||||
Type: notion.RichTextTypeText,
|
Type: notion.RichTextTypeText,
|
||||||
Text: ¬ion.Text{
|
Text: ¬ion.Text{
|
||||||
@ -4219,7 +4232,7 @@ func TestUpdateBlock(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "error response",
|
name: "error response",
|
||||||
block: ¬ion.ParagraphBlock{
|
block: ¬ion.ParagraphBlock{
|
||||||
Text: []notion.RichText{
|
RichText: []notion.RichText{
|
||||||
{
|
{
|
||||||
Text: ¬ion.Text{
|
Text: ¬ion.Text{
|
||||||
Content: "Foobar",
|
Content: "Foobar",
|
||||||
@ -4240,7 +4253,7 @@ func TestUpdateBlock(t *testing.T) {
|
|||||||
respStatusCode: http.StatusBadRequest,
|
respStatusCode: http.StatusBadRequest,
|
||||||
expPostBody: map[string]interface{}{
|
expPostBody: map[string]interface{}{
|
||||||
"paragraph": map[string]interface{}{
|
"paragraph": map[string]interface{}{
|
||||||
"text": []interface{}{
|
"rich_text": []interface{}{
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"text": map[string]interface{}{
|
"text": map[string]interface{}{
|
||||||
"content": "Foobar",
|
"content": "Foobar",
|
||||||
@ -4359,7 +4372,7 @@ func TestDeleteBlock(t *testing.T) {
|
|||||||
"archived": true,
|
"archived": true,
|
||||||
"type": "paragraph",
|
"type": "paragraph",
|
||||||
"paragraph": {
|
"paragraph": {
|
||||||
"text": [
|
"rich_text": [
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"text": {
|
"text": {
|
||||||
@ -4384,7 +4397,7 @@ func TestDeleteBlock(t *testing.T) {
|
|||||||
},
|
},
|
||||||
respStatusCode: http.StatusOK,
|
respStatusCode: http.StatusOK,
|
||||||
expResponse: ¬ion.ParagraphBlock{
|
expResponse: ¬ion.ParagraphBlock{
|
||||||
Text: []notion.RichText{
|
RichText: []notion.RichText{
|
||||||
{
|
{
|
||||||
Type: notion.RichTextTypeText,
|
Type: notion.RichTextTypeText,
|
||||||
Text: ¬ion.Text{
|
Text: ¬ion.Text{
|
||||||
|
65
database.go
65
database.go
@ -154,21 +154,46 @@ type DatabaseQueryResponse struct {
|
|||||||
type DatabaseQueryFilter struct {
|
type DatabaseQueryFilter struct {
|
||||||
Property string `json:"property,omitempty"`
|
Property string `json:"property,omitempty"`
|
||||||
|
|
||||||
Text *TextDatabaseQueryFilter `json:"text,omitempty"`
|
DatabaseQueryPropertyFilter
|
||||||
|
|
||||||
|
Timestamp Timestamp `json:"timestamp,omitempty"`
|
||||||
|
Or []DatabaseQueryFilter `json:"or,omitempty"`
|
||||||
|
And []DatabaseQueryFilter `json:"and,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DatabaseQueryPropertyFilter struct {
|
||||||
|
Title *TextPropertyFilter `json:"title,omitempty"`
|
||||||
|
RichText *TextPropertyFilter `json:"rich_text,omitempty"`
|
||||||
|
URL *TextPropertyFilter `json:"url,omitempty"`
|
||||||
|
Email *TextPropertyFilter `json:"email,omitempty"`
|
||||||
|
PhoneNumber *TextPropertyFilter `json:"phone_number,omitempty"`
|
||||||
|
|
||||||
|
Date *DatePropertyFilter `json:"date,omitempty"`
|
||||||
|
CreatedTime *DatePropertyFilter `json:"created_time,omitempty"`
|
||||||
|
LastEditedTime *DatePropertyFilter `json:"last_edited_time,omitempty"`
|
||||||
|
|
||||||
Number *NumberDatabaseQueryFilter `json:"number,omitempty"`
|
Number *NumberDatabaseQueryFilter `json:"number,omitempty"`
|
||||||
Checkbox *CheckboxDatabaseQueryFilter `json:"checkbox,omitempty"`
|
Checkbox *CheckboxDatabaseQueryFilter `json:"checkbox,omitempty"`
|
||||||
Select *SelectDatabaseQueryFilter `json:"select,omitempty"`
|
Select *SelectDatabaseQueryFilter `json:"select,omitempty"`
|
||||||
MultiSelect *MultiSelectDatabaseQueryFilter `json:"multi_select,omitempty"`
|
MultiSelect *MultiSelectDatabaseQueryFilter `json:"multi_select,omitempty"`
|
||||||
Date *DateDatabaseQueryFilter `json:"date,omitempty"`
|
|
||||||
People *PeopleDatabaseQueryFilter `json:"people,omitempty"`
|
People *PeopleDatabaseQueryFilter `json:"people,omitempty"`
|
||||||
Files *FilesDatabaseQueryFilter `json:"files,omitempty"`
|
Files *FilesDatabaseQueryFilter `json:"files,omitempty"`
|
||||||
Relation *RelationDatabaseQueryFilter `json:"relation,omitempty"`
|
Relation *RelationDatabaseQueryFilter `json:"relation,omitempty"`
|
||||||
|
Formula *FormulaDatabaseQueryFilter `json:"formula,omitempty"`
|
||||||
|
Rollup *RollupDatabaseQueryFilter `json:"rollup,omitempty"`
|
||||||
|
|
||||||
Or []DatabaseQueryFilter `json:"or,omitempty"`
|
CreatedBy *PeopleDatabaseQueryFilter `json:"created_by,omitempty"`
|
||||||
And []DatabaseQueryFilter `json:"and,omitempty"`
|
LastEditedBy *PeopleDatabaseQueryFilter `json:"last_edited_by,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TextDatabaseQueryFilter struct {
|
type Timestamp string
|
||||||
|
|
||||||
|
const (
|
||||||
|
TimestampCreatedTime = "created_time"
|
||||||
|
TimestampLastEditedTime = "last_edited_time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type TextPropertyFilter struct {
|
||||||
Equals string `json:"equals,omitempty"`
|
Equals string `json:"equals,omitempty"`
|
||||||
DoesNotEqual string `json:"does_not_equal,omitempty"`
|
DoesNotEqual string `json:"does_not_equal,omitempty"`
|
||||||
Contains string `json:"contains,omitempty"`
|
Contains string `json:"contains,omitempty"`
|
||||||
@ -209,7 +234,7 @@ type MultiSelectDatabaseQueryFilter struct {
|
|||||||
IsNotEmpty bool `json:"is_not_empty,omitempty"`
|
IsNotEmpty bool `json:"is_not_empty,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DateDatabaseQueryFilter struct {
|
type DatePropertyFilter struct {
|
||||||
Equals *time.Time `json:"equals,omitempty"`
|
Equals *time.Time `json:"equals,omitempty"`
|
||||||
Before *time.Time `json:"before,omitempty"`
|
Before *time.Time `json:"before,omitempty"`
|
||||||
After *time.Time `json:"after,omitempty"`
|
After *time.Time `json:"after,omitempty"`
|
||||||
@ -244,11 +269,19 @@ type RelationDatabaseQueryFilter struct {
|
|||||||
IsNotEmpty bool `json:"is_not_empty,omitempty"`
|
IsNotEmpty bool `json:"is_not_empty,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RollupDatabaseQueryFilter struct {
|
||||||
|
Any *DatabaseQueryPropertyFilter `json:"any,omitempty"`
|
||||||
|
Every *DatabaseQueryPropertyFilter `json:"every,omitempty"`
|
||||||
|
None *DatabaseQueryPropertyFilter `json:"none,omitempty"`
|
||||||
|
Number *NumberDatabaseQueryFilter `json:"number,omitempty"`
|
||||||
|
Date *DatePropertyFilter `json:"date,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type FormulaDatabaseQueryFilter struct {
|
type FormulaDatabaseQueryFilter struct {
|
||||||
Text TextDatabaseQueryFilter `json:"text,omitempty"`
|
String *TextPropertyFilter `json:"string,omitempty"`
|
||||||
Checkbox CheckboxDatabaseQueryFilter `json:"checkbox,omitempty"`
|
Checkbox *CheckboxDatabaseQueryFilter `json:"checkbox,omitempty"`
|
||||||
Number NumberDatabaseQueryFilter `json:"number,omitempty"`
|
Number *NumberDatabaseQueryFilter `json:"number,omitempty"`
|
||||||
Date DateDatabaseQueryFilter `json:"date,omitempty"`
|
Date *DatePropertyFilter `json:"date,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DatabaseQuerySort struct {
|
type DatabaseQuerySort struct {
|
||||||
@ -297,6 +330,10 @@ const (
|
|||||||
DBPropTypeLastEditedTime DatabasePropertyType = "last_edited_time"
|
DBPropTypeLastEditedTime DatabasePropertyType = "last_edited_time"
|
||||||
DBPropTypeLastEditedBy DatabasePropertyType = "last_edited_by"
|
DBPropTypeLastEditedBy DatabasePropertyType = "last_edited_by"
|
||||||
|
|
||||||
|
// Used for paginated property values.
|
||||||
|
// See: https://developers.notion.com/reference/property-item-object#paginated-property-values
|
||||||
|
DBPropTypePropertyItem DatabasePropertyType = "property_item"
|
||||||
|
|
||||||
// Number format enums.
|
// Number format enums.
|
||||||
NumberFormatNumber NumberFormat = "number"
|
NumberFormatNumber NumberFormat = "number"
|
||||||
NumberFormatNumberWithCommas NumberFormat = "number_with_commas"
|
NumberFormatNumberWithCommas NumberFormat = "number_with_commas"
|
||||||
@ -337,9 +374,11 @@ const (
|
|||||||
FormulaResultTypeDate FormulaResultType = "date"
|
FormulaResultTypeDate FormulaResultType = "date"
|
||||||
|
|
||||||
// Rollup result type enums.
|
// Rollup result type enums.
|
||||||
RollupResultTypeNumber RollupResultType = "number"
|
RollupResultTypeNumber RollupResultType = "number"
|
||||||
RollupResultTypeDate RollupResultType = "date"
|
RollupResultTypeDate RollupResultType = "date"
|
||||||
RollupResultTypeArray RollupResultType = "array"
|
RollupResultTypeArray RollupResultType = "array"
|
||||||
|
RollupResultTypeUnsupported RollupResultType = "unsupported"
|
||||||
|
RollupResultTypeIncomplete RollupResultType = "incomplete"
|
||||||
|
|
||||||
// Sort timestamp enums.
|
// Sort timestamp enums.
|
||||||
SortTimeStampCreatedTime SortTimestamp = "created_time"
|
SortTimeStampCreatedTime SortTimestamp = "created_time"
|
||||||
|
19
page.go
19
page.go
@ -117,14 +117,25 @@ type PagePropItem struct {
|
|||||||
|
|
||||||
// PagePropResponse contains a single database page property item or a list
|
// PagePropResponse contains a single database page property item or a list
|
||||||
// of items. For rollup props with an aggregation, both a `results` array and a
|
// of items. For rollup props with an aggregation, both a `results` array and a
|
||||||
// `rollup` field is included.
|
// `rollup` field (inside `page_property`) is included.
|
||||||
// See: https://developers.notion.com/reference/retrieve-a-page-property#rollup-properties
|
// See: https://developers.notion.com/reference/retrieve-a-page-property#rollup-properties
|
||||||
type PagePropResponse struct {
|
type PagePropResponse struct {
|
||||||
PagePropItem
|
PagePropItem
|
||||||
|
|
||||||
Results []PagePropItem `json:"results"`
|
Results []PagePropItem `json:"results"`
|
||||||
HasMore bool `json:"has_more"`
|
HasMore bool `json:"has_more"`
|
||||||
NextCursor string `json:"next_cursor"`
|
NextCursor string `json:"next_cursor"`
|
||||||
|
PropertyItem PagePropListItem `json:"property_item"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PagePropListItem describes the property returned in a paginated list
|
||||||
|
// response (e.g. `type` is `title`, `rich_text`, `relation` or `people`).
|
||||||
|
// See: https://developers.notion.com/reference/property-item-object#paginated-property-values
|
||||||
|
type PagePropListItem struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Type DatabasePropertyType `json:"type"`
|
||||||
|
NextURL string `json:"next_url"`
|
||||||
|
Rollup RollupResult `json:"rollup"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Value returns the underlying database page property value, based on its `type` field.
|
// Value returns the underlying database page property value, based on its `type` field.
|
||||||
|
Reference in New Issue
Block a user