Skip to main content

bitwarden_api_api/apis/
organization_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 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::{AuthRequired, 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 OrganizationBillingApi: Send + Sync {
29    /// POST /organizations/{organizationId}/billing/change-frequency
30    async fn change_plan_subscription_frequency<'a>(
31        &self,
32        organization_id: uuid::Uuid,
33        change_plan_frequency_request: Option<models::ChangePlanFrequencyRequest>,
34    ) -> Result<(), Error>;
35
36    /// GET /organizations/{organizationId}/billing
37    async fn get_billing<'a>(&self, organization_id: uuid::Uuid) -> Result<(), Error>;
38
39    /// GET /organizations/{organizationId}/billing/history
40    async fn get_history<'a>(&self, organization_id: uuid::Uuid) -> Result<(), Error>;
41
42    /// GET /organizations/{organizationId}/billing/invoices
43    async fn get_invoices<'a>(
44        &self,
45        organization_id: uuid::Uuid,
46        status: Option<&'a str>,
47        start_after: Option<&'a str>,
48    ) -> Result<(), Error>;
49
50    /// GET /organizations/{organizationId}/billing/transactions
51    async fn get_transactions<'a>(
52        &self,
53        organization_id: uuid::Uuid,
54        start_after: Option<String>,
55    ) -> Result<(), Error>;
56
57    /// POST /organizations/{organizationId}/billing/setup-business-unit
58    async fn setup_business_unit<'a>(
59        &self,
60        organization_id: uuid::Uuid,
61        setup_business_unit_request_body: Option<models::SetupBusinessUnitRequestBody>,
62    ) -> Result<(), Error>;
63}
64
65pub struct OrganizationBillingApiClient {
66    configuration: Arc<configuration::Configuration>,
67}
68
69impl OrganizationBillingApiClient {
70    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
71        Self { configuration }
72    }
73}
74
75#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
76#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
77impl OrganizationBillingApi for OrganizationBillingApiClient {
78    async fn change_plan_subscription_frequency<'a>(
79        &self,
80        organization_id: uuid::Uuid,
81        change_plan_frequency_request: Option<models::ChangePlanFrequencyRequest>,
82    ) -> Result<(), Error> {
83        let local_var_configuration = &self.configuration;
84
85        let local_var_client = &local_var_configuration.client;
86
87        let local_var_uri_str = format!(
88            "{}/organizations/{organizationId}/billing/change-frequency",
89            local_var_configuration.base_path,
90            organizationId = organization_id
91        );
92        let mut local_var_req_builder =
93            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
94
95        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
96        local_var_req_builder = local_var_req_builder.json(&change_plan_frequency_request);
97
98        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
99    }
100
101    async fn get_billing<'a>(&self, organization_id: uuid::Uuid) -> Result<(), Error> {
102        let local_var_configuration = &self.configuration;
103
104        let local_var_client = &local_var_configuration.client;
105
106        let local_var_uri_str = format!(
107            "{}/organizations/{organizationId}/billing",
108            local_var_configuration.base_path,
109            organizationId = organization_id
110        );
111        let mut local_var_req_builder =
112            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
113
114        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
115
116        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
117    }
118
119    async fn get_history<'a>(&self, organization_id: uuid::Uuid) -> Result<(), Error> {
120        let local_var_configuration = &self.configuration;
121
122        let local_var_client = &local_var_configuration.client;
123
124        let local_var_uri_str = format!(
125            "{}/organizations/{organizationId}/billing/history",
126            local_var_configuration.base_path,
127            organizationId = organization_id
128        );
129        let mut local_var_req_builder =
130            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
131
132        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
133
134        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
135    }
136
137    async fn get_invoices<'a>(
138        &self,
139        organization_id: uuid::Uuid,
140        status: Option<&'a str>,
141        start_after: Option<&'a str>,
142    ) -> Result<(), Error> {
143        let local_var_configuration = &self.configuration;
144
145        let local_var_client = &local_var_configuration.client;
146
147        let local_var_uri_str = format!(
148            "{}/organizations/{organizationId}/billing/invoices",
149            local_var_configuration.base_path,
150            organizationId = organization_id
151        );
152        let mut local_var_req_builder =
153            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
154
155        if let Some(ref param_value) = status {
156            local_var_req_builder =
157                local_var_req_builder.query(&[("status", &param_value.to_string())]);
158        }
159        if let Some(ref param_value) = start_after {
160            local_var_req_builder =
161                local_var_req_builder.query(&[("startAfter", &param_value.to_string())]);
162        }
163        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
164
165        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
166    }
167
168    async fn get_transactions<'a>(
169        &self,
170        organization_id: uuid::Uuid,
171        start_after: Option<String>,
172    ) -> Result<(), Error> {
173        let local_var_configuration = &self.configuration;
174
175        let local_var_client = &local_var_configuration.client;
176
177        let local_var_uri_str = format!(
178            "{}/organizations/{organizationId}/billing/transactions",
179            local_var_configuration.base_path,
180            organizationId = organization_id
181        );
182        let mut local_var_req_builder =
183            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
184
185        if let Some(ref param_value) = start_after {
186            local_var_req_builder =
187                local_var_req_builder.query(&[("startAfter", &param_value.to_string())]);
188        }
189        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
190
191        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
192    }
193
194    async fn setup_business_unit<'a>(
195        &self,
196        organization_id: uuid::Uuid,
197        setup_business_unit_request_body: Option<models::SetupBusinessUnitRequestBody>,
198    ) -> Result<(), Error> {
199        let local_var_configuration = &self.configuration;
200
201        let local_var_client = &local_var_configuration.client;
202
203        let local_var_uri_str = format!(
204            "{}/organizations/{organizationId}/billing/setup-business-unit",
205            local_var_configuration.base_path,
206            organizationId = organization_id
207        );
208        let mut local_var_req_builder =
209            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
210
211        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
212        local_var_req_builder = local_var_req_builder.json(&setup_business_unit_request_body);
213
214        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
215    }
216}