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

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

    pub async fn list(&self, params: &GetProductsParams) -> Result<GetProductsResponse> {
        self.http.get_with_query("/products", params).await
    }

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

    pub async fn create(&self, params: &CreateProductParams) -> Result<GetProductResponse> {
        self.http.post("/products", params).await
    }

    pub async fn update(
        &self,
        product_id: &str,
        params: &CreateProductParams,
    ) -> Result<GetProductResponse> {
        self.http
            .put(&format!("/products/{product_id}"), params)
            .await
    }

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

    // ── Prices ────────────────────────────────────────────────────────────────

    pub async fn list_prices(&self, product_id: &str) -> Result<ListPricesResponse> {
        self.http
            .get(&format!("/products/{product_id}/prices"))
            .await
    }

    pub async fn create_price(
        &self,
        product_id: &str,
        params: &CreatePriceParams,
    ) -> Result<ProductPrice> {
        self.http
            .post(&format!("/products/{product_id}/prices"), params)
            .await
    }
}