highlevel_api/apis/locations/
client.rs1use super::types::*;
2use crate::{error::Result, http::HttpClient};
3use std::sync::Arc;
4
5pub struct LocationsApi {
6 http: Arc<HttpClient>,
7}
8
9impl LocationsApi {
10 pub fn new(http: Arc<HttpClient>) -> Self {
11 Self { http }
12 }
13
14 pub async fn get(&self, location_id: &str) -> Result<GetLocationResponse> {
15 self.http.get(&format!("/locations/{location_id}")).await
16 }
17
18 pub async fn search(&self, params: &SearchLocationsParams) -> Result<SearchLocationsResponse> {
19 self.http.get_with_query("/locations/search", params).await
20 }
21
22 pub async fn create(&self, params: &CreateLocationParams) -> Result<GetLocationResponse> {
23 self.http.post("/locations", params).await
24 }
25
26 pub async fn update(
27 &self,
28 location_id: &str,
29 params: &UpdateLocationParams,
30 ) -> Result<GetLocationResponse> {
31 self.http
32 .put(&format!("/locations/{location_id}"), params)
33 .await
34 }
35
36 pub async fn delete(&self, location_id: &str) -> Result<DeleteLocationResponse> {
37 self.http.delete(&format!("/locations/{location_id}")).await
38 }
39
40 pub async fn get_custom_fields(&self, location_id: &str) -> Result<GetCustomFieldsResponse> {
43 self.http
44 .get(&format!("/locations/{location_id}/customFields"))
45 .await
46 }
47
48 pub async fn get_custom_field(
49 &self,
50 location_id: &str,
51 field_id: &str,
52 ) -> Result<GetCustomFieldResponse> {
53 self.http
54 .get(&format!("/locations/{location_id}/customFields/{field_id}"))
55 .await
56 }
57
58 pub async fn create_custom_field(
59 &self,
60 location_id: &str,
61 params: &CreateCustomFieldParams,
62 ) -> Result<GetCustomFieldResponse> {
63 self.http
64 .post(&format!("/locations/{location_id}/customFields"), params)
65 .await
66 }
67
68 pub async fn update_custom_field(
69 &self,
70 location_id: &str,
71 field_id: &str,
72 params: &CreateCustomFieldParams,
73 ) -> Result<GetCustomFieldResponse> {
74 self.http
75 .put(
76 &format!("/locations/{location_id}/customFields/{field_id}"),
77 params,
78 )
79 .await
80 }
81
82 pub async fn delete_custom_field(&self, location_id: &str, field_id: &str) -> Result<()> {
83 self.http
84 .delete_no_content(&format!("/locations/{location_id}/customFields/{field_id}"))
85 .await
86 }
87
88 pub async fn get_tags(&self, location_id: &str) -> Result<GetTagsResponse> {
91 self.http
92 .get(&format!("/locations/{location_id}/tags"))
93 .await
94 }
95
96 pub async fn get_tag(&self, location_id: &str, tag_id: &str) -> Result<GetTagResponse> {
97 self.http
98 .get(&format!("/locations/{location_id}/tags/{tag_id}"))
99 .await
100 }
101
102 pub async fn create_tag(
103 &self,
104 location_id: &str,
105 params: &CreateTagParams,
106 ) -> Result<GetTagResponse> {
107 self.http
108 .post(&format!("/locations/{location_id}/tags"), params)
109 .await
110 }
111
112 pub async fn update_tag(
113 &self,
114 location_id: &str,
115 tag_id: &str,
116 params: &CreateTagParams,
117 ) -> Result<GetTagResponse> {
118 self.http
119 .put(&format!("/locations/{location_id}/tags/{tag_id}"), params)
120 .await
121 }
122
123 pub async fn delete_tag(&self, location_id: &str, tag_id: &str) -> Result<()> {
124 self.http
125 .delete_no_content(&format!("/locations/{location_id}/tags/{tag_id}"))
126 .await
127 }
128}