Skip to content

Commit

Permalink
Deprecate 2022-02-22 backwards incompatible changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jomei committed Apr 25, 2022
1 parent f40ee82 commit 57c9965
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
4 changes: 3 additions & 1 deletion block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
8 changes: 4 additions & 4 deletions block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down Expand Up @@ -233,7 +233,7 @@ func TestBlockClient(t *testing.T) {
id: "some_id",
req: &notionapi.BlockUpdateRequest{
Paragraph: &notionapi.Paragraph{
Text: []notionapi.RichText{
RichText: []notionapi.RichText{
{
Text: notionapi.Text{Content: "Hello"},
},
Expand All @@ -249,7 +249,7 @@ func TestBlockClient(t *testing.T) {
LastEditedTime: &timestamp,
},
Paragraph: notionapi.Paragraph{
Text: []notionapi.RichText{
RichText: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Text: notionapi.Text{
Expand Down Expand Up @@ -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{
Expand Down
1 change: 1 addition & 0 deletions database.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"}}}]}}]}`),
},
}

Expand Down
2 changes: 1 addition & 1 deletion testdata/block_append_children.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"archived": false,
"type": "paragraph",
"paragraph": {
"text": [
"rich_text": [
{
"type": "text",
"text": {
Expand Down
2 changes: 1 addition & 1 deletion testdata/block_array_unmarshal.json
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
Expand Down
2 changes: 1 addition & 1 deletion testdata/block_update.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"archived": false,
"type": "paragraph",
"paragraph": {
"text": [
"rich_text": [
{
"type": "text",
"text": {
Expand Down

0 comments on commit 57c9965

Please sign in to comment.