Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: support match v5 #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions ENDPOINTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@ DDragon.Version.list()
Status.get()

/* MATCH-V4 */
Match.get(matchID: int)
MatchV4.get(matchID: int)
Matchlist.by.accountID(accountID: string)
Matchlist.Recent.by.accountID(accountID: string) /* April 27th deprecation by Riot, but will still work via the above endpoint */
MatchV4.timeline(matchID: int)
MatchV4.Tournament.listMatchIDs(tournamentCode: string)
MatchV4.Tournament.get(matchID: int, tournamentCode: string)

/* MATCH-V5 */
Match.get(matchID: int)
Match.by.puuid(puuid: string)
Match.timeline(matchID: int)
Match.Tournament.listMatchIDs(tournamentCode: string)
Match.Tournament.get(matchID: int, tournamentCode: string)

/* SPECTATOR-V4 */
CurrentGame.by.summonerID(summonerID: string)
Expand Down
86 changes: 86 additions & 0 deletions lib/Endpoints/MatchEndpoint/MatchEndpointV5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import METHOD_NAMES from 'Enums/method-names'
import Request from 'RequestClient/Request'
import MatchSuperclass from './MatchSuperclass'

class MatchEndpointV5 extends MatchSuperclass {
constructor(config, limiter) {
super()

this.config = config

this.get = this.get.bind(this)
this.timeline = this.timeline.bind(this)
this.by = {
puuid: this.puuid.bind(this),
}
this.limiter = limiter
}

/**
* Get match by match ID.
*
* Implements GET `/lol/match/v5/matches/{matchId}`.
*
* @param {number} matchID - The ID of the match.
*/
get(matchID) {
return new Request(
this.config,
this.serviceName,
`matches/${matchID}`,
METHOD_NAMES.MATCH.GET_MATCH_V5,
'GET',
this.limiter,
null,
false,
5,
)
}

/**
* Get matchlist for games played on given account ID and platform ID and filtered using given filter parameters, if any.
*
* Implements GET `/lol/match/v5/matches/by-puuid/{puuid}/ids`.
*
* @param {string} puuid - The account ID of the summoner.
*/
puuid(puuid) {
return new Request(
this.config,
this.serviceName,
`matches/by-puuid/${puuid}/ids`,
METHOD_NAMES.MATCH.GET_MATCHLIST_V5,
'GET',
this.limiter,
null,
false,
5,
)
}


/**
* Get match timeline by match ID.
*
* Implements GET `/lol/match/v5/timelines/by-match/{matchId}`.
*
* @param {number} matchID - The ID of the match.
*/
timeline(matchID) {
return new Request(
this.config,
this.serviceName,
`matches/${matchID}/timeline`,
METHOD_NAMES.MATCH.GET_MATCH_TIMELINE_V5,
'GET',
this.limiter,
null,
false,
5,
)
}


}

export default MatchEndpointV5
6 changes: 6 additions & 0 deletions lib/Enums/method-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ const MATCH = {
GET_MATCH_IDS_BY_TOURNAMENT_CODE_V4:
'MATCH.GET_MATCH_IDS_BY_TOURNAMENT_CODE_V4',
GET_MATCH_BY_TOURNAMENT_CODE_V4: 'MATCH.GET_MATCH_BY_TOURNAMENT_CODE_V4',

// V5
GET_MATCH_V5: 'MATCH.GET_MATCH_V5',
GET_MATCHLIST_V5: 'MATCH.GET_MATCHLIST_V5',
GET_MATCH_TIMELINE_V4: 'MATCH.GET_MATCH_TIMELINE_V5',

}

const SPECTATOR = {
Expand Down
4 changes: 3 additions & 1 deletion lib/Kayn.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import LeagueEndpointV4 from './Endpoints/LeagueEndpoint/LeagueEndpointV4'
import LeagueEntriesEndpointV4 from './Endpoints/LeagueEndpoint/LeagueEntriesEndpointV4'
import MasterEndpointV4 from './Endpoints/LeagueEndpoint/MasterEndpointV4'
import MatchEndpointV4 from './Endpoints/MatchEndpoint/MatchEndpointV4'
import MatchEndpointV5 from './Endpoints/MatchEndpoint/MatchEndpointV5'
import MatchlistEndpointV4 from './Endpoints/MatchEndpoint/MatchlistEndpointV4'
import SummonerEndpointV4 from './Endpoints/SummonerEndpointV4'
import ThirdPartyCodeEndpointV4 from './Endpoints/ThirdPartyCodeEndpointV4'
Expand Down Expand Up @@ -159,7 +160,8 @@ class Kayn {
this.MasterV4 = new MasterEndpointV4(this.config, this.limiter)
this.Master = this.MasterV4
this.MatchV4 = new MatchEndpointV4(this.config, this.limiter)
this.Match = this.MatchV4
this.MatchV5 = new MatchEndpointV5(this.config, this.limiter)
this.Match = this.MatchV5
this.MatchlistV4 = new MatchlistEndpointV4(this.config, this.limiter)
this.Matchlist = this.MatchlistV4
this.SummonerV4 = new SummonerEndpointV4(this.config, this.limiter)
Expand Down
Loading