all files / lib/Endpoints/MatchEndpoint/ MatchEndpointV4.js

69.23% Statements 9/13
100% Branches 0/0
20% Functions 1/5
69.23% Lines 9/13
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109                                                                                                                                                                                                        
import MatchSuperclass from './MatchSuperclass'
import Request from 'RequestClient/Request'
import METHOD_NAMES from 'Enums/method-names'
 
class MatchEndpointV4 extends MatchSuperclass {
    constructor(config, limiter) {
        super()
 
        this.config = config
 
        this.get = this.get.bind(this)
        this.timeline = this.timeline.bind(this)
 
        this.Tournament = {
            listMatchIDs: this.listMatchIDs.bind(this),
            get: this.getTournamentMatch.bind(this),
        }
 
        this.limiter = limiter
    }
 
    /**
     * Get match by match ID.
     *
     * Implements GET `/lol/match/v4/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_V4,
            'GET',
            this.limiter,
            null,
            false,
            4,
        )
    }
 
    /**
     * Get match timeline by match ID.
     *
     * Implements GET `/lol/match/v4/timelines/by-match/{matchId}`.
     *
     * @param {number} matchID - The ID of the match.
     */
    timeline(matchID) {
        return new Request(
            this.config,
            this.serviceName,
            `timelines/by-match/${matchID}`,
            METHOD_NAMES.MATCH.GET_MATCH_TIMELINE_V4,
            'GET',
            this.limiter,
            null,
            false,
            4,
        )
    }
 
    /**
     * Get match IDs by tournament code.
     *
     * Implements GET `/lol/match/v4/matches/by-tournament-code/{tournamentCode}/ids`.
     *
     * @param {string} tournamentCode - The code of the tournament.
     */
    listMatchIDs(tournamentCode) {
        return new Request(
            this.config,
            this.serviceName,
            `matches/by-tournament-code/${tournamentCode}/ids`,
            METHOD_NAMES.MATCH.GET_MATCH_IDS_BY_TOURNAMENT_CODE_V4,
            'GET',
            this.limiter,
            null,
            false,
            4,
        )
    }
 
    /**
     * Get match by match ID and tournament code.
     *
     * Implements GET `/lol/match/v4/matches/{matchId}/by-tournament-code/{tournamentCode}`.
     *
     * @param {number} matchID - The ID of the match.
     * @param {string} tournamentCode - The code of the tournament.
     */
    getTournamentMatch(matchID, tournamentCode) {
        return new Request(
            this.config,
            this.serviceName,
            `matches/${matchID}/by-tournament-code/${tournamentCode}`,
            METHOD_NAMES.MATCH.GET_MATCH_BY_TOURNAMENT_CODE_V4,
            'GET',
            this.limiter,
            null,
            false,
            4,
        )
    }
}
 
export default MatchEndpointV4