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, reqwest::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, reqwest::Error> {
let mut params = String::from("limit=100");
if let Some(member) = member {
write!(params, "&memberId={}", member).unwrap();
}
Ok(client
.read::<cost::Costs>("cost-periods", Some(¶ms))
.await?)
}
#[cfg(test)]
mod tests;