highlevel-api 0.1.0

Unofficial Rust SDK for the GoHighLevel (HighLevel) API
Documentation
use std::sync::Arc;
use crate::{error::Result, http::HttpClient};
use super::types::*;

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
    }
}