# all files / lib/Endpoints/ SummonerEndpointV4.js

75% Statements 9/12
100% Branches 0/0
40% Functions 2/5
75% Lines 9/12

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

    3×

    3×

    3×

    3×

    2×

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

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

            this.config = config

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

            this.serviceName = 'summoner'

            this.limiter = limiter
        }

        /**
         * Get a summoner by account ID.
         *
         * Implements GET `/lol/summoner/v4/summoners/by-account/{encryptedAccountId}`.
         *
         * @param {string} 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_V4,
                'GET',
                this.limiter,
                null,
                false,
                4,
            )
        }

        /**
         * Get a summoner by summoner name.
         *
         * Implements GET `/lol/summoner/v4/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_V4,
                'GET',
                this.limiter,
                null,
                false,
                4,
            )
        }

        /**
         * Get a summoner by summoner puuid.
         *
         * Implements GET `/lol/summoner/v4/summoners/by-puuid/{encryptedPUUID}`.
         *
         * @param {string} puuid - The puuid of the summoner.
         */
        puuid(puuid) {
            return new Request(
                this.config,
                this.serviceName,
                `summoners/by-puuid/${puuid}`,
                METHOD_NAMES.SUMMONER.GET_BY_PUUID_V4,
                'GET',
                this.limiter,
                null,
                false,
                4,
            )
        }

        /**
         * Get a summoner by summoner ID.
         *
         * Implements GET `/lol/summoner/v4/summoners/{encryptedSummonerId}`.
         *
         * @param {string} summonerID - The id of the summoner.
         */
        summonerID(summonerID) {
            return new Request(
                this.config,
                this.serviceName,
                `summoners/${summonerID}`,
                METHOD_NAMES.SUMMONER.GET_BY_SUMMONER_ID_V4,
                'GET',
                this.limiter,
                null,
                false,
                4,
            )
        }
    }

    export default SummonerEndpointV4