Skip to main content

bitwarden_api_api/apis/
provider_billing_v_next_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 ProviderBillingVNextApi: Send + Sync {
29    /// POST /providers/{providerId}/billing/vnext/credit/bitpay
30    async fn add_credit_via_bit_pay<'a>(
31        &self,
32        provider_id: &'a str,
33        bit_pay_credit_request: Option<models::BitPayCreditRequest>,
34    ) -> Result<(), Error<AddCreditViaBitPayError>>;
35
36    /// GET /providers/{providerId}/billing/vnext/address
37    async fn get_billing_address<'a>(
38        &self,
39        provider_id: &'a str,
40    ) -> Result<(), Error<GetBillingAddressError>>;
41
42    /// GET /providers/{providerId}/billing/vnext/credit
43    async fn get_credit<'a>(&self, provider_id: &'a str) -> Result<(), Error<GetCreditError>>;
44
45    /// GET /providers/{providerId}/billing/vnext/payment-method
46    async fn get_payment_method<'a>(
47        &self,
48        provider_id: &'a str,
49    ) -> Result<(), Error<GetPaymentMethodError>>;
50
51    /// GET /providers/{providerId}/billing/vnext/warnings
52    async fn get_warnings<'a>(&self, provider_id: &'a str) -> Result<(), Error<GetWarningsError>>;
53
54    /// PUT /providers/{providerId}/billing/vnext/address
55    async fn update_billing_address<'a>(
56        &self,
57        provider_id: &'a str,
58        billing_address_request: Option<models::BillingAddressRequest>,
59    ) -> Result<(), Error<UpdateBillingAddressError>>;
60
61    /// PUT /providers/{providerId}/billing/vnext/payment-method
62    async fn update_payment_method<'a>(
63        &self,
64        provider_id: &'a str,
65        tokenized_payment_method_request: Option<models::TokenizedPaymentMethodRequest>,
66    ) -> Result<(), Error<UpdatePaymentMethodError>>;
67}
68
69pub struct ProviderBillingVNextApiClient {
70    configuration: Arc<configuration::Configuration>,
71}
72
73impl ProviderBillingVNextApiClient {
74    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
75        Self { configuration }
76    }
77}
78
79#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
80#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
81impl ProviderBillingVNextApi for ProviderBillingVNextApiClient {
82    async fn add_credit_via_bit_pay<'a>(
83        &self,
84        provider_id: &'a str,
85        bit_pay_credit_request: Option<models::BitPayCreditRequest>,
86    ) -> Result<(), Error<AddCreditViaBitPayError>> {
87        let local_var_configuration = &self.configuration;
88
89        let local_var_client = &local_var_configuration.client;
90
91        let local_var_uri_str = format!(
92            "{}/providers/{providerId}/billing/vnext/credit/bitpay",
93            local_var_configuration.base_path,
94            providerId = crate::apis::urlencode(provider_id)
95        );
96        let mut local_var_req_builder =
97            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
98
99        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
100        local_var_req_builder = local_var_req_builder.json(&bit_pay_credit_request);
101
102        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
103    }
104
105    async fn get_billing_address<'a>(
106        &self,
107        provider_id: &'a str,
108    ) -> Result<(), Error<GetBillingAddressError>> {
109        let local_var_configuration = &self.configuration;
110
111        let local_var_client = &local_var_configuration.client;
112
113        let local_var_uri_str = format!(
114            "{}/providers/{providerId}/billing/vnext/address",
115            local_var_configuration.base_path,
116            providerId = crate::apis::urlencode(provider_id)
117        );
118        let mut local_var_req_builder =
119            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
120
121        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
122
123        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
124    }
125
126    async fn get_credit<'a>(&self, provider_id: &'a str) -> Result<(), Error<GetCreditError>> {
127        let local_var_configuration = &self.configuration;
128
129        let local_var_client = &local_var_configuration.client;
130
131        let local_var_uri_str = format!(
132            "{}/providers/{providerId}/billing/vnext/credit",
133            local_var_configuration.base_path,
134            providerId = crate::apis::urlencode(provider_id)
135        );
136        let mut local_var_req_builder =
137            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
138
139        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
140
141        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
142    }
143
144    async fn get_payment_method<'a>(
145        &self,
146        provider_id: &'a str,
147    ) -> Result<(), Error<GetPaymentMethodError>> {
148        let local_var_configuration = &self.configuration;
149
150        let local_var_client = &local_var_configuration.client;
151
152        let local_var_uri_str = format!(
153            "{}/providers/{providerId}/billing/vnext/payment-method",
154            local_var_configuration.base_path,
155            providerId = crate::apis::urlencode(provider_id)
156        );
157        let mut local_var_req_builder =
158            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
159
160        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
161
162        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
163    }
164
165    async fn get_warnings<'a>(&self, provider_id: &'a str) -> Result<(), Error<GetWarningsError>> {
166        let local_var_configuration = &self.configuration;
167
168        let local_var_client = &local_var_configuration.client;
169
170        let local_var_uri_str = format!(
171            "{}/providers/{providerId}/billing/vnext/warnings",
172            local_var_configuration.base_path,
173            providerId = crate::apis::urlencode(provider_id)
174        );
175        let mut local_var_req_builder =
176            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
177
178        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
179
180        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
181    }
182
183    async fn update_billing_address<'a>(
184        &self,
185        provider_id: &'a str,
186        billing_address_request: Option<models::BillingAddressRequest>,
187    ) -> Result<(), Error<UpdateBillingAddressError>> {
188        let local_var_configuration = &self.configuration;
189
190        let local_var_client = &local_var_configuration.client;
191
192        let local_var_uri_str = format!(
193            "{}/providers/{providerId}/billing/vnext/address",
194            local_var_configuration.base_path,
195            providerId = crate::apis::urlencode(provider_id)
196        );
197        let mut local_var_req_builder =
198            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
199
200        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
201        local_var_req_builder = local_var_req_builder.json(&billing_address_request);
202
203        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
204    }
205
206    async fn update_payment_method<'a>(
207        &self,
208        provider_id: &'a str,
209        tokenized_payment_method_request: Option<models::TokenizedPaymentMethodRequest>,
210    ) -> Result<(), Error<UpdatePaymentMethodError>> {
211        let local_var_configuration = &self.configuration;
212
213        let local_var_client = &local_var_configuration.client;
214
215        let local_var_uri_str = format!(
216            "{}/providers/{providerId}/billing/vnext/payment-method",
217            local_var_configuration.base_path,
218            providerId = crate::apis::urlencode(provider_id)
219        );
220        let mut local_var_req_builder =
221            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
222
223        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
224        local_var_req_builder = local_var_req_builder.json(&tokenized_payment_method_request);
225
226        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
227    }
228}
229
230/// struct for typed errors of method [`ProviderBillingVNextApi::add_credit_via_bit_pay`]
231#[derive(Debug, Clone, Serialize, Deserialize)]
232#[serde(untagged)]
233pub enum AddCreditViaBitPayError {
234    UnknownValue(serde_json::Value),
235}
236/// struct for typed errors of method [`ProviderBillingVNextApi::get_billing_address`]
237#[derive(Debug, Clone, Serialize, Deserialize)]
238#[serde(untagged)]
239pub enum GetBillingAddressError {
240    UnknownValue(serde_json::Value),
241}
242/// struct for typed errors of method [`ProviderBillingVNextApi::get_credit`]
243#[derive(Debug, Clone, Serialize, Deserialize)]
244#[serde(untagged)]
245pub enum GetCreditError {
246    UnknownValue(serde_json::Value),
247}
248/// struct for typed errors of method [`ProviderBillingVNextApi::get_payment_method`]
249#[derive(Debug, Clone, Serialize, Deserialize)]
250#[serde(untagged)]
251pub enum GetPaymentMethodError {
252    UnknownValue(serde_json::Value),
253}
254/// struct for typed errors of method [`ProviderBillingVNextApi::get_warnings`]
255#[derive(Debug, Clone, Serialize, Deserialize)]
256#[serde(untagged)]
257pub enum GetWarningsError {
258    UnknownValue(serde_json::Value),
259}
260/// struct for typed errors of method [`ProviderBillingVNextApi::update_billing_address`]
261#[derive(Debug, Clone, Serialize, Deserialize)]
262#[serde(untagged)]
263pub enum UpdateBillingAddressError {
264    UnknownValue(serde_json::Value),
265}
266/// struct for typed errors of method [`ProviderBillingVNextApi::update_payment_method`]
267#[derive(Debug, Clone, Serialize, Deserialize)]
268#[serde(untagged)]
269pub enum UpdatePaymentMethodError {
270    UnknownValue(serde_json::Value),
271}