Compare commits
3 commits
14e6e81278
...
bd27916aa5
Author | SHA1 | Date | |
---|---|---|---|
|
bd27916aa5 | ||
|
98073a37bd | ||
|
40913bc89b |
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -2294,7 +2294,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "torn-api"
|
name = "torn-api"
|
||||||
version = "1.6.1"
|
version = "1.6.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bon",
|
"bon",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
@ -2316,7 +2316,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "torn-api-codegen"
|
name = "torn-api-codegen"
|
||||||
version = "0.6.1"
|
version = "0.6.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck",
|
"heck",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "torn-api-codegen"
|
name = "torn-api-codegen"
|
||||||
authors = ["Pyrit [2111649]"]
|
authors = ["Pyrit [2111649]"]
|
||||||
version = "0.6.1"
|
version = "0.6.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Contains the v2 torn API model descriptions and codegen for the bindings"
|
description = "Contains the v2 torn API model descriptions and codegen for the bindings"
|
||||||
license-file = { workspace = true }
|
license-file = { workspace = true }
|
||||||
|
|
|
@ -429,6 +429,25 @@ impl Enum {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HACK: idk
|
||||||
|
let shared: Vec<_> = result
|
||||||
|
.variants
|
||||||
|
.iter_mut()
|
||||||
|
.filter(|v| v.name == "Variant")
|
||||||
|
.collect();
|
||||||
|
if shared.len() >= 2 {
|
||||||
|
for (idx, variant) in shared.into_iter().enumerate() {
|
||||||
|
let label = idx + 1;
|
||||||
|
variant.name = format!("Variant{}", label);
|
||||||
|
if let EnumVariantValue::Tuple(values) = &mut variant.value {
|
||||||
|
if let [EnumVariantTupleValue::Enum { name, inner, .. }] = values.as_mut_slice()
|
||||||
|
{
|
||||||
|
inner.name.push_str(&label.to_string());
|
||||||
|
name.push_str(&label.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Some(result)
|
Some(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,8 +463,8 @@ impl Enum {
|
||||||
|
|
||||||
pub fn codegen(&self, resolved: &ResolvedSchema) -> Option<TokenStream> {
|
pub fn codegen(&self, resolved: &ResolvedSchema) -> Option<TokenStream> {
|
||||||
let repr = self.repr.map(|r| match r {
|
let repr = self.repr.map(|r| match r {
|
||||||
EnumRepr::U8 => quote! { #[repr(u8)]},
|
EnumRepr::U8 => quote! { #[repr(u8)] },
|
||||||
EnumRepr::U32 => quote! { #[repr(u32)]},
|
EnumRepr::U32 => quote! { #[repr(u32)] },
|
||||||
});
|
});
|
||||||
let name = format_ident!("{}", self.name);
|
let name = format_ident!("{}", self.name);
|
||||||
let desc = self.description.as_ref().map(|d| {
|
let desc = self.description.as_ref().map(|d| {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "torn-api"
|
name = "torn-api"
|
||||||
version = "1.6.1"
|
version = "1.6.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Auto-generated bindings for the v2 torn api"
|
description = "Auto-generated bindings for the v2 torn api"
|
||||||
license-file = { workspace = true }
|
license-file = { workspace = true }
|
||||||
|
@ -39,7 +39,7 @@ strum = { version = "0.27.1", features = ["derive"], optional = true }
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
torn-api-codegen = { path = "../torn-api-codegen", version = "0.6.0" }
|
torn-api-codegen = { path = "../torn-api-codegen", version = "0.6.2" }
|
||||||
syn = { workspace = true, features = ["parsing"] }
|
syn = { workspace = true, features = ["parsing"] }
|
||||||
proc-macro2 = { workspace = true }
|
proc-macro2 = { workspace = true }
|
||||||
prettyplease = "0.2"
|
prettyplease = "0.2"
|
||||||
|
|
|
@ -3059,6 +3059,12 @@
|
||||||
{
|
{
|
||||||
"$ref": "#/components/parameters/ApiFactionSearchFilter"
|
"$ref": "#/components/parameters/ApiFactionSearchFilter"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/ApiLimit20"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/ApiOffset"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/components/parameters/ApiTimestamp"
|
"$ref": "#/components/parameters/ApiTimestamp"
|
||||||
},
|
},
|
||||||
|
@ -3647,7 +3653,23 @@
|
||||||
"description": "selection id",
|
"description": "selection id",
|
||||||
"required": false,
|
"required": false,
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/FactionId"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/FactionCrimeId"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/ChainId"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/RankedWarId"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/TerritoryWarId"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -3665,7 +3687,40 @@
|
||||||
"description": "Selection category",
|
"description": "Selection category",
|
||||||
"required": false,
|
"required": false,
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"all",
|
||||||
|
"current"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"all",
|
||||||
|
"recruiting",
|
||||||
|
"planning",
|
||||||
|
"failure",
|
||||||
|
"successful",
|
||||||
|
"expired",
|
||||||
|
"available",
|
||||||
|
"completed"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/FactionNewsCategory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/FactionRankedWarsCategoryEnum"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/ReportTypeEnum"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/FactionTerritoryWarsCategoryEnum"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -3674,7 +3729,7 @@
|
||||||
"description": "Stat category",
|
"description": "Stat category",
|
||||||
"required": false,
|
"required": false,
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"$ref": "#/components/schemas/FactionStatEnum"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -4171,7 +4226,17 @@
|
||||||
"description": "selection id",
|
"description": "selection id",
|
||||||
"required": false,
|
"required": false,
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/ForumThreadId"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/ForumId"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -4557,7 +4622,7 @@
|
||||||
"description": "selection id",
|
"description": "selection id",
|
||||||
"required": false,
|
"required": false,
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"$ref": "#/components/schemas/ItemId"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -4569,15 +4634,6 @@
|
||||||
"$ref": "#/components/schemas/WeaponBonusEnum"
|
"$ref": "#/components/schemas/WeaponBonusEnum"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "cat",
|
|
||||||
"in": "query",
|
|
||||||
"description": "Selection category",
|
|
||||||
"required": false,
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "sort",
|
"name": "sort",
|
||||||
"in": "query",
|
"in": "query",
|
||||||
|
@ -4712,6 +4768,66 @@
|
||||||
"x-stability": "Stable"
|
"x-stability": "Stable"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/racing/races": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"Racing"
|
||||||
|
],
|
||||||
|
"summary": "Get races",
|
||||||
|
"description": "Requires public access key. <br>Returns a list of races, ordered by race start timestamp.",
|
||||||
|
"operationId": "4be921a67d32b5e82c68835ef56175d0",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/ApiLimit100"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/ApiSortDesc"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/ApiTo"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/ApiFrom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cat",
|
||||||
|
"in": "query",
|
||||||
|
"description": "Category of races returned",
|
||||||
|
"required": false,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/RacingRaceTypeEnum"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/ApiTimestamp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/ApiComment"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/parameters/ApiKeyPublic"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Successful operation",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/RacingRacesResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"api_key": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"x-stability": "Stable"
|
||||||
|
}
|
||||||
|
},
|
||||||
"/racing/{raceId}/race": {
|
"/racing/{raceId}/race": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": [
|
"tags": [
|
||||||
|
@ -20288,7 +20404,8 @@
|
||||||
"ItemMarket": {
|
"ItemMarket": {
|
||||||
"required": [
|
"required": [
|
||||||
"item",
|
"item",
|
||||||
"listings"
|
"listings",
|
||||||
|
"timestamp"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"item": {
|
"item": {
|
||||||
|
@ -20306,6 +20423,11 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"cache_timestamp": {
|
||||||
|
"description": "Timestamp when the data was globally cached at.",
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int32"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"type": "object"
|
"type": "object"
|
||||||
|
|
|
@ -14,7 +14,13 @@ impl ApiRequest {
|
||||||
pub fn url(&self) -> String {
|
pub fn url(&self) -> String {
|
||||||
let mut url = format!("https://api.torn.com/v2{}?", self.path);
|
let mut url = format!("https://api.torn.com/v2{}?", self.path);
|
||||||
|
|
||||||
|
let mut first = true;
|
||||||
for (name, value) in &self.parameters {
|
for (name, value) in &self.parameters {
|
||||||
|
if first {
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
url.push('&');
|
||||||
|
}
|
||||||
url.push_str(&format!("{name}={value}"));
|
url.push_str(&format!("{name}={value}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue