36 lines
755 B
Go
36 lines
755 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"
|
|
"log"
|
|
)
|
|
|
|
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 {
|
|
log.Println(err)
|
|
return nil, err
|
|
}
|
|
return &user, nil
|
|
}
|