bitwarden_api_api/apis/
invoices_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 [`invoices_preview_organization_post`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum InvoicesPreviewOrganizationPostError {
21    UnknownValue(serde_json::Value),
22}
23
24pub async fn invoices_preview_organization_post(
25    configuration: &configuration::Configuration,
26    preview_organization_invoice_request_body: Option<
27        models::PreviewOrganizationInvoiceRequestBody,
28    >,
29) -> Result<(), Error<InvoicesPreviewOrganizationPostError>> {
30    let local_var_configuration = configuration;
31
32    let local_var_client = &local_var_configuration.client;
33
34    let local_var_uri_str = format!(
35        "{}/invoices/preview-organization",
36        local_var_configuration.base_path
37    );
38    let mut local_var_req_builder =
39        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
40
41    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
42        local_var_req_builder =
43            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
44    }
45    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
46        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
47    };
48    local_var_req_builder = local_var_req_builder.json(&preview_organization_invoice_request_body);
49
50    let local_var_req = local_var_req_builder.build()?;
51    let local_var_resp = local_var_client.execute(local_var_req).await?;
52
53    let local_var_status = local_var_resp.status();
54    let local_var_content = local_var_resp.text().await?;
55
56    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
57        Ok(())
58    } else {
59        let local_var_entity: Option<InvoicesPreviewOrganizationPostError> =
60            serde_json::from_str(&local_var_content).ok();
61        let local_var_error = ResponseContent {
62            status: local_var_status,
63            content: local_var_content,
64            entity: local_var_entity,
65        };
66        Err(Error::ResponseError(local_var_error))
67    }
68}