This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
e621-sdk-go/pkg/e621/builder/note.go

39 lines
759 B
Go
Raw Normal View History

package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"log"
"strconv"
)
type NoteBuilder interface {
SetNoteID(noteID int) NoteBuilder
Execute() (*model.Note, error)
}
func NewGetNoteBuilder(requestContext model.RequestContext) NoteBuilder {
return &getNote{requestContext: requestContext}
}
type getNote struct {
requestContext model.RequestContext
noteID int
}
func (g *getNote) SetNoteID(noteID int) NoteBuilder {
g.noteID = noteID
return g
}
func (g *getNote) Execute() (*model.Note, error) {
note, err := endpoints.GetNote(g.requestContext, strconv.Itoa(g.noteID))
if err != nil {
log.Println(err)
return nil, err
}
return &note, nil
}