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    /// POST /organizations/{organizationId}/integrations/slack/complete
30    async fn complete<'a>(
31        &self,
32        organization_id: uuid::Uuid,
33        organization_integration_o_auth_complete_request_model: Option<
34            models::OrganizationIntegrationOAuthCompleteRequestModel,
35        >,
36    ) -> Result<models::OrganizationIntegrationOAuthCompleteResponseModel, Error>;
37
38    /// GET /organizations/integrations/slack/create
39    async fn create<'a>(
40        &self,
41        code: Option<&'a str>,
42        state: Option<&'a str>,
43        error: Option<&'a str>,
44    ) -> Result<(), Error>;
45
46    /// GET /organizations/{organizationId}/integrations/slack/redirect
47    async fn redirect<'a>(
48        &self,
49        organization_id: uuid::Uuid,
50    ) -> Result<models::OrganizationIntegrationOAuthRedirectResponseModel, Error>;
51}
52
53pub struct SlackIntegrationApiClient {
54    configuration: Arc<configuration::Configuration>,
55}
56
57impl SlackIntegrationApiClient {
58    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
59        Self { configuration }
60    }
61}
62
63#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
64#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
65impl SlackIntegrationApi for SlackIntegrationApiClient {
66    async fn complete<'a>(
67        &self,
68        organization_id: uuid::Uuid,
69        organization_integration_o_auth_complete_request_model: Option<
70            models::OrganizationIntegrationOAuthCompleteRequestModel,
71        >,
72    ) -> Result<models::OrganizationIntegrationOAuthCompleteResponseModel, Error> {
73        let local_var_configuration = &self.configuration;
74
75        let local_var_client = &local_var_configuration.client;
76
77        let local_var_uri_str = format!(
78            "{}/organizations/{organizationId}/integrations/slack/complete",
79            local_var_configuration.base_path,
80            organizationId = organization_id
81        );
82        let mut local_var_req_builder =
83            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
84
85        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
86        local_var_req_builder =
87            local_var_req_builder.json(&organization_integration_o_auth_complete_request_model);
88
89        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
90    }
91
92    async fn create<'a>(
93        &self,
94        code: Option<&'a str>,
95        state: Option<&'a str>,
96        error: Option<&'a str>,
97    ) -> Result<(), Error> {
98        let local_var_configuration = &self.configuration;
99
100        let local_var_client = &local_var_configuration.client;
101
102        let local_var_uri_str = format!(
103            "{}/organizations/integrations/slack/create",
104            local_var_configuration.base_path
105        );
106        let mut local_var_req_builder =
107            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
108
109        if let Some(ref param_value) = code {
110            local_var_req_builder =
111                local_var_req_builder.query(&[("code", &param_value.to_string())]);
112        }
113        if let Some(ref param_value) = state {
114            local_var_req_builder =
115                local_var_req_builder.query(&[("state", &param_value.to_string())]);
116        }
117        if let Some(ref param_value) = error {
118            local_var_req_builder =
119                local_var_req_builder.query(&[("error", &param_value.to_string())]);
120        }
121        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
122
123        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
124    }
125
126    async fn redirect<'a>(
127        &self,
128        organization_id: uuid::Uuid,
129    ) -> Result<models::OrganizationIntegrationOAuthRedirectResponseModel, Error> {
130        let local_var_configuration = &self.configuration;
131
132        let local_var_client = &local_var_configuration.client;
133
134        let local_var_uri_str = format!(
135            "{}/organizations/{organizationId}/integrations/slack/redirect",
136            local_var_configuration.base_path,
137            organizationId = organization_id
138        );
139        let mut local_var_req_builder =
140            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
141
142        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
143
144        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
145    }
146}