highlevel_api/apis/products/
client.rs1use std::sync::Arc;
2use crate::{error::Result, http::HttpClient};
3use super::types::*;
4
5pub struct ProductsApi {
6 http: Arc<HttpClient>,
7}
8
9impl ProductsApi {
10 pub fn new(http: Arc<HttpClient>) -> Self {
11 Self { http }
12 }
13
14 pub async fn list(&self, params: &GetProductsParams) -> Result<GetProductsResponse> {
15 self.http.get_with_query("/products", params).await
16 }
17
18 pub async fn get(&self, product_id: &str) -> Result<GetProductResponse> {
19 self.http.get(&format!("/products/{product_id}")).await
20 }
21
22 pub async fn create(&self, params: &CreateProductParams) -> Result<GetProductResponse> {
23 self.http.post("/products", params).await
24 }
25
26 pub async fn update(
27 &self,
28 product_id: &str,
29 params: &CreateProductParams,
30 ) -> Result<GetProductResponse> {
31 self.http.put(&format!("/products/{product_id}"), params).await
32 }
33
34 pub async fn delete(&self, product_id: &str) -> Result<DeleteProductResponse> {
35 self.http.delete(&format!("/products/{product_id}")).await
36 }
37}