1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum BulkUpdateSettingsError {
22 Status401(models::ApiError),
23 UnknownValue(serde_json::Value),
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum DeleteCurrentUserSettingsError {
30 Status401(models::ApiError),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum GetCurrentUserSettingsError {
38 Status401(models::ApiError),
39 UnknownValue(serde_json::Value),
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum GetMailReadReceiptsPrefError {
46 Status401(models::ApiError),
47 UnknownValue(serde_json::Value),
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum GetSettingsPermissionsError {
54 Status401(models::ApiError),
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum GetUserSettingsError {
62 Status401(models::ApiError),
63 UnknownValue(serde_json::Value),
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum GetWorkspaceSettingsError {
70 Status401(models::ApiError),
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum PutCurrentUserSettingsError {
78 Status401(models::ApiError),
79 UnknownValue(serde_json::Value),
80}
81
82#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum PutMailReadReceiptsPrefError {
86 Status401(models::ApiError),
87 UnknownValue(serde_json::Value),
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize)]
92#[serde(untagged)]
93pub enum PutUserSettingsError {
94 Status401(models::ApiError),
95 UnknownValue(serde_json::Value),
96}
97
98#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum PutWorkspaceSettingsError {
102 Status401(models::ApiError),
103 UnknownValue(serde_json::Value),
104}
105
106
107pub async fn bulk_update_settings(configuration: &configuration::Configuration, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<BulkUpdateSettingsError>> {
108 let p_body_request_body = request_body;
110
111 let uri_str = format!("{}/v1/settings/bulk-update", configuration.base_path);
112 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
113
114 if let Some(ref user_agent) = configuration.user_agent {
115 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
116 }
117 if let Some(ref token) = configuration.bearer_access_token {
118 req_builder = req_builder.bearer_auth(token.to_owned());
119 };
120 req_builder = req_builder.json(&p_body_request_body);
121
122 let req = req_builder.build()?;
123 let resp = configuration.client.execute(req).await?;
124
125 let status = resp.status();
126 let content_type = resp
127 .headers()
128 .get("content-type")
129 .and_then(|v| v.to_str().ok())
130 .unwrap_or("application/octet-stream");
131 let content_type = super::ContentType::from(content_type);
132
133 if !status.is_client_error() && !status.is_server_error() {
134 let content = resp.text().await?;
135 match content_type {
136 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
137 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
138 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
139 }
140 } else {
141 let content = resp.text().await?;
142 let entity: Option<BulkUpdateSettingsError> = serde_json::from_str(&content).ok();
143 Err(Error::ResponseError(ResponseContent { status, content, entity }))
144 }
145}
146
147pub async fn delete_current_user_settings(configuration: &configuration::Configuration, ) -> Result<(), Error<DeleteCurrentUserSettingsError>> {
148
149 let uri_str = format!("{}/v1/settings", configuration.base_path);
150 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
151
152 if let Some(ref user_agent) = configuration.user_agent {
153 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
154 }
155 if let Some(ref token) = configuration.bearer_access_token {
156 req_builder = req_builder.bearer_auth(token.to_owned());
157 };
158
159 let req = req_builder.build()?;
160 let resp = configuration.client.execute(req).await?;
161
162 let status = resp.status();
163
164 if !status.is_client_error() && !status.is_server_error() {
165 Ok(())
166 } else {
167 let content = resp.text().await?;
168 let entity: Option<DeleteCurrentUserSettingsError> = serde_json::from_str(&content).ok();
169 Err(Error::ResponseError(ResponseContent { status, content, entity }))
170 }
171}
172
173pub async fn get_current_user_settings(configuration: &configuration::Configuration, ) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<GetCurrentUserSettingsError>> {
174
175 let uri_str = format!("{}/v1/settings", configuration.base_path);
176 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
177
178 if let Some(ref user_agent) = configuration.user_agent {
179 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
180 }
181 if let Some(ref token) = configuration.bearer_access_token {
182 req_builder = req_builder.bearer_auth(token.to_owned());
183 };
184
185 let req = req_builder.build()?;
186 let resp = configuration.client.execute(req).await?;
187
188 let status = resp.status();
189 let content_type = resp
190 .headers()
191 .get("content-type")
192 .and_then(|v| v.to_str().ok())
193 .unwrap_or("application/octet-stream");
194 let content_type = super::ContentType::from(content_type);
195
196 if !status.is_client_error() && !status.is_server_error() {
197 let content = resp.text().await?;
198 match content_type {
199 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
200 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
201 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
202 }
203 } else {
204 let content = resp.text().await?;
205 let entity: Option<GetCurrentUserSettingsError> = serde_json::from_str(&content).ok();
206 Err(Error::ResponseError(ResponseContent { status, content, entity }))
207 }
208}
209
210pub async fn get_mail_read_receipts_pref(configuration: &configuration::Configuration, ) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<GetMailReadReceiptsPrefError>> {
211
212 let uri_str = format!("{}/v1/me/preferences/mail-read-receipts", configuration.base_path);
213 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
214
215 if let Some(ref user_agent) = configuration.user_agent {
216 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
217 }
218 if let Some(ref token) = configuration.bearer_access_token {
219 req_builder = req_builder.bearer_auth(token.to_owned());
220 };
221
222 let req = req_builder.build()?;
223 let resp = configuration.client.execute(req).await?;
224
225 let status = resp.status();
226 let content_type = resp
227 .headers()
228 .get("content-type")
229 .and_then(|v| v.to_str().ok())
230 .unwrap_or("application/octet-stream");
231 let content_type = super::ContentType::from(content_type);
232
233 if !status.is_client_error() && !status.is_server_error() {
234 let content = resp.text().await?;
235 match content_type {
236 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
237 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
238 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
239 }
240 } else {
241 let content = resp.text().await?;
242 let entity: Option<GetMailReadReceiptsPrefError> = serde_json::from_str(&content).ok();
243 Err(Error::ResponseError(ResponseContent { status, content, entity }))
244 }
245}
246
247pub async fn get_settings_permissions(configuration: &configuration::Configuration, ) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<GetSettingsPermissionsError>> {
248
249 let uri_str = format!("{}/v1/settings/permissions", configuration.base_path);
250 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
251
252 if let Some(ref user_agent) = configuration.user_agent {
253 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
254 }
255 if let Some(ref token) = configuration.bearer_access_token {
256 req_builder = req_builder.bearer_auth(token.to_owned());
257 };
258
259 let req = req_builder.build()?;
260 let resp = configuration.client.execute(req).await?;
261
262 let status = resp.status();
263 let content_type = resp
264 .headers()
265 .get("content-type")
266 .and_then(|v| v.to_str().ok())
267 .unwrap_or("application/octet-stream");
268 let content_type = super::ContentType::from(content_type);
269
270 if !status.is_client_error() && !status.is_server_error() {
271 let content = resp.text().await?;
272 match content_type {
273 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
274 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
275 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
276 }
277 } else {
278 let content = resp.text().await?;
279 let entity: Option<GetSettingsPermissionsError> = serde_json::from_str(&content).ok();
280 Err(Error::ResponseError(ResponseContent { status, content, entity }))
281 }
282}
283
284pub async fn get_user_settings(configuration: &configuration::Configuration, user_id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<GetUserSettingsError>> {
285 let p_path_user_id = user_id;
287
288 let uri_str = format!("{}/v1/settings/user/{userId}", configuration.base_path, userId=crate::apis::urlencode(p_path_user_id));
289 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
290
291 if let Some(ref user_agent) = configuration.user_agent {
292 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
293 }
294 if let Some(ref token) = configuration.bearer_access_token {
295 req_builder = req_builder.bearer_auth(token.to_owned());
296 };
297
298 let req = req_builder.build()?;
299 let resp = configuration.client.execute(req).await?;
300
301 let status = resp.status();
302 let content_type = resp
303 .headers()
304 .get("content-type")
305 .and_then(|v| v.to_str().ok())
306 .unwrap_or("application/octet-stream");
307 let content_type = super::ContentType::from(content_type);
308
309 if !status.is_client_error() && !status.is_server_error() {
310 let content = resp.text().await?;
311 match content_type {
312 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
313 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
314 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
315 }
316 } else {
317 let content = resp.text().await?;
318 let entity: Option<GetUserSettingsError> = serde_json::from_str(&content).ok();
319 Err(Error::ResponseError(ResponseContent { status, content, entity }))
320 }
321}
322
323pub async fn get_workspace_settings(configuration: &configuration::Configuration, workspace_id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<GetWorkspaceSettingsError>> {
324 let p_path_workspace_id = workspace_id;
326
327 let uri_str = format!("{}/v1/settings/workspace/{workspaceId}", configuration.base_path, workspaceId=crate::apis::urlencode(p_path_workspace_id));
328 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
329
330 if let Some(ref user_agent) = configuration.user_agent {
331 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
332 }
333 if let Some(ref token) = configuration.bearer_access_token {
334 req_builder = req_builder.bearer_auth(token.to_owned());
335 };
336
337 let req = req_builder.build()?;
338 let resp = configuration.client.execute(req).await?;
339
340 let status = resp.status();
341 let content_type = resp
342 .headers()
343 .get("content-type")
344 .and_then(|v| v.to_str().ok())
345 .unwrap_or("application/octet-stream");
346 let content_type = super::ContentType::from(content_type);
347
348 if !status.is_client_error() && !status.is_server_error() {
349 let content = resp.text().await?;
350 match content_type {
351 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
352 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
353 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
354 }
355 } else {
356 let content = resp.text().await?;
357 let entity: Option<GetWorkspaceSettingsError> = serde_json::from_str(&content).ok();
358 Err(Error::ResponseError(ResponseContent { status, content, entity }))
359 }
360}
361
362pub async fn put_current_user_settings(configuration: &configuration::Configuration, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<PutCurrentUserSettingsError>> {
363 let p_body_request_body = request_body;
365
366 let uri_str = format!("{}/v1/settings", configuration.base_path);
367 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
368
369 if let Some(ref user_agent) = configuration.user_agent {
370 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
371 }
372 if let Some(ref token) = configuration.bearer_access_token {
373 req_builder = req_builder.bearer_auth(token.to_owned());
374 };
375 req_builder = req_builder.json(&p_body_request_body);
376
377 let req = req_builder.build()?;
378 let resp = configuration.client.execute(req).await?;
379
380 let status = resp.status();
381 let content_type = resp
382 .headers()
383 .get("content-type")
384 .and_then(|v| v.to_str().ok())
385 .unwrap_or("application/octet-stream");
386 let content_type = super::ContentType::from(content_type);
387
388 if !status.is_client_error() && !status.is_server_error() {
389 let content = resp.text().await?;
390 match content_type {
391 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
392 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
393 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
394 }
395 } else {
396 let content = resp.text().await?;
397 let entity: Option<PutCurrentUserSettingsError> = serde_json::from_str(&content).ok();
398 Err(Error::ResponseError(ResponseContent { status, content, entity }))
399 }
400}
401
402pub async fn put_mail_read_receipts_pref(configuration: &configuration::Configuration, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<(), Error<PutMailReadReceiptsPrefError>> {
403 let p_body_request_body = request_body;
405
406 let uri_str = format!("{}/v1/me/preferences/mail-read-receipts", configuration.base_path);
407 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
408
409 if let Some(ref user_agent) = configuration.user_agent {
410 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
411 }
412 if let Some(ref token) = configuration.bearer_access_token {
413 req_builder = req_builder.bearer_auth(token.to_owned());
414 };
415 req_builder = req_builder.json(&p_body_request_body);
416
417 let req = req_builder.build()?;
418 let resp = configuration.client.execute(req).await?;
419
420 let status = resp.status();
421
422 if !status.is_client_error() && !status.is_server_error() {
423 Ok(())
424 } else {
425 let content = resp.text().await?;
426 let entity: Option<PutMailReadReceiptsPrefError> = serde_json::from_str(&content).ok();
427 Err(Error::ResponseError(ResponseContent { status, content, entity }))
428 }
429}
430
431pub async fn put_user_settings(configuration: &configuration::Configuration, user_id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<PutUserSettingsError>> {
432 let p_path_user_id = user_id;
434 let p_body_request_body = request_body;
435
436 let uri_str = format!("{}/v1/settings/user/{userId}", configuration.base_path, userId=crate::apis::urlencode(p_path_user_id));
437 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
438
439 if let Some(ref user_agent) = configuration.user_agent {
440 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
441 }
442 if let Some(ref token) = configuration.bearer_access_token {
443 req_builder = req_builder.bearer_auth(token.to_owned());
444 };
445 req_builder = req_builder.json(&p_body_request_body);
446
447 let req = req_builder.build()?;
448 let resp = configuration.client.execute(req).await?;
449
450 let status = resp.status();
451 let content_type = resp
452 .headers()
453 .get("content-type")
454 .and_then(|v| v.to_str().ok())
455 .unwrap_or("application/octet-stream");
456 let content_type = super::ContentType::from(content_type);
457
458 if !status.is_client_error() && !status.is_server_error() {
459 let content = resp.text().await?;
460 match content_type {
461 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
462 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
463 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
464 }
465 } else {
466 let content = resp.text().await?;
467 let entity: Option<PutUserSettingsError> = serde_json::from_str(&content).ok();
468 Err(Error::ResponseError(ResponseContent { status, content, entity }))
469 }
470}
471
472pub async fn put_workspace_settings(configuration: &configuration::Configuration, workspace_id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<PutWorkspaceSettingsError>> {
473 let p_path_workspace_id = workspace_id;
475 let p_body_request_body = request_body;
476
477 let uri_str = format!("{}/v1/settings/workspace/{workspaceId}", configuration.base_path, workspaceId=crate::apis::urlencode(p_path_workspace_id));
478 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
479
480 if let Some(ref user_agent) = configuration.user_agent {
481 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
482 }
483 if let Some(ref token) = configuration.bearer_access_token {
484 req_builder = req_builder.bearer_auth(token.to_owned());
485 };
486 req_builder = req_builder.json(&p_body_request_body);
487
488 let req = req_builder.build()?;
489 let resp = configuration.client.execute(req).await?;
490
491 let status = resp.status();
492 let content_type = resp
493 .headers()
494 .get("content-type")
495 .and_then(|v| v.to_str().ok())
496 .unwrap_or("application/octet-stream");
497 let content_type = super::ContentType::from(content_type);
498
499 if !status.is_client_error() && !status.is_server_error() {
500 let content = resp.text().await?;
501 match content_type {
502 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
503 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
504 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
505 }
506 } else {
507 let content = resp.text().await?;
508 let entity: Option<PutWorkspaceSettingsError> = serde_json::from_str(&content).ok();
509 Err(Error::ResponseError(ResponseContent { status, content, entity }))
510 }
511}
512