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 CreateChannelError {
22 Status400(models::ApiError),
23 Status401(models::ApiError),
24 UnknownValue(serde_json::Value),
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum ExecuteChannelActionError {
31 Status400(models::ApiError),
32 Status401(models::ApiError),
33 UnknownValue(serde_json::Value),
34}
35
36#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(untagged)]
39pub enum JoinChannelError {
40 Status400(models::ApiError),
41 Status401(models::ApiError),
42 UnknownValue(serde_json::Value),
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum LeaveChannelError {
49 Status400(models::ApiError),
50 Status401(models::ApiError),
51 UnknownValue(serde_json::Value),
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum ListChannelActionsError {
58 Status401(models::ApiError),
59 UnknownValue(serde_json::Value),
60}
61
62#[derive(Debug, Clone, Serialize, Deserialize)]
64#[serde(untagged)]
65pub enum ListChannelMessagesError {
66 Status400(models::ApiError),
67 Status401(models::ApiError),
68 UnknownValue(serde_json::Value),
69}
70
71#[derive(Debug, Clone, Serialize, Deserialize)]
73#[serde(untagged)]
74pub enum ListChannelsError {
75 Status401(models::ApiError),
76 Status500(models::ApiError),
77 UnknownValue(serde_json::Value),
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize)]
82#[serde(untagged)]
83pub enum SendChannelMessageError {
84 Status400(models::ApiError),
85 Status401(models::ApiError),
86 UnknownValue(serde_json::Value),
87}
88
89#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum WorkspaceCreateChannelError {
93 Status401(models::ApiError),
94 Status403(models::ApiError),
95 UnknownValue(serde_json::Value),
96}
97
98#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum WorkspaceExecuteChannelActionError {
102 Status401(models::ApiError),
103 Status403(models::ApiError),
104 UnknownValue(serde_json::Value),
105}
106
107#[derive(Debug, Clone, Serialize, Deserialize)]
109#[serde(untagged)]
110pub enum WorkspaceJoinChannelError {
111 Status401(models::ApiError),
112 Status403(models::ApiError),
113 UnknownValue(serde_json::Value),
114}
115
116#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum WorkspaceLeaveChannelError {
120 Status401(models::ApiError),
121 Status403(models::ApiError),
122 UnknownValue(serde_json::Value),
123}
124
125#[derive(Debug, Clone, Serialize, Deserialize)]
127#[serde(untagged)]
128pub enum WorkspaceListChannelActionsError {
129 Status401(models::ApiError),
130 Status403(models::ApiError),
131 UnknownValue(serde_json::Value),
132}
133
134#[derive(Debug, Clone, Serialize, Deserialize)]
136#[serde(untagged)]
137pub enum WorkspaceListChannelMessagesError {
138 Status401(models::ApiError),
139 Status403(models::ApiError),
140 UnknownValue(serde_json::Value),
141}
142
143#[derive(Debug, Clone, Serialize, Deserialize)]
145#[serde(untagged)]
146pub enum WorkspaceListChannelsError {
147 Status401(models::ApiError),
148 Status403(models::ApiError),
149 UnknownValue(serde_json::Value),
150}
151
152#[derive(Debug, Clone, Serialize, Deserialize)]
154#[serde(untagged)]
155pub enum WorkspaceSendChannelMessageError {
156 Status401(models::ApiError),
157 Status403(models::ApiError),
158 UnknownValue(serde_json::Value),
159}
160
161
162pub async fn create_channel(configuration: &configuration::Configuration, create_channel_request: models::CreateChannelRequest) -> Result<models::CreateChannelResponse, Error<CreateChannelError>> {
163 let p_body_create_channel_request = create_channel_request;
165
166 let uri_str = format!("{}/v1/channels", configuration.base_path);
167 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
168
169 if let Some(ref user_agent) = configuration.user_agent {
170 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
171 }
172 if let Some(ref token) = configuration.bearer_access_token {
173 req_builder = req_builder.bearer_auth(token.to_owned());
174 };
175 req_builder = req_builder.json(&p_body_create_channel_request);
176
177 let req = req_builder.build()?;
178 let resp = configuration.client.execute(req).await?;
179
180 let status = resp.status();
181 let content_type = resp
182 .headers()
183 .get("content-type")
184 .and_then(|v| v.to_str().ok())
185 .unwrap_or("application/octet-stream");
186 let content_type = super::ContentType::from(content_type);
187
188 if !status.is_client_error() && !status.is_server_error() {
189 let content = resp.text().await?;
190 match content_type {
191 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
192 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateChannelResponse`"))),
193 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateChannelResponse`")))),
194 }
195 } else {
196 let content = resp.text().await?;
197 let entity: Option<CreateChannelError> = serde_json::from_str(&content).ok();
198 Err(Error::ResponseError(ResponseContent { status, content, entity }))
199 }
200}
201
202pub async fn execute_channel_action(configuration: &configuration::Configuration, execute_chat_action_request: models::ExecuteChatActionRequest) -> Result<models::ExecuteChatActionResponse, Error<ExecuteChannelActionError>> {
204 let p_body_execute_chat_action_request = execute_chat_action_request;
206
207 let uri_str = format!("{}/v1/channels/execute", configuration.base_path);
208 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
209
210 if let Some(ref user_agent) = configuration.user_agent {
211 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
212 }
213 if let Some(ref token) = configuration.bearer_access_token {
214 req_builder = req_builder.bearer_auth(token.to_owned());
215 };
216 req_builder = req_builder.json(&p_body_execute_chat_action_request);
217
218 let req = req_builder.build()?;
219 let resp = configuration.client.execute(req).await?;
220
221 let status = resp.status();
222 let content_type = resp
223 .headers()
224 .get("content-type")
225 .and_then(|v| v.to_str().ok())
226 .unwrap_or("application/octet-stream");
227 let content_type = super::ContentType::from(content_type);
228
229 if !status.is_client_error() && !status.is_server_error() {
230 let content = resp.text().await?;
231 match content_type {
232 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
233 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ExecuteChatActionResponse`"))),
234 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ExecuteChatActionResponse`")))),
235 }
236 } else {
237 let content = resp.text().await?;
238 let entity: Option<ExecuteChannelActionError> = serde_json::from_str(&content).ok();
239 Err(Error::ResponseError(ResponseContent { status, content, entity }))
240 }
241}
242
243pub async fn join_channel(configuration: &configuration::Configuration, id: &str, channel_membership_request: Option<models::ChannelMembershipRequest>) -> Result<models::SuccessFlag, Error<JoinChannelError>> {
244 let p_path_id = id;
246 let p_body_channel_membership_request = channel_membership_request;
247
248 let uri_str = format!("{}/v1/channels/{id}/join", configuration.base_path, id=crate::apis::urlencode(p_path_id));
249 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
250
251 if let Some(ref user_agent) = configuration.user_agent {
252 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
253 }
254 if let Some(ref token) = configuration.bearer_access_token {
255 req_builder = req_builder.bearer_auth(token.to_owned());
256 };
257 req_builder = req_builder.json(&p_body_channel_membership_request);
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 `models::SuccessFlag`"))),
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 `models::SuccessFlag`")))),
276 }
277 } else {
278 let content = resp.text().await?;
279 let entity: Option<JoinChannelError> = serde_json::from_str(&content).ok();
280 Err(Error::ResponseError(ResponseContent { status, content, entity }))
281 }
282}
283
284pub async fn leave_channel(configuration: &configuration::Configuration, id: &str, channel_membership_request: Option<models::ChannelMembershipRequest>) -> Result<models::SuccessFlag, Error<LeaveChannelError>> {
285 let p_path_id = id;
287 let p_body_channel_membership_request = channel_membership_request;
288
289 let uri_str = format!("{}/v1/channels/{id}/leave", configuration.base_path, id=crate::apis::urlencode(p_path_id));
290 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
291
292 if let Some(ref user_agent) = configuration.user_agent {
293 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
294 }
295 if let Some(ref token) = configuration.bearer_access_token {
296 req_builder = req_builder.bearer_auth(token.to_owned());
297 };
298 req_builder = req_builder.json(&p_body_channel_membership_request);
299
300 let req = req_builder.build()?;
301 let resp = configuration.client.execute(req).await?;
302
303 let status = resp.status();
304 let content_type = resp
305 .headers()
306 .get("content-type")
307 .and_then(|v| v.to_str().ok())
308 .unwrap_or("application/octet-stream");
309 let content_type = super::ContentType::from(content_type);
310
311 if !status.is_client_error() && !status.is_server_error() {
312 let content = resp.text().await?;
313 match content_type {
314 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
315 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessFlag`"))),
316 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessFlag`")))),
317 }
318 } else {
319 let content = resp.text().await?;
320 let entity: Option<LeaveChannelError> = serde_json::from_str(&content).ok();
321 Err(Error::ResponseError(ResponseContent { status, content, entity }))
322 }
323}
324
325pub async fn list_channel_actions(configuration: &configuration::Configuration, ) -> Result<models::ChatActionsList, Error<ListChannelActionsError>> {
327
328 let uri_str = format!("{}/v1/channels/actions", configuration.base_path);
329 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
330
331 if let Some(ref user_agent) = configuration.user_agent {
332 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
333 }
334 if let Some(ref token) = configuration.bearer_access_token {
335 req_builder = req_builder.bearer_auth(token.to_owned());
336 };
337
338 let req = req_builder.build()?;
339 let resp = configuration.client.execute(req).await?;
340
341 let status = resp.status();
342 let content_type = resp
343 .headers()
344 .get("content-type")
345 .and_then(|v| v.to_str().ok())
346 .unwrap_or("application/octet-stream");
347 let content_type = super::ContentType::from(content_type);
348
349 if !status.is_client_error() && !status.is_server_error() {
350 let content = resp.text().await?;
351 match content_type {
352 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
353 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ChatActionsList`"))),
354 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ChatActionsList`")))),
355 }
356 } else {
357 let content = resp.text().await?;
358 let entity: Option<ListChannelActionsError> = serde_json::from_str(&content).ok();
359 Err(Error::ResponseError(ResponseContent { status, content, entity }))
360 }
361}
362
363pub async fn list_channel_messages(configuration: &configuration::Configuration, channel: &str, account_id: Option<&str>, account_ids: Option<Vec<String>>, providers: Option<Vec<String>>, x_workspace_id: Option<&str>, limit: Option<i32>, cursor: Option<&str>, oldest_first: Option<bool>) -> Result<models::ListMessagesResponse, Error<ListChannelMessagesError>> {
365 let p_query_channel = channel;
367 let p_query_account_id = account_id;
368 let p_query_account_ids = account_ids;
369 let p_query_providers = providers;
370 let p_header_x_workspace_id = x_workspace_id;
371 let p_query_limit = limit;
372 let p_query_cursor = cursor;
373 let p_query_oldest_first = oldest_first;
374
375 let uri_str = format!("{}/v1/channels/messages", configuration.base_path);
376 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
377
378 req_builder = req_builder.query(&[("channel", &p_query_channel.to_string())]);
379 if let Some(ref param_value) = p_query_account_id {
380 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
381 }
382 if let Some(ref param_value) = p_query_account_ids {
383 req_builder = match "multi" {
384 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("accountIds".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
385 _ => req_builder.query(&[("accountIds", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
386 };
387 }
388 if let Some(ref param_value) = p_query_providers {
389 req_builder = match "multi" {
390 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("providers".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
391 _ => req_builder.query(&[("providers", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
392 };
393 }
394 if let Some(ref param_value) = p_query_limit {
395 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
396 }
397 if let Some(ref param_value) = p_query_cursor {
398 req_builder = req_builder.query(&[("cursor", ¶m_value.to_string())]);
399 }
400 if let Some(ref param_value) = p_query_oldest_first {
401 req_builder = req_builder.query(&[("oldestFirst", ¶m_value.to_string())]);
402 }
403 if let Some(ref user_agent) = configuration.user_agent {
404 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
405 }
406 if let Some(param_value) = p_header_x_workspace_id {
407 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
408 }
409 if let Some(ref token) = configuration.bearer_access_token {
410 req_builder = req_builder.bearer_auth(token.to_owned());
411 };
412
413 let req = req_builder.build()?;
414 let resp = configuration.client.execute(req).await?;
415
416 let status = resp.status();
417 let content_type = resp
418 .headers()
419 .get("content-type")
420 .and_then(|v| v.to_str().ok())
421 .unwrap_or("application/octet-stream");
422 let content_type = super::ContentType::from(content_type);
423
424 if !status.is_client_error() && !status.is_server_error() {
425 let content = resp.text().await?;
426 match content_type {
427 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
428 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListMessagesResponse`"))),
429 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListMessagesResponse`")))),
430 }
431 } else {
432 let content = resp.text().await?;
433 let entity: Option<ListChannelMessagesError> = serde_json::from_str(&content).ok();
434 Err(Error::ResponseError(ResponseContent { status, content, entity }))
435 }
436}
437
438pub async fn list_channels(configuration: &configuration::Configuration, account_ids: Option<Vec<String>>, providers: Option<Vec<String>>, x_workspace_id: Option<&str>, limit: Option<i32>, cursor: Option<&str>, include_archived: Option<bool>, types: Option<Vec<String>>) -> Result<models::ListChannelsResponse, Error<ListChannelsError>> {
440 let p_query_account_ids = account_ids;
442 let p_query_providers = providers;
443 let p_header_x_workspace_id = x_workspace_id;
444 let p_query_limit = limit;
445 let p_query_cursor = cursor;
446 let p_query_include_archived = include_archived;
447 let p_query_types = types;
448
449 let uri_str = format!("{}/v1/channels", configuration.base_path);
450 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
451
452 if let Some(ref param_value) = p_query_account_ids {
453 req_builder = match "multi" {
454 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("accountIds".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
455 _ => req_builder.query(&[("accountIds", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
456 };
457 }
458 if let Some(ref param_value) = p_query_providers {
459 req_builder = match "multi" {
460 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("providers".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
461 _ => req_builder.query(&[("providers", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
462 };
463 }
464 if let Some(ref param_value) = p_query_limit {
465 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
466 }
467 if let Some(ref param_value) = p_query_cursor {
468 req_builder = req_builder.query(&[("cursor", ¶m_value.to_string())]);
469 }
470 if let Some(ref param_value) = p_query_include_archived {
471 req_builder = req_builder.query(&[("includeArchived", ¶m_value.to_string())]);
472 }
473 if let Some(ref param_value) = p_query_types {
474 req_builder = match "multi" {
475 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("types".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
476 _ => req_builder.query(&[("types", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
477 };
478 }
479 if let Some(ref user_agent) = configuration.user_agent {
480 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
481 }
482 if let Some(param_value) = p_header_x_workspace_id {
483 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
484 }
485 if let Some(ref token) = configuration.bearer_access_token {
486 req_builder = req_builder.bearer_auth(token.to_owned());
487 };
488
489 let req = req_builder.build()?;
490 let resp = configuration.client.execute(req).await?;
491
492 let status = resp.status();
493 let content_type = resp
494 .headers()
495 .get("content-type")
496 .and_then(|v| v.to_str().ok())
497 .unwrap_or("application/octet-stream");
498 let content_type = super::ContentType::from(content_type);
499
500 if !status.is_client_error() && !status.is_server_error() {
501 let content = resp.text().await?;
502 match content_type {
503 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
504 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListChannelsResponse`"))),
505 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListChannelsResponse`")))),
506 }
507 } else {
508 let content = resp.text().await?;
509 let entity: Option<ListChannelsError> = serde_json::from_str(&content).ok();
510 Err(Error::ResponseError(ResponseContent { status, content, entity }))
511 }
512}
513
514pub async fn send_channel_message(configuration: &configuration::Configuration, send_chat_message_request: models::SendChatMessageRequest) -> Result<models::SendChatMessageResponse, Error<SendChannelMessageError>> {
515 let p_body_send_chat_message_request = send_chat_message_request;
517
518 let uri_str = format!("{}/v1/channels/messages", configuration.base_path);
519 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
520
521 if let Some(ref user_agent) = configuration.user_agent {
522 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
523 }
524 if let Some(ref token) = configuration.bearer_access_token {
525 req_builder = req_builder.bearer_auth(token.to_owned());
526 };
527 req_builder = req_builder.json(&p_body_send_chat_message_request);
528
529 let req = req_builder.build()?;
530 let resp = configuration.client.execute(req).await?;
531
532 let status = resp.status();
533 let content_type = resp
534 .headers()
535 .get("content-type")
536 .and_then(|v| v.to_str().ok())
537 .unwrap_or("application/octet-stream");
538 let content_type = super::ContentType::from(content_type);
539
540 if !status.is_client_error() && !status.is_server_error() {
541 let content = resp.text().await?;
542 match content_type {
543 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
544 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendChatMessageResponse`"))),
545 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendChatMessageResponse`")))),
546 }
547 } else {
548 let content = resp.text().await?;
549 let entity: Option<SendChannelMessageError> = serde_json::from_str(&content).ok();
550 Err(Error::ResponseError(ResponseContent { status, content, entity }))
551 }
552}
553
554pub async fn workspace_create_channel(configuration: &configuration::Configuration, org: &str, workspace: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceCreateChannelError>> {
555 let p_path_org = org;
557 let p_path_workspace = workspace;
558 let p_body_request_body = request_body;
559
560 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/channels", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
561 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
562
563 if let Some(ref user_agent) = configuration.user_agent {
564 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
565 }
566 if let Some(ref token) = configuration.bearer_access_token {
567 req_builder = req_builder.bearer_auth(token.to_owned());
568 };
569 req_builder = req_builder.json(&p_body_request_body);
570
571 let req = req_builder.build()?;
572 let resp = configuration.client.execute(req).await?;
573
574 let status = resp.status();
575 let content_type = resp
576 .headers()
577 .get("content-type")
578 .and_then(|v| v.to_str().ok())
579 .unwrap_or("application/octet-stream");
580 let content_type = super::ContentType::from(content_type);
581
582 if !status.is_client_error() && !status.is_server_error() {
583 let content = resp.text().await?;
584 match content_type {
585 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
586 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>`"))),
587 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>`")))),
588 }
589 } else {
590 let content = resp.text().await?;
591 let entity: Option<WorkspaceCreateChannelError> = serde_json::from_str(&content).ok();
592 Err(Error::ResponseError(ResponseContent { status, content, entity }))
593 }
594}
595
596pub async fn workspace_execute_channel_action(configuration: &configuration::Configuration, org: &str, workspace: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceExecuteChannelActionError>> {
597 let p_path_org = org;
599 let p_path_workspace = workspace;
600 let p_body_request_body = request_body;
601
602 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/channels/execute", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
603 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
604
605 if let Some(ref user_agent) = configuration.user_agent {
606 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
607 }
608 if let Some(ref token) = configuration.bearer_access_token {
609 req_builder = req_builder.bearer_auth(token.to_owned());
610 };
611 req_builder = req_builder.json(&p_body_request_body);
612
613 let req = req_builder.build()?;
614 let resp = configuration.client.execute(req).await?;
615
616 let status = resp.status();
617 let content_type = resp
618 .headers()
619 .get("content-type")
620 .and_then(|v| v.to_str().ok())
621 .unwrap_or("application/octet-stream");
622 let content_type = super::ContentType::from(content_type);
623
624 if !status.is_client_error() && !status.is_server_error() {
625 let content = resp.text().await?;
626 match content_type {
627 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
628 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>`"))),
629 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>`")))),
630 }
631 } else {
632 let content = resp.text().await?;
633 let entity: Option<WorkspaceExecuteChannelActionError> = serde_json::from_str(&content).ok();
634 Err(Error::ResponseError(ResponseContent { status, content, entity }))
635 }
636}
637
638pub async fn workspace_join_channel(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str, request_body: Option<std::collections::HashMap<String, serde_json::Value>>) -> Result<(), Error<WorkspaceJoinChannelError>> {
639 let p_path_org = org;
641 let p_path_workspace = workspace;
642 let p_path_id = id;
643 let p_body_request_body = request_body;
644
645 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/channels/{id}/join", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
646 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
647
648 if let Some(ref user_agent) = configuration.user_agent {
649 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
650 }
651 if let Some(ref token) = configuration.bearer_access_token {
652 req_builder = req_builder.bearer_auth(token.to_owned());
653 };
654 req_builder = req_builder.json(&p_body_request_body);
655
656 let req = req_builder.build()?;
657 let resp = configuration.client.execute(req).await?;
658
659 let status = resp.status();
660
661 if !status.is_client_error() && !status.is_server_error() {
662 Ok(())
663 } else {
664 let content = resp.text().await?;
665 let entity: Option<WorkspaceJoinChannelError> = serde_json::from_str(&content).ok();
666 Err(Error::ResponseError(ResponseContent { status, content, entity }))
667 }
668}
669
670pub async fn workspace_leave_channel(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str, request_body: Option<std::collections::HashMap<String, serde_json::Value>>) -> Result<(), Error<WorkspaceLeaveChannelError>> {
671 let p_path_org = org;
673 let p_path_workspace = workspace;
674 let p_path_id = id;
675 let p_body_request_body = request_body;
676
677 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/channels/{id}/leave", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
678 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
679
680 if let Some(ref user_agent) = configuration.user_agent {
681 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
682 }
683 if let Some(ref token) = configuration.bearer_access_token {
684 req_builder = req_builder.bearer_auth(token.to_owned());
685 };
686 req_builder = req_builder.json(&p_body_request_body);
687
688 let req = req_builder.build()?;
689 let resp = configuration.client.execute(req).await?;
690
691 let status = resp.status();
692
693 if !status.is_client_error() && !status.is_server_error() {
694 Ok(())
695 } else {
696 let content = resp.text().await?;
697 let entity: Option<WorkspaceLeaveChannelError> = serde_json::from_str(&content).ok();
698 Err(Error::ResponseError(ResponseContent { status, content, entity }))
699 }
700}
701
702pub async fn workspace_list_channel_actions(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListChannelActionsError>> {
703 let p_path_org = org;
705 let p_path_workspace = workspace;
706
707 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/channels/actions", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
708 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
709
710 if let Some(ref user_agent) = configuration.user_agent {
711 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
712 }
713 if let Some(ref token) = configuration.bearer_access_token {
714 req_builder = req_builder.bearer_auth(token.to_owned());
715 };
716
717 let req = req_builder.build()?;
718 let resp = configuration.client.execute(req).await?;
719
720 let status = resp.status();
721 let content_type = resp
722 .headers()
723 .get("content-type")
724 .and_then(|v| v.to_str().ok())
725 .unwrap_or("application/octet-stream");
726 let content_type = super::ContentType::from(content_type);
727
728 if !status.is_client_error() && !status.is_server_error() {
729 let content = resp.text().await?;
730 match content_type {
731 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
732 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>`"))),
733 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>`")))),
734 }
735 } else {
736 let content = resp.text().await?;
737 let entity: Option<WorkspaceListChannelActionsError> = serde_json::from_str(&content).ok();
738 Err(Error::ResponseError(ResponseContent { status, content, entity }))
739 }
740}
741
742pub async fn workspace_list_channel_messages(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListChannelMessagesError>> {
743 let p_path_org = org;
745 let p_path_workspace = workspace;
746
747 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/channels/messages", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
748 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
749
750 if let Some(ref user_agent) = configuration.user_agent {
751 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
752 }
753 if let Some(ref token) = configuration.bearer_access_token {
754 req_builder = req_builder.bearer_auth(token.to_owned());
755 };
756
757 let req = req_builder.build()?;
758 let resp = configuration.client.execute(req).await?;
759
760 let status = resp.status();
761 let content_type = resp
762 .headers()
763 .get("content-type")
764 .and_then(|v| v.to_str().ok())
765 .unwrap_or("application/octet-stream");
766 let content_type = super::ContentType::from(content_type);
767
768 if !status.is_client_error() && !status.is_server_error() {
769 let content = resp.text().await?;
770 match content_type {
771 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
772 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>`"))),
773 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>`")))),
774 }
775 } else {
776 let content = resp.text().await?;
777 let entity: Option<WorkspaceListChannelMessagesError> = serde_json::from_str(&content).ok();
778 Err(Error::ResponseError(ResponseContent { status, content, entity }))
779 }
780}
781
782pub async fn workspace_list_channels(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListChannelsError>> {
783 let p_path_org = org;
785 let p_path_workspace = workspace;
786
787 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/channels", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
788 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
789
790 if let Some(ref user_agent) = configuration.user_agent {
791 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
792 }
793 if let Some(ref token) = configuration.bearer_access_token {
794 req_builder = req_builder.bearer_auth(token.to_owned());
795 };
796
797 let req = req_builder.build()?;
798 let resp = configuration.client.execute(req).await?;
799
800 let status = resp.status();
801 let content_type = resp
802 .headers()
803 .get("content-type")
804 .and_then(|v| v.to_str().ok())
805 .unwrap_or("application/octet-stream");
806 let content_type = super::ContentType::from(content_type);
807
808 if !status.is_client_error() && !status.is_server_error() {
809 let content = resp.text().await?;
810 match content_type {
811 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
812 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>`"))),
813 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>`")))),
814 }
815 } else {
816 let content = resp.text().await?;
817 let entity: Option<WorkspaceListChannelsError> = serde_json::from_str(&content).ok();
818 Err(Error::ResponseError(ResponseContent { status, content, entity }))
819 }
820}
821
822pub async fn workspace_send_channel_message(configuration: &configuration::Configuration, org: &str, workspace: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceSendChannelMessageError>> {
823 let p_path_org = org;
825 let p_path_workspace = workspace;
826 let p_body_request_body = request_body;
827
828 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/channels/messages", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
829 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
830
831 if let Some(ref user_agent) = configuration.user_agent {
832 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
833 }
834 if let Some(ref token) = configuration.bearer_access_token {
835 req_builder = req_builder.bearer_auth(token.to_owned());
836 };
837 req_builder = req_builder.json(&p_body_request_body);
838
839 let req = req_builder.build()?;
840 let resp = configuration.client.execute(req).await?;
841
842 let status = resp.status();
843 let content_type = resp
844 .headers()
845 .get("content-type")
846 .and_then(|v| v.to_str().ok())
847 .unwrap_or("application/octet-stream");
848 let content_type = super::ContentType::from(content_type);
849
850 if !status.is_client_error() && !status.is_server_error() {
851 let content = resp.text().await?;
852 match content_type {
853 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
854 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>`"))),
855 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>`")))),
856 }
857 } else {
858 let content = resp.text().await?;
859 let entity: Option<WorkspaceSendChannelMessageError> = serde_json::from_str(&content).ok();
860 Err(Error::ResponseError(ResponseContent { status, content, entity }))
861 }
862}
863