35 lines
730 B
Go
35 lines
730 B
Go
package builder
|
|
|
|
import (
|
|
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
|
|
"git.dragse.it/anthrove/e621-to-graph/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) {
|
|
user, err := endpoints.GetUser(g.requestContext, g.username)
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
}
|
|
return &user, nil
|
|
}
|