{{
const spec = require('./.spec.json');
const dotUtils = require('./dotUtils.js');
}}
// This file is automatically generated.
// Do not directly edit.
// Generated on {{= (new Date).toISOString() }}
// http://www.mingweisamuel.com/riotapi-schema/tool/
// Version {{= spec.info.version }}
use std::future::Future;
use std::vec::Vec;
use reqwest;
use url::form_urlencoded::Serializer;
use crate::consts::Region;
use crate::riot_api::RiotApi;
{{
const endpointGroups = {};
for (let path of Object.entries(spec.paths)) {
let ep = path[1]['x-endpoint'];
endpointGroups[ep] = endpointGroups[ep] || [];
endpointGroups[ep].push(path);
}
for (let [ endpointName, endpointMethods ] of Object.entries(endpointGroups)) {
let endpoint = dotUtils.changeCase.pascalCase(endpointName);
}}
// {{= endpoint }}
impl RiotApi {
{{
for (let [ route, path ] of endpointMethods)
{
let get = path.get;
if (!get)
continue;
let operationId = get.operationId;
let method = dotUtils.changeCase.snakeCase(operationId.slice(operationId.indexOf('.') + 1));
let jsonInfo = get.responses['200'].content['application/json'];
let returnType = dotUtils.stringifyType(jsonInfo.schema, endpoint, false, false);
/* Cases if not rate limited. */
let rateLimitExcluded = get['x-app-rate-limit-excluded'] ? true : false;
/* Description processing. */
let desc = get.description;
let descArr = desc
.replace(/(#+)\s*([^\\]+)\\n(.*?)([\\n$])/g,
(m, g1, g2, g3, g4) => `${g2}\\n${g3}${g4}`)
.split('\n');
/* Build argument comment & string. */
let argBuilder = [];
let makeParamCode = '';
let allParams = get.parameters;
let queryParams = [];
let routeArgument = dotUtils.formatRouteArgument(route);
if (allParams && allParams.length)
{
let pathParams = allParams.filter(p => 'path' === p.in)
.sort(p => route.indexOf(p.name));
let reqParams = allParams.filter(p => 'path' !== p.in && p.required);
let optParams = allParams.filter(p => 'path' !== p.in && !p.required)
.sort(p => {
let match = /(^[a-z]+|[A-Z]+(?![a-z])|[A-Z][a-z]+)/.exec(p.name);
return match.slice(1).reverse().join('');
});
queryParams = reqParams.concat(optParams);
for (let paramList of [ pathParams, reqParams, optParams ])
{
let required = paramList === pathParams;
for (let param of paramList)
{
argBuilder.push(', ', dotUtils.changeCase.snakeCase(param.name), ': ',
dotUtils.stringifyType(param.schema, endpoint, !required, true, false));
}
}
routeArgument = dotUtils.formatRouteArgument(route, pathParams);
}
for (var descLine of descArr)
{
}}
///{{= descLine ? ' ' + descLine : '' }}
{{
}
}}
/// # {{= get.externalDocs.description }}
/// {{= get.externalDocs.url }}
/// # Parameters
/// * `region` - Region to query.
{{
if (allParams)
{
for (let param of allParams)
{
}}
/// * `{{= param.name }}`{{= param.required ? '' : ' (optional)' }}{{= param.description ? ' - ' + param.description : ''}}
{{
}
}
}}
pub fn {{= dotUtils.changeCase.snakeCase(endpoint) }}_{{= method }}<'a>(&'a self, region: Region{{= argBuilder.join('') }})
-> impl Future