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::{Deserialize, Serialize};
13
14use super::{configuration, 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 local_var_configuration = configuration;
42
43    let local_var_client = &local_var_configuration.client;
44
45    let local_var_uri_str = format!(
46        "{}/setup-intent/bank-account",
47        local_var_configuration.base_path
48    );
49    let mut local_var_req_builder =
50        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
51
52    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
53        local_var_req_builder =
54            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
55    }
56    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
57        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
58    };
59
60    let local_var_req = local_var_req_builder.build()?;
61    let local_var_resp = local_var_client.execute(local_var_req).await?;
62
63    let local_var_status = local_var_resp.status();
64    let local_var_content = local_var_resp.text().await?;
65
66    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
67        Ok(())
68    } else {
69        let local_var_entity: Option<SetupIntentBankAccountPostError> =
70            serde_json::from_str(&local_var_content).ok();
71        let local_var_error = ResponseContent {
72            status: local_var_status,
73            content: local_var_content,
74            entity: local_var_entity,
75        };
76        Err(Error::ResponseError(local_var_error))
77    }
78}
79
80pub async fn setup_intent_card_post(
81    configuration: &configuration::Configuration,
82) -> Result<(), Error<SetupIntentCardPostError>> {
83    let local_var_configuration = configuration;
84
85    let local_var_client = &local_var_configuration.client;
86
87    let local_var_uri_str = format!("{}/setup-intent/card", local_var_configuration.base_path);
88    let mut local_var_req_builder =
89        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
90
91    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
92        local_var_req_builder =
93            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
94    }
95    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
96        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
97    };
98
99    let local_var_req = local_var_req_builder.build()?;
100    let local_var_resp = local_var_client.execute(local_var_req).await?;
101
102    let local_var_status = local_var_resp.status();
103    let local_var_content = local_var_resp.text().await?;
104
105    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
106        Ok(())
107    } else {
108        let local_var_entity: Option<SetupIntentCardPostError> =
109            serde_json::from_str(&local_var_content).ok();
110        let local_var_error = ResponseContent {
111            status: local_var_status,
112            content: local_var_content,
113            entity: local_var_entity,
114        };
115        Err(Error::ResponseError(local_var_error))
116    }
117}
118
119pub async fn tax_is_country_supported_get(
120    configuration: &configuration::Configuration,
121    country: Option<&str>,
122) -> Result<(), Error<TaxIsCountrySupportedGetError>> {
123    let local_var_configuration = configuration;
124
125    let local_var_client = &local_var_configuration.client;
126
127    let local_var_uri_str = format!(
128        "{}/tax/is-country-supported",
129        local_var_configuration.base_path
130    );
131    let mut local_var_req_builder =
132        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
133
134    if let Some(ref local_var_str) = country {
135        local_var_req_builder =
136            local_var_req_builder.query(&[("country", &local_var_str.to_string())]);
137    }
138    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
139        local_var_req_builder =
140            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
141    }
142    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
143        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
144    };
145
146    let local_var_req = local_var_req_builder.build()?;
147    let local_var_resp = local_var_client.execute(local_var_req).await?;
148
149    let local_var_status = local_var_resp.status();
150    let local_var_content = local_var_resp.text().await?;
151
152    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
153        Ok(())
154    } else {
155        let local_var_entity: Option<TaxIsCountrySupportedGetError> =
156            serde_json::from_str(&local_var_content).ok();
157        let local_var_error = ResponseContent {
158            status: local_var_status,
159            content: local_var_content,
160            entity: local_var_entity,
161        };
162        Err(Error::ResponseError(local_var_error))
163    }
164}