bitwarden_api_api/apis/
plans_api.rs

1/*
2 * Bitwarden Internal API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: latest
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use reqwest;
12use serde::{Deserialize, Serialize};
13
14use super::{configuration, Error};
15use crate::{apis::ResponseContent, models};
16
17/// struct for typed errors of method [`plans_get`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum PlansGetError {
21    UnknownValue(serde_json::Value),
22}
23
24pub async fn plans_get(
25    configuration: &configuration::Configuration,
26) -> Result<models::PlanResponseModelListResponseModel, Error<PlansGetError>> {
27    let local_var_configuration = configuration;
28
29    let local_var_client = &local_var_configuration.client;
30
31    let local_var_uri_str = format!("{}/plans", local_var_configuration.base_path);
32    let mut local_var_req_builder =
33        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 =
37            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
38    }
39    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
40        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
41    };
42
43    let local_var_req = local_var_req_builder.build()?;
44    let local_var_resp = local_var_client.execute(local_var_req).await?;
45
46    let local_var_status = local_var_resp.status();
47    let local_var_content = local_var_resp.text().await?;
48
49    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
50        serde_json::from_str(&local_var_content).map_err(Error::from)
51    } else {
52        let local_var_entity: Option<PlansGetError> = serde_json::from_str(&local_var_content).ok();
53        let local_var_error = ResponseContent {
54            status: local_var_status,
55            content: local_var_content,
56            entity: local_var_entity,
57        };
58        Err(Error::ResponseError(local_var_error))
59    }
60}