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 reqwest;
12use serde::{de::Error as _, Deserialize, Serialize};
13
14use super::{configuration, ContentType, Error};
15use crate::{apis::ResponseContent, models};
16
17/// struct for typed errors of method [`tax_preview_amount_organization_trial_post`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum TaxPreviewAmountOrganizationTrialPostError {
21    UnknownValue(serde_json::Value),
22}
23
24pub async fn tax_preview_amount_organization_trial_post(
25    configuration: &configuration::Configuration,
26    preview_tax_amount_for_organization_trial_request_body: Option<
27        models::PreviewTaxAmountForOrganizationTrialRequestBody,
28    >,
29) -> Result<(), Error<TaxPreviewAmountOrganizationTrialPostError>> {
30    // add a prefix to parameters to efficiently prevent name collisions
31    let p_preview_tax_amount_for_organization_trial_request_body =
32        preview_tax_amount_for_organization_trial_request_body;
33
34    let uri_str = format!(
35        "{}/tax/preview-amount/organization-trial",
36        configuration.base_path
37    );
38    let mut req_builder = configuration
39        .client
40        .request(reqwest::Method::POST, &uri_str);
41
42    if let Some(ref user_agent) = configuration.user_agent {
43        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
44    }
45    if let Some(ref token) = configuration.oauth_access_token {
46        req_builder = req_builder.bearer_auth(token.to_owned());
47    };
48    req_builder = req_builder.json(&p_preview_tax_amount_for_organization_trial_request_body);
49
50    let req = req_builder.build()?;
51    let resp = configuration.client.execute(req).await?;
52
53    let status = resp.status();
54
55    if !status.is_client_error() && !status.is_server_error() {
56        Ok(())
57    } else {
58        let content = resp.text().await?;
59        let entity: Option<TaxPreviewAmountOrganizationTrialPostError> =
60            serde_json::from_str(&content).ok();
61        Err(Error::ResponseError(ResponseContent {
62            status,
63            content,
64            entity,
65        }))
66    }
67}