# all files / lib/Endpoints/MatchEndpoint/ MatchlistEndpoint.js

100% Statements 10/10
100% Branches 0/0
100% Functions 3/3
100% Lines 10/10

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

    3×

    3×

    3×

    3×

    2×

    1×

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

    class MatchlistEndpoint extends MatchSuperclass {
        constructor(config, limiter) {
            super()

            this.config = config

            this.by = {
                accountID: this.accountID.bind(this),
            }

            this.Recent = {
                by: {
                    accountID: this.getRecentMatchlistByAccountID.bind(this),
                },
            }

            this.limiter = limiter
        }

        /**
         * Get matchlist for games played on given account ID and platform ID and filtered using given filter parameters, if any.
         *
         * Implements GET `/lol/match/v3/matchlists/by-account/{accountId}`.
         *
         * @param {number} accountID - The account ID of the summoner.
         */
        accountID(accountID) {
            return new Request(
                this.config,
                this.serviceName,
                `matchlists/by-account/${accountID}`,
                METHOD_NAMES.MATCH.GET_MATCHLIST,
                'GET',
                this.limiter,
            )
        }

        /**
         * Get matchlist for last 20 matches played on given account ID and platform ID.
         * This is here for non-breaking purposes as there used to be a /recent endpoint.
         *
         * @param {number} accountID - The account ID of the summoner.
         */
        getRecentMatchlistByAccountID(accountID) {
            return this.accountID(accountID).query({ beginIndex: 0, endIndex: 20 })
        }
    }

    export default MatchlistEndpoint