bitwarden_api_api/apis/
accounts_billing_api.rs1use 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 AccountsBillingApi: Send + Sync {
29 async fn get_billing_history(
31 &self,
32 ) -> Result<models::BillingHistoryResponseModel, Error<GetBillingHistoryError>>;
33
34 async fn get_invoices<'a>(
36 &self,
37 status: Option<&'a str>,
38 start_after: Option<&'a str>,
39 ) -> Result<(), Error<GetInvoicesError>>;
40
41 async fn get_transactions<'a>(
43 &self,
44 start_after: Option<String>,
45 ) -> Result<(), Error<GetTransactionsError>>;
46}
47
48pub struct AccountsBillingApiClient {
49 configuration: Arc<configuration::Configuration>,
50}
51
52impl AccountsBillingApiClient {
53 pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
54 Self { configuration }
55 }
56}
57
58#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
59#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
60impl AccountsBillingApi for AccountsBillingApiClient {
61 async fn get_billing_history(
62 &self,
63 ) -> Result<models::BillingHistoryResponseModel, Error<GetBillingHistoryError>> {
64 let local_var_configuration = &self.configuration;
65
66 let local_var_client = &local_var_configuration.client;
67
68 let local_var_uri_str = format!(
69 "{}/accounts/billing/history",
70 local_var_configuration.base_path
71 );
72 let mut local_var_req_builder =
73 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
74
75 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
76
77 bitwarden_api_base::process_with_json_response(local_var_req_builder).await
78 }
79
80 async fn get_invoices<'a>(
81 &self,
82 status: Option<&'a str>,
83 start_after: Option<&'a str>,
84 ) -> Result<(), Error<GetInvoicesError>> {
85 let local_var_configuration = &self.configuration;
86
87 let local_var_client = &local_var_configuration.client;
88
89 let local_var_uri_str = format!(
90 "{}/accounts/billing/invoices",
91 local_var_configuration.base_path
92 );
93 let mut local_var_req_builder =
94 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
95
96 if let Some(ref param_value) = status {
97 local_var_req_builder =
98 local_var_req_builder.query(&[("status", ¶m_value.to_string())]);
99 }
100 if let Some(ref param_value) = start_after {
101 local_var_req_builder =
102 local_var_req_builder.query(&[("startAfter", ¶m_value.to_string())]);
103 }
104 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
105
106 bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
107 }
108
109 async fn get_transactions<'a>(
110 &self,
111 start_after: Option<String>,
112 ) -> Result<(), Error<GetTransactionsError>> {
113 let local_var_configuration = &self.configuration;
114
115 let local_var_client = &local_var_configuration.client;
116
117 let local_var_uri_str = format!(
118 "{}/accounts/billing/transactions",
119 local_var_configuration.base_path
120 );
121 let mut local_var_req_builder =
122 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
123
124 if let Some(ref param_value) = start_after {
125 local_var_req_builder =
126 local_var_req_builder.query(&[("startAfter", ¶m_value.to_string())]);
127 }
128 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
129
130 bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
131 }
132}
133
134#[derive(Debug, Clone, Serialize, Deserialize)]
136#[serde(untagged)]
137pub enum GetBillingHistoryError {
138 UnknownValue(serde_json::Value),
139}
140#[derive(Debug, Clone, Serialize, Deserialize)]
142#[serde(untagged)]
143pub enum GetInvoicesError {
144 UnknownValue(serde_json::Value),
145}
146#[derive(Debug, Clone, Serialize, Deserialize)]
148#[serde(untagged)]
149pub enum GetTransactionsError {
150 UnknownValue(serde_json::Value),
151}