Skip to content

Commit

Permalink
take care of a few goreportcard linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bshore committed Mar 3, 2022
1 parent d1302fe commit 87bfdb3
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 19 deletions.
2 changes: 1 addition & 1 deletion hirezapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion hirezapi/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions hirezapi_mock/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion hirezapi_mock/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions hirezapi_mock/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion hirezapi_mock/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion hirezapi_mock/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand Down
7 changes: 5 additions & 2 deletions models/connection.go
Original file line number Diff line number Diff line change
@@ -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"`
Expand All @@ -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"`
Expand All @@ -25,4 +28,4 @@ type DataUsed struct {
TotalRequestsToday int `json:"Total_Requests_Today"`
TotalSessionsToday int `json:"Total_Sessions_Today"`
RetMsg string `json:"ret_msg"`
}
}
17 changes: 9 additions & 8 deletions models/datatypes.go
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
13 changes: 9 additions & 4 deletions utils/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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{
Expand All @@ -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 {
Expand All @@ -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)
}
}

0 comments on commit 87bfdb3

Please sign in to comment.