mirror of
https://github.com/dstotijn/go-notion.git
synced 2025-06-17 00:07:45 +02:00
28
block.go
28
block.go
@ -46,6 +46,7 @@ type blockDTO struct {
|
|||||||
Code *CodeBlock `json:"code,omitempty"`
|
Code *CodeBlock `json:"code,omitempty"`
|
||||||
Embed *EmbedBlock `json:"embed,omitempty"`
|
Embed *EmbedBlock `json:"embed,omitempty"`
|
||||||
Image *ImageBlock `json:"image,omitempty"`
|
Image *ImageBlock `json:"image,omitempty"`
|
||||||
|
Audio *AudioBlock `json:"audio,omitempty"`
|
||||||
Video *VideoBlock `json:"video,omitempty"`
|
Video *VideoBlock `json:"video,omitempty"`
|
||||||
File *FileBlock `json:"file,omitempty"`
|
File *FileBlock `json:"file,omitempty"`
|
||||||
PDF *PDFBlock `json:"pdf,omitempty"`
|
PDF *PDFBlock `json:"pdf,omitempty"`
|
||||||
@ -460,6 +461,29 @@ func (b ImageBlock) MarshalJSON() ([]byte, error) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AudioBlock struct {
|
||||||
|
baseBlock
|
||||||
|
|
||||||
|
Type FileType `json:"type"`
|
||||||
|
File *FileFile `json:"file,omitempty"`
|
||||||
|
External *FileExternal `json:"external,omitempty"`
|
||||||
|
Caption []RichText `json:"caption,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalJSON implements json.Marshaler.
|
||||||
|
func (b AudioBlock) MarshalJSON() ([]byte, error) {
|
||||||
|
type (
|
||||||
|
blockAlias ImageBlock
|
||||||
|
dto struct {
|
||||||
|
Audio blockAlias `json:"audio"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return json.Marshal(dto{
|
||||||
|
Audio: blockAlias(b),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
type VideoBlock struct {
|
type VideoBlock struct {
|
||||||
baseBlock
|
baseBlock
|
||||||
|
|
||||||
@ -806,6 +830,7 @@ const (
|
|||||||
BlockTypeCode BlockType = "code"
|
BlockTypeCode BlockType = "code"
|
||||||
BlockTypeEmbed BlockType = "embed"
|
BlockTypeEmbed BlockType = "embed"
|
||||||
BlockTypeImage BlockType = "image"
|
BlockTypeImage BlockType = "image"
|
||||||
|
BlockTypeAudio BlockType = "audio"
|
||||||
BlockTypeVideo BlockType = "video"
|
BlockTypeVideo BlockType = "video"
|
||||||
BlockTypeFile BlockType = "file"
|
BlockTypeFile BlockType = "file"
|
||||||
BlockTypePDF BlockType = "pdf"
|
BlockTypePDF BlockType = "pdf"
|
||||||
@ -937,6 +962,9 @@ func (dto blockDTO) Block() Block {
|
|||||||
case BlockTypeImage:
|
case BlockTypeImage:
|
||||||
dto.Image.baseBlock = baseBlock
|
dto.Image.baseBlock = baseBlock
|
||||||
return dto.Image
|
return dto.Image
|
||||||
|
case BlockTypeAudio:
|
||||||
|
dto.Audio.baseBlock = baseBlock
|
||||||
|
return dto.Audio
|
||||||
case BlockTypeVideo:
|
case BlockTypeVideo:
|
||||||
dto.Video.baseBlock = baseBlock
|
dto.Video.baseBlock = baseBlock
|
||||||
return dto.Video
|
return dto.Video
|
||||||
|
@ -189,6 +189,12 @@ func main() {
|
|||||||
URL: "https://picsum.photos/600/200.jpg",
|
URL: "https://picsum.photos/600/200.jpg",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
notion.AudioBlock{
|
||||||
|
Type: notion.FileTypeExternal,
|
||||||
|
External: ¬ion.FileExternal{
|
||||||
|
URL: "https://download.samplelib.com/mp3/sample-3s.mp3",
|
||||||
|
},
|
||||||
|
},
|
||||||
notion.VideoBlock{
|
notion.VideoBlock{
|
||||||
Type: notion.FileTypeExternal,
|
Type: notion.FileTypeExternal,
|
||||||
External: ¬ion.FileExternal{
|
External: ¬ion.FileExternal{
|
||||||
|
Reference in New Issue
Block a user