btcpay_client/apis/
server_info_api.rs1use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ServerInfoGetServerInfoError {
22 UnknownValue(serde_json::Value),
23}
24
25
26pub async fn server_info_get_server_info(configuration: &configuration::Configuration, ) -> Result<crate::models::ApplicationServerInfoData, Error<ServerInfoGetServerInfoError>> {
28 let local_var_configuration = configuration;
29
30 let local_var_client = &local_var_configuration.client;
31
32 let local_var_uri_str = format!("{}/api/v1/server/info", local_var_configuration.base_path);
33 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
34
35 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
36 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
37 }
38 if let Some(ref local_var_apikey) = local_var_configuration.api_key {
39 let local_var_key = local_var_apikey.key.clone();
40 let local_var_value = match local_var_apikey.prefix {
41 Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
42 None => local_var_key,
43 };
44 local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
45 };
46 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
47 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
48 };
49
50 let local_var_req = local_var_req_builder.build()?;
51 let local_var_resp = local_var_client.execute(local_var_req).await?;
52
53 let local_var_status = local_var_resp.status();
54 let local_var_content = local_var_resp.text().await?;
55
56 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
57 serde_json::from_str(&local_var_content).map_err(Error::from)
58 } else {
59 let local_var_entity: Option<ServerInfoGetServerInfoError> = serde_json::from_str(&local_var_content).ok();
60 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
61 Err(Error::ResponseError(local_var_error))
62 }
63}
64