27 lines
620 B
Go
27 lines
620 B
Go
package api
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
pricing "git.pbiernat.space/egommerce/api-entities/pricing/dto"
|
|
cnf "git.pbiernat.space/egommerce/go-api-pkg/config"
|
|
)
|
|
|
|
func NewPricingAPI() *PricingAPI {
|
|
return &PricingAPI{NewHttpClient(cnf.GetEnv("API_REST_PRICING", "pricing-svc"))}
|
|
}
|
|
|
|
type PricingAPI struct {
|
|
httpClient *HttpClient
|
|
}
|
|
|
|
func (a *PricingAPI) GetProductPrice(productID int) (*pricing.ProductPriceResponseDTO, error) {
|
|
url := fmt.Sprintf("/api/v1/product/%d", productID)
|
|
res := new(pricing.ProductPriceResponseDTO)
|
|
if err := a.httpClient.SendGet(url, nil, res); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return res, nil
|
|
}
|