1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
// @generated by xtask/generate_services.py — do not edit by hand.
//! `custom-menus` — typed methods for all 5 API v3 operations
//! in this module.
//!
//! Access via [`Ghl::v3`](crate::Ghl::v3)`().custom_menus()`. These endpoints send `Version: v3`.
//!
//! Request and response types come from [`ghl_models::v3::custom_menus`](https://docs.rs/ghl-models/latest/ghl_models/v3/custom_menus/); every endpoint is also documented in the
//! [`custom-menus` API reference](https://github.com/Shahroz/ghl-rs/blob/main/docs/api/custom-menus.md).
//!
//! Enable with `features = ["custom-menus"]`.
#![allow(clippy::too_many_arguments)]
use crate::client::Ghl;
use crate::error::Result;
use ghl_models::v3::custom_menus as models;
/// Typed access to the `custom-menus` API v3 surface (5 operations). Obtained via
/// [`Ghl::v3`](crate::Ghl::v3)`().custom_menus()`.
#[derive(Debug, Clone)]
pub struct CustomMenusService {
pub(crate) client: Ghl,
}
impl CustomMenusService {
pub(crate) fn new(client: Ghl) -> Self {
Self { client }
}
}
/// Query parameters for [`CustomMenusService::get_custom_menu_links`].
#[derive(Debug, Clone, Default)]
pub struct GetCustomMenuLinksParams {
/// Unique identifier of the location
pub location_id: Option<String>,
/// Number of items to skip for pagination
pub skip: Option<f64>,
/// Maximum number of items to return
pub limit: Option<f64>,
/// Search query to filter custom menus by name, supports partial || full names
pub query: Option<String>,
/// Filter to show only agency-level menu links. When omitted, fetches both agency and
/// sub-account menu links. Ignored if locationId is provided
pub show_on_company: Option<bool>,
}
impl GetCustomMenuLinksParams {
/// Start from the parameters the API requires.
pub fn new() -> Self {
Self {
..Default::default()
}
}
/// Unique identifier of the location
pub fn location_id(mut self, v: impl Into<String>) -> Self {
self.location_id = Some(v.into());
self
}
/// Number of items to skip for pagination
pub fn skip(mut self, v: f64) -> Self {
self.skip = Some(v);
self
}
/// Maximum number of items to return
pub fn limit(mut self, v: f64) -> Self {
self.limit = Some(v);
self
}
/// Search query to filter custom menus by name, supports partial || full names
pub fn query(mut self, v: impl Into<String>) -> Self {
self.query = Some(v.into());
self
}
/// Filter to show only agency-level menu links. When omitted, fetches both agency and
/// sub-account menu links. Ignored if locationId is provided
pub fn show_on_company(mut self, v: bool) -> Self {
self.show_on_company = Some(v);
self
}
fn to_query(&self) -> Vec<(String, String)> {
let mut q: Vec<(String, String)> = Vec::new();
if let Some(v) = &self.location_id {
q.push(("locationId".into(), v.to_string()));
}
if let Some(v) = &self.skip {
q.push(("skip".into(), v.to_string()));
}
if let Some(v) = &self.limit {
q.push(("limit".into(), v.to_string()));
}
if let Some(v) = &self.query {
q.push(("query".into(), v.to_string()));
}
if let Some(v) = &self.show_on_company {
q.push(("showOnCompany".into(), v.to_string()));
}
q
}
}
impl CustomMenusService {
/// Get Custom Menu Links
///
/// Fetches a collection of custom menus based on specified criteria. This endpoint
/// allows clients to retrieve custom menu configurations, which may include menu items,
/// categories, and associated metadata. The response can be tailored using query
/// parameters for filtering, sorting, and pagination.
///
/// `GET /custom-menus/`
///
/// Requires scope: `custom-menu-link.readonly`.
pub async fn get_custom_menu_links(
&self,
params: &GetCustomMenuLinksParams,
) -> Result<models::GetCustomMenusResponseDTO> {
let query = params.to_query();
self.client
.send_versioned(
reqwest::Method::GET,
"/custom-menus/",
&query,
None::<&()>,
Some("v3"),
)
.await
}
/// Create Custom Menu Link
///
/// Creates a new custom menu for a company. Requires authentication and proper
/// permissions. For Icon Usage Details please refer to
/// <https://doc.clickup.com/8631005/d/h/87cpx-243696/d60fa70db6b92b2>
///
/// `POST /custom-menus/`
///
/// Requires scope: `custom-menu-link.write`.
pub async fn create_custom_menu_link(
&self,
body: &models::CreateCustomMenuDTO,
) -> Result<models::GetSingleCustomMenusSuccessfulResponseDTO> {
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::POST,
"/custom-menus/",
&query,
Some(body),
Some("v3"),
)
.await
}
/// Delete Custom Menu Link
///
/// Removes a specific custom menu from the system. This operation requires
/// authentication and proper permissions. The custom menu is identified by its unique
/// ID, and the operation is performed within the context of a specific company.
///
/// `DELETE /custom-menus/{customMenuId}`
///
/// Requires scope: `custom-menu-link.write`.
pub async fn delete_custom_menu_link(
&self,
custom_menu_id: &str,
) -> Result<models::DeleteCustomMenuSuccessfulResponseDTO> {
let path = format!("/custom-menus/{}", crate::services::encode(custom_menu_id));
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::DELETE,
&path,
&query,
None::<&()>,
Some("v3"),
)
.await
}
/// Get Custom Menu Link
///
/// Fetches a single custom menus based on id. This endpoint allows clients to retrieve
/// custom menu configurations, which may include menu items, categories, and associated
/// metadata
///
/// `GET /custom-menus/{customMenuId}`
///
/// Requires scope: `custom-menu-link.readonly`.
pub async fn get_custom_menu_link(
&self,
custom_menu_id: &str,
) -> Result<models::GetSingleCustomMenusSuccessfulResponseDTO> {
let path = format!("/custom-menus/{}", crate::services::encode(custom_menu_id));
let query = Vec::new();
self.client
.send_versioned(reqwest::Method::GET, &path, &query, None::<&()>, Some("v3"))
.await
}
/// Update Custom Menu Link
///
/// Updates an existing custom menu for a given company. Requires authentication and
/// proper permissions.
///
/// `PUT /custom-menus/{customMenuId}`
///
/// Requires scope: `custom-menu-link.write`.
pub async fn update_custom_menu_link(
&self,
custom_menu_id: &str,
body: &models::UpdateCustomMenuDTO,
) -> Result<models::UpdateCustomMenuLinkResponseDTO> {
let path = format!("/custom-menus/{}", crate::services::encode(custom_menu_id));
let query = Vec::new();
self.client
.send_versioned(reqwest::Method::PUT, &path, &query, Some(body), Some("v3"))
.await
}
}