artcoded_api/apis/
portfolio_controller_api.rs

1/*
2 * Artcoded
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 1.0.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16/// struct for typed errors of method [`delete10`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum Delete10Error {
20    UnknownValue(serde_json::Value),
21}
22
23/// struct for typed errors of method [`delete_tick_from_portfolio`]
24#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum DeleteTickFromPortfolioError {
27    UnknownValue(serde_json::Value),
28}
29
30/// struct for typed errors of method [`find_all5`]
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum FindAll5Error {
34    UnknownValue(serde_json::Value),
35}
36
37/// struct for typed errors of method [`find_by_id1`]
38#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum FindById1Error {
41    UnknownValue(serde_json::Value),
42}
43
44/// struct for typed errors of method [`save5`]
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum Save5Error {
48    UnknownValue(serde_json::Value),
49}
50
51/// struct for typed errors of method [`update_tag`]
52#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum UpdateTagError {
55    UnknownValue(serde_json::Value),
56}
57
58pub async fn delete10(
59    configuration: &configuration::Configuration,
60    id: &str,
61) -> Result<models::Restore200Response, Error<Delete10Error>> {
62    // add a prefix to parameters to efficiently prevent name collisions
63    let p_query_id = id;
64
65    let uri_str = format!("{}/api/finance/portfolio", configuration.base_path);
66    let mut req_builder = configuration
67        .client
68        .request(reqwest::Method::DELETE, &uri_str);
69
70    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
71    if let Some(ref user_agent) = configuration.user_agent {
72        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
73    }
74    if let Some(ref token) = configuration.bearer_access_token {
75        req_builder = req_builder.bearer_auth(token.to_owned());
76    };
77
78    let req = req_builder.build()?;
79    let resp = configuration.client.execute(req).await?;
80
81    let status = resp.status();
82    let content_type = resp
83        .headers()
84        .get("content-type")
85        .and_then(|v| v.to_str().ok())
86        .unwrap_or("application/octet-stream");
87    let content_type = super::ContentType::from(content_type);
88
89    if !status.is_client_error() && !status.is_server_error() {
90        let content = resp.text().await?;
91        match content_type {
92            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
93            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Restore200Response`"))),
94            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Restore200Response`")))),
95        }
96    } else {
97        let content = resp.text().await?;
98        let entity: Option<Delete10Error> = serde_json::from_str(&content).ok();
99        Err(Error::ResponseError(ResponseContent {
100            status,
101            content,
102            entity,
103        }))
104    }
105}
106
107pub async fn delete_tick_from_portfolio(
108    configuration: &configuration::Configuration,
109    id: &str,
110    symbol: &str,
111) -> Result<models::Restore200Response, Error<DeleteTickFromPortfolioError>> {
112    // add a prefix to parameters to efficiently prevent name collisions
113    let p_query_id = id;
114    let p_query_symbol = symbol;
115
116    let uri_str = format!("{}/api/finance/portfolio/tick", configuration.base_path);
117    let mut req_builder = configuration
118        .client
119        .request(reqwest::Method::DELETE, &uri_str);
120
121    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
122    req_builder = req_builder.query(&[("symbol", &p_query_symbol.to_string())]);
123    if let Some(ref user_agent) = configuration.user_agent {
124        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
125    }
126    if let Some(ref token) = configuration.bearer_access_token {
127        req_builder = req_builder.bearer_auth(token.to_owned());
128    };
129
130    let req = req_builder.build()?;
131    let resp = configuration.client.execute(req).await?;
132
133    let status = resp.status();
134    let content_type = resp
135        .headers()
136        .get("content-type")
137        .and_then(|v| v.to_str().ok())
138        .unwrap_or("application/octet-stream");
139    let content_type = super::ContentType::from(content_type);
140
141    if !status.is_client_error() && !status.is_server_error() {
142        let content = resp.text().await?;
143        match content_type {
144            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
145            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Restore200Response`"))),
146            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Restore200Response`")))),
147        }
148    } else {
149        let content = resp.text().await?;
150        let entity: Option<DeleteTickFromPortfolioError> = serde_json::from_str(&content).ok();
151        Err(Error::ResponseError(ResponseContent {
152            status,
153            content,
154            entity,
155        }))
156    }
157}
158
159pub async fn find_all5(
160    configuration: &configuration::Configuration,
161) -> Result<Vec<models::Portfolio>, Error<FindAll5Error>> {
162    let uri_str = format!("{}/api/finance/portfolio/find-all", configuration.base_path);
163    let mut req_builder = configuration
164        .client
165        .request(reqwest::Method::POST, &uri_str);
166
167    if let Some(ref user_agent) = configuration.user_agent {
168        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
169    }
170    if let Some(ref token) = configuration.bearer_access_token {
171        req_builder = req_builder.bearer_auth(token.to_owned());
172    };
173
174    let req = req_builder.build()?;
175    let resp = configuration.client.execute(req).await?;
176
177    let status = resp.status();
178    let content_type = resp
179        .headers()
180        .get("content-type")
181        .and_then(|v| v.to_str().ok())
182        .unwrap_or("application/octet-stream");
183    let content_type = super::ContentType::from(content_type);
184
185    if !status.is_client_error() && !status.is_server_error() {
186        let content = resp.text().await?;
187        match content_type {
188            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
189            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::Portfolio&gt;`"))),
190            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::Portfolio&gt;`")))),
191        }
192    } else {
193        let content = resp.text().await?;
194        let entity: Option<FindAll5Error> = serde_json::from_str(&content).ok();
195        Err(Error::ResponseError(ResponseContent {
196            status,
197            content,
198            entity,
199        }))
200    }
201}
202
203pub async fn find_by_id1(
204    configuration: &configuration::Configuration,
205    id: &str,
206) -> Result<models::Portfolio, Error<FindById1Error>> {
207    // add a prefix to parameters to efficiently prevent name collisions
208    let p_query_id = id;
209
210    let uri_str = format!(
211        "{}/api/finance/portfolio/find-by-id",
212        configuration.base_path
213    );
214    let mut req_builder = configuration
215        .client
216        .request(reqwest::Method::POST, &uri_str);
217
218    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
219    if let Some(ref user_agent) = configuration.user_agent {
220        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
221    }
222    if let Some(ref token) = configuration.bearer_access_token {
223        req_builder = req_builder.bearer_auth(token.to_owned());
224    };
225
226    let req = req_builder.build()?;
227    let resp = configuration.client.execute(req).await?;
228
229    let status = resp.status();
230    let content_type = resp
231        .headers()
232        .get("content-type")
233        .and_then(|v| v.to_str().ok())
234        .unwrap_or("application/octet-stream");
235    let content_type = super::ContentType::from(content_type);
236
237    if !status.is_client_error() && !status.is_server_error() {
238        let content = resp.text().await?;
239        match content_type {
240            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
241            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Portfolio`"))),
242            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Portfolio`")))),
243        }
244    } else {
245        let content = resp.text().await?;
246        let entity: Option<FindById1Error> = serde_json::from_str(&content).ok();
247        Err(Error::ResponseError(ResponseContent {
248            status,
249            content,
250            entity,
251        }))
252    }
253}
254
255pub async fn save5(
256    configuration: &configuration::Configuration,
257    portfolio: models::Portfolio,
258) -> Result<models::Portfolio, Error<Save5Error>> {
259    // add a prefix to parameters to efficiently prevent name collisions
260    let p_body_portfolio = portfolio;
261
262    let uri_str = format!("{}/api/finance/portfolio/save", configuration.base_path);
263    let mut req_builder = configuration
264        .client
265        .request(reqwest::Method::POST, &uri_str);
266
267    if let Some(ref user_agent) = configuration.user_agent {
268        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
269    }
270    if let Some(ref token) = configuration.bearer_access_token {
271        req_builder = req_builder.bearer_auth(token.to_owned());
272    };
273    req_builder = req_builder.json(&p_body_portfolio);
274
275    let req = req_builder.build()?;
276    let resp = configuration.client.execute(req).await?;
277
278    let status = resp.status();
279    let content_type = resp
280        .headers()
281        .get("content-type")
282        .and_then(|v| v.to_str().ok())
283        .unwrap_or("application/octet-stream");
284    let content_type = super::ContentType::from(content_type);
285
286    if !status.is_client_error() && !status.is_server_error() {
287        let content = resp.text().await?;
288        match content_type {
289            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
290            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Portfolio`"))),
291            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Portfolio`")))),
292        }
293    } else {
294        let content = resp.text().await?;
295        let entity: Option<Save5Error> = serde_json::from_str(&content).ok();
296        Err(Error::ResponseError(ResponseContent {
297            status,
298            content,
299            entity,
300        }))
301    }
302}
303
304pub async fn update_tag(
305    configuration: &configuration::Configuration,
306    id: &str,
307    tick: Vec<models::Tick>,
308) -> Result<(), Error<UpdateTagError>> {
309    // add a prefix to parameters to efficiently prevent name collisions
310    let p_query_id = id;
311    let p_body_tick = tick;
312
313    let uri_str = format!(
314        "{}/api/finance/portfolio/update-ticks",
315        configuration.base_path
316    );
317    let mut req_builder = configuration
318        .client
319        .request(reqwest::Method::POST, &uri_str);
320
321    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
322    if let Some(ref user_agent) = configuration.user_agent {
323        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
324    }
325    if let Some(ref token) = configuration.bearer_access_token {
326        req_builder = req_builder.bearer_auth(token.to_owned());
327    };
328    req_builder = req_builder.json(&p_body_tick);
329
330    let req = req_builder.build()?;
331    let resp = configuration.client.execute(req).await?;
332
333    let status = resp.status();
334
335    if !status.is_client_error() && !status.is_server_error() {
336        Ok(())
337    } else {
338        let content = resp.text().await?;
339        let entity: Option<UpdateTagError> = serde_json::from_str(&content).ok();
340        Err(Error::ResponseError(ResponseContent {
341            status,
342            content,
343            entity,
344        }))
345    }
346}