Fix issue with querying for a float instead of integer

This commit is contained in:
Tyler 2017-05-26 02:27:57 -04:00
parent 05b36eab15
commit c7cb3f5af5
2 changed files with 12 additions and 5 deletions

View File

@ -5,19 +5,26 @@ import (
"encoding/json"
"net/http"
"fmt"
"net/url"
)
type OvrStatApi struct {
Client *http.Client
URL string
URL *url.URL
}
func New(apiUrl string) *OvrStatApi {
return &OvrStatApi{Client: &http.Client{}, URL: apiUrl}
u, err := url.Parse(apiUrl)
if err != nil {
return nil
}
func (s *OvrStatApi) Fetch(region, platform, 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)))
return &OvrStatApi{Client: &http.Client{}, URL: u}
}
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, platform, region, strings.Replace(battletag, "#", "-", -1)))
if err != nil {
return nil, err

View File

@ -58,7 +58,7 @@ type HeroStat struct {
GamesWon int `json:"gamesWon"`
WinPercentage int `json:"winPercentage"`
WeaponAccuracy int `json:"weaponAccuracy"`
EliminationsPerLife int `json:"eliminationsPerLife"`
EliminationsPerLife float64 `json:"eliminationsPerLife"`
MultiKillBest int `json:"multiKillBest"`
ObjectiveKillsAvg float64 `json:"objectiveKillsAvg"`
}