mattermost_rust_client/apis/
webhooks_api.rs

1/*
2 * Mattermost API Reference
3 *
4 * There is also a work-in-progress [Postman API reference](https://documenter.getpostman.com/view/4508214/RW8FERUn). 
5 *
6 * The version of the OpenAPI document: 4.0.0
7 * Contact: feedback@mattermost.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`create_incoming_webhook`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateIncomingWebhookError {
22    Status400(crate::models::AppError),
23    Status401(crate::models::AppError),
24    Status403(crate::models::AppError),
25    UnknownValue(serde_json::Value),
26}
27
28/// struct for typed errors of method [`create_outgoing_webhook`]
29#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum CreateOutgoingWebhookError {
32    Status400(crate::models::AppError),
33    Status401(crate::models::AppError),
34    Status403(crate::models::AppError),
35    Status404(crate::models::AppError),
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`delete_incoming_webhook`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum DeleteIncomingWebhookError {
43    Status400(crate::models::AppError),
44    Status401(crate::models::AppError),
45    Status403(crate::models::AppError),
46    Status404(crate::models::AppError),
47    UnknownValue(serde_json::Value),
48}
49
50/// struct for typed errors of method [`delete_outgoing_webhook`]
51#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum DeleteOutgoingWebhookError {
54    Status400(crate::models::AppError),
55    Status401(crate::models::AppError),
56    Status403(crate::models::AppError),
57    Status404(crate::models::AppError),
58    UnknownValue(serde_json::Value),
59}
60
61/// struct for typed errors of method [`get_incoming_webhook`]
62#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum GetIncomingWebhookError {
65    Status400(crate::models::AppError),
66    Status401(crate::models::AppError),
67    Status403(crate::models::AppError),
68    Status404(crate::models::AppError),
69    UnknownValue(serde_json::Value),
70}
71
72/// struct for typed errors of method [`get_incoming_webhooks`]
73#[derive(Debug, Clone, Serialize, Deserialize)]
74#[serde(untagged)]
75pub enum GetIncomingWebhooksError {
76    Status400(crate::models::AppError),
77    Status401(crate::models::AppError),
78    Status403(crate::models::AppError),
79    UnknownValue(serde_json::Value),
80}
81
82/// struct for typed errors of method [`get_outgoing_webhook`]
83#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum GetOutgoingWebhookError {
86    Status400(crate::models::AppError),
87    Status401(crate::models::AppError),
88    Status403(crate::models::AppError),
89    Status404(crate::models::AppError),
90    UnknownValue(serde_json::Value),
91}
92
93/// struct for typed errors of method [`get_outgoing_webhooks`]
94#[derive(Debug, Clone, Serialize, Deserialize)]
95#[serde(untagged)]
96pub enum GetOutgoingWebhooksError {
97    Status400(crate::models::AppError),
98    Status401(crate::models::AppError),
99    Status403(crate::models::AppError),
100    Status404(crate::models::AppError),
101    UnknownValue(serde_json::Value),
102}
103
104/// struct for typed errors of method [`regen_outgoing_hook_token`]
105#[derive(Debug, Clone, Serialize, Deserialize)]
106#[serde(untagged)]
107pub enum RegenOutgoingHookTokenError {
108    Status400(crate::models::AppError),
109    Status401(crate::models::AppError),
110    Status403(crate::models::AppError),
111    Status404(crate::models::AppError),
112    UnknownValue(serde_json::Value),
113}
114
115/// struct for typed errors of method [`update_incoming_webhook`]
116#[derive(Debug, Clone, Serialize, Deserialize)]
117#[serde(untagged)]
118pub enum UpdateIncomingWebhookError {
119    Status400(crate::models::AppError),
120    Status401(crate::models::AppError),
121    Status403(crate::models::AppError),
122    Status404(crate::models::AppError),
123    UnknownValue(serde_json::Value),
124}
125
126/// struct for typed errors of method [`update_outgoing_webhook`]
127#[derive(Debug, Clone, Serialize, Deserialize)]
128#[serde(untagged)]
129pub enum UpdateOutgoingWebhookError {
130    Status400(crate::models::AppError),
131    Status401(crate::models::AppError),
132    Status403(crate::models::AppError),
133    Status404(crate::models::AppError),
134    UnknownValue(serde_json::Value),
135}
136
137
138/// Create an incoming webhook for a channel. ##### Permissions `manage_webhooks` for the team the webhook is in.  `manage_others_incoming_webhooks` for the team the webhook is in if the user is different than the requester. 
139pub async fn create_incoming_webhook(configuration: &configuration::Configuration, create_incoming_webhook_request: crate::models::CreateIncomingWebhookRequest) -> Result<crate::models::IncomingWebhook, Error<CreateIncomingWebhookError>> {
140    let local_var_configuration = configuration;
141
142    let local_var_client = &local_var_configuration.client;
143
144    let local_var_uri_str = format!("{}/hooks/incoming", local_var_configuration.base_path);
145    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
146
147    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
148        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
149    }
150    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
151        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
152    };
153    local_var_req_builder = local_var_req_builder.json(&create_incoming_webhook_request);
154
155    let local_var_req = local_var_req_builder.build()?;
156    let local_var_resp = local_var_client.execute(local_var_req).await?;
157
158    let local_var_status = local_var_resp.status();
159    let local_var_content = local_var_resp.text().await?;
160
161    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
162        serde_json::from_str(&local_var_content).map_err(Error::from)
163    } else {
164        let local_var_entity: Option<CreateIncomingWebhookError> = serde_json::from_str(&local_var_content).ok();
165        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
166        Err(Error::ResponseError(local_var_error))
167    }
168}
169
170/// Create an outgoing webhook for a team. ##### Permissions `manage_webhooks` for the team the webhook is in.  `manage_others_outgoing_webhooks` for the team the webhook is in if the user is different than the requester. 
171pub async fn create_outgoing_webhook(configuration: &configuration::Configuration, create_outgoing_webhook_request: crate::models::CreateOutgoingWebhookRequest) -> Result<crate::models::OutgoingWebhook, Error<CreateOutgoingWebhookError>> {
172    let local_var_configuration = configuration;
173
174    let local_var_client = &local_var_configuration.client;
175
176    let local_var_uri_str = format!("{}/hooks/outgoing", local_var_configuration.base_path);
177    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
178
179    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
180        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
181    }
182    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
183        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
184    };
185    local_var_req_builder = local_var_req_builder.json(&create_outgoing_webhook_request);
186
187    let local_var_req = local_var_req_builder.build()?;
188    let local_var_resp = local_var_client.execute(local_var_req).await?;
189
190    let local_var_status = local_var_resp.status();
191    let local_var_content = local_var_resp.text().await?;
192
193    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
194        serde_json::from_str(&local_var_content).map_err(Error::from)
195    } else {
196        let local_var_entity: Option<CreateOutgoingWebhookError> = serde_json::from_str(&local_var_content).ok();
197        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
198        Err(Error::ResponseError(local_var_error))
199    }
200}
201
202/// Delete an incoming webhook given the hook id. ##### Permissions `manage_webhooks` for system or `manage_webhooks` for the specific team or `manage_webhooks` for the channel. 
203pub async fn delete_incoming_webhook(configuration: &configuration::Configuration, hook_id: &str) -> Result<crate::models::StatusOk, Error<DeleteIncomingWebhookError>> {
204    let local_var_configuration = configuration;
205
206    let local_var_client = &local_var_configuration.client;
207
208    let local_var_uri_str = format!("{}/hooks/incoming/{hook_id}", local_var_configuration.base_path, hook_id=crate::apis::urlencode(hook_id));
209    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
210
211    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
212        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
213    }
214    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
215        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
216    };
217
218    let local_var_req = local_var_req_builder.build()?;
219    let local_var_resp = local_var_client.execute(local_var_req).await?;
220
221    let local_var_status = local_var_resp.status();
222    let local_var_content = local_var_resp.text().await?;
223
224    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
225        serde_json::from_str(&local_var_content).map_err(Error::from)
226    } else {
227        let local_var_entity: Option<DeleteIncomingWebhookError> = serde_json::from_str(&local_var_content).ok();
228        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
229        Err(Error::ResponseError(local_var_error))
230    }
231}
232
233/// Delete an outgoing webhook given the hook id. ##### Permissions `manage_webhooks` for system or `manage_webhooks` for the specific team or `manage_webhooks` for the channel. 
234pub async fn delete_outgoing_webhook(configuration: &configuration::Configuration, hook_id: &str) -> Result<crate::models::StatusOk, Error<DeleteOutgoingWebhookError>> {
235    let local_var_configuration = configuration;
236
237    let local_var_client = &local_var_configuration.client;
238
239    let local_var_uri_str = format!("{}/hooks/outgoing/{hook_id}", local_var_configuration.base_path, hook_id=crate::apis::urlencode(hook_id));
240    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
241
242    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
243        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
244    }
245    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
246        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
247    };
248
249    let local_var_req = local_var_req_builder.build()?;
250    let local_var_resp = local_var_client.execute(local_var_req).await?;
251
252    let local_var_status = local_var_resp.status();
253    let local_var_content = local_var_resp.text().await?;
254
255    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
256        serde_json::from_str(&local_var_content).map_err(Error::from)
257    } else {
258        let local_var_entity: Option<DeleteOutgoingWebhookError> = serde_json::from_str(&local_var_content).ok();
259        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
260        Err(Error::ResponseError(local_var_error))
261    }
262}
263
264/// Get an incoming webhook given the hook id. ##### Permissions `manage_webhooks` for system or `manage_webhooks` for the specific team or `manage_webhooks` for the channel. 
265pub async fn get_incoming_webhook(configuration: &configuration::Configuration, hook_id: &str) -> Result<crate::models::IncomingWebhook, Error<GetIncomingWebhookError>> {
266    let local_var_configuration = configuration;
267
268    let local_var_client = &local_var_configuration.client;
269
270    let local_var_uri_str = format!("{}/hooks/incoming/{hook_id}", local_var_configuration.base_path, hook_id=crate::apis::urlencode(hook_id));
271    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
272
273    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
274        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
275    }
276    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
277        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
278    };
279
280    let local_var_req = local_var_req_builder.build()?;
281    let local_var_resp = local_var_client.execute(local_var_req).await?;
282
283    let local_var_status = local_var_resp.status();
284    let local_var_content = local_var_resp.text().await?;
285
286    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
287        serde_json::from_str(&local_var_content).map_err(Error::from)
288    } else {
289        let local_var_entity: Option<GetIncomingWebhookError> = serde_json::from_str(&local_var_content).ok();
290        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
291        Err(Error::ResponseError(local_var_error))
292    }
293}
294
295/// Get a page of a list of incoming webhooks. Optionally filter for a specific team using query parameters. ##### Permissions `manage_webhooks` for the system or `manage_webhooks` for the specific team. 
296pub async fn get_incoming_webhooks(configuration: &configuration::Configuration, page: Option<i32>, per_page: Option<i32>, team_id: Option<&str>) -> Result<Vec<crate::models::IncomingWebhook>, Error<GetIncomingWebhooksError>> {
297    let local_var_configuration = configuration;
298
299    let local_var_client = &local_var_configuration.client;
300
301    let local_var_uri_str = format!("{}/hooks/incoming", local_var_configuration.base_path);
302    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
303
304    if let Some(ref local_var_str) = page {
305        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
306    }
307    if let Some(ref local_var_str) = per_page {
308        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
309    }
310    if let Some(ref local_var_str) = team_id {
311        local_var_req_builder = local_var_req_builder.query(&[("team_id", &local_var_str.to_string())]);
312    }
313    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
314        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
315    }
316    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
317        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
318    };
319
320    let local_var_req = local_var_req_builder.build()?;
321    let local_var_resp = local_var_client.execute(local_var_req).await?;
322
323    let local_var_status = local_var_resp.status();
324    let local_var_content = local_var_resp.text().await?;
325
326    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
327        serde_json::from_str(&local_var_content).map_err(Error::from)
328    } else {
329        let local_var_entity: Option<GetIncomingWebhooksError> = serde_json::from_str(&local_var_content).ok();
330        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
331        Err(Error::ResponseError(local_var_error))
332    }
333}
334
335/// Get an outgoing webhook given the hook id. ##### Permissions `manage_webhooks` for system or `manage_webhooks` for the specific team or `manage_webhooks` for the channel. 
336pub async fn get_outgoing_webhook(configuration: &configuration::Configuration, hook_id: &str) -> Result<crate::models::OutgoingWebhook, Error<GetOutgoingWebhookError>> {
337    let local_var_configuration = configuration;
338
339    let local_var_client = &local_var_configuration.client;
340
341    let local_var_uri_str = format!("{}/hooks/outgoing/{hook_id}", local_var_configuration.base_path, hook_id=crate::apis::urlencode(hook_id));
342    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
343
344    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
345        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
346    }
347    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
348        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
349    };
350
351    let local_var_req = local_var_req_builder.build()?;
352    let local_var_resp = local_var_client.execute(local_var_req).await?;
353
354    let local_var_status = local_var_resp.status();
355    let local_var_content = local_var_resp.text().await?;
356
357    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
358        serde_json::from_str(&local_var_content).map_err(Error::from)
359    } else {
360        let local_var_entity: Option<GetOutgoingWebhookError> = serde_json::from_str(&local_var_content).ok();
361        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
362        Err(Error::ResponseError(local_var_error))
363    }
364}
365
366/// Get a page of a list of outgoing webhooks. Optionally filter for a specific team or channel using query parameters. ##### Permissions `manage_webhooks` for the system or `manage_webhooks` for the specific team/channel. 
367pub async fn get_outgoing_webhooks(configuration: &configuration::Configuration, page: Option<i32>, per_page: Option<i32>, team_id: Option<&str>, channel_id: Option<&str>) -> Result<Vec<crate::models::OutgoingWebhook>, Error<GetOutgoingWebhooksError>> {
368    let local_var_configuration = configuration;
369
370    let local_var_client = &local_var_configuration.client;
371
372    let local_var_uri_str = format!("{}/hooks/outgoing", local_var_configuration.base_path);
373    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
374
375    if let Some(ref local_var_str) = page {
376        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
377    }
378    if let Some(ref local_var_str) = per_page {
379        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
380    }
381    if let Some(ref local_var_str) = team_id {
382        local_var_req_builder = local_var_req_builder.query(&[("team_id", &local_var_str.to_string())]);
383    }
384    if let Some(ref local_var_str) = channel_id {
385        local_var_req_builder = local_var_req_builder.query(&[("channel_id", &local_var_str.to_string())]);
386    }
387    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
388        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
389    }
390    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
391        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
392    };
393
394    let local_var_req = local_var_req_builder.build()?;
395    let local_var_resp = local_var_client.execute(local_var_req).await?;
396
397    let local_var_status = local_var_resp.status();
398    let local_var_content = local_var_resp.text().await?;
399
400    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
401        serde_json::from_str(&local_var_content).map_err(Error::from)
402    } else {
403        let local_var_entity: Option<GetOutgoingWebhooksError> = serde_json::from_str(&local_var_content).ok();
404        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
405        Err(Error::ResponseError(local_var_error))
406    }
407}
408
409/// Regenerate the token for the outgoing webhook. ##### Permissions `manage_webhooks` for system or `manage_webhooks` for the specific team or `manage_webhooks` for the channel. 
410pub async fn regen_outgoing_hook_token(configuration: &configuration::Configuration, hook_id: &str) -> Result<crate::models::StatusOk, Error<RegenOutgoingHookTokenError>> {
411    let local_var_configuration = configuration;
412
413    let local_var_client = &local_var_configuration.client;
414
415    let local_var_uri_str = format!("{}/hooks/outgoing/{hook_id}/regen_token", local_var_configuration.base_path, hook_id=crate::apis::urlencode(hook_id));
416    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
417
418    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
419        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
420    }
421    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
422        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
423    };
424
425    let local_var_req = local_var_req_builder.build()?;
426    let local_var_resp = local_var_client.execute(local_var_req).await?;
427
428    let local_var_status = local_var_resp.status();
429    let local_var_content = local_var_resp.text().await?;
430
431    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
432        serde_json::from_str(&local_var_content).map_err(Error::from)
433    } else {
434        let local_var_entity: Option<RegenOutgoingHookTokenError> = serde_json::from_str(&local_var_content).ok();
435        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
436        Err(Error::ResponseError(local_var_error))
437    }
438}
439
440/// Update an incoming webhook given the hook id. ##### Permissions `manage_webhooks` for system or `manage_webhooks` for the specific team or `manage_webhooks` for the channel. 
441pub async fn update_incoming_webhook(configuration: &configuration::Configuration, hook_id: &str, update_incoming_webhook_request: crate::models::UpdateIncomingWebhookRequest) -> Result<crate::models::IncomingWebhook, Error<UpdateIncomingWebhookError>> {
442    let local_var_configuration = configuration;
443
444    let local_var_client = &local_var_configuration.client;
445
446    let local_var_uri_str = format!("{}/hooks/incoming/{hook_id}", local_var_configuration.base_path, hook_id=crate::apis::urlencode(hook_id));
447    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
448
449    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
450        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
451    }
452    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
453        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
454    };
455    local_var_req_builder = local_var_req_builder.json(&update_incoming_webhook_request);
456
457    let local_var_req = local_var_req_builder.build()?;
458    let local_var_resp = local_var_client.execute(local_var_req).await?;
459
460    let local_var_status = local_var_resp.status();
461    let local_var_content = local_var_resp.text().await?;
462
463    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
464        serde_json::from_str(&local_var_content).map_err(Error::from)
465    } else {
466        let local_var_entity: Option<UpdateIncomingWebhookError> = serde_json::from_str(&local_var_content).ok();
467        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
468        Err(Error::ResponseError(local_var_error))
469    }
470}
471
472/// Update an outgoing webhook given the hook id. ##### Permissions `manage_webhooks` for system or `manage_webhooks` for the specific team or `manage_webhooks` for the channel. 
473pub async fn update_outgoing_webhook(configuration: &configuration::Configuration, hook_id: &str, update_outgoing_webhook_request: crate::models::UpdateOutgoingWebhookRequest) -> Result<crate::models::OutgoingWebhook, Error<UpdateOutgoingWebhookError>> {
474    let local_var_configuration = configuration;
475
476    let local_var_client = &local_var_configuration.client;
477
478    let local_var_uri_str = format!("{}/hooks/outgoing/{hook_id}", local_var_configuration.base_path, hook_id=crate::apis::urlencode(hook_id));
479    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
480
481    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
482        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
483    }
484    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
485        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
486    };
487    local_var_req_builder = local_var_req_builder.json(&update_outgoing_webhook_request);
488
489    let local_var_req = local_var_req_builder.build()?;
490    let local_var_resp = local_var_client.execute(local_var_req).await?;
491
492    let local_var_status = local_var_resp.status();
493    let local_var_content = local_var_resp.text().await?;
494
495    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
496        serde_json::from_str(&local_var_content).map_err(Error::from)
497    } else {
498        let local_var_entity: Option<UpdateOutgoingWebhookError> = serde_json::from_str(&local_var_content).ok();
499        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
500        Err(Error::ResponseError(local_var_error))
501    }
502}
503