1
0
mirror of https://github.com/dstotijn/go-notion.git synced 2025-02-17 13:40:49 +02:00

add block parent (#45)

* add block parent

* Use consts for parent types in page unmarshal

Co-authored-by: David Stotijn <dstotijn@gmail.com>
This commit is contained in:
bassettb 2022-10-27 05:45:25 -04:00 committed by GitHub
parent ebaecd3a42
commit de8cab86ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -276,16 +276,18 @@ func (p *Page) UnmarshalJSON(b []byte) error {
page := dto.PageAlias page := dto.PageAlias
switch dto.Parent.Type { switch dto.Parent.Type {
case "workspace": case ParentTypeWorkspace:
fallthrough fallthrough
case "page_id": case ParentTypeBlock:
fallthrough
case ParentTypePage:
var props PageProperties var props PageProperties
err := json.Unmarshal(dto.Properties, &props) err := json.Unmarshal(dto.Properties, &props)
if err != nil { if err != nil {
return err return err
} }
page.Properties = props page.Properties = props
case "database_id": case ParentTypeDatabase:
var props DatabasePageProperties var props DatabasePageProperties
err := json.Unmarshal(dto.Properties, &props) err := json.Unmarshal(dto.Properties, &props)
if err != nil { if err != nil {