bitwarden_api_api/apis/
stripe_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 [`setup_intent_bank_account_post`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum SetupIntentBankAccountPostError {
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`setup_intent_card_post`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum SetupIntentCardPostError {
28    UnknownValue(serde_json::Value),
29}
30
31/// struct for typed errors of method [`tax_is_country_supported_get`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum TaxIsCountrySupportedGetError {
35    UnknownValue(serde_json::Value),
36}
37
38pub async fn setup_intent_bank_account_post(
39    configuration: &configuration::Configuration,
40) -> Result<(), Error<SetupIntentBankAccountPostError>> {
41    let uri_str = format!("{}/setup-intent/bank-account", configuration.base_path);
42    let mut req_builder = configuration
43        .client
44        .request(reqwest::Method::POST, &uri_str);
45
46    if let Some(ref user_agent) = configuration.user_agent {
47        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
48    }
49    if let Some(ref token) = configuration.oauth_access_token {
50        req_builder = req_builder.bearer_auth(token.to_owned());
51    };
52
53    let req = req_builder.build()?;
54    let resp = configuration.client.execute(req).await?;
55
56    let status = resp.status();
57
58    if !status.is_client_error() && !status.is_server_error() {
59        Ok(())
60    } else {
61        let content = resp.text().await?;
62        let entity: Option<SetupIntentBankAccountPostError> = serde_json::from_str(&content).ok();
63        Err(Error::ResponseError(ResponseContent {
64            status,
65            content,
66            entity,
67        }))
68    }
69}
70
71pub async fn setup_intent_card_post(
72    configuration: &configuration::Configuration,
73) -> Result<(), Error<SetupIntentCardPostError>> {
74    let uri_str = format!("{}/setup-intent/card", configuration.base_path);
75    let mut req_builder = configuration
76        .client
77        .request(reqwest::Method::POST, &uri_str);
78
79    if let Some(ref user_agent) = configuration.user_agent {
80        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
81    }
82    if let Some(ref token) = configuration.oauth_access_token {
83        req_builder = req_builder.bearer_auth(token.to_owned());
84    };
85
86    let req = req_builder.build()?;
87    let resp = configuration.client.execute(req).await?;
88
89    let status = resp.status();
90
91    if !status.is_client_error() && !status.is_server_error() {
92        Ok(())
93    } else {
94        let content = resp.text().await?;
95        let entity: Option<SetupIntentCardPostError> = serde_json::from_str(&content).ok();
96        Err(Error::ResponseError(ResponseContent {
97            status,
98            content,
99            entity,
100        }))
101    }
102}
103
104pub async fn tax_is_country_supported_get(
105    configuration: &configuration::Configuration,
106    country: Option<&str>,
107) -> Result<(), Error<TaxIsCountrySupportedGetError>> {
108    // add a prefix to parameters to efficiently prevent name collisions
109    let p_country = country;
110
111    let uri_str = format!("{}/tax/is-country-supported", configuration.base_path);
112    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
113
114    if let Some(ref param_value) = p_country {
115        req_builder = req_builder.query(&[("country", &param_value.to_string())]);
116    }
117    if let Some(ref user_agent) = configuration.user_agent {
118        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
119    }
120    if let Some(ref token) = configuration.oauth_access_token {
121        req_builder = req_builder.bearer_auth(token.to_owned());
122    };
123
124    let req = req_builder.build()?;
125    let resp = configuration.client.execute(req).await?;
126
127    let status = resp.status();
128
129    if !status.is_client_error() && !status.is_server_error() {
130        Ok(())
131    } else {
132        let content = resp.text().await?;
133        let entity: Option<TaxIsCountrySupportedGetError> = serde_json::from_str(&content).ok();
134        Err(Error::ResponseError(ResponseContent {
135            status,
136            content,
137            entity,
138        }))
139    }
140}