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
31pub async fn setup_intent_bank_account_post(
32    configuration: &configuration::Configuration,
33) -> Result<(), Error<SetupIntentBankAccountPostError>> {
34    let local_var_configuration = configuration;
35
36    let local_var_client = &local_var_configuration.client;
37
38    let local_var_uri_str = format!(
39        "{}/setup-intent/bank-account",
40        local_var_configuration.base_path
41    );
42    let mut local_var_req_builder =
43        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
44
45    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
46        local_var_req_builder =
47            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
48    }
49    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
50        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
51    };
52
53    let local_var_req = local_var_req_builder.build()?;
54    let local_var_resp = local_var_client.execute(local_var_req).await?;
55
56    let local_var_status = local_var_resp.status();
57    let local_var_content = local_var_resp.text().await?;
58
59    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
60        Ok(())
61    } else {
62        let local_var_entity: Option<SetupIntentBankAccountPostError> =
63            serde_json::from_str(&local_var_content).ok();
64        let local_var_error = ResponseContent {
65            status: local_var_status,
66            content: local_var_content,
67            entity: local_var_entity,
68        };
69        Err(Error::ResponseError(local_var_error))
70    }
71}
72
73pub async fn setup_intent_card_post(
74    configuration: &configuration::Configuration,
75) -> Result<(), Error<SetupIntentCardPostError>> {
76    let local_var_configuration = configuration;
77
78    let local_var_client = &local_var_configuration.client;
79
80    let local_var_uri_str = format!("{}/setup-intent/card", local_var_configuration.base_path);
81    let mut local_var_req_builder =
82        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
83
84    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
85        local_var_req_builder =
86            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
87    }
88    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
89        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
90    };
91
92    let local_var_req = local_var_req_builder.build()?;
93    let local_var_resp = local_var_client.execute(local_var_req).await?;
94
95    let local_var_status = local_var_resp.status();
96    let local_var_content = local_var_resp.text().await?;
97
98    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
99        Ok(())
100    } else {
101        let local_var_entity: Option<SetupIntentCardPostError> =
102            serde_json::from_str(&local_var_content).ok();
103        let local_var_error = ResponseContent {
104            status: local_var_status,
105            content: local_var_content,
106            entity: local_var_entity,
107        };
108        Err(Error::ResponseError(local_var_error))
109    }
110}