Fix issue with querying for a float instead of integer
This commit is contained in:
parent
05b36eab15
commit
c7cb3f5af5
15
ovrstat.go
15
ovrstat.go
|
@ -5,19 +5,26 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OvrStatApi struct {
|
type OvrStatApi struct {
|
||||||
Client *http.Client
|
Client *http.Client
|
||||||
URL string
|
URL *url.URL
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(apiUrl string) *OvrStatApi {
|
func New(apiUrl string) *OvrStatApi {
|
||||||
return &OvrStatApi{Client: &http.Client{}, URL: apiUrl}
|
u, err := url.Parse(apiUrl)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return &OvrStatApi{Client: &http.Client{}, URL: u}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *OvrStatApi) Fetch(region, platform, battletag string) (*OverstatApiResponse, error) {
|
func (s *OvrStatApi) Fetch(platform, region, battletag string) (*OverstatApiResponse, error) {
|
||||||
res, err := s.Client.Get(fmt.Sprintf("%s/v1/stats/%s/%s/%s", s.URL, region, platform, strings.Replace(battletag, "#", "-", -1)))
|
res, err := s.Client.Get(fmt.Sprintf("%s/v1/stats/%s/%s/%s", s.URL, platform, region, strings.Replace(battletag, "#", "-", -1)))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -58,7 +58,7 @@ type HeroStat struct {
|
||||||
GamesWon int `json:"gamesWon"`
|
GamesWon int `json:"gamesWon"`
|
||||||
WinPercentage int `json:"winPercentage"`
|
WinPercentage int `json:"winPercentage"`
|
||||||
WeaponAccuracy int `json:"weaponAccuracy"`
|
WeaponAccuracy int `json:"weaponAccuracy"`
|
||||||
EliminationsPerLife int `json:"eliminationsPerLife"`
|
EliminationsPerLife float64 `json:"eliminationsPerLife"`
|
||||||
MultiKillBest int `json:"multiKillBest"`
|
MultiKillBest int `json:"multiKillBest"`
|
||||||
ObjectiveKillsAvg float64 `json:"objectiveKillsAvg"`
|
ObjectiveKillsAvg float64 `json:"objectiveKillsAvg"`
|
||||||
}
|
}
|
Loading…
Reference in New Issue