Added Internal API Client's classes
This commit is contained in:
26
api/pricing.go
Normal file
26
api/pricing.go
Normal file
@@ -0,0 +1,26 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user