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::{de::Error as _, Deserialize, Serialize};
13
14use super::{configuration, ContentType, 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    // add a prefix to parameters to efficiently prevent name collisions
50    let p_provider_id = provider_id;
51
52    let uri_str = format!(
53        "{}/providers/{providerId}/billing/invoices",
54        configuration.base_path,
55        providerId = crate::apis::urlencode(p_provider_id.to_string())
56    );
57    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
58
59    if let Some(ref user_agent) = configuration.user_agent {
60        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
61    }
62    if let Some(ref token) = configuration.oauth_access_token {
63        req_builder = req_builder.bearer_auth(token.to_owned());
64    };
65
66    let req = req_builder.build()?;
67    let resp = configuration.client.execute(req).await?;
68
69    let status = resp.status();
70
71    if !status.is_client_error() && !status.is_server_error() {
72        Ok(())
73    } else {
74        let content = resp.text().await?;
75        let entity: Option<ProvidersProviderIdBillingInvoicesGetError> =
76            serde_json::from_str(&content).ok();
77        Err(Error::ResponseError(ResponseContent {
78            status,
79            content,
80            entity,
81        }))
82    }
83}
84
85pub async fn providers_provider_id_billing_invoices_invoice_id_get(
86    configuration: &configuration::Configuration,
87    provider_id: uuid::Uuid,
88    invoice_id: &str,
89) -> Result<(), Error<ProvidersProviderIdBillingInvoicesInvoiceIdGetError>> {
90    // add a prefix to parameters to efficiently prevent name collisions
91    let p_provider_id = provider_id;
92    let p_invoice_id = invoice_id;
93
94    let uri_str = format!(
95        "{}/providers/{providerId}/billing/invoices/{invoiceId}",
96        configuration.base_path,
97        providerId = crate::apis::urlencode(p_provider_id.to_string()),
98        invoiceId = crate::apis::urlencode(p_invoice_id)
99    );
100    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
101
102    if let Some(ref user_agent) = configuration.user_agent {
103        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
104    }
105    if let Some(ref token) = configuration.oauth_access_token {
106        req_builder = req_builder.bearer_auth(token.to_owned());
107    };
108
109    let req = req_builder.build()?;
110    let resp = configuration.client.execute(req).await?;
111
112    let status = resp.status();
113
114    if !status.is_client_error() && !status.is_server_error() {
115        Ok(())
116    } else {
117        let content = resp.text().await?;
118        let entity: Option<ProvidersProviderIdBillingInvoicesInvoiceIdGetError> =
119            serde_json::from_str(&content).ok();
120        Err(Error::ResponseError(ResponseContent {
121            status,
122            content,
123            entity,
124        }))
125    }
126}
127
128pub async fn providers_provider_id_billing_subscription_get(
129    configuration: &configuration::Configuration,
130    provider_id: uuid::Uuid,
131) -> Result<(), Error<ProvidersProviderIdBillingSubscriptionGetError>> {
132    // add a prefix to parameters to efficiently prevent name collisions
133    let p_provider_id = provider_id;
134
135    let uri_str = format!(
136        "{}/providers/{providerId}/billing/subscription",
137        configuration.base_path,
138        providerId = crate::apis::urlencode(p_provider_id.to_string())
139    );
140    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
141
142    if let Some(ref user_agent) = configuration.user_agent {
143        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
144    }
145    if let Some(ref token) = configuration.oauth_access_token {
146        req_builder = req_builder.bearer_auth(token.to_owned());
147    };
148
149    let req = req_builder.build()?;
150    let resp = configuration.client.execute(req).await?;
151
152    let status = resp.status();
153
154    if !status.is_client_error() && !status.is_server_error() {
155        Ok(())
156    } else {
157        let content = resp.text().await?;
158        let entity: Option<ProvidersProviderIdBillingSubscriptionGetError> =
159            serde_json::from_str(&content).ok();
160        Err(Error::ResponseError(ResponseContent {
161            status,
162            content,
163            entity,
164        }))
165    }
166}
167
168pub async fn providers_provider_id_billing_tax_information_put(
169    configuration: &configuration::Configuration,
170    provider_id: uuid::Uuid,
171    tax_information_request_body: Option<models::TaxInformationRequestBody>,
172) -> Result<(), Error<ProvidersProviderIdBillingTaxInformationPutError>> {
173    // add a prefix to parameters to efficiently prevent name collisions
174    let p_provider_id = provider_id;
175    let p_tax_information_request_body = tax_information_request_body;
176
177    let uri_str = format!(
178        "{}/providers/{providerId}/billing/tax-information",
179        configuration.base_path,
180        providerId = crate::apis::urlencode(p_provider_id.to_string())
181    );
182    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
183
184    if let Some(ref user_agent) = configuration.user_agent {
185        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
186    }
187    if let Some(ref token) = configuration.oauth_access_token {
188        req_builder = req_builder.bearer_auth(token.to_owned());
189    };
190    req_builder = req_builder.json(&p_tax_information_request_body);
191
192    let req = req_builder.build()?;
193    let resp = configuration.client.execute(req).await?;
194
195    let status = resp.status();
196
197    if !status.is_client_error() && !status.is_server_error() {
198        Ok(())
199    } else {
200        let content = resp.text().await?;
201        let entity: Option<ProvidersProviderIdBillingTaxInformationPutError> =
202            serde_json::from_str(&content).ok();
203        Err(Error::ResponseError(ResponseContent {
204            status,
205            content,
206            entity,
207        }))
208    }
209}