# all files / lib/Endpoints/ SummonerEndpoint.js

100% Statements 11/11
100% Branches 0/0
100% Functions 4/4
100% Lines 11/11

    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
    781×
    1×
    1×

    5×

    5×

    5×

    5×

    2×

    1×

    1×

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

    class SummonerEndpoint extends Endpoint {
        constructor(config, limiter) {
            super()

            this.config = config

            this.by = {
                name: this.summonerName.bind(this),
                id: this.summonerID.bind(this),
                accountID: this.accountID.bind(this),
            }

            this.serviceName = 'summoner'

            this.limiter = limiter
        }

        /**
         * Get a summoner by summoner name.
         *
         * Implements GET `/lol/summoner/v3/summoners/by-name/{summonerName}`.
         *
         * @param {string} summonerName - The name of the summoner.
         */
        summonerName(summonerName) {
            return new Request(
                this.config,
                this.serviceName,
                `summoners/by-name/${encodeURI(summonerName)}`,
                METHOD_NAMES.SUMMONER.GET_BY_SUMMONER_NAME,
                'GET',
                this.limiter,
            )
        }

        /**
         * Get a summoner by summoner ID.
         *
         * Implements GET `/lol/summoner/v3/summoners/{summonerId}`.
         *
         * @param {number} summonerID - The id of the summoner.
         */
        summonerID(summonerID) {
            return new Request(
                this.config,
                this.serviceName,
                `summoners/${summonerID}`,
                METHOD_NAMES.SUMMONER.GET_BY_SUMMONER_ID,
                'GET',
                this.limiter,
            )
        }

        /**
         * Get a summoner by account ID.
         *
         * Implements GET `/lol/summoner/v3/summoners/by-account/{accountId}`.
         *
         * @param {number} accountID - The account ID of the summoner.
         */
        accountID(accountID) {
            return new Request(
                this.config,
                this.serviceName,
                `summoners/by-account/${accountID}`,
                METHOD_NAMES.SUMMONER.GET_BY_ACCOUNT_ID,
                'GET',
                this.limiter,
            )
        }
    }

    export default SummonerEndpoint