highlevel_api/apis/businesses/
client.rs1use super::types::*;
2use crate::{error::Result, http::HttpClient};
3use std::sync::Arc;
4
5pub struct BusinessesApi {
6 http: Arc<HttpClient>,
7}
8
9impl BusinessesApi {
10 pub fn new(http: Arc<HttpClient>) -> Self {
11 Self { http }
12 }
13
14 pub async fn list(&self, location_id: &str) -> Result<GetBusinessesResponse> {
15 #[derive(serde::Serialize)]
16 struct Q<'a> {
17 #[serde(rename = "locationId")]
18 location_id: &'a str,
19 }
20 self.http
21 .get_with_query("/businesses", &Q { location_id })
22 .await
23 }
24
25 pub async fn get(&self, business_id: &str) -> Result<GetBusinessResponse> {
26 self.http.get(&format!("/businesses/{business_id}")).await
27 }
28
29 pub async fn create(&self, params: &CreateBusinessParams) -> Result<GetBusinessResponse> {
30 self.http.post("/businesses", params).await
31 }
32
33 pub async fn update(
34 &self,
35 business_id: &str,
36 params: &UpdateBusinessParams,
37 ) -> Result<GetBusinessResponse> {
38 self.http
39 .put(&format!("/businesses/{business_id}"), params)
40 .await
41 }
42
43 pub async fn delete(&self, business_id: &str) -> Result<DeleteBusinessResponse> {
44 self.http
45 .delete(&format!("/businesses/{business_id}"))
46 .await
47 }
48}