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_invoices_get`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum AccountsBillingInvoicesGetError {
28    UnknownValue(serde_json::Value),
29}
30
31/// struct for typed errors of method [`accounts_billing_payment_method_get`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum AccountsBillingPaymentMethodGetError {
35    UnknownValue(serde_json::Value),
36}
37
38/// struct for typed errors of method [`accounts_billing_preview_invoice_post`]
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum AccountsBillingPreviewInvoicePostError {
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`accounts_billing_transactions_get`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum AccountsBillingTransactionsGetError {
49    UnknownValue(serde_json::Value),
50}
51
52pub async fn accounts_billing_history_get(
53    configuration: &configuration::Configuration,
54) -> Result<models::BillingHistoryResponseModel, Error<AccountsBillingHistoryGetError>> {
55    let local_var_configuration = configuration;
56
57    let local_var_client = &local_var_configuration.client;
58
59    let local_var_uri_str = format!(
60        "{}/accounts/billing/history",
61        local_var_configuration.base_path
62    );
63    let mut local_var_req_builder =
64        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
65
66    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
67        local_var_req_builder =
68            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
69    }
70    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
71        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
72    };
73
74    let local_var_req = local_var_req_builder.build()?;
75    let local_var_resp = local_var_client.execute(local_var_req).await?;
76
77    let local_var_status = local_var_resp.status();
78    let local_var_content = local_var_resp.text().await?;
79
80    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
81        serde_json::from_str(&local_var_content).map_err(Error::from)
82    } else {
83        let local_var_entity: Option<AccountsBillingHistoryGetError> =
84            serde_json::from_str(&local_var_content).ok();
85        let local_var_error = ResponseContent {
86            status: local_var_status,
87            content: local_var_content,
88            entity: local_var_entity,
89        };
90        Err(Error::ResponseError(local_var_error))
91    }
92}
93
94pub async fn accounts_billing_invoices_get(
95    configuration: &configuration::Configuration,
96    status: Option<&str>,
97    start_after: Option<&str>,
98) -> Result<(), Error<AccountsBillingInvoicesGetError>> {
99    let local_var_configuration = configuration;
100
101    let local_var_client = &local_var_configuration.client;
102
103    let local_var_uri_str = format!(
104        "{}/accounts/billing/invoices",
105        local_var_configuration.base_path
106    );
107    let mut local_var_req_builder =
108        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
109
110    if let Some(ref local_var_str) = status {
111        local_var_req_builder =
112            local_var_req_builder.query(&[("status", &local_var_str.to_string())]);
113    }
114    if let Some(ref local_var_str) = start_after {
115        local_var_req_builder =
116            local_var_req_builder.query(&[("startAfter", &local_var_str.to_string())]);
117    }
118    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
119        local_var_req_builder =
120            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
121    }
122    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
123        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
124    };
125
126    let local_var_req = local_var_req_builder.build()?;
127    let local_var_resp = local_var_client.execute(local_var_req).await?;
128
129    let local_var_status = local_var_resp.status();
130    let local_var_content = local_var_resp.text().await?;
131
132    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
133        Ok(())
134    } else {
135        let local_var_entity: Option<AccountsBillingInvoicesGetError> =
136            serde_json::from_str(&local_var_content).ok();
137        let local_var_error = ResponseContent {
138            status: local_var_status,
139            content: local_var_content,
140            entity: local_var_entity,
141        };
142        Err(Error::ResponseError(local_var_error))
143    }
144}
145
146pub async fn accounts_billing_payment_method_get(
147    configuration: &configuration::Configuration,
148) -> Result<models::BillingPaymentResponseModel, Error<AccountsBillingPaymentMethodGetError>> {
149    let local_var_configuration = configuration;
150
151    let local_var_client = &local_var_configuration.client;
152
153    let local_var_uri_str = format!(
154        "{}/accounts/billing/payment-method",
155        local_var_configuration.base_path
156    );
157    let mut local_var_req_builder =
158        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
159
160    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
161        local_var_req_builder =
162            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
163    }
164    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
165        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
166    };
167
168    let local_var_req = local_var_req_builder.build()?;
169    let local_var_resp = local_var_client.execute(local_var_req).await?;
170
171    let local_var_status = local_var_resp.status();
172    let local_var_content = local_var_resp.text().await?;
173
174    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
175        serde_json::from_str(&local_var_content).map_err(Error::from)
176    } else {
177        let local_var_entity: Option<AccountsBillingPaymentMethodGetError> =
178            serde_json::from_str(&local_var_content).ok();
179        let local_var_error = ResponseContent {
180            status: local_var_status,
181            content: local_var_content,
182            entity: local_var_entity,
183        };
184        Err(Error::ResponseError(local_var_error))
185    }
186}
187
188pub async fn accounts_billing_preview_invoice_post(
189    configuration: &configuration::Configuration,
190    preview_individual_invoice_request_body: Option<models::PreviewIndividualInvoiceRequestBody>,
191) -> Result<(), Error<AccountsBillingPreviewInvoicePostError>> {
192    let local_var_configuration = configuration;
193
194    let local_var_client = &local_var_configuration.client;
195
196    let local_var_uri_str = format!(
197        "{}/accounts/billing/preview-invoice",
198        local_var_configuration.base_path
199    );
200    let mut local_var_req_builder =
201        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
202
203    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
204        local_var_req_builder =
205            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
206    }
207    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
208        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
209    };
210    local_var_req_builder = local_var_req_builder.json(&preview_individual_invoice_request_body);
211
212    let local_var_req = local_var_req_builder.build()?;
213    let local_var_resp = local_var_client.execute(local_var_req).await?;
214
215    let local_var_status = local_var_resp.status();
216    let local_var_content = local_var_resp.text().await?;
217
218    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
219        Ok(())
220    } else {
221        let local_var_entity: Option<AccountsBillingPreviewInvoicePostError> =
222            serde_json::from_str(&local_var_content).ok();
223        let local_var_error = ResponseContent {
224            status: local_var_status,
225            content: local_var_content,
226            entity: local_var_entity,
227        };
228        Err(Error::ResponseError(local_var_error))
229    }
230}
231
232pub async fn accounts_billing_transactions_get(
233    configuration: &configuration::Configuration,
234    start_after: Option<String>,
235) -> Result<(), Error<AccountsBillingTransactionsGetError>> {
236    let local_var_configuration = configuration;
237
238    let local_var_client = &local_var_configuration.client;
239
240    let local_var_uri_str = format!(
241        "{}/accounts/billing/transactions",
242        local_var_configuration.base_path
243    );
244    let mut local_var_req_builder =
245        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
246
247    if let Some(ref local_var_str) = start_after {
248        local_var_req_builder =
249            local_var_req_builder.query(&[("startAfter", &local_var_str.to_string())]);
250    }
251    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
252        local_var_req_builder =
253            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
254    }
255    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
256        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
257    };
258
259    let local_var_req = local_var_req_builder.build()?;
260    let local_var_resp = local_var_client.execute(local_var_req).await?;
261
262    let local_var_status = local_var_resp.status();
263    let local_var_content = local_var_resp.text().await?;
264
265    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
266        Ok(())
267    } else {
268        let local_var_entity: Option<AccountsBillingTransactionsGetError> =
269            serde_json::from_str(&local_var_content).ok();
270        let local_var_error = ResponseContent {
271            status: local_var_status,
272            content: local_var_content,
273            entity: local_var_entity,
274        };
275        Err(Error::ResponseError(local_var_error))
276    }
277}