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 | 1x 1x 1x 1x 2x 2x 3x 3x 3x 1x 1x 2x 2x 3x | import { INTERNAL_SERVER_ERROR, NOT_FOUND } from 'http-status-codes'
import { Regions } from '../../../constants'
import { endpointsV4 } from '../../../endpoints/endpoints'
import { ThirdPartyCodeDTO } from '../../../models-dto/third-party-code/third-party-code.dto'
import { ApiResponseDTO } from '../../../models-dto/api-response/api-response'
import { BaseApiLol } from '../base/base.api.lol'
/**
* Third party methods
*/
export class ThirdPartyCode extends BaseApiLol {
private errorHandler (e: any) {
const { statusCode } = e.error || e
Iif (statusCode !== INTERNAL_SERVER_ERROR && statusCode !== NOT_FOUND) {
throw e
}
}
/**
* Valid codes must be no longer than 256 characters and only use valid characters: 0-9, a-z, A-Z, and -
* @param encryptedSummonerId
* @param region
*/
public async get (encryptedSummonerId: string, region: Regions): Promise<ApiResponseDTO<ThirdPartyCodeDTO>> {
let code
let rateLimits
const params = {
encryptedSummonerId
}
try {
const data = await this.request<string>(region, endpointsV4.ThirdPartyCode, params)
rateLimits = data.rateLimits
code = data.response
} catch (e) {
this.errorHandler(e)
code = null
}
return {
rateLimits,
response: {
code
}
}
}
}
|