Skip to main content

bitwarden_api_api/apis/
slack_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 SlackIntegrationApi: Send + Sync {
29    /// GET /organizations/integrations/slack/create
30    async fn create<'a>(&self, code: Option<&'a str>, state: Option<&'a str>) -> Result<(), Error>;
31
32    /// GET /organizations/{organizationId}/integrations/slack/redirect
33    async fn redirect<'a>(&self, organization_id: uuid::Uuid) -> Result<(), Error>;
34}
35
36pub struct SlackIntegrationApiClient {
37    configuration: Arc<configuration::Configuration>,
38}
39
40impl SlackIntegrationApiClient {
41    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
42        Self { configuration }
43    }
44}
45
46#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
47#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
48impl SlackIntegrationApi for SlackIntegrationApiClient {
49    async fn create<'a>(&self, code: Option<&'a str>, state: Option<&'a str>) -> Result<(), Error> {
50        let local_var_configuration = &self.configuration;
51
52        let local_var_client = &local_var_configuration.client;
53
54        let local_var_uri_str = format!(
55            "{}/organizations/integrations/slack/create",
56            local_var_configuration.base_path
57        );
58        let mut local_var_req_builder =
59            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
60
61        if let Some(ref param_value) = code {
62            local_var_req_builder =
63                local_var_req_builder.query(&[("code", &param_value.to_string())]);
64        }
65        if let Some(ref param_value) = state {
66            local_var_req_builder =
67                local_var_req_builder.query(&[("state", &param_value.to_string())]);
68        }
69        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
70
71        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
72    }
73
74    async fn redirect<'a>(&self, organization_id: uuid::Uuid) -> Result<(), Error> {
75        let local_var_configuration = &self.configuration;
76
77        let local_var_client = &local_var_configuration.client;
78
79        let local_var_uri_str = format!(
80            "{}/organizations/{organizationId}/integrations/slack/redirect",
81            local_var_configuration.base_path,
82            organizationId = organization_id
83        );
84        let mut local_var_req_builder =
85            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
86
87        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
88
89        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
90    }
91}