package memos import "time" // Memo represents a memo from the Memos API. // JSON field names follow protojson camelCase convention. type Memo struct { Name string `json:"name"` State string `json:"state"` Creator string `json:"creator"` CreateTime time.Time `json:"createTime"` UpdateTime time.Time `json:"updateTime"` DisplayTime time.Time `json:"displayTime"` Content string `json:"content"` Visibility string `json:"visibility"` Tags []string `json:"tags"` Pinned bool `json:"pinned"` Snippet string `json:"snippet"` Attachments []Attachment `json:"attachments"` } // Attachment represents a file attached to a memo. type Attachment struct { Name string `json:"name"` // "attachments/{uid}" Filename string `json:"filename"` Type string `json:"type"` // MIME type Size int64 `json:"size,string"` ExternalLink string `json:"externalLink"` } // IsImage returns true if the attachment is an image. func (a Attachment) IsImage() bool { switch a.Type { case "image/png", "image/jpeg", "image/gif", "image/webp", "image/heic", "image/heif", "image/svg+xml": return true } return false } // IsVideo returns true if the attachment is a video. func (a Attachment) IsVideo() bool { switch a.Type { case "video/mp4", "video/quicktime", "video/webm", "video/mpeg": return true } return false } // IsAudio returns true if the attachment is an audio file. func (a Attachment) IsAudio() bool { switch a.Type { case "audio/mpeg", "audio/ogg", "audio/wav", "audio/mp4", "audio/aac": return true } return false } // UID extracts the uid part from "attachments/{uid}". func (a Attachment) UID() string { const prefix = "attachments/" if len(a.Name) > len(prefix) { return a.Name[len(prefix):] } return a.Name } // ListMemosResponse is the response from GET /api/v1/memos. type ListMemosResponse struct { Memos []*Memo `json:"memos"` NextPageToken string `json:"nextPageToken"` } func (r *ListMemosResponse) GetMemos() []*Memo { if r == nil { return nil } return r.Memos }