Skip to content

Commit

Permalink
fixed unmarshaling error for int/string/float vals, took care of more…
Browse files Browse the repository at this point in the history
… report card issues
  • Loading branch information
bshore committed Sep 2, 2022
1 parent 87bfdb3 commit e6fa85f
Show file tree
Hide file tree
Showing 13 changed files with 200 additions and 117 deletions.
2 changes: 1 addition & 1 deletion hirezapi/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (a *APIClient) TestSession() (string, error) {
return string(body), nil
}

// GetHirezServerStatus returns UP/DOWN status for the primary game/platform environments. Data is cached once a minute.
// GetHiRezServerStatus returns UP/DOWN status for the primary game/platform environments. Data is cached once a minute.
func (a *APIClient) GetHiRezServerStatus() ([]models.HiRezServerStatus, error) {
resp, err := a.makeRequest("gethirezserverstatus", "")
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion hirezapi/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func (a *APIClient) GetGodAltAbilities() ([]models.GodAltAbility, error) {
if err != nil {
return nil, err
}
fmt.Println(string(body))
var output []models.GodAltAbility
err = a.unmarshalResponse(body, &output)
return output, err
Expand Down
6 changes: 6 additions & 0 deletions hirezapi/hirezapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "github.com/bshore/go-hirez/models"
// Definitions here are taken from the publicly available "Smite API Developer Guide" PDF
type HiRezAPI interface {
// ===== Connectivity =====

// Ping is a quick way of validating access to the Hi-Rez API.
Ping() error
// CreateSession is a required step to Authenticate the developerId/signature for further API use.
Expand All @@ -22,6 +23,7 @@ type HiRezAPI interface {
ChangeResponseType(respType string)

// ===== Player Related =====

// GetPlayer returns league and other high level data for a particular player.
GetPlayer(player string) ([]models.Player, error)
// GetPlayer returns league and other high level data for a particular player.
Expand Down Expand Up @@ -52,6 +54,7 @@ type HiRezAPI interface {
SearchPlayers(searchPlayer string) ([]models.PlayerIDInfo, error)

// ===== Game Entity Related =====

// GetGods returns all Gods and their various attributes.
GetGods(langCode string) ([]models.God, error)
// GetGodAltAbilities returns alt abilities for all Gods.
Expand All @@ -64,6 +67,7 @@ type HiRezAPI interface {
GetItems(langCode string) ([]models.Item, error)

// ===== Match Related =====

// GetMatchDetails returns the statistics for a particular completed match.
GetMatchDetails(matchID string) ([]models.MatchPlayer, error)
/*GetMatchDetailsBatch returns the statistics for a particular set of completed matches. (limit batch query to 5-10 matchIDs)
Expand All @@ -87,6 +91,7 @@ type HiRezAPI interface {
GetQueueStats(player, queueID string) ([]models.PlayerGodQueueStat, error)

// ===== Miscellaneous =====

// GetESportsProLeagueDetails returns matchup info for each matchup of the current season. match_status = 1 - scheduled, 2 - in progress, 3 - complete
GetESportsProLeagueDetails() ([]models.ESportsProLeagueDetail, error)
// GetGodLeaderboard returns the current season's leaderboard for a god/queue. [SmiteAPI: only queues 440, 450, 451 apply]
Expand All @@ -103,6 +108,7 @@ type HiRezAPI interface {
GetPatchInfo() (*models.VersionInfo, error)

// ===== Paladins =====

// GetPlayerBatch returns league and other high level data for a particular list of players. [20 max]
GetPlayerBatch(playerIDs []string) ([]models.Player, error)
// GetChampionRanks returns the rank and worshipper values for each Champion a player has played.
Expand Down
3 changes: 2 additions & 1 deletion hirezapi/matches.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ func (a *APIClient) GetMatchPlayerDetails(matchID string) ([]models.LiveMatchPla
return output, err
}

/*GetMatchIDsByQueue lists all MatchIDs for a particular match queue.
/*
GetMatchIDsByQueue lists all MatchIDs for a particular match queue.
- queueID can be referened by constants defined in this package (eg, hirezapi.ConquestRanked).
- date must be formatted/formattable by hirezapi.DateFormat (yyyyMMdd).
- hour may be "0" - "23" and optionally may contain a ten minute window separated by a comma (eg, "6,30").
Expand Down
2 changes: 1 addition & 1 deletion hirezapi/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (a *APIClient) GetLeagueLeaderboard(queueID, tier, round string) ([]models.
return output, err
}

// GetLeageSeasons returns a list of seasons for a match queue.
// GetLeagueSeasons returns a list of seasons for a match queue.
func (a *APIClient) GetLeagueSeasons(queueID string) ([]models.Season, error) {
if !utils.IsSmitePath(a.BasePath) {
return nil, fmt.Errorf("GetLeageSeasons() %s", utils.NotSmiteErrMsg)
Expand Down
3 changes: 2 additions & 1 deletion hirezapi_mock/matches.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ func (a *APIClient) GetMatchPlayerDetails(matchID string) ([]models.LiveMatchPla
return output, err
}

/*GetMatchIDsByQueue lists all MatchIDs for a particular match queue.
/*
GetMatchIDsByQueue lists all MatchIDs for a particular match queue.
- queueID can be referened by constants defined in this package (eg, hirezapi.ConquestRanked).
- date must be formatted/formattable by hirezapi.DateFormat (yyyyMMdd).
- hour may be "0" - "23" and optionally may contain a ten minute window separated by a comma (eg, "6,30").
Expand Down
200 changes: 105 additions & 95 deletions models/datatypes.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package models

// Excessive '// nolint' directives are an attempt to keep the Go Report Card happy

const (
// URLSmitePC is the base URL for making Smite requests
URLSmitePC = "https://api.smitegame.com/smiteapi.svc"
URLSmitePC string = "https://api.smitegame.com/smiteapi.svc"

// URLPaladinsPC is the base URL for making Paladins requests
URLPaladinsPC = "https://api.paladins.com/paladinsapi.svc"
URLPaladinsPC string = "https://api.paladins.com/paladinsapi.svc"

// ResponseTypeJSON is the json response type
ResponseTypeJSON = "json"
ResponseTypeJSON string = "json"

// ResponseTypeXML is the xml response type
ResponseTypeXML = "xml"
ResponseTypeXML string = "xml"

// DateFormat yyyyMMdd
DateFormat string = "20060102"
Expand All @@ -17,103 +22,108 @@ const (
TimeFormat string = "20060102150405"

// PortalIDs (Gaming Platforms)
HiRez, Steam, PS4, XBOX, Switch, Discord, Epic string = "1", "5", "9", "10", "22", "25", "28"

HiRez, Steam, PS4, XBOX, Switch, Discord, Epic string = "1", "5", "9", "10", "22", "25", "28" // nolint

// Language Codes
English string = "1"
German string = "2"
French string = "3"
Chinese string = "5"
Spanish string = "7"
SpanishLAM string = "9"
Portuguese string = "10"
Russian string = "11"
Polish string = "12"
Turkish string = "13"

English string = "1" // nolint
German string = "2" // nolint
French string = "3" // nolint
Chinese string = "5" // nolint
Spanish string = "7" // nolint
SpanishLAM string = "9" // nolint
Portuguese string = "10" // nolint
Russian string = "11" // nolint
Polish string = "12" // nolint
Turkish string = "13" // nolint

// League Tiers
Bronze5, Bronze4, Bronze3, Bronze2, Bronze1 string = "1", "2", "3", "4", "5"
Silver5, Silver4, Silver3, Silver2, Silver1 string = "6", "7", "8", "9", "10"
Gold5, Gold4, Gold3, Gold2, Gold1 string = "11", "12", "13", "14", "15"
Platinum5, Platinum4, Platinum3, Platinum2, Platinum1 string = "16", "17", "18", "19", "20"
Diamond5, Diamond4, Diamond3, Diamond2, Diamond1 string = "21", "22", "23", "24", "25"
Masters, Grandmaster string = "26", "27"

Bronze5, Bronze4, Bronze3, Bronze2, Bronze1 string = "1", "2", "3", "4", "5" // nolint
Silver5, Silver4, Silver3, Silver2, Silver1 string = "6", "7", "8", "9", "10" // nolint
Gold5, Gold4, Gold3, Gold2, Gold1 string = "11", "12", "13", "14", "15" // nolint
Platinum5, Platinum4, Platinum3, Platinum2, Platinum1 string = "16", "17", "18", "19", "20" // nolint
Diamond5, Diamond4, Diamond3, Diamond2, Diamond1 string = "21", "22", "23", "24", "25" // nolint
Masters, Grandmaster string = "26", "27" // nolint

// Smite Match Queue IDs
Adventures string = "495"
Arena string = "435"
ArenaAIEasy string = "457"
ArenaAIMedium string = "468"
ArenaChallenge string = "438"
ArenaPracticeEasy string = "443"
ArenaPracticeMedium string = "472"
ArenaTraining string = "483"
ArenaTutorial string = "462"
Assault string = "445"
AssaultAIEasy string = "481"
AssaultAIMedium string = "454"
AssaultChallenge string = "446"
AssaultPracticeEasy string = "479"
AssaultPracticeMedium string = "480"
BasicTutorial string = "436"
Clash string = "466"
ClashAIEasy string = "478"
ClashAIMedium string = "469"
ClashChallenge string = "467"
ClashPracticeEasy string = "470"
ClashPracticeMedium string = "477"
ClashTutorial string = "471"
ConqeustChallenge string = "429"
Conquest string = "426"
ConquestAIEasy string = "476"
ConquestAIMedium string = "461"
ConquestPracticeEasy string = "458"
ConquestPracticeMedium string = "475"
ConquestRanked string = "451"
ConquestTutorial string = "463"
Joust string = "448"
Joust1v1Ranked string = "440"
Joust3v3Ranked string = "450"
Joust3v3Training string = "482"
JoustAIEasy string = "474"
JoustAIMedium string = "456"
JoustChallenge string = "441"
JoustPracticeEasy string = "464"
JunglePracicePreselect string = "496"
JunglePracitceMedium string = "473"
JunglePractice string = "444"
MatchOfTheDay string = "434"
Siege string = "459"
SiegeChallenge string = "460"

Adventures string = "495" // nolint
Arena string = "435" // nolint
ArenaAIEasy string = "457" // nolint
ArenaAIMedium string = "468" // nolint
ArenaChallenge string = "438" // nolint
ArenaPracticeEasy string = "443" // nolint
ArenaPracticeMedium string = "472" // nolint
ArenaTraining string = "483" // nolint
ArenaTutorial string = "462" // nolint
Assault string = "445" // nolint
AssaultAIEasy string = "481" // nolint
AssaultAIMedium string = "454" // nolint
AssaultChallenge string = "446" // nolint
AssaultPracticeEasy string = "479" // nolint
AssaultPracticeMedium string = "480" // nolint
BasicTutorial string = "436" // nolint
Clash string = "466" // nolint
ClashAIEasy string = "478" // nolint
ClashAIMedium string = "469" // nolint
ClashChallenge string = "467" // nolint
ClashPracticeEasy string = "470" // nolint
ClashPracticeMedium string = "477" // nolint
ClashTutorial string = "471" // nolint
ConqeustChallenge string = "429" // nolint
Conquest string = "426" // nolint
ConquestAIEasy string = "476" // nolint
ConquestAIMedium string = "461" // nolint
ConquestPracticeEasy string = "458" // nolint
ConquestPracticeMedium string = "475" // nolint
ConquestRanked string = "451" // nolint
ConquestTutorial string = "463" // nolint
Joust string = "448" // nolint
Joust1v1Ranked string = "440" // nolint
Joust3v3Ranked string = "450" // nolint
Joust3v3Training string = "482" // nolint
JoustAIEasy string = "474" // nolint
JoustAIMedium string = "456" // nolint
JoustChallenge string = "441" // nolint
JoustPracticeEasy string = "464" // nolint
JunglePracicePreselect string = "496" // nolint
JunglePracitceMedium string = "473" // nolint
JunglePractice string = "444" // nolint
MatchOfTheDay string = "434" // nolint
Siege string = "459" // nolint
SiegeChallenge string = "460" // nolint

// Paladins Match Queue IDs
ClassicSiege string = "465"
CustomOnslaughtForemansRise string = "462"
CustomOnslaughtMagistratesArchives string = "464"
CustomOnslaughtPrimalCourt string = "455"
CustomOnslaughtSnowfallJunction string = "454"
CustomSiegeBrightmarsh string = "458"
CustomSiegeFishMarket string = "431"
CustomSiegeFrogIsle string = "433"
CustomSiegeFrozenGuard string = "432"
CustomSiegeIceMines string = "439"
CustomSiegeJaguarFalls string = "438"
CustomSiegeSerpentBeach string = "440"
CustomSiegeSplitstoneQuarry string = "459"
CustomSiegeStoneKeep string = "423"
CustomSiegeTimberMill string = "430"
CustomTDMForemansRise string = "471"
CustomTDMMagistrateArchives string = "472"
CustomTDMTradeDistrict string = "468"
LiveBattleGroundsDuo string = "475"
LiveBattleGroundsQuad string = "476"
LiveBattlegroundsSolo string = "474"
LiveCasual string = "424"
LiveCompetitive string = "428"
LiveOnslaught string = "452"
LiveOnslaughtPractice string = "453"
LiveSiegePractice string = "425"
LiveTeamDeathmatch string = "469"
LiveTeamDeathmatchPractice string = "470"
LiveTestMaps string = "445"

ClassicSiege string = "465" // nolint
CustomOnslaughtForemansRise string = "462" // nolint
CustomOnslaughtMagistratesArchives string = "464" // nolint
CustomOnslaughtPrimalCourt string = "455" // nolint
CustomOnslaughtSnowfallJunction string = "454" // nolint
CustomSiegeBrightmarsh string = "458" // nolint
CustomSiegeFishMarket string = "431" // nolint
CustomSiegeFrogIsle string = "433" // nolint
CustomSiegeFrozenGuard string = "432" // nolint
CustomSiegeIceMines string = "439" // nolint
CustomSiegeJaguarFalls string = "438" // nolint
CustomSiegeSerpentBeach string = "440" // nolint
CustomSiegeSplitstoneQuarry string = "459" // nolint
CustomSiegeStoneKeep string = "423" // nolint
CustomSiegeTimberMill string = "430" // nolint
CustomTDMForemansRise string = "471" // nolint
CustomTDMMagistrateArchives string = "472" // nolint
CustomTDMTradeDistrict string = "468" // nolint
LiveBattleGroundsDuo string = "475" // nolint
LiveBattleGroundsQuad string = "476" // nolint
LiveBattlegroundsSolo string = "474" // nolint
LiveCasual string = "424" // nolint
LiveCompetitive string = "428" // nolint
LiveOnslaught string = "452" // nolint
LiveOnslaughtPractice string = "453" // nolint
LiveSiegePractice string = "425" // nolint
LiveTeamDeathmatch string = "469" // nolint
LiveTeamDeathmatchPractice string = "470" // nolint
LiveTestMaps string = "445" // nolint
)
Loading

0 comments on commit e6fa85f

Please sign in to comment.