Skip to main content

highlevel_api/apis/custom_menus/
client.rs

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