eventify_http_client/apis/
block_api.rs

1/*
2 * eventify-http-server
3 *
4 * Ethereum Indexer
5 *
6 * The version of the OpenAPI document: 0.0.0-reserved
7 * Contact: lachezarkolevgg@gmail.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11use reqwest;
12
13use super::{configuration, Error};
14use crate::apis::ResponseContent;
15
16/// struct for typed errors of method [`get_blocks_count`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum GetBlocksCountError {
20    Status500(),
21    UnknownValue(serde_json::Value),
22}
23
24/// Get the Count of Blocks  This endpoint returns the total count of blocks present in the database. The response is a JSON object containing the count.  # Responses  * `200 OK`: Successfully retrieved the count of blocks. The response body will be a JSON object with the structure `{ \"count\": i64 }`, where `i64` is the total number of blocks. * `500 Internal Server Error`: Indicates that an error occurred on the server while processing the request. The response body will contain a JSON object with an error message.  # Example  ```json { \"count\": 42 } ```
25pub async fn get_blocks_count(
26    configuration: &configuration::Configuration,
27) -> Result<(), Error<GetBlocksCountError>> {
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/blocks/count", local_var_configuration.base_path);
33    let mut local_var_req_builder =
34        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
35
36    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
37        local_var_req_builder =
38            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
39    }
40
41    let local_var_req = local_var_req_builder.build()?;
42    let local_var_resp = local_var_client.execute(local_var_req).await?;
43
44    let local_var_status = local_var_resp.status();
45    let local_var_content = local_var_resp.text().await?;
46
47    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
48        Ok(())
49    } else {
50        let local_var_entity: Option<GetBlocksCountError> =
51            serde_json::from_str(&local_var_content).ok();
52        let local_var_error = ResponseContent {
53            status: local_var_status,
54            content: local_var_content,
55            entity: local_var_entity,
56        };
57        Err(Error::ResponseError(local_var_error))
58    }
59}