From c9173bfac223ef0f38b232b47fbd20d1e23e5f5f Mon Sep 17 00:00:00 2001 From: Harmon Herring Date: Wed, 15 May 2024 09:38:02 -0400 Subject: [PATCH] Migrate to Spectator v5 (#63) * use spectator v5 endpoint * add puuid field to spectator response --- riot/lol/constants.go | 2 +- riot/lol/model.go | 1 + riot/lol/spectator.go | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/riot/lol/constants.go b/riot/lol/constants.go index 8ade9ae..253fcf0 100644 --- a/riot/lol/constants.go +++ b/riot/lol/constants.go @@ -35,7 +35,7 @@ const ( endpointSummonerBase = endpointBase + "/summoner/v4" endpointGetSummonerBySummonerID = endpointSummonerBase + "/summoners/%s" endpointGetSummonerBy = endpointSummonerBase + "/summoners/by-%s/%s" - endpointSpectatorBase = endpointBase + "/spectator/v4" + endpointSpectatorBase = endpointBase + "/spectator/v5" endpointGetCurrentGame = endpointSpectatorBase + "/active-games/by-summoner/%s" endpointGetFeaturedGames = endpointSpectatorBase + "/featured-games" endpointTournamentStubBase = endpointBase + "/tournament-stub/v4" diff --git a/riot/lol/model.go b/riot/lol/model.go index 7b33f01..d039594 100644 --- a/riot/lol/model.go +++ b/riot/lol/model.go @@ -604,6 +604,7 @@ type CurrentGameParticipant struct { Spell1ID int `json:"spell1Id"` TeamID int `json:"teamId"` SummonerID string `json:"summonerId"` + PUUID string `json:"puuid"` } // GetChampion returns the champion played by this participant diff --git a/riot/lol/spectator.go b/riot/lol/spectator.go index 4cf0ffe..1dc9bb9 100644 --- a/riot/lol/spectator.go +++ b/riot/lol/spectator.go @@ -14,10 +14,10 @@ type SpectatorClient struct { } // GetCurrent returns a currently running game for a summoner -func (s *SpectatorClient) GetCurrent(summonerID string) (*GameInfo, error) { +func (s *SpectatorClient) GetCurrent(puuid string) (*GameInfo, error) { logger := s.logger().WithField("method", "GetCurrent") var games GameInfo - if err := s.c.GetInto(fmt.Sprintf(endpointGetCurrentGame, summonerID), &games); err != nil { + if err := s.c.GetInto(fmt.Sprintf(endpointGetCurrentGame, puuid), &games); err != nil { logger.Debug(err) return nil, err }