Skip to main content

bitwarden_api_api/apis/
teams_integration_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 std::sync::Arc;
12
13use async_trait::async_trait;
14#[cfg(feature = "mockall")]
15use mockall::automock;
16use reqwest;
17use serde::{Deserialize, Serialize, de::Error as _};
18
19use super::{Error, configuration};
20use crate::{
21    apis::{AuthRequired, ContentType, ResponseContent},
22    models,
23};
24
25#[cfg_attr(feature = "mockall", automock)]
26#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
27#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
28pub trait TeamsIntegrationApi: Send + Sync {
29    /// GET /organizations/integrations/teams/create
30    async fn create<'a>(&self, code: Option<&'a str>, state: Option<&'a str>) -> Result<(), Error>;
31
32    /// POST /organizations/integrations/teams/incoming
33    async fn incoming_post(&self) -> Result<(), Error>;
34
35    /// GET /organizations/{organizationId}/integrations/teams/redirect
36    async fn redirect<'a>(&self, organization_id: uuid::Uuid) -> Result<(), Error>;
37}
38
39pub struct TeamsIntegrationApiClient {
40    configuration: Arc<configuration::Configuration>,
41}
42
43impl TeamsIntegrationApiClient {
44    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
45        Self { configuration }
46    }
47}
48
49#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
50#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
51impl TeamsIntegrationApi for TeamsIntegrationApiClient {
52    async fn create<'a>(&self, code: Option<&'a str>, state: Option<&'a str>) -> Result<(), Error> {
53        let local_var_configuration = &self.configuration;
54
55        let local_var_client = &local_var_configuration.client;
56
57        let local_var_uri_str = format!(
58            "{}/organizations/integrations/teams/create",
59            local_var_configuration.base_path
60        );
61        let mut local_var_req_builder =
62            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
63
64        if let Some(ref param_value) = code {
65            local_var_req_builder =
66                local_var_req_builder.query(&[("code", &param_value.to_string())]);
67        }
68        if let Some(ref param_value) = state {
69            local_var_req_builder =
70                local_var_req_builder.query(&[("state", &param_value.to_string())]);
71        }
72        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
73
74        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
75    }
76
77    async fn incoming_post(&self) -> Result<(), Error> {
78        let local_var_configuration = &self.configuration;
79
80        let local_var_client = &local_var_configuration.client;
81
82        let local_var_uri_str = format!(
83            "{}/organizations/integrations/teams/incoming",
84            local_var_configuration.base_path
85        );
86        let mut local_var_req_builder =
87            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
88
89        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
90
91        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
92    }
93
94    async fn redirect<'a>(&self, organization_id: uuid::Uuid) -> Result<(), Error> {
95        let local_var_configuration = &self.configuration;
96
97        let local_var_client = &local_var_configuration.client;
98
99        let local_var_uri_str = format!(
100            "{}/organizations/{organizationId}/integrations/teams/redirect",
101            local_var_configuration.base_path,
102            organizationId = organization_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        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
108
109        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
110    }
111}