highlevel_api/apis/conversations/
client.rs1use super::types::*;
2use crate::{error::Result, http::HttpClient};
3use std::sync::Arc;
4
5pub struct ConversationsApi {
6 http: Arc<HttpClient>,
7}
8
9impl ConversationsApi {
10 pub fn new(http: Arc<HttpClient>) -> Self {
11 Self { http }
12 }
13
14 pub async fn search(
15 &self,
16 params: &SearchConversationsParams,
17 ) -> Result<SearchConversationsResponse> {
18 self.http
19 .get_with_query("/conversations/search", params)
20 .await
21 }
22
23 pub async fn get(&self, conversation_id: &str) -> Result<GetConversationResponse> {
24 self.http
25 .get(&format!("/conversations/{conversation_id}"))
26 .await
27 }
28
29 pub async fn create(
30 &self,
31 params: &CreateConversationParams,
32 ) -> Result<GetConversationResponse> {
33 self.http.post("/conversations", params).await
34 }
35
36 pub async fn update(
37 &self,
38 conversation_id: &str,
39 params: &UpdateConversationParams,
40 ) -> Result<GetConversationResponse> {
41 self.http
42 .put(&format!("/conversations/{conversation_id}"), params)
43 .await
44 }
45
46 pub async fn delete(&self, conversation_id: &str) -> Result<DeleteConversationResponse> {
47 self.http
48 .delete(&format!("/conversations/{conversation_id}"))
49 .await
50 }
51
52 pub async fn get_messages(&self, conversation_id: &str) -> Result<GetMessagesResponse> {
53 self.http
54 .get(&format!("/conversations/{conversation_id}/messages"))
55 .await
56 }
57
58 pub async fn send_message(&self, params: &SendMessageParams) -> Result<SendMessageResponse> {
59 self.http.post("/conversations/messages", params).await
60 }
61
62 pub async fn add_inbound_message(
63 &self,
64 params: &SendMessageParams,
65 ) -> Result<SendMessageResponse> {
66 self.http
67 .post("/conversations/messages/inbound", params)
68 .await
69 }
70}