bitwarden_api_api/apis/
tax_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 std::sync::Arc;
12
13use async_trait::async_trait;
14#[cfg(feature = "mockall")]
15use mockall::automock;
16use reqwest;
17use serde::{Deserialize, Serialize, de::Error as _};
18
19use super::{Error, configuration};
20use crate::{
21    apis::{ContentType, ResponseContent},
22    models,
23};
24
25#[cfg_attr(feature = "mockall", automock)]
26#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
27#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
28pub trait TaxApi: Send + Sync {
29    /// POST /tax/preview-amount/organization-trial
30    async fn preview_tax_amount_for_organization_trial<'a>(
31        &self,
32        preview_tax_amount_for_organization_trial_request_body: Option<
33            models::PreviewTaxAmountForOrganizationTrialRequestBody,
34        >,
35    ) -> Result<(), Error<PreviewTaxAmountForOrganizationTrialError>>;
36}
37
38pub struct TaxApiClient {
39    configuration: Arc<configuration::Configuration>,
40}
41
42impl TaxApiClient {
43    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
44        Self { configuration }
45    }
46}
47
48#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
49#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
50impl TaxApi for TaxApiClient {
51    async fn preview_tax_amount_for_organization_trial<'a>(
52        &self,
53        preview_tax_amount_for_organization_trial_request_body: Option<
54            models::PreviewTaxAmountForOrganizationTrialRequestBody,
55        >,
56    ) -> Result<(), Error<PreviewTaxAmountForOrganizationTrialError>> {
57        let local_var_configuration = &self.configuration;
58
59        let local_var_client = &local_var_configuration.client;
60
61        let local_var_uri_str = format!(
62            "{}/tax/preview-amount/organization-trial",
63            local_var_configuration.base_path
64        );
65        let mut local_var_req_builder =
66            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
67
68        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
69            local_var_req_builder = local_var_req_builder
70                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
71        }
72        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
73            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
74        };
75        local_var_req_builder =
76            local_var_req_builder.json(&preview_tax_amount_for_organization_trial_request_body);
77
78        let local_var_req = local_var_req_builder.build()?;
79        let local_var_resp = local_var_client.execute(local_var_req).await?;
80
81        let local_var_status = local_var_resp.status();
82        let local_var_content = local_var_resp.text().await?;
83
84        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
85            Ok(())
86        } else {
87            let local_var_entity: Option<PreviewTaxAmountForOrganizationTrialError> =
88                serde_json::from_str(&local_var_content).ok();
89            let local_var_error = ResponseContent {
90                status: local_var_status,
91                content: local_var_content,
92                entity: local_var_entity,
93            };
94            Err(Error::ResponseError(local_var_error))
95        }
96    }
97}
98
99/// struct for typed errors of method [`TaxApi::preview_tax_amount_for_organization_trial`]
100#[derive(Debug, Clone, Serialize, Deserialize)]
101#[serde(untagged)]
102pub enum PreviewTaxAmountForOrganizationTrialError {
103    UnknownValue(serde_json::Value),
104}