zsgf_client/apis/
currency_api.rs

1/*
2 * 全部  API 文档
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: v1
7 * 
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 [`currencies`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CurrenciesError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`currency`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum CurrencyError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`currency_delete`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum CurrencyDeleteError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`currency_exchange_rate_delete`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum CurrencyExchangeRateDeleteError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`currency_exchange_rate_put`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum CurrencyExchangeRatePutError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`currency_exchange_rates`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum CurrencyExchangeRatesError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`currency_post`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum CurrencyPostError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`currency_put`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum CurrencyPutError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`currency_transactions`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum CurrencyTransactionsError {
78    UnknownValue(serde_json::Value),
79}
80
81
82/// 获取所有货币的列表,按ID降序排列。
83pub async fn currencies(configuration: &configuration::Configuration, app_key: &str) -> Result<models::CurrencyListApiResponse, Error<CurrenciesError>> {
84    // add a prefix to parameters to efficiently prevent name collisions
85    let p_app_key = app_key;
86
87    let uri_str = format!("{}/Currency/{appKey}", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
88    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
89
90    if let Some(ref user_agent) = configuration.user_agent {
91        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
92    }
93    if let Some(ref token) = configuration.bearer_access_token {
94        req_builder = req_builder.bearer_auth(token.to_owned());
95    };
96
97    let req = req_builder.build()?;
98    let resp = configuration.client.execute(req).await?;
99
100    let status = resp.status();
101    let content_type = resp
102        .headers()
103        .get("content-type")
104        .and_then(|v| v.to_str().ok())
105        .unwrap_or("application/octet-stream");
106    let content_type = super::ContentType::from(content_type);
107
108    if !status.is_client_error() && !status.is_server_error() {
109        let content = resp.text().await?;
110        match content_type {
111            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
112            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CurrencyListApiResponse`"))),
113            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::CurrencyListApiResponse`")))),
114        }
115    } else {
116        let content = resp.text().await?;
117        let entity: Option<CurrenciesError> = serde_json::from_str(&content).ok();
118        Err(Error::ResponseError(ResponseContent { status, content, entity }))
119    }
120}
121
122/// 根据货币ID获取货币的详细信息。
123pub async fn currency(configuration: &configuration::Configuration, id: i64, app_key: &str) -> Result<models::CurrencyApiResponse, Error<CurrencyError>> {
124    // add a prefix to parameters to efficiently prevent name collisions
125    let p_id = id;
126    let p_app_key = app_key;
127
128    let uri_str = format!("{}/Currency/{appKey}/{id}", configuration.base_path, id=p_id, appKey=crate::apis::urlencode(p_app_key));
129    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
130
131    if let Some(ref user_agent) = configuration.user_agent {
132        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
133    }
134    if let Some(ref token) = configuration.bearer_access_token {
135        req_builder = req_builder.bearer_auth(token.to_owned());
136    };
137
138    let req = req_builder.build()?;
139    let resp = configuration.client.execute(req).await?;
140
141    let status = resp.status();
142    let content_type = resp
143        .headers()
144        .get("content-type")
145        .and_then(|v| v.to_str().ok())
146        .unwrap_or("application/octet-stream");
147    let content_type = super::ContentType::from(content_type);
148
149    if !status.is_client_error() && !status.is_server_error() {
150        let content = resp.text().await?;
151        match content_type {
152            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
153            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CurrencyApiResponse`"))),
154            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::CurrencyApiResponse`")))),
155        }
156    } else {
157        let content = resp.text().await?;
158        let entity: Option<CurrencyError> = serde_json::from_str(&content).ok();
159        Err(Error::ResponseError(ResponseContent { status, content, entity }))
160    }
161}
162
163/// 根据货币ID删除货币。
164pub async fn currency_delete(configuration: &configuration::Configuration, id: i64, app_key: &str) -> Result<models::BooleanApiResponse, Error<CurrencyDeleteError>> {
165    // add a prefix to parameters to efficiently prevent name collisions
166    let p_id = id;
167    let p_app_key = app_key;
168
169    let uri_str = format!("{}/Currency/{appKey}/{id}", configuration.base_path, id=p_id, appKey=crate::apis::urlencode(p_app_key));
170    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
171
172    if let Some(ref user_agent) = configuration.user_agent {
173        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
174    }
175    if let Some(ref token) = configuration.bearer_access_token {
176        req_builder = req_builder.bearer_auth(token.to_owned());
177    };
178
179    let req = req_builder.build()?;
180    let resp = configuration.client.execute(req).await?;
181
182    let status = resp.status();
183    let content_type = resp
184        .headers()
185        .get("content-type")
186        .and_then(|v| v.to_str().ok())
187        .unwrap_or("application/octet-stream");
188    let content_type = super::ContentType::from(content_type);
189
190    if !status.is_client_error() && !status.is_server_error() {
191        let content = resp.text().await?;
192        match content_type {
193            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
194            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BooleanApiResponse`"))),
195            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::BooleanApiResponse`")))),
196        }
197    } else {
198        let content = resp.text().await?;
199        let entity: Option<CurrencyDeleteError> = serde_json::from_str(&content).ok();
200        Err(Error::ResponseError(ResponseContent { status, content, entity }))
201    }
202}
203
204/// 根据汇率ID删除汇率。
205pub async fn currency_exchange_rate_delete(configuration: &configuration::Configuration, id: i64, app_key: &str) -> Result<models::BooleanApiResponse, Error<CurrencyExchangeRateDeleteError>> {
206    // add a prefix to parameters to efficiently prevent name collisions
207    let p_id = id;
208    let p_app_key = app_key;
209
210    let uri_str = format!("{}/Currency/{appKey}/ExchangeRates/{id}", configuration.base_path, id=p_id, appKey=crate::apis::urlencode(p_app_key));
211    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
212
213    if let Some(ref user_agent) = configuration.user_agent {
214        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
215    }
216    if let Some(ref token) = configuration.bearer_access_token {
217        req_builder = req_builder.bearer_auth(token.to_owned());
218    };
219
220    let req = req_builder.build()?;
221    let resp = configuration.client.execute(req).await?;
222
223    let status = resp.status();
224    let content_type = resp
225        .headers()
226        .get("content-type")
227        .and_then(|v| v.to_str().ok())
228        .unwrap_or("application/octet-stream");
229    let content_type = super::ContentType::from(content_type);
230
231    if !status.is_client_error() && !status.is_server_error() {
232        let content = resp.text().await?;
233        match content_type {
234            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
235            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BooleanApiResponse`"))),
236            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::BooleanApiResponse`")))),
237        }
238    } else {
239        let content = resp.text().await?;
240        let entity: Option<CurrencyExchangeRateDeleteError> = serde_json::from_str(&content).ok();
241        Err(Error::ResponseError(ResponseContent { status, content, entity }))
242    }
243}
244
245/// 根据货币代码更新汇率信息。
246pub async fn currency_exchange_rate_put(configuration: &configuration::Configuration, code: &str, app_key: &str, exchange_rate_put_request: Option<models::ExchangeRatePutRequest>) -> Result<models::Int64ApiResponse, Error<CurrencyExchangeRatePutError>> {
247    // add a prefix to parameters to efficiently prevent name collisions
248    let p_code = code;
249    let p_app_key = app_key;
250    let p_exchange_rate_put_request = exchange_rate_put_request;
251
252    let uri_str = format!("{}/Currency/{appKey}/ExchangeRates/{code}", configuration.base_path, code=crate::apis::urlencode(p_code), appKey=crate::apis::urlencode(p_app_key));
253    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
254
255    if let Some(ref user_agent) = configuration.user_agent {
256        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
257    }
258    if let Some(ref token) = configuration.bearer_access_token {
259        req_builder = req_builder.bearer_auth(token.to_owned());
260    };
261    req_builder = req_builder.json(&p_exchange_rate_put_request);
262
263    let req = req_builder.build()?;
264    let resp = configuration.client.execute(req).await?;
265
266    let status = resp.status();
267    let content_type = resp
268        .headers()
269        .get("content-type")
270        .and_then(|v| v.to_str().ok())
271        .unwrap_or("application/octet-stream");
272    let content_type = super::ContentType::from(content_type);
273
274    if !status.is_client_error() && !status.is_server_error() {
275        let content = resp.text().await?;
276        match content_type {
277            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
278            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Int64ApiResponse`"))),
279            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::Int64ApiResponse`")))),
280        }
281    } else {
282        let content = resp.text().await?;
283        let entity: Option<CurrencyExchangeRatePutError> = serde_json::from_str(&content).ok();
284        Err(Error::ResponseError(ResponseContent { status, content, entity }))
285    }
286}
287
288/// 根据货币代码获取该货币的汇率列表。
289pub async fn currency_exchange_rates(configuration: &configuration::Configuration, code: &str, app_key: &str) -> Result<models::CurrencyExchangeRateApiResponse, Error<CurrencyExchangeRatesError>> {
290    // add a prefix to parameters to efficiently prevent name collisions
291    let p_code = code;
292    let p_app_key = app_key;
293
294    let uri_str = format!("{}/Currency/{appKey}/ExchangeRates/{code}", configuration.base_path, code=crate::apis::urlencode(p_code), appKey=crate::apis::urlencode(p_app_key));
295    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
296
297    if let Some(ref user_agent) = configuration.user_agent {
298        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
299    }
300    if let Some(ref token) = configuration.bearer_access_token {
301        req_builder = req_builder.bearer_auth(token.to_owned());
302    };
303
304    let req = req_builder.build()?;
305    let resp = configuration.client.execute(req).await?;
306
307    let status = resp.status();
308    let content_type = resp
309        .headers()
310        .get("content-type")
311        .and_then(|v| v.to_str().ok())
312        .unwrap_or("application/octet-stream");
313    let content_type = super::ContentType::from(content_type);
314
315    if !status.is_client_error() && !status.is_server_error() {
316        let content = resp.text().await?;
317        match content_type {
318            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
319            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CurrencyExchangeRateApiResponse`"))),
320            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::CurrencyExchangeRateApiResponse`")))),
321        }
322    } else {
323        let content = resp.text().await?;
324        let entity: Option<CurrencyExchangeRatesError> = serde_json::from_str(&content).ok();
325        Err(Error::ResponseError(ResponseContent { status, content, entity }))
326    }
327}
328
329/// 创建一个新的货币并返回其ID。
330pub async fn currency_post(configuration: &configuration::Configuration, app_key: &str, currency: Option<models::Currency>) -> Result<models::Int64ApiResponse, Error<CurrencyPostError>> {
331    // add a prefix to parameters to efficiently prevent name collisions
332    let p_app_key = app_key;
333    let p_currency = currency;
334
335    let uri_str = format!("{}/Currency/{appKey}", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
336    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
337
338    if let Some(ref user_agent) = configuration.user_agent {
339        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
340    }
341    if let Some(ref token) = configuration.bearer_access_token {
342        req_builder = req_builder.bearer_auth(token.to_owned());
343    };
344    req_builder = req_builder.json(&p_currency);
345
346    let req = req_builder.build()?;
347    let resp = configuration.client.execute(req).await?;
348
349    let status = resp.status();
350    let content_type = resp
351        .headers()
352        .get("content-type")
353        .and_then(|v| v.to_str().ok())
354        .unwrap_or("application/octet-stream");
355    let content_type = super::ContentType::from(content_type);
356
357    if !status.is_client_error() && !status.is_server_error() {
358        let content = resp.text().await?;
359        match content_type {
360            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
361            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Int64ApiResponse`"))),
362            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::Int64ApiResponse`")))),
363        }
364    } else {
365        let content = resp.text().await?;
366        let entity: Option<CurrencyPostError> = serde_json::from_str(&content).ok();
367        Err(Error::ResponseError(ResponseContent { status, content, entity }))
368    }
369}
370
371/// 根据货币ID更新货币的详细信息。
372pub async fn currency_put(configuration: &configuration::Configuration, id: i64, app_key: &str, currency: Option<models::Currency>) -> Result<models::BooleanApiResponse, Error<CurrencyPutError>> {
373    // add a prefix to parameters to efficiently prevent name collisions
374    let p_id = id;
375    let p_app_key = app_key;
376    let p_currency = currency;
377
378    let uri_str = format!("{}/Currency/{appKey}/{id}", configuration.base_path, id=p_id, appKey=crate::apis::urlencode(p_app_key));
379    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
380
381    if let Some(ref user_agent) = configuration.user_agent {
382        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
383    }
384    if let Some(ref token) = configuration.bearer_access_token {
385        req_builder = req_builder.bearer_auth(token.to_owned());
386    };
387    req_builder = req_builder.json(&p_currency);
388
389    let req = req_builder.build()?;
390    let resp = configuration.client.execute(req).await?;
391
392    let status = resp.status();
393    let content_type = resp
394        .headers()
395        .get("content-type")
396        .and_then(|v| v.to_str().ok())
397        .unwrap_or("application/octet-stream");
398    let content_type = super::ContentType::from(content_type);
399
400    if !status.is_client_error() && !status.is_server_error() {
401        let content = resp.text().await?;
402        match content_type {
403            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
404            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BooleanApiResponse`"))),
405            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::BooleanApiResponse`")))),
406        }
407    } else {
408        let content = resp.text().await?;
409        let entity: Option<CurrencyPutError> = serde_json::from_str(&content).ok();
410        Err(Error::ResponseError(ResponseContent { status, content, entity }))
411    }
412}
413
414/// 根据用户ID、交易类型、货币代码、时间范围等条件获取货币交易记录。
415pub async fn currency_transactions(configuration: &configuration::Configuration, app_key: &str, user_id: Option<i64>, trans_type: Option<&str>, cur_code: Option<&str>, start_time: Option<String>, end_time: Option<String>, skip: Option<i32>, take: Option<i32>) -> Result<models::CurrencyTransactionListApiResponse, Error<CurrencyTransactionsError>> {
416    // add a prefix to parameters to efficiently prevent name collisions
417    let p_app_key = app_key;
418    let p_user_id = user_id;
419    let p_trans_type = trans_type;
420    let p_cur_code = cur_code;
421    let p_start_time = start_time;
422    let p_end_time = end_time;
423    let p_skip = skip;
424    let p_take = take;
425
426    let uri_str = format!("{}/Currency/{appKey}/Transactions", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
427    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
428
429    if let Some(ref param_value) = p_user_id {
430        req_builder = req_builder.query(&[("userId", &param_value.to_string())]);
431    }
432    if let Some(ref param_value) = p_trans_type {
433        req_builder = req_builder.query(&[("transType", &param_value.to_string())]);
434    }
435    if let Some(ref param_value) = p_cur_code {
436        req_builder = req_builder.query(&[("curCode", &param_value.to_string())]);
437    }
438    if let Some(ref param_value) = p_start_time {
439        req_builder = req_builder.query(&[("startTime", &param_value.to_string())]);
440    }
441    if let Some(ref param_value) = p_end_time {
442        req_builder = req_builder.query(&[("endTime", &param_value.to_string())]);
443    }
444    if let Some(ref param_value) = p_skip {
445        req_builder = req_builder.query(&[("skip", &param_value.to_string())]);
446    }
447    if let Some(ref param_value) = p_take {
448        req_builder = req_builder.query(&[("take", &param_value.to_string())]);
449    }
450    if let Some(ref user_agent) = configuration.user_agent {
451        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
452    }
453    if let Some(ref token) = configuration.bearer_access_token {
454        req_builder = req_builder.bearer_auth(token.to_owned());
455    };
456
457    let req = req_builder.build()?;
458    let resp = configuration.client.execute(req).await?;
459
460    let status = resp.status();
461    let content_type = resp
462        .headers()
463        .get("content-type")
464        .and_then(|v| v.to_str().ok())
465        .unwrap_or("application/octet-stream");
466    let content_type = super::ContentType::from(content_type);
467
468    if !status.is_client_error() && !status.is_server_error() {
469        let content = resp.text().await?;
470        match content_type {
471            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
472            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CurrencyTransactionListApiResponse`"))),
473            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::CurrencyTransactionListApiResponse`")))),
474        }
475    } else {
476        let content = resp.text().await?;
477        let entity: Option<CurrencyTransactionsError> = serde_json::from_str(&content).ok();
478        Err(Error::ResponseError(ResponseContent { status, content, entity }))
479    }
480}
481