mirror of
https://github.com/dstotijn/go-notion.git
synced 2025-06-06 23:36:14 +02:00
39 lines
712 B
Go
39 lines
712 B
Go
package notion
|
|
|
|
import "errors"
|
|
|
|
type CoverType string
|
|
|
|
const (
|
|
CoverTypeFile CoverType = "file"
|
|
CoverTypeExternal CoverType = "external"
|
|
)
|
|
|
|
type Cover struct {
|
|
Type CoverType `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"`
|
|
}
|
|
|
|
func (cover Cover) Validate() error {
|
|
if cover.Type == "" {
|
|
return errors.New("cover type cannot be empty")
|
|
}
|
|
|
|
if cover.Type == CoverTypeExternal && cover.External == nil {
|
|
return errors.New("cover external cannot be empty")
|
|
}
|
|
|
|
return nil
|
|
}
|