Skip to content

Commit

Permalink
add parsing of child_database
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarion authored and jomei committed Oct 4, 2021
1 parent 18dace7 commit 43ea89a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
17 changes: 17 additions & 0 deletions block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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))
}
Expand Down
7 changes: 4 additions & 3 deletions const.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 43ea89a

Please sign in to comment.