go-api-pkg/api/pricing.go

27 lines
580 B
Go
Raw Normal View History

2022-12-25 21:39:20 +01:00
package api
import (
"fmt"
def "git.pbiernat.dev/egommerce/api-entities/http"
"github.com/go-redis/redis/v8"
)
2022-12-25 22:59:04 +01:00
func NewPricingAPI(ua string, redis *redis.Client) *PricingAPI {
return &PricingAPI{NewHttpClient(ua, redis)}
2022-12-25 21:39:20 +01:00
}
type PricingAPI struct {
httpClient *HttpClient
}
func (a *PricingAPI) GetProductPrice(productID int) (*def.ProductPriceResponse, error) {
url := fmt.Sprintf("/api/v1/product/%d", productID)
res := new(def.ProductPriceResponse)
2022-12-25 22:59:04 +01:00
if err := a.httpClient.SendGet("pricing-svc", url, nil, res); err != nil {
2022-12-25 21:39:20 +01:00
return nil, err
}
return res, nil
}