27 lines
561 B
Go
27 lines
561 B
Go
|
package api
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
def "git.pbiernat.dev/egommerce/api-entities/http"
|
||
|
"github.com/go-redis/redis/v8"
|
||
|
)
|
||
|
|
||
|
func NewPricingAPI(redis *redis.Client) *PricingAPI {
|
||
|
return &PricingAPI{NewHttpClient(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", url, nil, res); err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
return res, nil
|
||
|
}
|