2021-02-04 16:31:37 +01:00
|
|
|
use crate::backend::{Backend, Result, Work};
|
2020-11-29 00:12:23 +01:00
|
|
|
|
|
|
|
|
impl Backend {
|
|
|
|
|
/// Get all available works from the server.
|
|
|
|
|
pub async fn get_works(&self, composer_id: &str) -> Result<Vec<Work>> {
|
|
|
|
|
let body = self.get(&format!("persons/{}/works", composer_id)).await?;
|
|
|
|
|
let works: Vec<Work> = serde_json::from_str(&body)?;
|
|
|
|
|
Ok(works)
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-29 01:00:19 +01:00
|
|
|
/// Post a new work to the server.
|
2020-11-29 00:12:23 +01:00
|
|
|
pub async fn post_work(&self, data: &Work) -> Result<()> {
|
|
|
|
|
self.post("works", serde_json::to_string(data)?).await?;
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
}
|