bitwarden_api_api/apis/
provider_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 [`providers_provider_id_billing_invoices_get`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum ProvidersProviderIdBillingInvoicesGetError {
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`providers_provider_id_billing_invoices_invoice_id_get`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum ProvidersProviderIdBillingInvoicesInvoiceIdGetError {
28    UnknownValue(serde_json::Value),
29}
30
31/// struct for typed errors of method [`providers_provider_id_billing_subscription_get`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum ProvidersProviderIdBillingSubscriptionGetError {
35    UnknownValue(serde_json::Value),
36}
37
38/// struct for typed errors of method [`providers_provider_id_billing_tax_information_put`]
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum ProvidersProviderIdBillingTaxInformationPutError {
42    UnknownValue(serde_json::Value),
43}
44
45pub async fn providers_provider_id_billing_invoices_get(
46    configuration: &configuration::Configuration,
47    provider_id: uuid::Uuid,
48) -> Result<(), Error<ProvidersProviderIdBillingInvoicesGetError>> {
49    let local_var_configuration = configuration;
50
51    let local_var_client = &local_var_configuration.client;
52
53    let local_var_uri_str = format!(
54        "{}/providers/{providerId}/billing/invoices",
55        local_var_configuration.base_path,
56        providerId = crate::apis::urlencode(provider_id.to_string())
57    );
58    let mut local_var_req_builder =
59        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
60
61    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
62        local_var_req_builder =
63            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
64    }
65    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
66        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
67    };
68
69    let local_var_req = local_var_req_builder.build()?;
70    let local_var_resp = local_var_client.execute(local_var_req).await?;
71
72    let local_var_status = local_var_resp.status();
73    let local_var_content = local_var_resp.text().await?;
74
75    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
76        Ok(())
77    } else {
78        let local_var_entity: Option<ProvidersProviderIdBillingInvoicesGetError> =
79            serde_json::from_str(&local_var_content).ok();
80        let local_var_error = ResponseContent {
81            status: local_var_status,
82            content: local_var_content,
83            entity: local_var_entity,
84        };
85        Err(Error::ResponseError(local_var_error))
86    }
87}
88
89pub async fn providers_provider_id_billing_invoices_invoice_id_get(
90    configuration: &configuration::Configuration,
91    provider_id: uuid::Uuid,
92    invoice_id: &str,
93) -> Result<(), Error<ProvidersProviderIdBillingInvoicesInvoiceIdGetError>> {
94    let local_var_configuration = configuration;
95
96    let local_var_client = &local_var_configuration.client;
97
98    let local_var_uri_str = format!(
99        "{}/providers/{providerId}/billing/invoices/{invoiceId}",
100        local_var_configuration.base_path,
101        providerId = crate::apis::urlencode(provider_id.to_string()),
102        invoiceId = crate::apis::urlencode(invoice_id)
103    );
104    let mut local_var_req_builder =
105        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
106
107    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
108        local_var_req_builder =
109            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
110    }
111    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
112        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
113    };
114
115    let local_var_req = local_var_req_builder.build()?;
116    let local_var_resp = local_var_client.execute(local_var_req).await?;
117
118    let local_var_status = local_var_resp.status();
119    let local_var_content = local_var_resp.text().await?;
120
121    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
122        Ok(())
123    } else {
124        let local_var_entity: Option<ProvidersProviderIdBillingInvoicesInvoiceIdGetError> =
125            serde_json::from_str(&local_var_content).ok();
126        let local_var_error = ResponseContent {
127            status: local_var_status,
128            content: local_var_content,
129            entity: local_var_entity,
130        };
131        Err(Error::ResponseError(local_var_error))
132    }
133}
134
135pub async fn providers_provider_id_billing_subscription_get(
136    configuration: &configuration::Configuration,
137    provider_id: uuid::Uuid,
138) -> Result<(), Error<ProvidersProviderIdBillingSubscriptionGetError>> {
139    let local_var_configuration = configuration;
140
141    let local_var_client = &local_var_configuration.client;
142
143    let local_var_uri_str = format!(
144        "{}/providers/{providerId}/billing/subscription",
145        local_var_configuration.base_path,
146        providerId = crate::apis::urlencode(provider_id.to_string())
147    );
148    let mut local_var_req_builder =
149        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
150
151    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
152        local_var_req_builder =
153            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
154    }
155    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
156        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
157    };
158
159    let local_var_req = local_var_req_builder.build()?;
160    let local_var_resp = local_var_client.execute(local_var_req).await?;
161
162    let local_var_status = local_var_resp.status();
163    let local_var_content = local_var_resp.text().await?;
164
165    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
166        Ok(())
167    } else {
168        let local_var_entity: Option<ProvidersProviderIdBillingSubscriptionGetError> =
169            serde_json::from_str(&local_var_content).ok();
170        let local_var_error = ResponseContent {
171            status: local_var_status,
172            content: local_var_content,
173            entity: local_var_entity,
174        };
175        Err(Error::ResponseError(local_var_error))
176    }
177}
178
179pub async fn providers_provider_id_billing_tax_information_put(
180    configuration: &configuration::Configuration,
181    provider_id: uuid::Uuid,
182    tax_information_request_body: Option<models::TaxInformationRequestBody>,
183) -> Result<(), Error<ProvidersProviderIdBillingTaxInformationPutError>> {
184    let local_var_configuration = configuration;
185
186    let local_var_client = &local_var_configuration.client;
187
188    let local_var_uri_str = format!(
189        "{}/providers/{providerId}/billing/tax-information",
190        local_var_configuration.base_path,
191        providerId = crate::apis::urlencode(provider_id.to_string())
192    );
193    let mut local_var_req_builder =
194        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
195
196    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
197        local_var_req_builder =
198            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
199    }
200    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
201        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
202    };
203    local_var_req_builder = local_var_req_builder.json(&tax_information_request_body);
204
205    let local_var_req = local_var_req_builder.build()?;
206    let local_var_resp = local_var_client.execute(local_var_req).await?;
207
208    let local_var_status = local_var_resp.status();
209    let local_var_content = local_var_resp.text().await?;
210
211    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
212        Ok(())
213    } else {
214        let local_var_entity: Option<ProvidersProviderIdBillingTaxInformationPutError> =
215            serde_json::from_str(&local_var_content).ok();
216        let local_var_error = ResponseContent {
217            status: local_var_status,
218            content: local_var_content,
219            entity: local_var_entity,
220        };
221        Err(Error::ResponseError(local_var_error))
222    }
223}