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 NotesBuilder interface { SearchInBody(body string) NotesBuilder NoteID(noteID int) NotesBuilder SearchTags(tags string) NotesBuilder SearchCreatorID(creatorID int) NotesBuilder searchCreatorName(creatorName string) NotesBuilder Active(isActive bool) NotesBuilder SetLimit(limitNotes int) NotesBuilder Execute() ([]model.Note, error) } func NewGetNotesBuilder(requestContext model.RequestContext) NotesBuilder { return &getNotes{ requestContext: requestContext, query: make(map[string]string), } } type getNotes struct { requestContext model.RequestContext query map[string]string } func (g getNotes) SearchInBody(body string) NotesBuilder { g.query["search[body_matches]"] = body return g } func (g getNotes) NoteID(noteID int) NotesBuilder { g.query["search[post_id]"] = strconv.Itoa(noteID) return g } func (g getNotes) SearchTags(tags string) NotesBuilder { g.query["search[post_tags_match]"] = tags return g } func (g getNotes) SearchCreatorID(creatorID int) NotesBuilder { g.query["search[creator_id]"] = strconv.Itoa(creatorID) return g } func (g getNotes) searchCreatorName(creatorName string) NotesBuilder { g.query["search[creator_name]"] = creatorName return g } func (g getNotes) Active(isActive bool) NotesBuilder { g.query["search[is_active]"] = strconv.FormatBool(isActive) return g } func (g getNotes) SetLimit(limitNotes int) NotesBuilder { g.query["limit"] = strconv.Itoa(limitNotes) return g } func (g getNotes) Execute() ([]model.Note, error) { notes, err := endpoints.GetNotes(g.requestContext, g.query) if err != nil { log.Println(err) return nil, err } return notes, nil }