# all files / lib/Endpoints/ ChampionMasteryEndpointV4.js

100% Statements 15/15
100% Branches 0/0
100% Functions 5/5
100% Lines 15/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
    84
    85
    86
    87
    88
    89
    90
    91
    921×
    1×
    1×

    4×

    4×
    4×
    4×

    4×

    4×

    1×

    1×
    1×

    1×

    1×

    1×
     import Endpoint from 'Endpoint'
    import Request from 'RequestClient/Request'
    import METHOD_NAMES from 'Enums/method-names'

    class ChampionMasteryEndpointV4 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/v4/champion-masteries/by-summoner/{encryptedSummonerId}/by-champion/{championId}`.
         *
         * @param {string} 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_V4,
                    'GET',
                    self.limiter,
                    null,
                    false,
                    4,
                )
            }
        }

        /**
         * Get all champion mastery entries sorted by number of champion points descending.
         *
         * Implements GET `/lol/champion-mastery/v4/champion-masteries/by-summoner/{encryptedSummonerId}`.
         *
         * @param {string} 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_V4,
                'GET',
                this.limiter,
                null,
                false,
                4,
            )
        }

        /**
         * Get all champion mastery entries sorted by number of champion points descending.
         *
         * Implements GET `/lol/champion-mastery/v4/scores/by-summoner/{encryptedSummonerId}`.
         *
         * @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_V4,
                'GET',
                this.limiter,
                null,
                false,
                4,
            )
        }
    }

    export default ChampionMasteryEndpointV4