This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
e621-sdk-go/pkg/e621/builder/user.go
SoXX 08d584111e feat: added mit-level API for getUser
Signed-off-by: SoXX <soxx@fenpa.ws>
2023-10-23 10:21:51 +02:00

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
}