diff --git a/Cargo.lock b/Cargo.lock index 7afc738..50ab1ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2294,7 +2294,7 @@ dependencies = [ [[package]] name = "torn-api" -version = "4.2.0" +version = "4.1.1" dependencies = [ "bon", "bytes", @@ -2316,7 +2316,7 @@ dependencies = [ [[package]] name = "torn-api-codegen" -version = "0.7.5" +version = "0.7.4" dependencies = [ "heck", "indexmap", @@ -2329,7 +2329,7 @@ dependencies = [ [[package]] name = "torn-key-pool" -version = "2.0.0" +version = "1.2.0" dependencies = [ "chrono", "futures", diff --git a/torn-api-codegen/Cargo.toml b/torn-api-codegen/Cargo.toml index 2ec7ec7..038e453 100644 --- a/torn-api-codegen/Cargo.toml +++ b/torn-api-codegen/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "torn-api-codegen" authors = ["Pyrit [2111649]"] -version = "0.7.5" +version = "0.7.4" edition = "2021" description = "Contains the v2 torn API model descriptions and codegen for the bindings" license = { workspace = true } diff --git a/torn-api-codegen/src/model/path.rs b/torn-api-codegen/src/model/path.rs index 66df454..8360baa 100644 --- a/torn-api-codegen/src/model/path.rs +++ b/torn-api-codegen/src/model/path.rs @@ -258,14 +258,12 @@ impl Path { } else { let ty = if param.required { convert_field.push(quote! { - parameters.push((#query_val, self.#name.to_string())); + .chain(std::iter::once(&self.#name).map(|v| (#query_val, v.to_string()))) }); ty } else { convert_field.push(quote! { - if let Some(value) = &self.#name { - parameters.push((#query_val, value.to_string())); - } + .chain(self.#name.as_ref().into_iter().map(|v| (#query_val, v.to_string()))) }); quote! { Option<#ty>} }; @@ -297,8 +295,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), } } @@ -326,15 +324,14 @@ 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, + parameters: std::iter::empty() + #(#convert_field)* + .collect(), } ) } diff --git a/torn-api/Cargo.toml b/torn-api/Cargo.toml index 9453718..82f3ab2 100644 --- a/torn-api/Cargo.toml +++ b/torn-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "torn-api" -version = "4.2.0" +version = "4.1.1" edition = "2021" description = "Auto-generated bindings for the v2 torn api" license = { workspace = true } diff --git a/torn-api/openapi.json b/torn-api/openapi.json index a51a3ec..ea223e3 100644 --- a/torn-api/openapi.json +++ b/torn-api/openapi.json @@ -3,7 +3,7 @@ "info": { "title": "Torn API", "description": "\n * The development of Torn's API v2 is still ongoing.\n * If selections remain unaltered, they will default to the API v1 version.\n * Unlike API v1, API v2 accepts both selections and IDs as path and query parameters.\n * If any discrepancies or errors are found, please submit a [bug report](https://www.torn.com/forums.php#/p=forums&f=19&b=0&a=0) on the Torn Forums.\n * In case you're using bots to check for changes on openapi.json file, make sure to specificy a custom user-agent header - CloudFlare sometimes prevents requests from default user-agents.", - "version": "4.2.0" + "version": "4.1.1" }, "servers": [ { @@ -120,45 +120,6 @@ "x-stability": "Stable" } }, - "/user/bars": { - "get": { - "tags": [ - "User" - ], - "summary": "Get your bars information", - "description": "Requires minimal access key.
", - "operationId": "62b16119fb11b6a4d12864987f2a7223", - "parameters": [ - { - "$ref": "#/components/parameters/ApiTimestamp" - }, - { - "$ref": "#/components/parameters/ApiComment" - }, - { - "$ref": "#/components/parameters/ApiKeyMinimal" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserBarsResponse" - } - } - } - } - }, - "security": [ - { - "api_key": [] - } - ], - "x-stability": "Unstable" - } - }, "/user/basic": { "get": { "tags": [ @@ -327,7 +288,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/user/{id}/bounties": { @@ -504,45 +465,6 @@ "x-stability": "Unstable" } }, - "/user/cooldowns": { - "get": { - "tags": [ - "User" - ], - "summary": "Get your cooldowns information", - "description": "Requires minimal access key.
", - "operationId": "fe1a505c4c4b83c667fa9e7313045d8b", - "parameters": [ - { - "$ref": "#/components/parameters/ApiTimestamp" - }, - { - "$ref": "#/components/parameters/ApiComment" - }, - { - "$ref": "#/components/parameters/ApiKeyMinimal" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserCooldownsResponse" - } - } - } - } - }, - "security": [ - { - "api_key": [] - } - ], - "x-stability": "Unstable" - } - }, "/user/{crimeId}/crimes": { "get": { "tags": [ @@ -627,7 +549,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/user/enlistedcars": { @@ -1570,7 +1492,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/user/jobranks": { @@ -1740,7 +1662,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/user/medals": { @@ -1908,7 +1830,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/user/newevents": { @@ -1992,45 +1914,6 @@ "x-stability": "Unstable" } }, - "/user/notifications": { - "get": { - "tags": [ - "User" - ], - "summary": "Get your notifications", - "description": "Requires minimal access key.
", - "operationId": "6c73f06efc23903e15343c95e426b7ad", - "parameters": [ - { - "$ref": "#/components/parameters/ApiTimestamp" - }, - { - "$ref": "#/components/parameters/ApiComment" - }, - { - "$ref": "#/components/parameters/ApiKeyMinimal" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserNotificationsResponse" - } - } - } - } - }, - "security": [ - { - "api_key": [] - } - ], - "x-stability": "Unstable" - } - }, "/user/organizedcrime": { "get": { "tags": [ @@ -2355,7 +2238,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/user/{id}/properties": { @@ -2412,7 +2295,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/user/property": { @@ -2451,7 +2334,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/user/{id}/property": { @@ -2499,7 +2382,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/user/races": { @@ -2598,45 +2481,6 @@ "api_key": [] } ], - "x-stability": "Stable" - } - }, - "/user/refills": { - "get": { - "tags": [ - "User" - ], - "summary": "Get your refills information", - "description": "Requires minimal access key.
", - "operationId": "f504d71a34f5cb3398bee32d6f67ee0e", - "parameters": [ - { - "$ref": "#/components/parameters/ApiTimestamp" - }, - { - "$ref": "#/components/parameters/ApiComment" - }, - { - "$ref": "#/components/parameters/ApiKeyMinimal" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserRefillsResponse" - } - } - } - } - }, - "security": [ - { - "api_key": [] - } - ], "x-stability": "Unstable" } }, @@ -2700,7 +2544,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/user/revives": { @@ -2853,84 +2697,6 @@ "api_key": [] } ], - "x-stability": "Stable" - } - }, - "/user/travel": { - "get": { - "tags": [ - "User" - ], - "summary": "Get your travel information", - "description": "Requires minimal access key.
", - "operationId": "b129b86b2f3902d6f875da827d0dee17", - "parameters": [ - { - "$ref": "#/components/parameters/ApiTimestamp" - }, - { - "$ref": "#/components/parameters/ApiComment" - }, - { - "$ref": "#/components/parameters/ApiKeyMinimal" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserTravelResponse" - } - } - } - } - }, - "security": [ - { - "api_key": [] - } - ], - "x-stability": "Unstable" - } - }, - "/user/virus": { - "get": { - "tags": [ - "User" - ], - "summary": "Get your virus information", - "description": "Requires minimal access key.
", - "operationId": "5e94a9ab2363bed4a7dfdef02ce135f6", - "parameters": [ - { - "$ref": "#/components/parameters/ApiTimestamp" - }, - { - "$ref": "#/components/parameters/ApiComment" - }, - { - "$ref": "#/components/parameters/ApiKeyMinimal" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserVirusResponse" - } - } - } - } - }, - "security": [ - { - "api_key": [] - } - ], "x-stability": "Unstable" } }, @@ -3277,24 +3043,6 @@ { "$ref": "#/components/schemas/FactionAttacksResponse" }, - { - "$ref": "#/components/schemas/UserBarsResponse" - }, - { - "$ref": "#/components/schemas/UserCooldownsResponse" - }, - { - "$ref": "#/components/schemas/UserNotificationsResponse" - }, - { - "$ref": "#/components/schemas/UserRefillsResponse" - }, - { - "$ref": "#/components/schemas/UserTravelResponse" - }, - { - "$ref": "#/components/schemas/UserVirusResponse" - }, { "$ref": "#/components/schemas/FactionAttacksFullResponse" }, @@ -3961,7 +3709,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/faction/crimes": { @@ -4376,7 +4124,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/faction/rackets": { @@ -4415,7 +4163,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/faction/{raidWarId}/raidreport": { @@ -4463,7 +4211,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/faction/raids": { @@ -4511,7 +4259,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/faction/{id}/raids": { @@ -4559,7 +4307,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/faction/rankedwars": { @@ -4766,7 +4514,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/faction/revives": { @@ -4931,7 +4679,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/faction/stats": { @@ -4970,7 +4718,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/faction/territory": { @@ -5009,7 +4757,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/faction/{id}/territory": { @@ -5057,7 +4805,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/faction/territoryownership": { @@ -5102,7 +4850,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/faction/territorywars": { @@ -5153,7 +4901,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/faction/{id}/territorywars": { @@ -5201,7 +4949,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/faction/{territoryWarId}/territorywarreport": { @@ -5249,7 +4997,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/faction/upgrades": { @@ -5288,7 +5036,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/faction/warfare": { @@ -6289,7 +6037,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/key/info": { @@ -6328,7 +6076,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/key": { @@ -6441,7 +6189,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/market/{id}/bazaar": { @@ -6489,7 +6237,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/market/{id}/itemmarket": { @@ -6549,7 +6297,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/market/{propertyTypeId}/properties": { @@ -6606,7 +6354,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/market/{propertyTypeId}/rentals": { @@ -6663,7 +6411,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/market/lookup": { @@ -7416,7 +7164,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/property/lookup": { @@ -7785,7 +7533,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/torn/factionhof": { @@ -7878,7 +7626,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/torn/honors": { @@ -8505,7 +8253,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/torn/properties": { @@ -8544,7 +8292,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/torn/{crimeId}/subcrimes": { @@ -8651,7 +8399,7 @@ "api_key": [] } ], - "x-stability": "Stable" + "x-stability": "Unstable" } }, "/torn/lookup": { @@ -8999,15 +8747,6 @@ "airliner" ] }, - "UserFlyMethodEnum": { - "type": "string", - "enum": [ - "Private", - "Business", - "Airstrip", - "Standard" - ] - }, "UserStatusStateEnum": { "type": "string", "enum": [ @@ -9165,8 +8904,7 @@ "Canada", "United Kingdom", "UAE", - "Cayman Islands", - "Torn" + "Cayman Islands" ] }, "ReportTypeEnum": { @@ -15453,295 +15191,6 @@ } ] }, - "UserVirus": { - "required": [ - "item", - "until" - ], - "properties": { - "item": { - "required": [ - "id", - "name" - ], - "properties": { - "id": { - "$ref": "#/components/schemas/ItemId" - }, - "name": { - "type": "string" - } - }, - "type": "object" - }, - "until": { - "type": "integer", - "format": "int32" - } - }, - "type": "object" - }, - "UserVirusResponse": { - "required": [ - "virus" - ], - "properties": { - "virus": { - "description": "Null if the player is currently not programming a virus.", - "oneOf": [ - { - "$ref": "#/components/schemas/UserVirus" - }, - { - "type": "null" - } - ] - } - }, - "type": "object" - }, - "UserTravelResponse": { - "required": [ - "travel" - ], - "properties": { - "travel": { - "required": [ - "destination", - "method", - "departed_at", - "arrival_at", - "time_left" - ], - "properties": { - "destination": { - "$ref": "#/components/schemas/CountryEnum" - }, - "method": { - "description": "Null if the player has never flown before.", - "oneOf": [ - { - "$ref": "#/components/schemas/UserFlyMethodEnum" - }, - { - "type": "null" - } - ] - }, - "departed_at": { - "description": "Null if the player has never flown before.", - "oneOf": [ - { - "type": "integer", - "format": "int32" - }, - { - "type": "null" - } - ] - }, - "arrival_at": { - "description": "Null if the player has never flown before.", - "oneOf": [ - { - "type": "integer", - "format": "int32" - }, - { - "type": "null" - } - ] - }, - "time_left": { - "description": "Time left in seconds.", - "type": "integer", - "format": "int32" - } - }, - "type": "object" - } - }, - "type": "object" - }, - "UserRefillsResponse": { - "required": [ - "refills" - ], - "properties": { - "refills": { - "required": [ - "energy", - "nerve", - "token", - "special_count" - ], - "properties": { - "energy": { - "type": "boolean" - }, - "nerve": { - "type": "boolean" - }, - "token": { - "type": "boolean" - }, - "special_count": { - "type": "integer", - "format": "int32" - } - }, - "type": "object" - } - }, - "type": "object" - }, - "UserNotificationsResponse": { - "required": [ - "notifications" - ], - "properties": { - "notifications": { - "required": [ - "messages", - "events", - "awards", - "competition" - ], - "properties": { - "messages": { - "type": "integer", - "format": "int32" - }, - "events": { - "type": "integer", - "format": "int32" - }, - "awards": { - "type": "integer", - "format": "int32" - }, - "competition": { - "type": "integer", - "format": "int32" - } - }, - "type": "object" - } - }, - "type": "object" - }, - "UserCooldownsResponse": { - "required": [ - "cooldowns" - ], - "properties": { - "cooldowns": { - "required": [ - "drug", - "medical", - "booster" - ], - "properties": { - "drug": { - "type": "integer", - "format": "int32" - }, - "medical": { - "type": "integer", - "format": "int32" - }, - "booster": { - "type": "integer", - "format": "int32" - } - }, - "type": "object" - } - }, - "type": "object" - }, - "UserBar": { - "required": [ - "current", - "maximum", - "increment", - "interval", - "tick_time", - "full_time" - ], - "properties": { - "current": { - "type": "integer", - "format": "int32" - }, - "maximum": { - "type": "integer", - "format": "int32" - }, - "increment": { - "type": "integer", - "format": "int32" - }, - "interval": { - "type": "integer", - "format": "int32" - }, - "tick_time": { - "type": "integer", - "format": "int32" - }, - "full_time": { - "type": "integer", - "format": "int32" - } - }, - "type": "object" - }, - "UserBars": { - "required": [ - "energy", - "nerve", - "happy", - "life", - "chain" - ], - "properties": { - "energy": { - "$ref": "#/components/schemas/UserBar" - }, - "nerve": { - "$ref": "#/components/schemas/UserBar" - }, - "happy": { - "$ref": "#/components/schemas/UserBar" - }, - "life": { - "$ref": "#/components/schemas/UserBar" - }, - "chain": { - "oneOf": [ - { - "$ref": "#/components/schemas/FactionOngoingChain" - }, - { - "type": "null" - } - ] - } - }, - "type": "object" - }, - "UserBarsResponse": { - "required": [ - "bars" - ], - "properties": { - "bars": { - "$ref": "#/components/schemas/UserBars" - } - }, - "type": "object" - }, "UserNewEventsResponse": { "required": [ "events" @@ -16268,24 +15717,10 @@ "format": "int32" }, "rank": { - "oneOf": [ - { - "$ref": "#/components/schemas/UserRankEnum" - }, - { - "type": "string" - } - ] + "$ref": "#/components/schemas/UserRankEnum" }, "title": { - "oneOf": [ - { - "$ref": "#/components/schemas/UserTitleEnum" - }, - { - "type": "string" - } - ] + "$ref": "#/components/schemas/UserTitleEnum" }, "donator_status": { "oneOf": [ @@ -18642,18 +18077,16 @@ "UserSelectionName": { "oneOf": [ { - "description": "The following selections will fallback to API v1 and may change at any time: 'ammo','bazaar','criminalrecord','discord','display','equipment','gym','inventory','missions','networth','perks','stocks','weaponexp'.", + "description": "The following selections will fallback to API v1 and may change at any time: 'ammo','bars','bazaar','cooldowns','criminalrecord','discord','display','education','equipment','gym','inventory','missions','networth','notifications','perks','refills','stocks','travel','weaponexp'.", "type": "string", "enum": [ "attacks", "attacksfull", - "bars", "basic", "battlestats", "bounties", "calendar", "competition", - "cooldowns", "crimes", "enlistedcars", "events", @@ -18680,7 +18113,6 @@ "money", "newevents", "newmessages", - "notifications", "organizedcrime", "personalstats", "profile", @@ -18688,16 +18120,16 @@ "property", "races", "racingrecords", - "refills", "reports", "revives", "revivesfull", "skills", "timestamp", - "travel", "workstats", "ammo", + "bars", "bazaar", + "cooldowns", "criminalrecord", "discord", "display", @@ -18707,8 +18139,11 @@ "inventory", "missions", "networth", + "notifications", "perks", + "refills", "stocks", + "travel", "weaponexp" ] }, diff --git a/torn-api/src/scopes.rs b/torn-api/src/scopes.rs index 6eef90b..c7ab02e 100644 --- a/torn-api/src/scopes.rs +++ b/torn-api/src/scopes.rs @@ -9,14 +9,12 @@ pub(super) mod test { use crate::{ executor::{ExecutorExt, ReqwestClient}, models::{ - faction_selection_name::FactionSelectionNameVariant, AttackCode, - PersonalStatsCategoryEnum, PersonalStatsStatName, UserListEnum, + faction_selection_name::FactionSelectionNameVariant, + user_selection_name::UserSelectionNameVariant, AttackCode, PersonalStatsCategoryEnum, + PersonalStatsStatName, UserListEnum, }, }; - #[cfg(feature = "strum")] - use crate::models::user_selection_name::UserSelectionNameVariant; - use super::*; static TICKETS: OnceLock>> = OnceLock::new(); @@ -501,14 +499,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() { @@ -1146,8 +1144,6 @@ 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]