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 PostBuilder interface {
SetPostID(postID int) PostBuilder
Execute() (*model.Post, error)
}
func NewGetPostBuilder(requestContext model.RequestContext) PostBuilder {
return &getPost{requestContext: requestContext}
type getPost struct {
requestContext model.RequestContext
postID int
func (g *getPost) SetPostID(postID int) PostBuilder {
g.postID = postID
return g
func (g *getPost) Execute() (*model.Post, error) {
post, err := endpoints.GetPost(g.requestContext, strconv.Itoa(g.postID))
if err != nil {
return nil, err
return &post, nil