From 43ea89a1488e63c4f0ba8b730e142bc178e6ae98 Mon Sep 17 00:00:00 2001 From: Pierre Carion Date: Sun, 3 Oct 2021 11:11:28 -0700 Subject: [PATCH] add parsing of child_database --- block.go | 17 +++++++++++++++++ const.go | 7 ++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/block.go b/block.go index 2f43c44..5faa0c7 100644 --- a/block.go +++ b/block.go @@ -419,6 +419,21 @@ type Bookmark struct { URL string `json:"url"` } +type ChildDatabaseBlock 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"` + ChildDatabase struct { + Title string `json:"title"` + } `json:"child_database"` +} + +func (b ChildDatabaseBlock) GetType() BlockType { + return b.Type +} + func decodeBlock(raw map[string]interface{}) (Block, error) { var b Block switch BlockType(raw["type"].(string)) { @@ -454,6 +469,8 @@ func decodeBlock(raw map[string]interface{}) (Block, error) { b = &PdfBlock{} case BlockTypeBookmark: b = &BookmarkBlock{} + case BlockTypeChildDatabase: + b = &ChildDatabaseBlock{} default: return nil, fmt.Errorf("unsupported block type: %s", raw["type"].(string)) } diff --git a/const.go b/const.go index ee71827..f8dd219 100644 --- a/const.go +++ b/const.go @@ -183,9 +183,10 @@ const ( BlockTypeBulletedListItem BlockType = "bulleted_list_item" BlockTypeNumberedListItem BlockType = "numbered_list_item" - BlockTypeToDo BlockType = "to_do" - BlockTypeToggle BlockType = "toggle" - BlockTypeChildPage BlockType = "child_page" + BlockTypeToDo BlockType = "to_do" + BlockTypeToggle BlockType = "toggle" + BlockTypeChildPage BlockType = "child_page" + BlockTypeChildDatabase BlockType = "child_database" BlockTypeEmbed BlockType = "embed" BlockTypeImage BlockType = "image"