use super::{configuration, ContentType, Error};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};
#[derive(Clone, Debug, Default)]
pub struct LinkedSignerControllerGetAccountQuotaParams {
pub subaccount_id: String,
}
#[derive(Clone, Debug, Default)]
pub struct LinkedSignerControllerGetSignerParams {
pub id: String,
}
#[derive(Clone, Debug, Default)]
pub struct LinkedSignerControllerLinkSignerParams {
pub link_signer_dto: models::LinkSignerDto,
}
#[derive(Clone, Debug, Default)]
pub struct LinkedSignerControllerListBySubaccountIdParams {
pub subaccount_id: String,
pub order: Option<String>,
pub limit: Option<f64>,
pub cursor: Option<String>,
pub statuses: Option<Vec<String>>,
pub order_by: Option<String>,
}
#[derive(Clone, Debug, Default)]
pub struct LinkedSignerControllerRefreshSignerParams {
pub refresh_linked_signer_dto: models::RefreshLinkedSignerDto,
}
#[derive(Clone, Debug, Default)]
pub struct LinkedSignerControllerRevokeSignerParams {
pub revoke_linked_signer_dto: models::RevokeLinkedSignerDto,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LinkedSignerControllerGetAccountQuotaError {
Status400(models::BadRequestDto),
Status401(models::UnauthorizedDto),
Status403(models::ForbiddenDto),
Status404(models::NotFoundDto),
Status422(models::UnprocessableEntityDto),
Status429(models::TooManyRequestsDto),
Status500(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LinkedSignerControllerGetSignerError {
Status400(models::BadRequestDto),
Status401(models::UnauthorizedDto),
Status403(models::ForbiddenDto),
Status404(models::NotFoundDto),
Status422(models::UnprocessableEntityDto),
Status429(models::TooManyRequestsDto),
Status500(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LinkedSignerControllerLinkSignerError {
Status400(models::BadRequestDto),
Status401(models::UnauthorizedDto),
Status403(models::ForbiddenDto),
Status404(models::NotFoundDto),
Status422(models::UnprocessableEntityDto),
Status429(models::TooManyRequestsDto),
Status500(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LinkedSignerControllerListBySubaccountIdError {
Status400(models::BadRequestDto),
Status401(models::UnauthorizedDto),
Status403(models::ForbiddenDto),
Status404(models::NotFoundDto),
Status422(models::UnprocessableEntityDto),
Status429(models::TooManyRequestsDto),
Status500(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LinkedSignerControllerRefreshSignerError {
Status400(models::BadRequestDto),
Status401(models::UnauthorizedDto),
Status403(models::ForbiddenDto),
Status404(models::NotFoundDto),
Status422(models::UnprocessableEntityDto),
Status429(models::TooManyRequestsDto),
Status500(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LinkedSignerControllerRevokeSignerError {
Status400(models::BadRequestDto),
Status401(models::UnauthorizedDto),
Status403(models::ForbiddenDto),
Status404(models::NotFoundDto),
Status422(models::UnprocessableEntityDto),
Status429(models::TooManyRequestsDto),
Status500(),
UnknownValue(serde_json::Value),
}
pub async fn linked_signer_controller_get_account_quota(
configuration: &configuration::Configuration,
params: LinkedSignerControllerGetAccountQuotaParams,
) -> Result<models::AccountSignerQuotaDto, Error<LinkedSignerControllerGetAccountQuotaError>> {
let uri_str = format!("{}/v1/linked-signer/quota", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("subaccountId", ¶ms.subaccount_id.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccountSignerQuotaDto`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccountSignerQuotaDto`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LinkedSignerControllerGetAccountQuotaError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn linked_signer_controller_get_signer(
configuration: &configuration::Configuration,
params: LinkedSignerControllerGetSignerParams,
) -> Result<models::SignerDto, Error<LinkedSignerControllerGetSignerError>> {
let uri_str = format!(
"{}/v1/linked-signer/{id}",
configuration.base_path,
id = crate::apis::urlencode(params.id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SignerDto`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SignerDto`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LinkedSignerControllerGetSignerError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn linked_signer_controller_link_signer(
configuration: &configuration::Configuration,
params: LinkedSignerControllerLinkSignerParams,
) -> Result<models::SignerDto, Error<LinkedSignerControllerLinkSignerError>> {
let uri_str = format!("{}/v1/linked-signer/link", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(¶ms.link_signer_dto);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SignerDto`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SignerDto`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LinkedSignerControllerLinkSignerError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn linked_signer_controller_list_by_subaccount_id(
configuration: &configuration::Configuration,
params: LinkedSignerControllerListBySubaccountIdParams,
) -> Result<models::PageOfSignersDto, Error<LinkedSignerControllerListBySubaccountIdError>> {
let uri_str = format!("{}/v1/linked-signer", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = params.order {
req_builder = req_builder.query(&[("order", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.cursor {
req_builder = req_builder.query(&[("cursor", ¶m_value.to_string())]);
}
req_builder = req_builder.query(&[("subaccountId", ¶ms.subaccount_id.to_string())]);
if let Some(ref param_value) = params.statuses {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("statuses".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"statuses",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = params.order_by {
req_builder = req_builder.query(&[("orderBy", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PageOfSignersDto`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PageOfSignersDto`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LinkedSignerControllerListBySubaccountIdError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn linked_signer_controller_refresh_signer(
configuration: &configuration::Configuration,
params: LinkedSignerControllerRefreshSignerParams,
) -> Result<models::SignerDto, Error<LinkedSignerControllerRefreshSignerError>> {
let uri_str = format!("{}/v1/linked-signer/refresh", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(¶ms.refresh_linked_signer_dto);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SignerDto`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SignerDto`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LinkedSignerControllerRefreshSignerError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn linked_signer_controller_revoke_signer(
configuration: &configuration::Configuration,
params: LinkedSignerControllerRevokeSignerParams,
) -> Result<models::SignerDto, Error<LinkedSignerControllerRevokeSignerError>> {
let uri_str = format!("{}/v1/linked-signer/revoke", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(¶ms.revoke_linked_signer_dto);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SignerDto`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SignerDto`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LinkedSignerControllerRevokeSignerError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}