27 lines
579 B
Go
27 lines
579 B
Go
package api
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
def "git.pbiernat.io/egommerce/api-entities/http"
|
|
"github.com/go-redis/redis/v8"
|
|
)
|
|
|
|
func NewPricingAPI(ua string, redis *redis.Client) *PricingAPI {
|
|
return &PricingAPI{NewHttpClient(ua, redis)}
|
|
}
|
|
|
|
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)
|
|
if err := a.httpClient.SendGet("pricing-svc", url, nil, res); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return res, nil
|
|
}
|