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 BusinessesApi {
    http: Arc<HttpClient>,
}

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

    pub async fn list(&self, location_id: &str) -> Result<GetBusinessesResponse> {
        #[derive(serde::Serialize)]
        struct Q<'a> {
            #[serde(rename = "locationId")]
            location_id: &'a str,
        }
        self.http
            .get_with_query("/businesses", &Q { location_id })
            .await
    }

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

    pub async fn create(&self, params: &CreateBusinessParams) -> Result<GetBusinessResponse> {
        self.http.post("/businesses", params).await
    }

    pub async fn update(
        &self,
        business_id: &str,
        params: &UpdateBusinessParams,
    ) -> Result<GetBusinessResponse> {
        self.http
            .put(&format!("/businesses/{business_id}"), params)
            .await
    }

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