bitwarden_api_api/apis/
accounts_billing_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 [`accounts_billing_history_get`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum AccountsBillingHistoryGetError {
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`accounts_billing_payment_method_get`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum AccountsBillingPaymentMethodGetError {
28    UnknownValue(serde_json::Value),
29}
30
31pub async fn accounts_billing_history_get(
32    configuration: &configuration::Configuration,
33) -> Result<models::BillingHistoryResponseModel, Error<AccountsBillingHistoryGetError>> {
34    let local_var_configuration = configuration;
35
36    let local_var_client = &local_var_configuration.client;
37
38    let local_var_uri_str = format!(
39        "{}/accounts/billing/history",
40        local_var_configuration.base_path
41    );
42    let mut local_var_req_builder =
43        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
44
45    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
46        local_var_req_builder =
47            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
48    }
49    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
50        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
51    };
52
53    let local_var_req = local_var_req_builder.build()?;
54    let local_var_resp = local_var_client.execute(local_var_req).await?;
55
56    let local_var_status = local_var_resp.status();
57    let local_var_content = local_var_resp.text().await?;
58
59    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
60        serde_json::from_str(&local_var_content).map_err(Error::from)
61    } else {
62        let local_var_entity: Option<AccountsBillingHistoryGetError> =
63            serde_json::from_str(&local_var_content).ok();
64        let local_var_error = ResponseContent {
65            status: local_var_status,
66            content: local_var_content,
67            entity: local_var_entity,
68        };
69        Err(Error::ResponseError(local_var_error))
70    }
71}
72
73pub async fn accounts_billing_payment_method_get(
74    configuration: &configuration::Configuration,
75) -> Result<models::BillingPaymentResponseModel, Error<AccountsBillingPaymentMethodGetError>> {
76    let local_var_configuration = configuration;
77
78    let local_var_client = &local_var_configuration.client;
79
80    let local_var_uri_str = format!(
81        "{}/accounts/billing/payment-method",
82        local_var_configuration.base_path
83    );
84    let mut local_var_req_builder =
85        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
86
87    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
88        local_var_req_builder =
89            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
90    }
91    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
92        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
93    };
94
95    let local_var_req = local_var_req_builder.build()?;
96    let local_var_resp = local_var_client.execute(local_var_req).await?;
97
98    let local_var_status = local_var_resp.status();
99    let local_var_content = local_var_resp.text().await?;
100
101    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
102        serde_json::from_str(&local_var_content).map_err(Error::from)
103    } else {
104        let local_var_entity: Option<AccountsBillingPaymentMethodGetError> =
105            serde_json::from_str(&local_var_content).ok();
106        let local_var_error = ResponseContent {
107            status: local_var_status,
108            content: local_var_content,
109            entity: local_var_entity,
110        };
111        Err(Error::ResponseError(local_var_error))
112    }
113}