all files / lib/Endpoints/ ChampionMasteryEndpoint.js

86.67% Statements 13/15
100% Branches 0/0
60% Functions 3/5
86.67% Lines 13/15
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                                                                                                                                            
import Endpoint from 'Endpoint'
import Request from 'RequestClient/Request'
import METHOD_NAMES from 'Enums/method-names'
 
class ChampionMasteryEndpoint extends Endpoint {
    constructor(config, limiter) {
        super()
 
        this.config = config
 
        this.get = this.get.bind(this)
        this.list = this.list.bind(this)
        this.totalScore = this.totalScore.bind(this)
 
        this.serviceName = 'champion-mastery'
 
        this.limiter = limiter
    }
 
    /**
     * Get a champion mastery by player ID and champion ID. Returns a function that takes in a champion ID.
     *
     * Implements GET `/lol/champion-mastery/v3/champion-masteries/by-summoner/{summonerId}/by-champion/{championId}`.
     *
     * @param {number} summonerID - The ID of the summoner.
     * @returns {ChampionMastery.get.inner} - The curried function.
     */
    get(summonerID) {
        const self = this
        /**
         * @name ChampionMastery.get.inner
         */
        return function(championID) {
            return new Request(
                self.config,
                self.serviceName,
                `champion-masteries/by-summoner/${summonerID}/by-champion/${championID}`,
                METHOD_NAMES.CHAMPION_MASTERY.GET_CHAMPION_MASTERY,
                'GET',
                self.limiter,
            )
        }
    }
 
    /**
     * Get all champion mastery entries sorted by number of champion points descending.
     *
     * Implements GET `/lol/champion-mastery/v3/champion-masteries/by-summoner/{summonerId}`.
     *
     * @param {number} summonerID - The ID of the summoner.
     */
    list(summonerID) {
        return new Request(
            this.config,
            this.serviceName,
            `champion-masteries/by-summoner/${summonerID}`,
            METHOD_NAMES.CHAMPION_MASTERY.GET_ALL_CHAMPION_MASTERIES,
            'GET',
            this.limiter,
        )
    }
 
    /**
     * Get all champion mastery entries sorted by number of champion points descending.
     *
     * Implements GET `/lol/champion-mastery/v3/scores/by-summoner/{summonerId}`.
     *
     * @param {number} summonerID - The ID of the summoner.
     */
    totalScore(summonerID) {
        return new Request(
            this.config,
            this.serviceName,
            `scores/by-summoner/${summonerID}`,
            METHOD_NAMES.CHAMPION_MASTERY.GET_CHAMPION_MASTERY_SCORE,
            'GET',
            this.limiter,
        )
    }
}
 
export default ChampionMasteryEndpoint