diff --git a/ovrstat.go b/ovrstat.go index 60bf5e1..02692ad 100644 --- a/ovrstat.go +++ b/ovrstat.go @@ -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 + } + + return &OvrStatApi{Client: &http.Client{}, URL: u} } -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))) +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 diff --git a/structs.go b/structs.go index 1aa5f81..b55b8ea 100644 --- a/structs.go +++ b/structs.go @@ -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"` } \ No newline at end of file