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>(
31        &self,
32        code: Option<&'a str>,
33        state: Option<&'a str>,
34    ) -> Result<(), Error<CreateError>>;
35
36    /// GET /organizations/{organizationId}/integrations/slack/redirect
37    async fn redirect<'a>(&self, organization_id: uuid::Uuid) -> Result<(), Error<RedirectError>>;
38}
39
40pub struct SlackIntegrationApiClient {
41    configuration: Arc<configuration::Configuration>,
42}
43
44impl SlackIntegrationApiClient {
45    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
46        Self { configuration }
47    }
48}
49
50#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
51#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
52impl SlackIntegrationApi for SlackIntegrationApiClient {
53    async fn create<'a>(
54        &self,
55        code: Option<&'a str>,
56        state: Option<&'a str>,
57    ) -> Result<(), Error<CreateError>> {
58        let local_var_configuration = &self.configuration;
59
60        let local_var_client = &local_var_configuration.client;
61
62        let local_var_uri_str = format!(
63            "{}/organizations/integrations/slack/create",
64            local_var_configuration.base_path
65        );
66        let mut local_var_req_builder =
67            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
68
69        if let Some(ref param_value) = code {
70            local_var_req_builder =
71                local_var_req_builder.query(&[("code", &param_value.to_string())]);
72        }
73        if let Some(ref param_value) = state {
74            local_var_req_builder =
75                local_var_req_builder.query(&[("state", &param_value.to_string())]);
76        }
77        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
78
79        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
80    }
81
82    async fn redirect<'a>(&self, organization_id: uuid::Uuid) -> Result<(), Error<RedirectError>> {
83        let local_var_configuration = &self.configuration;
84
85        let local_var_client = &local_var_configuration.client;
86
87        let local_var_uri_str = format!(
88            "{}/organizations/{organizationId}/integrations/slack/redirect",
89            local_var_configuration.base_path,
90            organizationId = organization_id
91        );
92        let mut local_var_req_builder =
93            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
94
95        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
96
97        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
98    }
99}
100
101/// struct for typed errors of method [`SlackIntegrationApi::create`]
102#[derive(Debug, Clone, Serialize, Deserialize)]
103#[serde(untagged)]
104pub enum CreateError {
105    UnknownValue(serde_json::Value),
106}
107/// struct for typed errors of method [`SlackIntegrationApi::redirect`]
108#[derive(Debug, Clone, Serialize, Deserialize)]
109#[serde(untagged)]
110pub enum RedirectError {
111    UnknownValue(serde_json::Value),
112}