use crate::client::Scope;
use crate::error::Error;
use crate::generated::routes;
use crate::generated::types::*;
pub struct ColumnsService<'a> {
scope: Scope<'a>,
}
impl<'a> ColumnsService<'a> {
pub(crate) fn new(scope: Scope<'a>) -> Self {
Self { scope }
}
pub fn scope(&self) -> &Scope<'a> {
&self.scope
}
pub async fn create(
&self,
board_id: &str,
body: &CreateColumnRequestContent,
) -> Result<Column, Error> {
let mut operation = self.scope.operation(&routes::CREATE_COLUMN, &[&board_id])?;
operation.resource_id(board_id);
operation.json(body)?;
self.scope.client().send(operation).await
}
pub async fn delete(&self, board_id: &str, column_id: &str) -> Result<(), Error> {
let mut operation = self
.scope
.operation(&routes::DELETE_COLUMN, &[&board_id, &column_id])?;
operation.resource_id(column_id);
self.scope.client().send_unit(operation).await
}
pub async fn get(&self, board_id: &str, column_id: &str) -> Result<Column, Error> {
let mut operation = self
.scope
.operation(&routes::GET_COLUMN, &[&board_id, &column_id])?;
operation.resource_id(column_id);
self.scope.client().send(operation).await
}
pub async fn list(&self, board_id: &str) -> Result<Vec<Column>, Error> {
let mut operation = self.scope.operation(&routes::LIST_COLUMNS, &[&board_id])?;
operation.resource_id(board_id);
self.scope.client().send(operation).await
}
pub async fn move_left(&self, column_id: &str) -> Result<(), Error> {
let mut operation = self
.scope
.operation(&routes::MOVE_COLUMN_LEFT, &[&column_id])?;
operation.resource_id(column_id);
self.scope.client().send_unit(operation).await
}
pub async fn move_right(&self, column_id: &str) -> Result<(), Error> {
let mut operation = self
.scope
.operation(&routes::MOVE_COLUMN_RIGHT, &[&column_id])?;
operation.resource_id(column_id);
self.scope.client().send_unit(operation).await
}
pub async fn update(
&self,
board_id: &str,
column_id: &str,
body: &UpdateColumnRequestContent,
) -> Result<Column, Error> {
let mut operation = self
.scope
.operation(&routes::UPDATE_COLUMN, &[&board_id, &column_id])?;
operation.resource_id(column_id);
operation.json(body)?;
self.scope.client().send(operation).await
}
}