use crate::client::Client;
#[allow(unused_imports)]
use crate::enums::*;
use crate::error::Error;
#[allow(unused_imports)]
use crate::models::*;
use serde::Serialize;
pub struct PipesApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Serialize)]
pub struct AuthorizeDataIntegrationParams {
#[serde(skip)]
pub body: DataIntegrationsGetDataIntegrationAuthorizeUrlRequest,
}
impl AuthorizeDataIntegrationParams {
#[allow(deprecated)]
pub fn new(body: DataIntegrationsGetDataIntegrationAuthorizeUrlRequest) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateDataIntegrationTokenParams {
#[serde(skip)]
pub body: DataIntegrationsGetUserTokenRequest,
}
impl CreateDataIntegrationTokenParams {
#[allow(deprecated)]
pub fn new(body: DataIntegrationsGetUserTokenRequest) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetUserConnectedAccountParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub organization_id: Option<String>,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct DeleteUserConnectedAccountParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub organization_id: Option<String>,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListUserDataProvidersParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub organization_id: Option<String>,
}
impl<'a> PipesApi<'a> {
pub async fn authorize_data_integration(
&self,
slug: &str,
params: AuthorizeDataIntegrationParams,
) -> Result<DataIntegrationAuthorizeUrlResponse, Error> {
self.authorize_data_integration_with_options(slug, params, None)
.await
}
pub async fn authorize_data_integration_with_options(
&self,
slug: &str,
params: AuthorizeDataIntegrationParams,
options: Option<&crate::RequestOptions>,
) -> Result<DataIntegrationAuthorizeUrlResponse, Error> {
let slug = crate::client::path_segment(slug);
let path = format!("/data-integrations/{slug}/authorize");
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn create_data_integration_token(
&self,
slug: &str,
params: CreateDataIntegrationTokenParams,
) -> Result<DataIntegrationAccessTokenResponse, Error> {
self.create_data_integration_token_with_options(slug, params, None)
.await
}
pub async fn create_data_integration_token_with_options(
&self,
slug: &str,
params: CreateDataIntegrationTokenParams,
options: Option<&crate::RequestOptions>,
) -> Result<DataIntegrationAccessTokenResponse, Error> {
let slug = crate::client::path_segment(slug);
let path = format!("/data-integrations/{slug}/token");
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn get_user_connected_account(
&self,
user_id: &str,
slug: &str,
params: GetUserConnectedAccountParams,
) -> Result<ConnectedAccount, Error> {
self.get_user_connected_account_with_options(user_id, slug, params, None)
.await
}
pub async fn get_user_connected_account_with_options(
&self,
user_id: &str,
slug: &str,
params: GetUserConnectedAccountParams,
options: Option<&crate::RequestOptions>,
) -> Result<ConnectedAccount, Error> {
let user_id = crate::client::path_segment(user_id);
let slug = crate::client::path_segment(slug);
let path = format!("/user_management/users/{user_id}/connected_accounts/{slug}");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, ¶ms, options)
.await
}
pub async fn delete_user_connected_account(
&self,
user_id: &str,
slug: &str,
params: DeleteUserConnectedAccountParams,
) -> Result<(), Error> {
self.delete_user_connected_account_with_options(user_id, slug, params, None)
.await
}
pub async fn delete_user_connected_account_with_options(
&self,
user_id: &str,
slug: &str,
params: DeleteUserConnectedAccountParams,
options: Option<&crate::RequestOptions>,
) -> Result<(), Error> {
let user_id = crate::client::path_segment(user_id);
let slug = crate::client::path_segment(slug);
let path = format!("/user_management/users/{user_id}/connected_accounts/{slug}");
let method = http::Method::DELETE;
self.client
.request_with_query_opts_empty(method, &path, ¶ms, options)
.await
}
pub async fn list_user_data_providers(
&self,
user_id: &str,
params: ListUserDataProvidersParams,
) -> Result<DataIntegrationsListResponse, Error> {
self.list_user_data_providers_with_options(user_id, params, None)
.await
}
pub async fn list_user_data_providers_with_options(
&self,
user_id: &str,
params: ListUserDataProvidersParams,
options: Option<&crate::RequestOptions>,
) -> Result<DataIntegrationsListResponse, Error> {
let user_id = crate::client::path_segment(user_id);
let path = format!("/user_management/users/{user_id}/data_providers");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, ¶ms, options)
.await
}
}