Compare commits

...

2 commits

6 changed files with 638 additions and 66 deletions

6
Cargo.lock generated
View file

@ -2294,7 +2294,7 @@ dependencies = [
[[package]]
name = "torn-api"
version = "4.1.1"
version = "4.2.0"
dependencies = [
"bon",
"bytes",
@ -2316,7 +2316,7 @@ dependencies = [
[[package]]
name = "torn-api-codegen"
version = "0.7.4"
version = "0.7.5"
dependencies = [
"heck",
"indexmap",
@ -2329,7 +2329,7 @@ dependencies = [
[[package]]
name = "torn-key-pool"
version = "1.2.0"
version = "2.0.0"
dependencies = [
"chrono",
"futures",

View file

@ -1,7 +1,7 @@
[package]
name = "torn-api-codegen"
authors = ["Pyrit [2111649]"]
version = "0.7.4"
version = "0.7.5"
edition = "2021"
description = "Contains the v2 torn API model descriptions and codegen for the bindings"
license = { workspace = true }

View file

@ -258,12 +258,14 @@ impl Path {
} else {
let ty = if param.required {
convert_field.push(quote! {
.chain(std::iter::once(&self.#name).map(|v| (#query_val, v.to_string())))
parameters.push((#query_val, self.#name.to_string()));
});
ty
} else {
convert_field.push(quote! {
.chain(self.#name.as_ref().into_iter().map(|v| (#query_val, v.to_string())))
if let Some(value) = &self.#name {
parameters.push((#query_val, value.to_string()));
}
});
quote! { Option<#ty>}
};
@ -295,8 +297,8 @@ impl Path {
let mut path_fmt_str = String::new();
for seg in &self.segments {
match seg {
PathSegment::Constant(val) => _ = write!(path_fmt_str, "/{}", val),
PathSegment::Parameter { name } => _ = write!(path_fmt_str, "/{{{}}}", name),
PathSegment::Constant(val) => _ = write!(path_fmt_str, "/{val}"),
PathSegment::Parameter { name } => _ = write!(path_fmt_str, "/{{{name}}}"),
}
}
@ -324,14 +326,15 @@ impl Path {
type Response = #response_ty;
fn into_request(self) -> (Self::Discriminant, crate::request::ApiRequest) {
let path = format!(#path_fmt_str, #(#fmt_val),*);
let mut parameters = Vec::new();
#(#convert_field)*
#[allow(unused_parens)]
(
(#(#discriminant_val),*),
crate::request::ApiRequest {
path,
parameters: std::iter::empty()
#(#convert_field)*
.collect(),
parameters,
}
)
}

View file

@ -1,6 +1,6 @@
[package]
name = "torn-api"
version = "4.1.1"
version = "4.2.0"
edition = "2021"
description = "Auto-generated bindings for the v2 torn api"
license = { workspace = true }

File diff suppressed because it is too large Load diff

View file

@ -9,12 +9,14 @@ pub(super) mod test {
use crate::{
executor::{ExecutorExt, ReqwestClient},
models::{
faction_selection_name::FactionSelectionNameVariant,
user_selection_name::UserSelectionNameVariant, AttackCode, PersonalStatsCategoryEnum,
PersonalStatsStatName, UserListEnum,
faction_selection_name::FactionSelectionNameVariant, AttackCode,
PersonalStatsCategoryEnum, PersonalStatsStatName, UserListEnum,
},
};
#[cfg(feature = "strum")]
use crate::models::user_selection_name::UserSelectionNameVariant;
use super::*;
static TICKETS: OnceLock<mpsc::Sender<mpsc::Sender<ReqwestClient>>> = OnceLock::new();
@ -499,14 +501,14 @@ pub(super) mod test {
racing_scope.carupgrades(|b| b).await.unwrap();
}
/* #[tokio::test]
#[tokio::test]
async fn racing_races() {
let client = test_client().await;
let racing_scope = RacingScope(&client);
racing_scope.races(|b| b).await.unwrap();
} */
}
#[tokio::test]
async fn racing_race_for_race_id() {
@ -1144,6 +1146,8 @@ pub(super) mod test {
let client = test_client().await;
client.user().profile(|b| b).await.unwrap();
client.user().profile_for_id(4.into(), |b| b).await.unwrap();
}
#[tokio::test]