diff options
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/handlers/login.go | 10 | ||||
| -rw-r--r-- | backend/models/models.go | 25 |
2 files changed, 9 insertions, 26 deletions
diff --git a/backend/handlers/login.go b/backend/handlers/login.go index 1a74166..a6e99bd 100644 --- a/backend/handlers/login.go +++ b/backend/handlers/login.go | |||
| @@ -145,15 +145,15 @@ func DeleteCookie(c *gin.Context) { | |||
| 145 | }) | 145 | }) |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | func GetPlayerSummaries(steamId, apiKey string) (*models.PlayerSummaries, error) { | 148 | func GetPlayerSummaries(steamId, apiKey string) (models.PlayerSummaries, error) { |
| 149 | url := fmt.Sprintf("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=%s&steamids=%s", apiKey, steamId) | 149 | url := fmt.Sprintf("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=%s&steamids=%s", apiKey, steamId) |
| 150 | resp, err := http.Get(url) | 150 | resp, err := http.Get(url) |
| 151 | if err != nil { | 151 | if err != nil { |
| 152 | return nil, err | 152 | return models.PlayerSummaries{}, err |
| 153 | } | 153 | } |
| 154 | body, err := io.ReadAll(resp.Body) | 154 | body, err := io.ReadAll(resp.Body) |
| 155 | if err != nil { | 155 | if err != nil { |
| 156 | return nil, err | 156 | return models.PlayerSummaries{}, err |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | type Result struct { | 159 | type Result struct { |
| @@ -163,7 +163,7 @@ func GetPlayerSummaries(steamId, apiKey string) (*models.PlayerSummaries, error) | |||
| 163 | } | 163 | } |
| 164 | var data Result | 164 | var data Result |
| 165 | if err := json.Unmarshal(body, &data); err != nil { | 165 | if err := json.Unmarshal(body, &data); err != nil { |
| 166 | return nil, err | 166 | return models.PlayerSummaries{}, err |
| 167 | } | 167 | } |
| 168 | return &data.Response.Players[0], err | 168 | return data.Response.Players[0], err |
| 169 | } | 169 | } |
diff --git a/backend/models/models.go b/backend/models/models.go index 3aa2e9c..bf3ac86 100644 --- a/backend/models/models.go +++ b/backend/models/models.go | |||
| @@ -122,25 +122,8 @@ type Pagination struct { | |||
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | type PlayerSummaries struct { | 124 | type PlayerSummaries struct { |
| 125 | SteamId string `json:"steamid"` | 125 | SteamId string `json:"steamid"` |
| 126 | CommunityVisibilityState int `json:"communityvisibilitystate"` | 126 | PersonaName string `json:"personaname"` |
| 127 | ProfileState int `json:"profilestate"` | 127 | AvatarFull string `json:"avatarfull"` |
| 128 | PersonaName string `json:"personaname"` | 128 | LocCountryCode string `json:"loccountrycode"` |
| 129 | LastLogOff int `json:"lastlogoff"` | ||
| 130 | ProfileUrl string `json:"profileurl"` | ||
| 131 | Avatar string `json:"avatar"` | ||
| 132 | AvatarMedium string `json:"avatarmedium"` | ||
| 133 | AvatarFull string `json:"avatarfull"` | ||
| 134 | PersonaState int `json:"personastate"` | ||
| 135 | |||
| 136 | CommentPermission int `json:"commentpermission"` | ||
| 137 | RealName string `json:"realname"` | ||
| 138 | PrimaryClanId string `json:"primaryclanid"` | ||
| 139 | TimeCreated int `json:"timecreated"` | ||
| 140 | LocCountryCode string `json:"loccountrycode"` | ||
| 141 | LocStateCode string `json:"locstatecode"` | ||
| 142 | LocCityId int `json:"loccityid"` | ||
| 143 | GameId int `json:"gameid"` | ||
| 144 | GameExtraInfo string `json:"gameextrainfo"` | ||
| 145 | GameServerIp string `json:"gameserverip"` | ||
| 146 | } | 129 | } |