diff --git a/block.go b/block.go index 93d6600..6cee215 100644 --- a/block.go +++ b/block.go @@ -231,7 +231,9 @@ type ParagraphBlock struct { } type Paragraph struct { - Text []RichText `json:"text"` + // DEPRECATED use RichText instead + Text []RichText `json:"text,omitempty"` + RichText []RichText `json:"rich_text"` Children Blocks `json:"children,omitempty"` } diff --git a/block_test.go b/block_test.go index abfa5d5..b7baf2b 100644 --- a/block_test.go +++ b/block_test.go @@ -110,7 +110,7 @@ func TestBlockClient(t *testing.T) { }, }, Paragraph: notionapi.Paragraph{ - Text: []notionapi.RichText{ + RichText: []notionapi.RichText{ { Type: notionapi.ObjectTypeText, Text: notionapi.Text{Content: "AAAAAA"}, @@ -233,7 +233,7 @@ func TestBlockClient(t *testing.T) { id: "some_id", req: ¬ionapi.BlockUpdateRequest{ Paragraph: ¬ionapi.Paragraph{ - Text: []notionapi.RichText{ + RichText: []notionapi.RichText{ { Text: notionapi.Text{Content: "Hello"}, }, @@ -249,7 +249,7 @@ func TestBlockClient(t *testing.T) { LastEditedTime: ×tamp, }, Paragraph: notionapi.Paragraph{ - Text: []notionapi.RichText{ + RichText: []notionapi.RichText{ { Type: notionapi.ObjectTypeText, Text: notionapi.Text{ @@ -436,7 +436,7 @@ func TestBlockArrayUnmarshal(t *testing.T) { LastEditedBy: user, }, Paragraph: notionapi.Paragraph{ - Text: []notionapi.RichText{ + RichText: []notionapi.RichText{ { Type: "text", Text: notionapi.Text{ diff --git a/database.go b/database.go index 1569754..117f336 100644 --- a/database.go +++ b/database.go @@ -17,6 +17,7 @@ func (dID DatabaseID) String() string { type DatabaseService interface { Get(context.Context, DatabaseID) (*Database, error) + // DEPRECATED: this endpoint is removed in 2022-02-22 List(context.Context, *Pagination) (*DatabaseListResponse, error) Query(context.Context, DatabaseID, *DatabaseQueryRequest) (*DatabaseQueryResponse, error) Update(context.Context, DatabaseID, *DatabaseUpdateRequest) (*Database, error) diff --git a/page_test.go b/page_test.go index 5db8a64..6adb863 100644 --- a/page_test.go +++ b/page_test.go @@ -443,7 +443,7 @@ func TestPageCreateRequest_MarshallJSON(t *testing.T) { Type: notionapi.BlockTypeParagraph, }, Paragraph: notionapi.Paragraph{ - Text: []notionapi.RichText{ + RichText: []notionapi.RichText{ { Text: notionapi.Text{ Content: "Lacinato", @@ -458,7 +458,7 @@ func TestPageCreateRequest_MarshallJSON(t *testing.T) { }, }, }, - want: []byte(`{"parent":{"database_id":"some_id"},"properties":{"Link":{"url":"some_url"},"Name":{"title":[{"text":{"content":"New Media Article"}}]},"Publishing/Release Date":{"date":{"start":"2020-12-08T12:00:00Z","end":null}},"Read":{"checkbox":false},"Summary":{"text":[{"type":"text","text":{"content":"Some content"},"annotations":{"bold":true,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"blue"},"plain_text":"Some content"}]},"Type":{"select":{"id":"some_id","name":"Article","color":"default"}}},"children":[{"object":"block","type":"heading_2","heading_2":{"text":[{"type":"text","text":{"content":"Lacinato"}}]}},{"object":"block","type":"paragraph","paragraph":{"text":[{"text":{"content":"Lacinato","link":{"url":"some_url"}}}]}}]}`), + want: []byte(`{"parent":{"database_id":"some_id"},"properties":{"Link":{"url":"some_url"},"Name":{"title":[{"text":{"content":"New Media Article"}}]},"Publishing/Release Date":{"date":{"start":"2020-12-08T12:00:00Z","end":null}},"Read":{"checkbox":false},"Summary":{"text":[{"type":"text","text":{"content":"Some content"},"annotations":{"bold":true,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"blue"},"plain_text":"Some content"}]},"Type":{"select":{"id":"some_id","name":"Article","color":"default"}}},"children":[{"object":"block","type":"heading_2","heading_2":{"text":[{"type":"text","text":{"content":"Lacinato"}}]}},{"object":"block","type":"paragraph","paragraph":{"rich_text":[{"text":{"content":"Lacinato","link":{"url":"some_url"}}}]}}]}`), }, } diff --git a/testdata/block_append_children.json b/testdata/block_append_children.json index c350365..358815e 100644 --- a/testdata/block_append_children.json +++ b/testdata/block_append_children.json @@ -18,7 +18,7 @@ "archived": false, "type": "paragraph", "paragraph": { - "text": [ + "rich_text": [ { "type": "text", "text": { diff --git a/testdata/block_array_unmarshal.json b/testdata/block_array_unmarshal.json index d77d97e..09b3b8a 100644 --- a/testdata/block_array_unmarshal.json +++ b/testdata/block_array_unmarshal.json @@ -157,7 +157,7 @@ "id": "some_id" }, "paragraph": { - "text": [{ + "rich_text": [{ "type": "text", "text": { "content": "All essays and papers are due in lecture (due dates are listed on the schedule). No electronic copies will be accepted!" diff --git a/testdata/block_update.json b/testdata/block_update.json index 6e2af6c..6d370a4 100644 --- a/testdata/block_update.json +++ b/testdata/block_update.json @@ -7,7 +7,7 @@ "archived": false, "type": "paragraph", "paragraph": { - "text": [ + "rich_text": [ { "type": "text", "text": {