From 87bfdb315b8eec99eaaae170fcadb30f2ea767c8 Mon Sep 17 00:00:00 2001 From: bshore Date: Wed, 2 Mar 2022 21:38:00 -0600 Subject: [PATCH] take care of a few goreportcard linter warnings --- hirezapi/client.go | 2 +- hirezapi/player.go | 2 +- hirezapi_mock/client.go | 1 + hirezapi_mock/connection.go | 2 +- hirezapi_mock/game.go | 1 + hirezapi_mock/misc.go | 2 +- hirezapi_mock/player.go | 2 +- models/connection.go | 7 +++++-- models/datatypes.go | 17 +++++++++-------- utils/helpers.go | 13 +++++++++---- 10 files changed, 30 insertions(+), 19 deletions(-) diff --git a/hirezapi/client.go b/hirezapi/client.go index b6b57ab..0c74c47 100644 --- a/hirezapi/client.go +++ b/hirezapi/client.go @@ -12,7 +12,7 @@ import ( "github.com/bshore/go-hirez/models" ) -// APIClient is the implementation of the HiRezAPI interface. +// APIClient stores data needed to interface with the HiRez API and implements the HiRezAPI interface methods. type APIClient struct { DeveloperID string AuthKey string diff --git a/hirezapi/player.go b/hirezapi/player.go index d30cc47..b6b0306 100644 --- a/hirezapi/player.go +++ b/hirezapi/player.go @@ -24,7 +24,7 @@ func (a *APIClient) GetPlayer(player string) ([]models.Player, error) { return output, err } -// GetPlayer returns league and other high level data for a particular player. +// GetPlayerByPlatform returns league and other high level data for a particular player. func (a *APIClient) GetPlayerByPlatform(player, portalID string) ([]models.Player, error) { path := fmt.Sprintf("%v/%v", player, portalID) resp, err := a.makeRequest("getplayer", path) diff --git a/hirezapi_mock/client.go b/hirezapi_mock/client.go index ff7da73..81aec3b 100644 --- a/hirezapi_mock/client.go +++ b/hirezapi_mock/client.go @@ -14,6 +14,7 @@ import ( "github.com/bshore/go-hirez/utils" ) +// APIClient stores data needed to interface with the HiRez API and implements the HiRezAPI interface methods. type APIClient struct { DeveloperID string AuthKey string diff --git a/hirezapi_mock/connection.go b/hirezapi_mock/connection.go index 3bb0a3c..8736556 100644 --- a/hirezapi_mock/connection.go +++ b/hirezapi_mock/connection.go @@ -50,7 +50,7 @@ func (a *APIClient) TestSession() (string, error) { return "", fmt.Errorf("session not initialized") } -// 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", "", []models.HiRezServerStatus{}) if err != nil { diff --git a/hirezapi_mock/game.go b/hirezapi_mock/game.go index fad5730..e770ee7 100644 --- a/hirezapi_mock/game.go +++ b/hirezapi_mock/game.go @@ -24,6 +24,7 @@ func (a *APIClient) GetGods(langCode string) ([]models.God, error) { return output, err } +// GetGodAltAbilities returns alt abilities for all Gods. func (a *APIClient) GetGodAltAbilities() ([]models.GodAltAbility, error) { if !utils.IsSmitePath(a.BasePath) { return nil, fmt.Errorf("GetGodAltAbilities(), %s", utils.NotSmiteErrMsg) diff --git a/hirezapi_mock/misc.go b/hirezapi_mock/misc.go index bfd9dfa..f4d1eee 100644 --- a/hirezapi_mock/misc.go +++ b/hirezapi_mock/misc.go @@ -54,7 +54,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) diff --git a/hirezapi_mock/player.go b/hirezapi_mock/player.go index ba944e2..277e5df 100644 --- a/hirezapi_mock/player.go +++ b/hirezapi_mock/player.go @@ -18,7 +18,7 @@ func (a *APIClient) GetPlayer(player string) ([]models.Player, error) { return output, err } -// GetPlayer returns league and other high level data for a particular player. +// GetPlayerByPlatform returns league and other high level data for a particular player. func (a *APIClient) GetPlayerByPlatform(player, portalID string) ([]models.Player, error) { path := fmt.Sprintf("%v/%v", player, portalID) resp, err := a.makeRequest("getplayer", path, []models.Player{}) diff --git a/models/connection.go b/models/connection.go index 009f7b7..063db2e 100644 --- a/models/connection.go +++ b/models/connection.go @@ -1,11 +1,13 @@ package models +// Session stores data related to a current HiRezAPI Session. type Session struct { RetMsg string `json:"ret_msg"` SessionID string `json:"session_id"` - Timestamp string `json:"timestmap"` + Timestamp string `json:"timestamp"` } +// HiRezServerStatus stores data related to a HiRez Service's current status. type HiRezServerStatus struct { EntryDatetime string `json:"entry_datetime"` Environment string `json:"environment"` @@ -16,6 +18,7 @@ type HiRezServerStatus struct { Version string `json:"version"` } +// DataUsed stores data related to how many requests and sessions have been used of the daily cap. type DataUsed struct { ActiveSessions int `json:"Active_Sessions"` ConcurrentSessions int `json:"Concurrent_Sessions"` @@ -25,4 +28,4 @@ type DataUsed struct { TotalRequestsToday int `json:"Total_Requests_Today"` TotalSessionsToday int `json:"Total_Sessions_Today"` RetMsg string `json:"ret_msg"` -} \ No newline at end of file +} diff --git a/models/datatypes.go b/models/datatypes.go index 1612c1f..b30fd06 100644 --- a/models/datatypes.go +++ b/models/datatypes.go @@ -1,18 +1,19 @@ package models -// URL determinmes the baseURL to use when calling Hi-Rez API endpoints -type URL int - const ( - URLSmitePC = "https://api.smitegame.com/smiteapi.svc" - URLPaladinsPC = "https://api.paladins.com/paladinsapi.svc" + // URLSmitePC is the base URL for making Smite requests + URLSmitePC = "https://api.smitegame.com/smiteapi.svc" + // URLPaladinsPC is the base URL for making Paladins requests + URLPaladinsPC = "https://api.paladins.com/paladinsapi.svc" + // ResponseTypeJSON is the json response type ResponseTypeJSON = "json" - ResponseTypeXML = "xml" + // ResponseTypeXML is the xml response type + ResponseTypeXML = "xml" - // yyyyMMdd + // DateFormat yyyyMMdd DateFormat string = "20060102" - // yyyyMMddHHmmss + // TimeFormat yyyyMMddHHmmss TimeFormat string = "20060102150405" // PortalIDs (Gaming Platforms) diff --git a/utils/helpers.go b/utils/helpers.go index b90ae84..3981211 100644 --- a/utils/helpers.go +++ b/utils/helpers.go @@ -7,11 +7,13 @@ import ( "github.com/bshore/go-hirez/models" ) - const ( - NotSmiteErrMsg = "is only available for Smite requests" + // NotSmiteErrMsg is an error message from making non Smite requests to the Smite URL + NotSmiteErrMsg = "is only available for Smite requests" + // NotPaladinsErrMsg is an error message from making non Paladins requests to the Paladins URL NotPaladinsErrMsg = "is only available for Paladins requests" - NotRankedErrMsg = "only applies to queues: Joust1v1Ranked, Joust3v3Ranked, and ConquestRanked (440, 450, and 451)" + // NotRankedErrMsg is an error message from making a request to an endpoint marked as "Ranked Only" + NotRankedErrMsg = "only applies to queues: Joust1v1Ranked, Joust3v3Ranked, and ConquestRanked (440, 450, and 451)" ) // IsNotSmitePath checks that the client BasePath is for Smite @@ -24,6 +26,7 @@ func IsPaladinsPath(basePath string) bool { return strings.Contains(basePath, "paladins") } +// IsNotRanked returns true if the passed in queueID is not a ranked queueID func IsNotRanked(queueID string) bool { return !Contains( []string{ @@ -33,6 +36,7 @@ func IsNotRanked(queueID string) bool { }, queueID) } +// Contains checks if string slice 'a' contains string 'b' func Contains(a []string, b string) bool { for _, v := range a { if b == v { @@ -42,6 +46,7 @@ func Contains(a []string, b string) bool { return false } +// FormatTime formats a go timestamp to the format expected/returned by the HiRez API func FormatTime(t time.Time) string { return t.Format(models.TimeFormat) -} \ No newline at end of file +}