Skip to content

Commit

Permalink
Merge pull request #2 from bshore/get-god-alt-abilities
Browse files Browse the repository at this point in the history
Support New Endopint GetGodAltAbilities
  • Loading branch information
bshore authored Mar 2, 2022
2 parents c575af5 + f837d35 commit 8b46778
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 53 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func main() {
client := &hirezapi.APIClient{
DeveloperID: devID,
AuthKey: authKey,
BasePath: "http://api.smitegame.com/smiteapi.svc",
BasePath: "https://api.smitegame.com/smiteapi.svc",
RespType: "json",
}
}
Expand Down
10 changes: 5 additions & 5 deletions hirezapi/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package hirezapi
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"

"github.com/bshore/go-hirez/models"
Expand Down Expand Up @@ -40,7 +40,7 @@ func (a *APIClient) CreateSession() error {
}
defer resp.Body.Close()
sess := &models.Session{}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("error reading response: %v", err)
}
Expand All @@ -63,7 +63,7 @@ func (a *APIClient) TestSession() (string, error) {
return "", err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return "", err
}
Expand All @@ -77,7 +77,7 @@ func (a *APIClient) GetHiRezServerStatus() ([]models.HiRezServerStatus, error) {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -93,7 +93,7 @@ func (a *APIClient) GetDataUsed() ([]models.DataUsed, error) {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand Down
29 changes: 24 additions & 5 deletions hirezapi/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package hirezapi

import (
"fmt"
"io/ioutil"
"io"

"github.com/bshore/go-hirez/models"
"github.com/bshore/go-hirez/utils"
Expand All @@ -21,7 +21,7 @@ func (a *APIClient) GetGods(langCode string) ([]models.God, error) {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -30,6 +30,25 @@ func (a *APIClient) GetGods(langCode string) ([]models.God, error) {
return output, err
}

func (a *APIClient) GetGodAltAbilities() ([]models.GodAltAbility, error) {
if !utils.IsSmitePath(a.BasePath) {
return nil, fmt.Errorf("GetGodAltAbilities(), %s", utils.NotSmiteErrMsg)
}
resp, err := a.makeRequest("getgodaltabilities", "")
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
fmt.Println(string(body))
var output []models.GodAltAbility
err = a.unmarshalResponse(body, &output)
return output, err
}

// GetGodSkins returns all available skins for a particular God.
func (a *APIClient) GetGodSkins(godID int64, langCode string) ([]models.GodSkin, error) {
if !utils.IsSmitePath(a.BasePath) {
Expand All @@ -44,7 +63,7 @@ func (a *APIClient) GetGodSkins(godID int64, langCode string) ([]models.GodSkin,
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -67,7 +86,7 @@ func (a *APIClient) GetGodRecommendedItems(godID int64, langCode string) ([]mode
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -86,7 +105,7 @@ func (a *APIClient) GetItems(langCode string) ([]models.Item, error) {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand Down
2 changes: 2 additions & 0 deletions hirezapi/hirezapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ type HiRezAPI interface {
// ===== Game Entity Related =====
// GetGods returns all Gods and their various attributes.
GetGods(langCode string) ([]models.God, error)
// GetGodAltAbilities returns alt abilities for all Gods.
GetGodAltAbilities() ([]models.GodAltAbility, error)
// GetGodSkins returns all available skins for a particular God.
GetGodSkins(godID int64, langCode string) ([]models.GodSkin, error)
// GetGodRecommendedItems returns the recommended items for a particular God.
Expand Down
12 changes: 6 additions & 6 deletions hirezapi/matches.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package hirezapi

import (
"fmt"
"io/ioutil"
"io"
"strconv"
"strings"

Expand All @@ -16,7 +16,7 @@ func (a *APIClient) GetMatchDetails(matchID string) ([]models.MatchPlayer, error
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -35,7 +35,7 @@ func (a *APIClient) GetMatchDetailsBatch(matchIDs []string) ([]models.MatchPlaye
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -74,7 +74,7 @@ func (a *APIClient) GetMatchPlayerDetails(matchID string) ([]models.LiveMatchPla
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -96,7 +96,7 @@ func (a *APIClient) GetMatchIDsByQueue(queueID, date, hour string) ([]models.Mat
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -113,7 +113,7 @@ func (a *APIClient) GetQueueStats(player, queueID string) ([]models.PlayerGodQue
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand Down
16 changes: 8 additions & 8 deletions hirezapi/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package hirezapi

import (
"fmt"
"io/ioutil"
"io"

"github.com/bshore/go-hirez/models"
"github.com/bshore/go-hirez/utils"
Expand All @@ -15,7 +15,7 @@ func (a *APIClient) GetESportsProLeagueDetails() ([]models.ESportsProLeagueDetai
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -38,7 +38,7 @@ func (a *APIClient) GetGodLeaderboard(godID, queueID string) ([]models.GodLeader
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -61,7 +61,7 @@ func (a *APIClient) GetLeagueLeaderboard(queueID, tier, round string) ([]models.
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -83,7 +83,7 @@ func (a *APIClient) GetLeagueSeasons(queueID string) ([]models.Season, error) {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -99,7 +99,7 @@ func (a *APIClient) GetMOTD() ([]models.MOTD, error) {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -115,7 +115,7 @@ func (a *APIClient) GetTopMatches() ([]models.TopMatch, error) {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -131,7 +131,7 @@ func (a *APIClient) GetPatchInfo() (*models.VersionInfo, error) {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand Down
20 changes: 10 additions & 10 deletions hirezapi/paladins.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package hirezapi

import (
"fmt"
"io/ioutil"
"io"
"strings"

"github.com/bshore/go-hirez/models"
Expand All @@ -22,7 +22,7 @@ func (a *APIClient) GetPlayerBatch(playerIDs []string) ([]models.Player, error)
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -41,7 +41,7 @@ func (a *APIClient) GetChampionRanks(player string) ([]models.ChampionRank, erro
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -63,7 +63,7 @@ func (a *APIClient) GetChampions(langCode string) ([]models.Champion, error) {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -83,7 +83,7 @@ func (a *APIClient) GetChampionLeaderboard(champID string) ([]models.ChampionLea
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -106,7 +106,7 @@ func (a *APIClient) GetChampionSkins(champID, langCode string) ([]models.Champio
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -125,7 +125,7 @@ func (a *APIClient) GetPlayerIDInfoForXBOXAndSwitch(player string) ([]models.Pla
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -148,7 +148,7 @@ func (a *APIClient) GetPlayerLoadouts(player, langCode string) ([]models.PlayerL
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -168,7 +168,7 @@ func (a *APIClient) GetChampionCards(champID, langCode string) ([]models.Champio
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand All @@ -187,7 +187,7 @@ func (a *APIClient) GetBountyItems() ([]models.BountyItem, error) {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 8b46778

Please sign in to comment.