use std::sync::Arc;
use crate::{error::Result, model::*, transport::*};
pub struct ConversationsResource {
pub(crate) t: Arc<Transport>,
}
impl ConversationsResource {
pub async fn create(&self, req: ConversationCreateRequest) -> Result<Conversation> {
self.t.post(&path_conversations(), &req).await
}
pub async fn list(&self, last_id: i64, size: u32) -> Result<PageResult<Conversation>> {
let path = format!("{}?lastId={}&size={}", path_conversations(), last_id, size);
self.t.get(&path).await
}
pub async fn get(&self, id: &str) -> Result<Conversation> {
self.t.get(&path_conversation(id)).await
}
pub async fn update(&self, id: &str, req: ConversationUpdateRequest) -> Result<Conversation> {
self.t.patch(&path_conversation(id), &req).await
}
pub async fn delete(&self, id: &str) -> Result<()> {
self.t.delete(&path_conversation(id)).await
}
pub async fn messages(&self, id: &str, last_id: i64, size: u32) -> Result<PageResult<Message>> {
let path = format!("{}?lastId={}&size={}", path_messages(id), last_id, size);
self.t.get(&path).await
}
}