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:
parent
ebaecd3a42
commit
de8cab86ca
8
page.go
8
page.go
@ -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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user