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:
24
cover.go
24
cover.go
@ -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")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user