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