all files / lib/Endpoints/MatchEndpoint/ MatchlistEndpointV4.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 54 55 56 57 58 59 60                                                                                                    
import MatchSuperclass from './MatchSuperclass'
import Request from 'RequestClient/Request'
import METHOD_NAMES from 'Enums/method-names'
 
class MatchlistEndpointV4 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/v4/matchlists/by-account/{encryptedAccountId}`.
     *
     * @param {string} 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_V4,
            'GET',
            this.limiter,
            null,
            false,
            4,
        )
    }
 
    /**
     * 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 MatchlistEndpointV4