use super::types::*;
use crate::{error::Result, http::HttpClient};
use std::sync::Arc;
pub struct ConversationsApi {
http: Arc<HttpClient>,
}
impl ConversationsApi {
pub fn new(http: Arc<HttpClient>) -> Self {
Self { http }
}
pub async fn search(
&self,
params: &SearchConversationsParams,
) -> Result<SearchConversationsResponse> {
self.http
.get_with_query("/conversations/search", params)
.await
}
pub async fn get(&self, conversation_id: &str) -> Result<GetConversationResponse> {
self.http
.get(&format!("/conversations/{conversation_id}"))
.await
}
pub async fn create(
&self,
params: &CreateConversationParams,
) -> Result<GetConversationResponse> {
self.http.post("/conversations", params).await
}
pub async fn update(
&self,
conversation_id: &str,
params: &UpdateConversationParams,
) -> Result<GetConversationResponse> {
self.http
.put(&format!("/conversations/{conversation_id}"), params)
.await
}
pub async fn delete(&self, conversation_id: &str) -> Result<DeleteConversationResponse> {
self.http
.delete(&format!("/conversations/{conversation_id}"))
.await
}
pub async fn get_messages(&self, conversation_id: &str) -> Result<GetMessagesResponse> {
self.http
.get(&format!("/conversations/{conversation_id}/messages"))
.await
}
pub async fn send_message(&self, params: &SendMessageParams) -> Result<SendMessageResponse> {
self.http.post("/conversations/messages", params).await
}
pub async fn add_inbound_message(
&self,
params: &SendMessageParams,
) -> Result<SendMessageResponse> {
self.http
.post("/conversations/messages/inbound", params)
.await
}
}