highlevel-api 0.2.0

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

pub struct OpportunitiesApi {
    http: Arc<HttpClient>,
}

impl OpportunitiesApi {
    pub fn new(http: Arc<HttpClient>) -> Self {
        Self { http }
    }

    pub async fn search(
        &self,
        params: &SearchOpportunitiesParams,
    ) -> Result<SearchOpportunitiesResponse> {
        self.http
            .get_with_query("/opportunities/search", params)
            .await
    }

    pub async fn get(&self, opportunity_id: &str) -> Result<GetOpportunityResponse> {
        self.http
            .get(&format!("/opportunities/{opportunity_id}"))
            .await
    }

    pub async fn create(&self, params: &CreateOpportunityParams) -> Result<GetOpportunityResponse> {
        self.http.post("/opportunities", params).await
    }

    pub async fn update(
        &self,
        opportunity_id: &str,
        params: &UpdateOpportunityParams,
    ) -> Result<GetOpportunityResponse> {
        self.http
            .put(&format!("/opportunities/{opportunity_id}"), params)
            .await
    }

    pub async fn delete(&self, opportunity_id: &str) -> Result<DeleteOpportunityResponse> {
        self.http
            .delete(&format!("/opportunities/{opportunity_id}"))
            .await
    }

    pub async fn update_status(
        &self,
        opportunity_id: &str,
        params: &UpdateOpportunityStatusParams,
    ) -> Result<GetOpportunityResponse> {
        self.http
            .put(&format!("/opportunities/{opportunity_id}/status"), params)
            .await
    }
}