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>;
35
36    /// GET /providers/{providerId}/billing/vnext/address
37    async fn get_billing_address<'a>(&self, provider_id: &'a str) -> Result<(), Error>;
38
39    /// GET /providers/{providerId}/billing/vnext/credit
40    async fn get_credit<'a>(&self, provider_id: &'a str) -> Result<(), Error>;
41
42    /// GET /providers/{providerId}/billing/vnext/payment-method
43    async fn get_payment_method<'a>(&self, provider_id: &'a str) -> Result<(), Error>;
44
45    /// GET /providers/{providerId}/billing/vnext/warnings
46    async fn get_warnings<'a>(&self, provider_id: &'a str) -> Result<(), Error>;
47
48    /// PUT /providers/{providerId}/billing/vnext/address
49    async fn update_billing_address<'a>(
50        &self,
51        provider_id: &'a str,
52        billing_address_request: Option<models::BillingAddressRequest>,
53    ) -> Result<(), Error>;
54
55    /// PUT /providers/{providerId}/billing/vnext/payment-method
56    async fn update_payment_method<'a>(
57        &self,
58        provider_id: &'a str,
59        tokenized_payment_method_request: Option<models::TokenizedPaymentMethodRequest>,
60    ) -> Result<(), Error>;
61}
62
63pub struct ProviderBillingVNextApiClient {
64    configuration: Arc<configuration::Configuration>,
65}
66
67impl ProviderBillingVNextApiClient {
68    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
69        Self { configuration }
70    }
71}
72
73#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
74#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
75impl ProviderBillingVNextApi for ProviderBillingVNextApiClient {
76    async fn add_credit_via_bit_pay<'a>(
77        &self,
78        provider_id: &'a str,
79        bit_pay_credit_request: Option<models::BitPayCreditRequest>,
80    ) -> Result<(), Error> {
81        let local_var_configuration = &self.configuration;
82
83        let local_var_client = &local_var_configuration.client;
84
85        let local_var_uri_str = format!(
86            "{}/providers/{providerId}/billing/vnext/credit/bitpay",
87            local_var_configuration.base_path,
88            providerId = crate::apis::urlencode(provider_id)
89        );
90        let mut local_var_req_builder =
91            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
92
93        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
94        local_var_req_builder = local_var_req_builder.json(&bit_pay_credit_request);
95
96        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
97    }
98
99    async fn get_billing_address<'a>(&self, provider_id: &'a str) -> Result<(), Error> {
100        let local_var_configuration = &self.configuration;
101
102        let local_var_client = &local_var_configuration.client;
103
104        let local_var_uri_str = format!(
105            "{}/providers/{providerId}/billing/vnext/address",
106            local_var_configuration.base_path,
107            providerId = crate::apis::urlencode(provider_id)
108        );
109        let mut local_var_req_builder =
110            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
111
112        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
113
114        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
115    }
116
117    async fn get_credit<'a>(&self, provider_id: &'a str) -> Result<(), Error> {
118        let local_var_configuration = &self.configuration;
119
120        let local_var_client = &local_var_configuration.client;
121
122        let local_var_uri_str = format!(
123            "{}/providers/{providerId}/billing/vnext/credit",
124            local_var_configuration.base_path,
125            providerId = crate::apis::urlencode(provider_id)
126        );
127        let mut local_var_req_builder =
128            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
129
130        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
131
132        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
133    }
134
135    async fn get_payment_method<'a>(&self, provider_id: &'a str) -> Result<(), Error> {
136        let local_var_configuration = &self.configuration;
137
138        let local_var_client = &local_var_configuration.client;
139
140        let local_var_uri_str = format!(
141            "{}/providers/{providerId}/billing/vnext/payment-method",
142            local_var_configuration.base_path,
143            providerId = crate::apis::urlencode(provider_id)
144        );
145        let mut local_var_req_builder =
146            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
147
148        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
149
150        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
151    }
152
153    async fn get_warnings<'a>(&self, provider_id: &'a str) -> Result<(), Error> {
154        let local_var_configuration = &self.configuration;
155
156        let local_var_client = &local_var_configuration.client;
157
158        let local_var_uri_str = format!(
159            "{}/providers/{providerId}/billing/vnext/warnings",
160            local_var_configuration.base_path,
161            providerId = crate::apis::urlencode(provider_id)
162        );
163        let mut local_var_req_builder =
164            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
165
166        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
167
168        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
169    }
170
171    async fn update_billing_address<'a>(
172        &self,
173        provider_id: &'a str,
174        billing_address_request: Option<models::BillingAddressRequest>,
175    ) -> Result<(), Error> {
176        let local_var_configuration = &self.configuration;
177
178        let local_var_client = &local_var_configuration.client;
179
180        let local_var_uri_str = format!(
181            "{}/providers/{providerId}/billing/vnext/address",
182            local_var_configuration.base_path,
183            providerId = crate::apis::urlencode(provider_id)
184        );
185        let mut local_var_req_builder =
186            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
187
188        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
189        local_var_req_builder = local_var_req_builder.json(&billing_address_request);
190
191        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
192    }
193
194    async fn update_payment_method<'a>(
195        &self,
196        provider_id: &'a str,
197        tokenized_payment_method_request: Option<models::TokenizedPaymentMethodRequest>,
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            "{}/providers/{providerId}/billing/vnext/payment-method",
205            local_var_configuration.base_path,
206            providerId = crate::apis::urlencode(provider_id)
207        );
208        let mut local_var_req_builder =
209            local_var_client.request(reqwest::Method::PUT, 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(&tokenized_payment_method_request);
213
214        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
215    }
216}