2023-01-07 20:07:35 -08:00
|
|
|
{{
|
|
|
|
const dotUtils = require('./dotUtils.js');
|
|
|
|
const routesTable = require('./.routesTable.json');
|
|
|
|
}}{{= dotUtils.preamble() }}
|
|
|
|
|
|
|
|
use num_enum::{ IntoPrimitive, TryFromPrimitive };
|
|
|
|
use strum_macros::{ EnumString, EnumIter, Display, IntoStaticStr };
|
|
|
|
|
2023-05-09 22:09:13 -07:00
|
|
|
/// Regional routes, used in tournament services, Legends of Runeterra (LoR), and other some endpoints.
|
2023-01-07 20:07:35 -08:00
|
|
|
#[derive(Debug)]
|
|
|
|
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord)]
|
|
|
|
#[derive(IntoPrimitive, TryFromPrimitive)]
|
|
|
|
#[derive(EnumString, EnumIter, Display, IntoStaticStr)]
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
#[repr(u8)]
|
|
|
|
#[non_exhaustive]
|
|
|
|
pub enum RegionalRoute {
|
|
|
|
{{
|
|
|
|
for (const [ name, { id, description, deprecated } ] of Object.entries(routesTable['regional'])) {
|
|
|
|
const desc = description.split('\n');
|
|
|
|
}}
|
|
|
|
{{~ desc :line }}
|
|
|
|
/// {{= line }}
|
|
|
|
{{~}}
|
|
|
|
///
|
|
|
|
/// `{{= id }}` (riotapi-schema ID/repr)
|
|
|
|
{{? deprecated }}
|
|
|
|
#[deprecated]
|
|
|
|
{{?}}
|
|
|
|
{{= name.toUpperCase() }} = {{= id }},
|
|
|
|
|
|
|
|
{{
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Platform routes for League of Legends (LoL), Teamfight Tactics (TFT), and Legends of Runeterra (LoR).
|
|
|
|
#[derive(Debug)]
|
|
|
|
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord)]
|
|
|
|
#[derive(IntoPrimitive, TryFromPrimitive)]
|
|
|
|
#[derive(EnumString, EnumIter, Display, IntoStaticStr)]
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
#[repr(u8)]
|
|
|
|
#[non_exhaustive]
|
|
|
|
// Note: strum(serialize = ...) actually specifies extra DEserialization values.
|
|
|
|
pub enum PlatformRoute {
|
|
|
|
{{
|
|
|
|
for (const [ name, { id, description, altName, deprecated } ] of Object.entries(routesTable['platform'])) {
|
|
|
|
const desc = description.split('\n');
|
|
|
|
}}
|
|
|
|
{{~ desc :line }}
|
|
|
|
/// {{= line }}
|
|
|
|
{{~}}
|
|
|
|
///
|
|
|
|
/// `{{= id }}` (riotapi-schema ID/repr)
|
|
|
|
{{? deprecated }}
|
|
|
|
#[deprecated]
|
|
|
|
{{?}}
|
|
|
|
{{? altName }}
|
|
|
|
#[strum(to_string="{{= name.toUpperCase() }}", serialize="{{= altName }}")]
|
|
|
|
{{?}}
|
|
|
|
{{= name.toUpperCase() }} = {{= id }},
|
|
|
|
|
|
|
|
{{
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PlatformRoute {
|
|
|
|
/// Converts this [`PlatformRoute`] into its corresponding
|
|
|
|
/// [`RegionalRoute`] for LoL and TFT match endpoints.
|
|
|
|
/// For example, [`match-v5`](crate::endpoints::MatchV5).
|
|
|
|
pub fn to_regional(self) -> RegionalRoute {
|
|
|
|
match self {
|
|
|
|
{{
|
|
|
|
for (const [ name, { regionalRoute } ] of Object.entries(routesTable['platform'])) {
|
|
|
|
}}
|
|
|
|
Self::{{= name.toUpperCase() }} => RegionalRoute::{{= regionalRoute.toUpperCase() }},
|
|
|
|
{{
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Converts this [`PlatformRoute`] into its corresponding
|
|
|
|
/// [`RegionalRoute`] for LoR endpoints.
|
|
|
|
/// For example, [`lor-match-v1`](crate::endpoints::LorMatchV1).
|
|
|
|
pub fn to_regional_lor(self) -> RegionalRoute {
|
|
|
|
match self {
|
|
|
|
{{
|
|
|
|
for (const [ name, { regionalRouteLor } ] of Object.entries(routesTable['platform'])) {
|
|
|
|
}}
|
|
|
|
Self::{{= name.toUpperCase() }} => RegionalRoute::{{= regionalRouteLor.toUpperCase() }},
|
|
|
|
{{
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-20 22:03:13 -08:00
|
|
|
/// Used in the LoL Tournament API. Specifically
|
|
|
|
/// [`tournament-stub-v4.registerProviderData`](crate::endpoints::TournamentStubV4::register_provider_data)
|
|
|
|
/// and [`tournament-v4.registerProviderData`](crate::endpoints::TournamentV4::register_provider_data).
|
|
|
|
pub fn to_tournament_region(self) -> Option<TournamentRegion> {
|
|
|
|
match self {
|
|
|
|
{{
|
|
|
|
for (const [ name, { tournamentRegion } ] of Object.entries(routesTable['platform'])) {
|
|
|
|
if (!tournamentRegion) continue;
|
|
|
|
}}
|
|
|
|
Self::{{= name.toUpperCase() }} => Some(TournamentRegion::{{= tournamentRegion }}),
|
|
|
|
{{
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
_other => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Get the slightly more human-friendly alternate name for this `PlatformRoute`. Specifically
|
|
|
|
/// excludes any trailing numbers and appends extra N(orth), S(outh), E(ast), and/or W(est)
|
|
|
|
/// suffixes to some names. Some of these are old region names which are often still used as
|
|
|
|
/// user-facing names, e.g. on op.gg.
|
|
|
|
///
|
|
|
|
/// Note these strings *are* handled by the `FromStr` implementation, if you wish to parse them
|
|
|
|
/// back into `PlatformRoute`s.
|
2023-01-07 20:07:35 -08:00
|
|
|
pub fn as_region_str(self) -> &'static str {
|
|
|
|
match self {
|
|
|
|
{{
|
|
|
|
for (const [ name, { altName } ] of Object.entries(routesTable['platform'])) {
|
|
|
|
if (!altName) continue;
|
|
|
|
}}
|
|
|
|
Self::{{= name.toUpperCase() }} => "{{= altName }}",
|
|
|
|
{{
|
|
|
|
}
|
|
|
|
}}
|
2023-01-20 22:03:13 -08:00
|
|
|
other => other.into(),
|
2023-01-07 20:07:35 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Platform routes for Valorant.
|
|
|
|
#[derive(Debug)]
|
|
|
|
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord)]
|
|
|
|
#[derive(IntoPrimitive, TryFromPrimitive)]
|
|
|
|
#[derive(EnumString, EnumIter, Display, IntoStaticStr)]
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
#[repr(u8)]
|
|
|
|
#[non_exhaustive]
|
|
|
|
pub enum ValPlatformRoute {
|
|
|
|
{{
|
|
|
|
for (const [ name, { id, description, deprecated } ] of Object.entries(routesTable['val-platform'])) {
|
|
|
|
const desc = description.split('\n');
|
|
|
|
}}
|
|
|
|
{{~ desc :line }}
|
|
|
|
/// {{= line }}
|
|
|
|
{{~}}
|
|
|
|
///
|
|
|
|
/// `{{= id }}` (riotapi-schema ID/repr)
|
|
|
|
{{? deprecated }}
|
|
|
|
#[deprecated]
|
|
|
|
{{?}}
|
|
|
|
{{= name.toUpperCase() }} = {{= id }},
|
|
|
|
|
|
|
|
{{
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
}
|
2023-01-20 22:03:13 -08:00
|
|
|
|
|
|
|
/// Tournament regions for League of Legends (LoL) used in
|
|
|
|
/// [`tournament-stub-v4.registerProviderData`](crate::endpoints::TournamentStubV4::register_provider_data)
|
|
|
|
/// and [`tournament-v4.registerProviderData`](crate::endpoints::TournamentV4::register_provider_data).
|
|
|
|
#[derive(Debug)]
|
|
|
|
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord)]
|
|
|
|
#[derive(IntoPrimitive, TryFromPrimitive)]
|
|
|
|
#[derive(EnumString, EnumIter, Display, IntoStaticStr)]
|
|
|
|
#[derive(serde::Serialize, serde::Deserialize)]
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
#[repr(u8)]
|
|
|
|
#[non_exhaustive]
|
|
|
|
// Note: strum(serialize = ...) actually specifies extra DEserialization values.
|
|
|
|
pub enum TournamentRegion {
|
|
|
|
{{
|
|
|
|
for (const [ name, { id, description, tournamentRegion, deprecated } ] of Object.entries(routesTable['platform'])) {
|
|
|
|
if (tournamentRegion) {
|
|
|
|
const desc = description.split('\n');
|
|
|
|
}}
|
|
|
|
{{~ desc :line }}
|
|
|
|
/// {{= line }}
|
|
|
|
{{~}}
|
|
|
|
{{? deprecated }}
|
|
|
|
#[deprecated]
|
|
|
|
{{?}}
|
|
|
|
{{= tournamentRegion }} = {{= id }},
|
|
|
|
{{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
}
|