Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x | import * as _ from 'lodash'
import { endpointsV4, IEndpoint } from '../../../endpoints/endpoints'
import { SummonerV4DTO } from '../../../models-dto/summoners/summoner.dto'
import { Regions } from '../../../constants'
import { FindSummonerBy } from '../../../constants/summoner.find'
import { BaseApiLol } from '../base/base.api.lol'
/**
* Summoner methods
*/
export class SummonerApi extends BaseApiLol {
private parsePath (endpoint: IEndpoint, by: FindSummonerBy) {
let { path } = endpoint
Eif (by === FindSummonerBy.ID) {
path = path.replace('/$(by)/', '/')
}
return path
}
private genericRequest (by: FindSummonerBy, value: string, region: Regions) {
const endpoint = _.cloneDeep(endpointsV4.Summoner)
endpoint.path = this.parsePath(endpoint, by)
const params = {
summonerName: value,
by
}
return this.request<SummonerV4DTO>(region, endpoint, params)
}
/**
* Get by name
* @param summonerName Summoner name
* @param region Riot region
*/
public async getByName (summonerName: string, region: Regions) {
return this.genericRequest(FindSummonerBy.NAME, summonerName, region)
}
/**
* Get by id
* @param id Summoner id
* @param region Riot region
*/
public async getById (id: string, region: Regions) {
return this.genericRequest(FindSummonerBy.ID, id, region)
}
/**
* Get by PUUID
* @param puuid
* @param region Riot region
*/
public async getByPUUID (puuid: string, region: Regions) {
return this.genericRequest(FindSummonerBy.PUUID, puuid, region)
}
/**
* Get by PUUID
* @param puuid
* @param region Riot region
*/
public async getByAccountID (accountId: string, region: Regions) {
return this.genericRequest(FindSummonerBy.ACCOUNT_ID, accountId, region)
}
}
|