Skip to main content

highlevel_api/apis/links/
client.rs

1use super::types::*;
2use crate::{error::Result, http::HttpClient};
3use std::sync::Arc;
4
5pub struct LinksApi {
6    http: Arc<HttpClient>,
7}
8
9impl LinksApi {
10    pub fn new(http: Arc<HttpClient>) -> Self {
11        Self { http }
12    }
13
14    pub async fn list(&self, location_id: &str) -> Result<GetLinksResponse> {
15        #[derive(serde::Serialize)]
16        struct Q<'a> {
17            #[serde(rename = "locationId")]
18            location_id: &'a str,
19        }
20        self.http.get_with_query("/links", &Q { location_id }).await
21    }
22
23    pub async fn create(&self, params: &CreateLinkParams) -> Result<GetLinkResponse> {
24        self.http.post("/links", params).await
25    }
26
27    pub async fn update(
28        &self,
29        link_id: &str,
30        params: &UpdateLinkParams,
31    ) -> Result<GetLinkResponse> {
32        self.http.put(&format!("/links/{link_id}"), params).await
33    }
34
35    pub async fn delete(&self, link_id: &str) -> Result<DeleteLinkResponse> {
36        self.http.delete(&format!("/links/{link_id}")).await
37    }
38}