package builder import ( "context" "git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints" "git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model" ) type UserBuilder interface { SetUsername(username string) UserBuilder Execute() (model.User, error) } func NewGetUserBuilder(requestContext model.RequestContext) UserBuilder { return &getUser{requestContext: requestContext} } type getUser struct { requestContext model.RequestContext username string } func (g *getUser) SetUsername(username string) UserBuilder { g.username = username return g } func (g *getUser) Execute() (model.User, error) { if g.requestContext.RateLimiter != nil { err := g.requestContext.RateLimiter.Wait(context.Background()) if err != nil { return model.User{}, err } } user, err := endpoints.GetUser(g.requestContext, g.username) if err != nil { return model.User{}, err } return user, nil }