37 lines
739 B
Go
37 lines
739 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"
|
|
"strconv"
|
|
)
|
|
|
|
type PoolBuilder interface {
|
|
ID(poolID int) PoolBuilder
|
|
Execute() (model.Pool, error)
|
|
}
|
|
|
|
func NewGetPoolBuilder(requestContext model.RequestContext) PoolBuilder {
|
|
return &getPool{requestContext: requestContext}
|
|
}
|
|
|
|
type getPool struct {
|
|
requestContext model.RequestContext
|
|
id int
|
|
}
|
|
|
|
func (g getPool) ID(poolID int) PoolBuilder {
|
|
g.id = poolID
|
|
return g
|
|
}
|
|
|
|
func (g getPool) Execute() (model.Pool, error) {
|
|
pool, err := endpoints.GetPool(g.requestContext, strconv.Itoa(g.id))
|
|
if err != nil {
|
|
log.Println(err)
|
|
return model.Pool{}, err
|
|
}
|
|
return pool, nil
|
|
}
|