package builder import ( "context" "git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints" "git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model" "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) { if g.requestContext.RateLimiter != nil { err := g.requestContext.RateLimiter.Wait(context.Background()) if err != nil { return nil, err } } note, err := endpoints.GetNote(g.requestContext, strconv.Itoa(g.noteID)) if err != nil { return nil, err } return ¬e, nil }