use std::fmt::Write;
use crate::client::client;
use crate::model::{cost, types};
pub async fn cost(
client: &client::Client,
id: types::UUID,
) -> Result<cost::Cost, Box<dyn std::error::Error>> {
Ok(client
.read::<cost::Cost>(&format!("cost-periods/{id}"), None)
.await?)
}
pub async fn costs(
client: &client::Client,
member: Option<types::UUID>,
) -> Result<cost::Costs, Box<dyn std::error::Error>> {
let mut params = String::from("limit=100");
if let Some(member) = member {
write!(params, "&memberId={}", member)?;
}
Ok(client
.read::<cost::Costs>("cost-periods", Some(¶ms))
.await?)
}
#[cfg(test)]
mod tests;