#![allow(clippy::too_many_arguments)]
use crate::client::Client;
use crate::error::Error;
use crate::generated::routes;
use crate::generated::types::*;
use crate::pagination::Page;
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetClearancesParams {
pub include_clearances: Option<bool>,
pub page: Option<String>,
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetMyClearancesParams {
pub page: Option<String>,
}
pub struct Clearances<'a> {
client: &'a Client,
}
impl<'a> Clearances<'a> {
pub(crate) fn new(client: &'a Client) -> Self {
Self { client }
}
pub fn client(&self) -> &'a Client {
self.client
}
pub async fn bulk_update(
&self,
body: &BulkUpdateClearancesRequestContent,
) -> Result<BulkUpdateClearancesResponseContent, Error> {
let mut operation = self.client.operation(&routes::BULK_UPDATE_CLEARANCES, &[]);
operation.json(body)?;
self.client.send(operation).await
}
pub async fn get(
&self,
params: &GetClearancesParams,
) -> Result<Page<GetClearancesResponseContent>, Error> {
let mut operation = self.client.operation(&routes::GET_CLEARANCES, &[]);
operation.query_optional("include_clearances", params.include_clearances.as_ref());
operation.query_optional("page", params.page.as_ref());
self.client.send_page(operation).await
}
pub async fn get_my(
&self,
params: &GetMyClearancesParams,
) -> Result<Page<GetMyClearancesResponseContent>, Error> {
let mut operation = self.client.operation(&routes::GET_MY_CLEARANCES, &[]);
operation.query_optional("page", params.page.as_ref());
self.client.send_page(operation).await
}
pub async fn punt(&self) -> Result<(), Error> {
let operation = self.client.operation(&routes::PUNT_CLEARANCES, &[]);
self.client.send_unit(operation).await
}
pub async fn update(
&self,
clearance_id: i64,
body: &UpdateClearanceRequestContent,
) -> Result<UpdateClearanceResponseContent, Error> {
let mut operation = self
.client
.operation(&routes::UPDATE_CLEARANCE, &[&clearance_id]);
operation.resource_id(clearance_id);
operation.json(body)?;
self.client.send(operation).await
}
pub async fn update_my(
&self,
clearance_id: i64,
body: &UpdateMyClearanceRequestContent,
) -> Result<UpdateMyClearanceResponseContent, Error> {
let mut operation = self
.client
.operation(&routes::UPDATE_MY_CLEARANCE, &[&clearance_id]);
operation.resource_id(clearance_id);
operation.json(body)?;
self.client.send(operation).await
}
}