package api import ( "fmt" def "git.pbiernat.dev/egommerce/api-entities/http" "github.com/go-redis/redis/v8" ) func NewBasketAPI(redis *redis.Client) *BasketAPI { return &BasketAPI{NewHttpClient(redis)} } type BasketAPI struct { httpClient *HttpClient } func (a *BasketAPI) GetBasket(basketID string) (*def.GetBasketResponse, error) { req := &def.GetBasketRequest{BasketID: basketID} res := new(def.GetBasketResponse) if err := a.httpClient.SendGet("basket", "/api/v1/basket", req, res); err != nil { return nil, err } return res, nil } func (a *BasketAPI) GetBasketItems(basketID string) ([]*def.GetBasketItemsResponse, error) { url := fmt.Sprintf("/api/v1/basket/%s/items", basketID) var res []*def.GetBasketItemsResponse if err := a.httpClient.SendGet("basket", url, nil, &res); err != nil { return nil, err } return res, nil }