Compare commits

...

3 commits

6 changed files with 169 additions and 22 deletions

4
Cargo.lock generated
View file

@ -2294,7 +2294,7 @@ dependencies = [
[[package]]
name = "torn-api"
version = "1.6.1"
version = "1.6.2"
dependencies = [
"bon",
"bytes",
@ -2316,7 +2316,7 @@ dependencies = [
[[package]]
name = "torn-api-codegen"
version = "0.6.1"
version = "0.6.2"
dependencies = [
"heck",
"indexmap",

View file

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

View file

@ -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)
}

View file

@ -1,6 +1,6 @@
[package]
name = "torn-api"
version = "1.6.1"
version = "1.6.2"
edition = "2021"
description = "Auto-generated bindings for the v2 torn api"
license-file = { workspace = true }
@ -39,7 +39,7 @@ strum = { version = "0.27.1", features = ["derive"], optional = true }
tokio = { version = "1", features = ["full"] }
[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"] }
proc-macro2 = { workspace = true }
prettyplease = "0.2"

View file

@ -3059,6 +3059,12 @@
{
"$ref": "#/components/parameters/ApiFactionSearchFilter"
},
{
"$ref": "#/components/parameters/ApiLimit20"
},
{
"$ref": "#/components/parameters/ApiOffset"
},
{
"$ref": "#/components/parameters/ApiTimestamp"
},
@ -3647,7 +3653,23 @@
"description": "selection id",
"required": false,
"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",
"required": false,
"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",
"required": false,
"schema": {
"type": "string"
"$ref": "#/components/schemas/FactionStatEnum"
}
},
{
@ -4171,7 +4226,17 @@
"description": "selection id",
"required": false,
"schema": {
"type": "string"
"oneOf": [
{
"$ref": "#/components/schemas/ForumThreadId"
},
{
"type": "array",
"items": {
"$ref": "#/components/schemas/ForumId"
}
}
]
}
},
{
@ -4557,7 +4622,7 @@
"description": "selection id",
"required": false,
"schema": {
"type": "string"
"$ref": "#/components/schemas/ItemId"
}
},
{
@ -4569,15 +4634,6 @@
"$ref": "#/components/schemas/WeaponBonusEnum"
}
},
{
"name": "cat",
"in": "query",
"description": "Selection category",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "sort",
"in": "query",
@ -4712,6 +4768,66 @@
"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": {
"get": {
"tags": [
@ -20288,7 +20404,8 @@
"ItemMarket": {
"required": [
"item",
"listings"
"listings",
"timestamp"
],
"properties": {
"item": {
@ -20306,6 +20423,11 @@
}
]
}
},
"cache_timestamp": {
"description": "Timestamp when the data was globally cached at.",
"type": "integer",
"format": "int32"
}
},
"type": "object"

View file

@ -14,7 +14,13 @@ impl ApiRequest {
pub fn url(&self) -> String {
let mut url = format!("https://api.torn.com/v2{}?", self.path);
let mut first = true;
for (name, value) in &self.parameters {
if first {
first = false;
} else {
url.push('&');
}
url.push_str(&format!("{name}={value}"));
}