highlevel_api/apis/products/
client.rs1use super::types::*;
2use crate::{error::Result, http::HttpClient};
3use std::sync::Arc;
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
32 .put(&format!("/products/{product_id}"), params)
33 .await
34 }
35
36 pub async fn delete(&self, product_id: &str) -> Result<DeleteProductResponse> {
37 self.http.delete(&format!("/products/{product_id}")).await
38 }
39
40 pub async fn list_prices(&self, product_id: &str) -> Result<ListPricesResponse> {
43 self.http
44 .get(&format!("/products/{product_id}/prices"))
45 .await
46 }
47
48 pub async fn create_price(
49 &self,
50 product_id: &str,
51 params: &CreatePriceParams,
52 ) -> Result<ProductPrice> {
53 self.http
54 .post(&format!("/products/{product_id}/prices"), params)
55 .await
56 }
57}