1
0
mirror of https://github.com/dstotijn/go-notion.git synced 2025-06-15 00:05:04 +02:00

Add file metadata to file DB page prop

This commit is contained in:
David Stotijn
2021-12-20 20:12:44 +01:00
parent a2507e3ec1
commit 50cebe29de
6 changed files with 48 additions and 68 deletions

View File

@ -2,27 +2,11 @@ package notion
import "errors"
type CoverType string
const (
CoverTypeFile CoverType = "file"
CoverTypeExternal CoverType = "external"
)
type Cover struct {
Type CoverType `json:"type"`
Type FileType `json:"type"`
File *CoverFile `json:"file,omitempty"`
External *CoverExternal `json:"external,omitempty"`
}
type CoverFile struct {
URL string `json:"url"`
ExpiryTime DateTime `json:"expiry_time"`
}
type CoverExternal struct {
URL string `json:"url"`
File *FileFile `json:"file,omitempty"`
External *FileExternal `json:"external,omitempty"`
}
func (cover Cover) Validate() error {
@ -30,7 +14,7 @@ func (cover Cover) Validate() error {
return errors.New("cover type cannot be empty")
}
if cover.Type == CoverTypeExternal && cover.External == nil {
if cover.Type == FileTypeExternal && cover.External == nil {
return errors.New("cover external cannot be empty")
}