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 CustomMenusApi {
    http: Arc<HttpClient>,
}

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

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

    pub async fn get(&self, menu_id: &str) -> Result<GetCustomMenuResponse> {
        self.http.get(&format!("/menus/{menu_id}")).await
    }

    pub async fn create(&self, params: &CreateCustomMenuParams) -> Result<GetCustomMenuResponse> {
        self.http.post("/menus", params).await
    }

    pub async fn update(
        &self,
        menu_id: &str,
        params: &CreateCustomMenuParams,
    ) -> Result<GetCustomMenuResponse> {
        self.http.put(&format!("/menus/{menu_id}"), params).await
    }

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