go-api-pkg/api/pricing.go

27 lines
579 B
Go
Raw Normal View History

2022-12-25 21:39:20 +01:00
package api
import (
"fmt"
2024-05-30 17:01:18 +02:00
def "git.pbiernat.io/egommerce/api-entities/http"
2022-12-25 21:39:20 +01:00
"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
}