2021-12-20 19:54:19 +01:00
|
|
|
package notion
|
|
|
|
|
|
|
|
import "errors"
|
|
|
|
|
|
|
|
type Cover struct {
|
2021-12-20 20:12:44 +01:00
|
|
|
Type FileType `json:"type"`
|
2021-12-20 19:54:19 +01:00
|
|
|
|
2021-12-20 20:12:44 +01:00
|
|
|
File *FileFile `json:"file,omitempty"`
|
|
|
|
External *FileExternal `json:"external,omitempty"`
|
2021-12-20 19:54:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cover Cover) Validate() error {
|
|
|
|
if cover.Type == "" {
|
|
|
|
return errors.New("cover type cannot be empty")
|
|
|
|
}
|
|
|
|
|
2021-12-20 20:12:44 +01:00
|
|
|
if cover.Type == FileTypeExternal && cover.External == nil {
|
2021-12-20 19:54:19 +01:00
|
|
|
return errors.New("cover external cannot be empty")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|