highlevel-api 0.2.0

Unofficial Rust SDK for the GoHighLevel (HighLevel) API
Documentation
use super::types::*;
use crate::{error::Result, http::HttpClient};
use std::sync::Arc;

pub struct LinksApi {
    http: Arc<HttpClient>,
}

impl LinksApi {
    pub fn new(http: Arc<HttpClient>) -> Self {
        Self { http }
    }

    pub async fn list(&self, location_id: &str) -> Result<GetLinksResponse> {
        #[derive(serde::Serialize)]
        struct Q<'a> {
            #[serde(rename = "locationId")]
            location_id: &'a str,
        }
        self.http.get_with_query("/links", &Q { location_id }).await
    }

    pub async fn create(&self, params: &CreateLinkParams) -> Result<GetLinkResponse> {
        self.http.post("/links", params).await
    }

    pub async fn update(
        &self,
        link_id: &str,
        params: &UpdateLinkParams,
    ) -> Result<GetLinkResponse> {
        self.http.put(&format!("/links/{link_id}"), params).await
    }

    pub async fn delete(&self, link_id: &str) -> Result<DeleteLinkResponse> {
        self.http.delete(&format!("/links/{link_id}")).await
    }
}