sendinblue_v3/apis/
account_api.rs

1/*
2 * SendinBlue API
3 *
4 * SendinBlue provide a RESTFul API that can be used with any languages. With this API, you will be able to :   - Manage your campaigns and get the statistics   - Manage your contacts   - Send transactional Emails and SMS   - and much more...  You can download our wrappers at https://github.com/orgs/sendinblue  **Possible responses**   | Code | Message |   | :-------------: | ------------- |   | 200  | OK. Successful Request  |   | 201  | OK. Successful Creation |   | 202  | OK. Request accepted |   | 204  | OK. Successful Update/Deletion  |   | 400  | Error. Bad Request  |   | 401  | Error. Authentication Needed  |   | 402  | Error. Not enough credit, plan upgrade needed  |   | 403  | Error. Permission denied  |   | 404  | Error. Object does not exist |   | 405  | Error. Method not allowed  |   | 406  | Error. Not Acceptable  | 
5 *
6 * The version of the OpenAPI document: 3.0.0
7 * Contact: contact@sendinblue.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`get_account`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetAccountError {
22    UnknownValue(serde_json::Value),
23}
24
25
26pub async fn get_account(configuration: &configuration::Configuration, ) -> Result<crate::models::GetAccount, Error<GetAccountError>> {
27    let local_var_configuration = configuration;
28
29    let local_var_client = &local_var_configuration.client;
30
31    let local_var_uri_str = format!("{}/account", local_var_configuration.base_path);
32    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
33
34    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
35        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
36    }
37    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
38        let local_var_key = local_var_apikey.key.clone();
39        let local_var_value = match local_var_apikey.prefix {
40            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
41            None => local_var_key,
42        };
43        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
44    };
45
46    let local_var_req = local_var_req_builder.build()?;
47    let local_var_resp = local_var_client.execute(local_var_req).await?;
48
49    let local_var_status = local_var_resp.status();
50    let local_var_content = local_var_resp.text().await?;
51
52    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
53        serde_json::from_str(&local_var_content).map_err(Error::from)
54    } else {
55        let local_var_entity: Option<GetAccountError> = serde_json::from_str(&local_var_content).ok();
56        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
57        Err(Error::ResponseError(local_var_error))
58    }
59}
60