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/pool.go
2023-10-24 10:35:33 +02:00

36 lines
714 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"
"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 {
return model.Pool{}, err
}
return pool, nil
}