warframe_client/apis/
unstable_api.rs

1/*
2 * WarframeStat.us API
3 *
4 * Simple API for data from the game Warframe. [Parser Docs](https://wfcd.github.io/warframe-worldstate-parser/) [Items Types](https://github.com/WFCD/warframe-items/blob/master/index.d.ts) 
5 *
6 * The version of the OpenAPI document: 2.0.8
7 * Contact: tobiah@protonmail.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`get_arbitration_by_platform`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetArbitrationByPlatformError {
22    Status400(models::InlineObject),
23    Status500(models::InlineObject),
24    UnknownValue(serde_json::Value),
25}
26
27/// struct for typed errors of method [`get_kuva_by_platform`]
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum GetKuvaByPlatformError {
31    Status400(models::InlineObject),
32    Status500(models::InlineObject),
33    UnknownValue(serde_json::Value),
34}
35
36
37/// Description of the currently active arbitration
38pub async fn get_arbitration_by_platform(configuration: &configuration::Configuration, language: models::Language, accept_language: Option<models::Language>) -> Result<models::Arbitration, Error<GetArbitrationByPlatformError>> {
39    // add a prefix to parameters to efficiently prevent name collisions
40    let p_query_language = language;
41    let p_header_accept_language = accept_language;
42
43    let uri_str = format!("{}/pc/arbitration", configuration.base_path);
44    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
45
46    req_builder = req_builder.query(&[("language", &p_query_language.to_string())]);
47    if let Some(ref user_agent) = configuration.user_agent {
48        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
49    }
50    if let Some(param_value) = p_header_accept_language {
51        req_builder = req_builder.header("Accept-Language", param_value.to_string());
52    }
53
54    let req = req_builder.build()?;
55    let resp = configuration.client.execute(req).await?;
56
57    let status = resp.status();
58    let content_type = resp
59        .headers()
60        .get("content-type")
61        .and_then(|v| v.to_str().ok())
62        .unwrap_or("application/octet-stream");
63    let content_type = super::ContentType::from(content_type);
64
65    if !status.is_client_error() && !status.is_server_error() {
66        let content = resp.text().await?;
67        match content_type {
68            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
69            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Arbitration`"))),
70            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Arbitration`")))),
71        }
72    } else {
73        let content = resp.text().await?;
74        let entity: Option<GetArbitrationByPlatformError> = serde_json::from_str(&content).ok();
75        Err(Error::ResponseError(ResponseContent { status, content, entity }))
76    }
77}
78
79/// Current Kuva Mission listing (provided by [semlar](https://10o.io/kuvalog)).
80pub async fn get_kuva_by_platform(configuration: &configuration::Configuration, language: models::Language, accept_language: Option<models::Language>) -> Result<Vec<models::Arbitration>, Error<GetKuvaByPlatformError>> {
81    // add a prefix to parameters to efficiently prevent name collisions
82    let p_query_language = language;
83    let p_header_accept_language = accept_language;
84
85    let uri_str = format!("{}/pc/kuva", configuration.base_path);
86    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
87
88    req_builder = req_builder.query(&[("language", &p_query_language.to_string())]);
89    if let Some(ref user_agent) = configuration.user_agent {
90        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
91    }
92    if let Some(param_value) = p_header_accept_language {
93        req_builder = req_builder.header("Accept-Language", param_value.to_string());
94    }
95
96    let req = req_builder.build()?;
97    let resp = configuration.client.execute(req).await?;
98
99    let status = resp.status();
100    let content_type = resp
101        .headers()
102        .get("content-type")
103        .and_then(|v| v.to_str().ok())
104        .unwrap_or("application/octet-stream");
105    let content_type = super::ContentType::from(content_type);
106
107    if !status.is_client_error() && !status.is_server_error() {
108        let content = resp.text().await?;
109        match content_type {
110            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
111            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::Arbitration&gt;`"))),
112            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::Arbitration&gt;`")))),
113        }
114    } else {
115        let content = resp.text().await?;
116        let entity: Option<GetKuvaByPlatformError> = serde_json::from_str(&content).ok();
117        Err(Error::ResponseError(ResponseContent { status, content, entity }))
118    }
119}
120