mattermost_client/openapi/apis/
posts_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
11use reqwest;
12
13use super::ResponseContent;
14use super::{configuration, Error};
15
16/// struct for passing parameters to the method [`create_post`]
17#[derive(Clone, Debug, Default)]
18pub struct CreatePostParams {
19    /// Post object to create
20    pub create_post_request: crate::openapi::models::CreatePostRequest,
21    /// Whether to set the user status as online or not.
22    pub set_online: Option<bool>,
23}
24
25/// struct for passing parameters to the method [`create_post_ephemeral`]
26#[derive(Clone, Debug, Default)]
27pub struct CreatePostEphemeralParams {
28    /// Ephemeral Post object to send
29    pub create_post_ephemeral_request: crate::openapi::models::CreatePostEphemeralRequest,
30}
31
32/// struct for passing parameters to the method [`delete_post`]
33#[derive(Clone, Debug, Default)]
34pub struct DeletePostParams {
35    /// ID of the post to delete
36    pub post_id: String,
37}
38
39/// struct for passing parameters to the method [`do_post_action`]
40#[derive(Clone, Debug, Default)]
41pub struct DoPostActionParams {
42    /// Post GUID
43    pub post_id: String,
44    /// Action GUID
45    pub action_id: String,
46}
47
48/// struct for passing parameters to the method [`get_file_infos_for_post`]
49#[derive(Clone, Debug, Default)]
50pub struct GetFileInfosForPostParams {
51    /// ID of the post
52    pub post_id: String,
53    /// Defines if result should include deleted posts, must have 'manage_system' (admin) permission.
54    pub include_deleted: Option<bool>,
55}
56
57/// struct for passing parameters to the method [`get_flagged_posts_for_user`]
58#[derive(Clone, Debug, Default)]
59pub struct GetFlaggedPostsForUserParams {
60    /// ID of the user
61    pub user_id: String,
62    /// Team ID
63    pub team_id: Option<String>,
64    /// Channel ID
65    pub channel_id: Option<String>,
66    /// The page to select
67    pub page: Option<i32>,
68    /// The number of posts per page
69    pub per_page: Option<i32>,
70}
71
72/// struct for passing parameters to the method [`get_post`]
73#[derive(Clone, Debug, Default)]
74pub struct GetPostParams {
75    /// ID of the post to get
76    pub post_id: String,
77    /// Defines if result should include deleted posts, must have 'manage_system' (admin) permission.
78    pub include_deleted: Option<bool>,
79}
80
81/// struct for passing parameters to the method [`get_post_thread`]
82#[derive(Clone, Debug, Default)]
83pub struct GetPostThreadParams {
84    /// ID of a post in the thread
85    pub post_id: String,
86    /// The number of posts per page
87    pub per_page: Option<i32>,
88    /// The post_id to return the next page of posts from
89    pub from_post: Option<String>,
90    /// The create_at timestamp to return the next page of posts from
91    pub from_create_at: Option<i32>,
92    /// The direction to return the posts. Either up or down.
93    pub direction: Option<String>,
94    /// Whether to skip fetching threads or not
95    pub skip_fetch_threads: Option<bool>,
96    /// Whether the client uses CRT or not
97    pub collapsed_threads: Option<bool>,
98    /// Whether to return the associated users as part of the response or not
99    pub collapsed_threads_extended: Option<bool>,
100}
101
102/// struct for passing parameters to the method [`get_posts_around_last_unread`]
103#[derive(Clone, Debug, Default)]
104pub struct GetPostsAroundLastUnreadParams {
105    /// ID of the user
106    pub user_id: String,
107    /// The channel ID to get the posts for
108    pub channel_id: String,
109    /// Number of posts before the oldest unread posts. Maximum is 200 posts if limit is set greater than that.
110    pub limit_before: Option<u32>,
111    /// Number of posts after and including the oldest unread post. Maximum is 200 posts if limit is set greater than that.
112    pub limit_after: Option<u32>,
113    /// Whether to skip fetching threads or not
114    pub skip_fetch_threads: Option<bool>,
115    /// Whether the client uses CRT or not
116    pub collapsed_threads: Option<bool>,
117    /// Whether to return the associated users as part of the response or not
118    pub collapsed_threads_extended: Option<bool>,
119}
120
121/// struct for passing parameters to the method [`get_posts_by_ids`]
122#[derive(Clone, Debug, Default)]
123pub struct GetPostsByIdsParams {
124    /// List of post ids
125    pub request_body: Vec<String>,
126}
127
128/// struct for passing parameters to the method [`get_posts_for_channel`]
129#[derive(Clone, Debug, Default)]
130pub struct GetPostsForChannelParams {
131    /// The channel ID to get the posts for
132    pub channel_id: String,
133    /// The page to select
134    pub page: Option<i32>,
135    /// The number of posts per page
136    pub per_page: Option<i32>,
137    /// Provide a non-zero value in Unix time milliseconds to select posts modified after that time
138    pub since: Option<i32>,
139    /// A post id to select the posts that came before this one
140    pub before: Option<String>,
141    /// A post id to select the posts that came after this one
142    pub after: Option<String>,
143    /// Whether to include deleted posts or not. Must have system admin permissions.
144    pub include_deleted: Option<bool>,
145}
146
147/// struct for passing parameters to the method [`patch_post`]
148#[derive(Clone, Debug, Default)]
149pub struct PatchPostParams {
150    /// Post GUID
151    pub post_id: String,
152    /// Post object that is to be updated
153    pub patch_post_request: crate::openapi::models::PatchPostRequest,
154}
155
156/// struct for passing parameters to the method [`pin_post`]
157#[derive(Clone, Debug, Default)]
158pub struct PinPostParams {
159    /// Post GUID
160    pub post_id: String,
161}
162
163/// struct for passing parameters to the method [`save_acknowledgement_for_post`]
164#[derive(Clone, Debug, Default)]
165pub struct SaveAcknowledgementForPostParams {
166    /// User GUID
167    pub user_id: String,
168    /// Post GUID
169    pub post_id: String,
170}
171
172/// struct for passing parameters to the method [`save_acknowledgement_for_post_0`]
173#[derive(Clone, Debug, Default)]
174pub struct SaveAcknowledgementForPost0Params {
175    /// User GUID
176    pub user_id: String,
177    /// Post GUID
178    pub post_id: String,
179}
180
181/// struct for passing parameters to the method [`search_posts`]
182#[derive(Clone, Debug, Default)]
183pub struct SearchPostsParams {
184    /// Team GUID
185    pub team_id: String,
186    /// The search terms and logic to use in the search.
187    pub search_posts_request: crate::openapi::models::SearchPostsRequest,
188}
189
190/// struct for passing parameters to the method [`set_post_reminder`]
191#[derive(Clone, Debug, Default)]
192pub struct SetPostReminderParams {
193    /// User GUID
194    pub user_id: String,
195    /// Post GUID
196    pub post_id: String,
197    /// Target time for the reminder
198    pub set_post_reminder_request: crate::openapi::models::SetPostReminderRequest,
199}
200
201/// struct for passing parameters to the method [`set_post_unread`]
202#[derive(Clone, Debug, Default)]
203pub struct SetPostUnreadParams {
204    /// User GUID
205    pub user_id: String,
206    /// Post GUID
207    pub post_id: String,
208}
209
210/// struct for passing parameters to the method [`unpin_post`]
211#[derive(Clone, Debug, Default)]
212pub struct UnpinPostParams {
213    /// Post GUID
214    pub post_id: String,
215}
216
217/// struct for passing parameters to the method [`update_post`]
218#[derive(Clone, Debug, Default)]
219pub struct UpdatePostParams {
220    /// ID of the post to update
221    pub post_id: String,
222    /// Post object that is to be updated
223    pub update_post_request: crate::openapi::models::UpdatePostRequest,
224}
225
226/// struct for typed errors of method [`create_post`]
227#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
228#[serde(untagged)]
229pub enum CreatePostError {
230    Status400(crate::openapi::models::AppError),
231    Status401(crate::openapi::models::AppError),
232    Status403(crate::openapi::models::AppError),
233    UnknownValue(serde_json::Value),
234}
235
236/// struct for typed errors of method [`create_post_ephemeral`]
237#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
238#[serde(untagged)]
239pub enum CreatePostEphemeralError {
240    Status400(crate::openapi::models::AppError),
241    Status401(crate::openapi::models::AppError),
242    Status403(crate::openapi::models::AppError),
243    UnknownValue(serde_json::Value),
244}
245
246/// struct for typed errors of method [`delete_post`]
247#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
248#[serde(untagged)]
249pub enum DeletePostError {
250    Status400(crate::openapi::models::AppError),
251    Status401(crate::openapi::models::AppError),
252    Status403(crate::openapi::models::AppError),
253    UnknownValue(serde_json::Value),
254}
255
256/// struct for typed errors of method [`do_post_action`]
257#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
258#[serde(untagged)]
259pub enum DoPostActionError {
260    Status400(crate::openapi::models::AppError),
261    Status401(crate::openapi::models::AppError),
262    Status403(crate::openapi::models::AppError),
263    UnknownValue(serde_json::Value),
264}
265
266/// struct for typed errors of method [`get_file_infos_for_post`]
267#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
268#[serde(untagged)]
269pub enum GetFileInfosForPostError {
270    Status400(crate::openapi::models::AppError),
271    Status401(crate::openapi::models::AppError),
272    Status403(crate::openapi::models::AppError),
273    UnknownValue(serde_json::Value),
274}
275
276/// struct for typed errors of method [`get_flagged_posts_for_user`]
277#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
278#[serde(untagged)]
279pub enum GetFlaggedPostsForUserError {
280    Status400(crate::openapi::models::AppError),
281    Status401(crate::openapi::models::AppError),
282    Status403(crate::openapi::models::AppError),
283    UnknownValue(serde_json::Value),
284}
285
286/// struct for typed errors of method [`get_post`]
287#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
288#[serde(untagged)]
289pub enum GetPostError {
290    Status400(crate::openapi::models::AppError),
291    Status401(crate::openapi::models::AppError),
292    Status403(crate::openapi::models::AppError),
293    UnknownValue(serde_json::Value),
294}
295
296/// struct for typed errors of method [`get_post_thread`]
297#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
298#[serde(untagged)]
299pub enum GetPostThreadError {
300    Status400(crate::openapi::models::AppError),
301    Status401(crate::openapi::models::AppError),
302    Status403(crate::openapi::models::AppError),
303    UnknownValue(serde_json::Value),
304}
305
306/// struct for typed errors of method [`get_posts_around_last_unread`]
307#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
308#[serde(untagged)]
309pub enum GetPostsAroundLastUnreadError {
310    Status400(crate::openapi::models::AppError),
311    Status401(crate::openapi::models::AppError),
312    Status403(crate::openapi::models::AppError),
313    UnknownValue(serde_json::Value),
314}
315
316/// struct for typed errors of method [`get_posts_by_ids`]
317#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
318#[serde(untagged)]
319pub enum GetPostsByIdsError {
320    Status400(crate::openapi::models::AppError),
321    Status401(crate::openapi::models::AppError),
322    Status403(crate::openapi::models::AppError),
323    UnknownValue(serde_json::Value),
324}
325
326/// struct for typed errors of method [`get_posts_for_channel`]
327#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
328#[serde(untagged)]
329pub enum GetPostsForChannelError {
330    Status400(crate::openapi::models::AppError),
331    Status401(crate::openapi::models::AppError),
332    Status403(crate::openapi::models::AppError),
333    UnknownValue(serde_json::Value),
334}
335
336/// struct for typed errors of method [`patch_post`]
337#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
338#[serde(untagged)]
339pub enum PatchPostError {
340    Status400(crate::openapi::models::AppError),
341    Status401(crate::openapi::models::AppError),
342    Status403(crate::openapi::models::AppError),
343    UnknownValue(serde_json::Value),
344}
345
346/// struct for typed errors of method [`pin_post`]
347#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
348#[serde(untagged)]
349pub enum PinPostError {
350    Status400(crate::openapi::models::AppError),
351    Status401(crate::openapi::models::AppError),
352    Status403(crate::openapi::models::AppError),
353    UnknownValue(serde_json::Value),
354}
355
356/// struct for typed errors of method [`save_acknowledgement_for_post`]
357#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
358#[serde(untagged)]
359pub enum SaveAcknowledgementForPostError {
360    Status400(crate::openapi::models::AppError),
361    Status401(crate::openapi::models::AppError),
362    Status403(crate::openapi::models::AppError),
363    Status404(crate::openapi::models::AppError),
364    UnknownValue(serde_json::Value),
365}
366
367/// struct for typed errors of method [`save_acknowledgement_for_post_0`]
368#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
369#[serde(untagged)]
370pub enum SaveAcknowledgementForPost0Error {
371    Status400(crate::openapi::models::AppError),
372    Status401(crate::openapi::models::AppError),
373    Status403(crate::openapi::models::AppError),
374    Status404(crate::openapi::models::AppError),
375    UnknownValue(serde_json::Value),
376}
377
378/// struct for typed errors of method [`search_posts`]
379#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
380#[serde(untagged)]
381pub enum SearchPostsError {
382    Status400(crate::openapi::models::AppError),
383    Status401(crate::openapi::models::AppError),
384    Status403(crate::openapi::models::AppError),
385    UnknownValue(serde_json::Value),
386}
387
388/// struct for typed errors of method [`set_post_reminder`]
389#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
390#[serde(untagged)]
391pub enum SetPostReminderError {
392    Status400(crate::openapi::models::AppError),
393    Status401(crate::openapi::models::AppError),
394    Status403(crate::openapi::models::AppError),
395    Status404(crate::openapi::models::AppError),
396    UnknownValue(serde_json::Value),
397}
398
399/// struct for typed errors of method [`set_post_unread`]
400#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
401#[serde(untagged)]
402pub enum SetPostUnreadError {
403    Status400(crate::openapi::models::AppError),
404    Status401(crate::openapi::models::AppError),
405    Status403(crate::openapi::models::AppError),
406    Status404(crate::openapi::models::AppError),
407    UnknownValue(serde_json::Value),
408}
409
410/// struct for typed errors of method [`unpin_post`]
411#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
412#[serde(untagged)]
413pub enum UnpinPostError {
414    Status400(crate::openapi::models::AppError),
415    Status401(crate::openapi::models::AppError),
416    Status403(crate::openapi::models::AppError),
417    UnknownValue(serde_json::Value),
418}
419
420/// struct for typed errors of method [`update_post`]
421#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
422#[serde(untagged)]
423pub enum UpdatePostError {
424    Status400(crate::openapi::models::AppError),
425    Status401(crate::openapi::models::AppError),
426    Status403(crate::openapi::models::AppError),
427    UnknownValue(serde_json::Value),
428}
429
430/// Create a new post in a channel. To create the post as a comment on another post, provide `root_id`. ##### Permissions Must have `create_post` permission for the channel the post is being created in.
431pub async fn create_post(
432    configuration: &configuration::Configuration,
433    params: CreatePostParams,
434) -> Result<crate::openapi::models::Post, Error<CreatePostError>> {
435    let local_var_configuration = configuration;
436
437    // unbox the parameters
438    let create_post_request = params.create_post_request;
439    let set_online = params.set_online;
440
441    let local_var_client = &local_var_configuration.client;
442
443    let local_var_uri_str = format!("{}/api/v4/posts", local_var_configuration.base_path);
444    let mut local_var_req_builder =
445        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
446
447    if let Some(ref local_var_str) = set_online {
448        local_var_req_builder =
449            local_var_req_builder.query(&[("set_online", &local_var_str.to_string())]);
450    }
451    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
452        local_var_req_builder =
453            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
454    }
455    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
456        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
457    };
458    local_var_req_builder = local_var_req_builder.json(&create_post_request);
459
460    let local_var_req = local_var_req_builder.build()?;
461    let local_var_resp = local_var_client.execute(local_var_req).await?;
462
463    let local_var_status = local_var_resp.status();
464    let local_var_content = local_var_resp.text().await?;
465
466    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
467        serde_json::from_str(&local_var_content).map_err(Error::from)
468    } else {
469        let local_var_entity: Option<CreatePostError> =
470            serde_json::from_str(&local_var_content).ok();
471        let local_var_error = ResponseContent {
472            status: local_var_status,
473            content: local_var_content,
474            entity: local_var_entity,
475        };
476        Err(Error::ResponseError(local_var_error))
477    }
478}
479
480/// Create a new ephemeral post in a channel. ##### Permissions Must have `create_post_ephemeral` permission (currently only given to system admin)
481pub async fn create_post_ephemeral(
482    configuration: &configuration::Configuration,
483    params: CreatePostEphemeralParams,
484) -> Result<crate::openapi::models::Post, Error<CreatePostEphemeralError>> {
485    let local_var_configuration = configuration;
486
487    // unbox the parameters
488    let create_post_ephemeral_request = params.create_post_ephemeral_request;
489
490    let local_var_client = &local_var_configuration.client;
491
492    let local_var_uri_str = format!(
493        "{}/api/v4/posts/ephemeral",
494        local_var_configuration.base_path
495    );
496    let mut local_var_req_builder =
497        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
498
499    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
500        local_var_req_builder =
501            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
502    }
503    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
504        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
505    };
506    local_var_req_builder = local_var_req_builder.json(&create_post_ephemeral_request);
507
508    let local_var_req = local_var_req_builder.build()?;
509    let local_var_resp = local_var_client.execute(local_var_req).await?;
510
511    let local_var_status = local_var_resp.status();
512    let local_var_content = local_var_resp.text().await?;
513
514    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
515        serde_json::from_str(&local_var_content).map_err(Error::from)
516    } else {
517        let local_var_entity: Option<CreatePostEphemeralError> =
518            serde_json::from_str(&local_var_content).ok();
519        let local_var_error = ResponseContent {
520            status: local_var_status,
521            content: local_var_content,
522            entity: local_var_entity,
523        };
524        Err(Error::ResponseError(local_var_error))
525    }
526}
527
528/// Soft deletes a post, by marking the post as deleted in the database. Soft deleted posts will not be returned in post queries. ##### Permissions Must be logged in as the user or have `delete_others_posts` permission.
529pub async fn delete_post(
530    configuration: &configuration::Configuration,
531    params: DeletePostParams,
532) -> Result<crate::openapi::models::StatusOk, Error<DeletePostError>> {
533    let local_var_configuration = configuration;
534
535    // unbox the parameters
536    let post_id = params.post_id;
537
538    let local_var_client = &local_var_configuration.client;
539
540    let local_var_uri_str = format!(
541        "{}/api/v4/posts/{post_id}",
542        local_var_configuration.base_path,
543        post_id = super::urlencode(post_id)
544    );
545    let mut local_var_req_builder =
546        local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
547
548    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
549        local_var_req_builder =
550            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
551    }
552    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
553        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
554    };
555
556    let local_var_req = local_var_req_builder.build()?;
557    let local_var_resp = local_var_client.execute(local_var_req).await?;
558
559    let local_var_status = local_var_resp.status();
560    let local_var_content = local_var_resp.text().await?;
561
562    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
563        serde_json::from_str(&local_var_content).map_err(Error::from)
564    } else {
565        let local_var_entity: Option<DeletePostError> =
566            serde_json::from_str(&local_var_content).ok();
567        let local_var_error = ResponseContent {
568            status: local_var_status,
569            content: local_var_content,
570            entity: local_var_entity,
571        };
572        Err(Error::ResponseError(local_var_error))
573    }
574}
575
576/// Perform a post action, which allows users to interact with integrations through posts. ##### Permissions Must be authenticated and have the `read_channel` permission to the channel the post is in.
577pub async fn do_post_action(
578    configuration: &configuration::Configuration,
579    params: DoPostActionParams,
580) -> Result<crate::openapi::models::StatusOk, Error<DoPostActionError>> {
581    let local_var_configuration = configuration;
582
583    // unbox the parameters
584    let post_id = params.post_id;
585    let action_id = params.action_id;
586
587    let local_var_client = &local_var_configuration.client;
588
589    let local_var_uri_str = format!(
590        "{}/api/v4/posts/{post_id}/actions/{action_id}",
591        local_var_configuration.base_path,
592        post_id = super::urlencode(post_id),
593        action_id = super::urlencode(action_id)
594    );
595    let mut local_var_req_builder =
596        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
597
598    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
599        local_var_req_builder =
600            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
601    }
602    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
603        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
604    };
605
606    let local_var_req = local_var_req_builder.build()?;
607    let local_var_resp = local_var_client.execute(local_var_req).await?;
608
609    let local_var_status = local_var_resp.status();
610    let local_var_content = local_var_resp.text().await?;
611
612    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
613        serde_json::from_str(&local_var_content).map_err(Error::from)
614    } else {
615        let local_var_entity: Option<DoPostActionError> =
616            serde_json::from_str(&local_var_content).ok();
617        let local_var_error = ResponseContent {
618            status: local_var_status,
619            content: local_var_content,
620            entity: local_var_entity,
621        };
622        Err(Error::ResponseError(local_var_error))
623    }
624}
625
626/// Gets a list of file information objects for the files attached to a post. ##### Permissions Must have `read_channel` permission for the channel the post is in.
627pub async fn get_file_infos_for_post(
628    configuration: &configuration::Configuration,
629    params: GetFileInfosForPostParams,
630) -> Result<Vec<crate::openapi::models::FileInfo>, Error<GetFileInfosForPostError>> {
631    let local_var_configuration = configuration;
632
633    // unbox the parameters
634    let post_id = params.post_id;
635    let include_deleted = params.include_deleted;
636
637    let local_var_client = &local_var_configuration.client;
638
639    let local_var_uri_str = format!(
640        "{}/api/v4/posts/{post_id}/files/info",
641        local_var_configuration.base_path,
642        post_id = super::urlencode(post_id)
643    );
644    let mut local_var_req_builder =
645        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
646
647    if let Some(ref local_var_str) = include_deleted {
648        local_var_req_builder =
649            local_var_req_builder.query(&[("include_deleted", &local_var_str.to_string())]);
650    }
651    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
652        local_var_req_builder =
653            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
654    }
655    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
656        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
657    };
658
659    let local_var_req = local_var_req_builder.build()?;
660    let local_var_resp = local_var_client.execute(local_var_req).await?;
661
662    let local_var_status = local_var_resp.status();
663    let local_var_content = local_var_resp.text().await?;
664
665    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
666        serde_json::from_str(&local_var_content).map_err(Error::from)
667    } else {
668        let local_var_entity: Option<GetFileInfosForPostError> =
669            serde_json::from_str(&local_var_content).ok();
670        let local_var_error = ResponseContent {
671            status: local_var_status,
672            content: local_var_content,
673            entity: local_var_entity,
674        };
675        Err(Error::ResponseError(local_var_error))
676    }
677}
678
679/// Get a page of flagged posts of a user provided user id string. Selects from a channel, team, or all flagged posts by a user. Will only return posts from channels in which the user is member. ##### Permissions Must be user or have `manage_system` permission.
680pub async fn get_flagged_posts_for_user(
681    configuration: &configuration::Configuration,
682    params: GetFlaggedPostsForUserParams,
683) -> Result<Vec<crate::openapi::models::PostList>, Error<GetFlaggedPostsForUserError>> {
684    let local_var_configuration = configuration;
685
686    // unbox the parameters
687    let user_id = params.user_id;
688    let team_id = params.team_id;
689    let channel_id = params.channel_id;
690    let page = params.page;
691    let per_page = params.per_page;
692
693    let local_var_client = &local_var_configuration.client;
694
695    let local_var_uri_str = format!(
696        "{}/api/v4/users/{user_id}/posts/flagged",
697        local_var_configuration.base_path,
698        user_id = super::urlencode(user_id)
699    );
700    let mut local_var_req_builder =
701        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
702
703    if let Some(ref local_var_str) = team_id {
704        local_var_req_builder =
705            local_var_req_builder.query(&[("team_id", &local_var_str.to_string())]);
706    }
707    if let Some(ref local_var_str) = channel_id {
708        local_var_req_builder =
709            local_var_req_builder.query(&[("channel_id", &local_var_str.to_string())]);
710    }
711    if let Some(ref local_var_str) = page {
712        local_var_req_builder =
713            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
714    }
715    if let Some(ref local_var_str) = per_page {
716        local_var_req_builder =
717            local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
718    }
719    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
720        local_var_req_builder =
721            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
722    }
723    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
724        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
725    };
726
727    let local_var_req = local_var_req_builder.build()?;
728    let local_var_resp = local_var_client.execute(local_var_req).await?;
729
730    let local_var_status = local_var_resp.status();
731    let local_var_content = local_var_resp.text().await?;
732
733    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
734        serde_json::from_str(&local_var_content).map_err(Error::from)
735    } else {
736        let local_var_entity: Option<GetFlaggedPostsForUserError> =
737            serde_json::from_str(&local_var_content).ok();
738        let local_var_error = ResponseContent {
739            status: local_var_status,
740            content: local_var_content,
741            entity: local_var_entity,
742        };
743        Err(Error::ResponseError(local_var_error))
744    }
745}
746
747/// Get a single post. ##### Permissions Must have `read_channel` permission for the channel the post is in or if the channel is public, have the `read_public_channels` permission for the team.
748pub async fn get_post(
749    configuration: &configuration::Configuration,
750    params: GetPostParams,
751) -> Result<crate::openapi::models::Post, Error<GetPostError>> {
752    let local_var_configuration = configuration;
753
754    // unbox the parameters
755    let post_id = params.post_id;
756    let include_deleted = params.include_deleted;
757
758    let local_var_client = &local_var_configuration.client;
759
760    let local_var_uri_str = format!(
761        "{}/api/v4/posts/{post_id}",
762        local_var_configuration.base_path,
763        post_id = super::urlencode(post_id)
764    );
765    let mut local_var_req_builder =
766        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
767
768    if let Some(ref local_var_str) = include_deleted {
769        local_var_req_builder =
770            local_var_req_builder.query(&[("include_deleted", &local_var_str.to_string())]);
771    }
772    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
773        local_var_req_builder =
774            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
775    }
776    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
777        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
778    };
779
780    let local_var_req = local_var_req_builder.build()?;
781    let local_var_resp = local_var_client.execute(local_var_req).await?;
782
783    let local_var_status = local_var_resp.status();
784    let local_var_content = local_var_resp.text().await?;
785
786    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
787        serde_json::from_str(&local_var_content).map_err(Error::from)
788    } else {
789        let local_var_entity: Option<GetPostError> = serde_json::from_str(&local_var_content).ok();
790        let local_var_error = ResponseContent {
791            status: local_var_status,
792            content: local_var_content,
793            entity: local_var_entity,
794        };
795        Err(Error::ResponseError(local_var_error))
796    }
797}
798
799/// Get a post and the rest of the posts in the same thread. ##### Permissions Must have `read_channel` permission for the channel the post is in or if the channel is public, have the `read_public_channels` permission for the team.
800pub async fn get_post_thread(
801    configuration: &configuration::Configuration,
802    params: GetPostThreadParams,
803) -> Result<crate::openapi::models::PostList, Error<GetPostThreadError>> {
804    let local_var_configuration = configuration;
805
806    // unbox the parameters
807    let post_id = params.post_id;
808    let per_page = params.per_page;
809    let from_post = params.from_post;
810    let from_create_at = params.from_create_at;
811    let direction = params.direction;
812    let skip_fetch_threads = params.skip_fetch_threads;
813    let collapsed_threads = params.collapsed_threads;
814    let collapsed_threads_extended = params.collapsed_threads_extended;
815
816    let local_var_client = &local_var_configuration.client;
817
818    let local_var_uri_str = format!(
819        "{}/api/v4/posts/{post_id}/thread",
820        local_var_configuration.base_path,
821        post_id = super::urlencode(post_id)
822    );
823    let mut local_var_req_builder =
824        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
825
826    if let Some(ref local_var_str) = per_page {
827        local_var_req_builder =
828            local_var_req_builder.query(&[("perPage", &local_var_str.to_string())]);
829    }
830    if let Some(ref local_var_str) = from_post {
831        local_var_req_builder =
832            local_var_req_builder.query(&[("fromPost", &local_var_str.to_string())]);
833    }
834    if let Some(ref local_var_str) = from_create_at {
835        local_var_req_builder =
836            local_var_req_builder.query(&[("fromCreateAt", &local_var_str.to_string())]);
837    }
838    if let Some(ref local_var_str) = direction {
839        local_var_req_builder =
840            local_var_req_builder.query(&[("direction", &local_var_str.to_string())]);
841    }
842    if let Some(ref local_var_str) = skip_fetch_threads {
843        local_var_req_builder =
844            local_var_req_builder.query(&[("skipFetchThreads", &local_var_str.to_string())]);
845    }
846    if let Some(ref local_var_str) = collapsed_threads {
847        local_var_req_builder =
848            local_var_req_builder.query(&[("collapsedThreads", &local_var_str.to_string())]);
849    }
850    if let Some(ref local_var_str) = collapsed_threads_extended {
851        local_var_req_builder = local_var_req_builder
852            .query(&[("collapsedThreadsExtended", &local_var_str.to_string())]);
853    }
854    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
855        local_var_req_builder =
856            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
857    }
858    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
859        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
860    };
861
862    let local_var_req = local_var_req_builder.build()?;
863    let local_var_resp = local_var_client.execute(local_var_req).await?;
864
865    let local_var_status = local_var_resp.status();
866    let local_var_content = local_var_resp.text().await?;
867
868    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
869        serde_json::from_str(&local_var_content).map_err(Error::from)
870    } else {
871        let local_var_entity: Option<GetPostThreadError> =
872            serde_json::from_str(&local_var_content).ok();
873        let local_var_error = ResponseContent {
874            status: local_var_status,
875            content: local_var_content,
876            entity: local_var_entity,
877        };
878        Err(Error::ResponseError(local_var_error))
879    }
880}
881
882/// Get the oldest unread post in the channel for the given user as well as the posts around it. The returned list is sorted in descending order (most recent post first). ##### Permissions Must be logged in as the user or have `edit_other_users` permission, and must have `read_channel` permission for the channel. __Minimum server version__: 5.14
883pub async fn get_posts_around_last_unread(
884    configuration: &configuration::Configuration,
885    params: GetPostsAroundLastUnreadParams,
886) -> Result<crate::openapi::models::PostList, Error<GetPostsAroundLastUnreadError>> {
887    let local_var_configuration = configuration;
888
889    // unbox the parameters
890    let user_id = params.user_id;
891    let channel_id = params.channel_id;
892    let limit_before = params.limit_before;
893    let limit_after = params.limit_after;
894    let skip_fetch_threads = params.skip_fetch_threads;
895    let collapsed_threads = params.collapsed_threads;
896    let collapsed_threads_extended = params.collapsed_threads_extended;
897
898    let local_var_client = &local_var_configuration.client;
899
900    let local_var_uri_str = format!(
901        "{}/api/v4/users/{user_id}/channels/{channel_id}/posts/unread",
902        local_var_configuration.base_path,
903        user_id = super::urlencode(user_id),
904        channel_id = super::urlencode(channel_id)
905    );
906    let mut local_var_req_builder =
907        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
908
909    if let Some(ref local_var_str) = limit_before {
910        local_var_req_builder =
911            local_var_req_builder.query(&[("limit_before", &local_var_str.to_string())]);
912    }
913    if let Some(ref local_var_str) = limit_after {
914        local_var_req_builder =
915            local_var_req_builder.query(&[("limit_after", &local_var_str.to_string())]);
916    }
917    if let Some(ref local_var_str) = skip_fetch_threads {
918        local_var_req_builder =
919            local_var_req_builder.query(&[("skipFetchThreads", &local_var_str.to_string())]);
920    }
921    if let Some(ref local_var_str) = collapsed_threads {
922        local_var_req_builder =
923            local_var_req_builder.query(&[("collapsedThreads", &local_var_str.to_string())]);
924    }
925    if let Some(ref local_var_str) = collapsed_threads_extended {
926        local_var_req_builder = local_var_req_builder
927            .query(&[("collapsedThreadsExtended", &local_var_str.to_string())]);
928    }
929    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
930        local_var_req_builder =
931            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
932    }
933    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
934        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
935    };
936
937    let local_var_req = local_var_req_builder.build()?;
938    let local_var_resp = local_var_client.execute(local_var_req).await?;
939
940    let local_var_status = local_var_resp.status();
941    let local_var_content = local_var_resp.text().await?;
942
943    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
944        serde_json::from_str(&local_var_content).map_err(Error::from)
945    } else {
946        let local_var_entity: Option<GetPostsAroundLastUnreadError> =
947            serde_json::from_str(&local_var_content).ok();
948        let local_var_error = ResponseContent {
949            status: local_var_status,
950            content: local_var_content,
951            entity: local_var_entity,
952        };
953        Err(Error::ResponseError(local_var_error))
954    }
955}
956
957/// Fetch a list of posts based on the provided postIDs ##### Permissions Must have `read_channel` permission for the channel the post is in or if the channel is public, have the `read_public_channels` permission for the team.
958pub async fn get_posts_by_ids(
959    configuration: &configuration::Configuration,
960    params: GetPostsByIdsParams,
961) -> Result<Vec<crate::openapi::models::Post>, Error<GetPostsByIdsError>> {
962    let local_var_configuration = configuration;
963
964    // unbox the parameters
965    let request_body = params.request_body;
966
967    let local_var_client = &local_var_configuration.client;
968
969    let local_var_uri_str = format!("{}/api/v4/posts/ids", local_var_configuration.base_path);
970    let mut local_var_req_builder =
971        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
972
973    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
974        local_var_req_builder =
975            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
976    }
977    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
978        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
979    };
980    local_var_req_builder = local_var_req_builder.json(&request_body);
981
982    let local_var_req = local_var_req_builder.build()?;
983    let local_var_resp = local_var_client.execute(local_var_req).await?;
984
985    let local_var_status = local_var_resp.status();
986    let local_var_content = local_var_resp.text().await?;
987
988    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
989        serde_json::from_str(&local_var_content).map_err(Error::from)
990    } else {
991        let local_var_entity: Option<GetPostsByIdsError> =
992            serde_json::from_str(&local_var_content).ok();
993        let local_var_error = ResponseContent {
994            status: local_var_status,
995            content: local_var_content,
996            entity: local_var_entity,
997        };
998        Err(Error::ResponseError(local_var_error))
999    }
1000}
1001
1002/// Get a page of posts in a channel. Use the query parameters to modify the behaviour of this endpoint. The parameter `since` must not be used with any of `before`, `after`, `page`, and `per_page` parameters. If `since` is used, it will always return all posts modified since that time, ordered by their create time limited till 1000. A caveat with this parameter is that there is no guarantee that the returned posts will be consecutive. It is left to the clients to maintain state and fill any missing holes in the post order. ##### Permissions Must have `read_channel` permission for the channel.
1003pub async fn get_posts_for_channel(
1004    configuration: &configuration::Configuration,
1005    params: GetPostsForChannelParams,
1006) -> Result<crate::openapi::models::PostList, Error<GetPostsForChannelError>> {
1007    let local_var_configuration = configuration;
1008
1009    // unbox the parameters
1010    let channel_id = params.channel_id;
1011    let page = params.page;
1012    let per_page = params.per_page;
1013    let since = params.since;
1014    let before = params.before;
1015    let after = params.after;
1016    let include_deleted = params.include_deleted;
1017
1018    let local_var_client = &local_var_configuration.client;
1019
1020    let local_var_uri_str = format!(
1021        "{}/api/v4/channels/{channel_id}/posts",
1022        local_var_configuration.base_path,
1023        channel_id = super::urlencode(channel_id)
1024    );
1025    let mut local_var_req_builder =
1026        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1027
1028    if let Some(ref local_var_str) = page {
1029        local_var_req_builder =
1030            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
1031    }
1032    if let Some(ref local_var_str) = per_page {
1033        local_var_req_builder =
1034            local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
1035    }
1036    if let Some(ref local_var_str) = since {
1037        local_var_req_builder =
1038            local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
1039    }
1040    if let Some(ref local_var_str) = before {
1041        local_var_req_builder =
1042            local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
1043    }
1044    if let Some(ref local_var_str) = after {
1045        local_var_req_builder =
1046            local_var_req_builder.query(&[("after", &local_var_str.to_string())]);
1047    }
1048    if let Some(ref local_var_str) = include_deleted {
1049        local_var_req_builder =
1050            local_var_req_builder.query(&[("include_deleted", &local_var_str.to_string())]);
1051    }
1052    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1053        local_var_req_builder =
1054            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1055    }
1056    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1057        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1058    };
1059
1060    let local_var_req = local_var_req_builder.build()?;
1061    let local_var_resp = local_var_client.execute(local_var_req).await?;
1062
1063    let local_var_status = local_var_resp.status();
1064    let local_var_content = local_var_resp.text().await?;
1065
1066    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1067        serde_json::from_str(&local_var_content).map_err(Error::from)
1068    } else {
1069        let local_var_entity: Option<GetPostsForChannelError> =
1070            serde_json::from_str(&local_var_content).ok();
1071        let local_var_error = ResponseContent {
1072            status: local_var_status,
1073            content: local_var_content,
1074            entity: local_var_entity,
1075        };
1076        Err(Error::ResponseError(local_var_error))
1077    }
1078}
1079
1080/// Partially update a post by providing only the fields you want to update. Omitted fields will not be updated. The fields that can be updated are defined in the request body, all other provided fields will be ignored. ##### Permissions Must have the `edit_post` permission.
1081pub async fn patch_post(
1082    configuration: &configuration::Configuration,
1083    params: PatchPostParams,
1084) -> Result<crate::openapi::models::Post, Error<PatchPostError>> {
1085    let local_var_configuration = configuration;
1086
1087    // unbox the parameters
1088    let post_id = params.post_id;
1089    let patch_post_request = params.patch_post_request;
1090
1091    let local_var_client = &local_var_configuration.client;
1092
1093    let local_var_uri_str = format!(
1094        "{}/api/v4/posts/{post_id}/patch",
1095        local_var_configuration.base_path,
1096        post_id = super::urlencode(post_id)
1097    );
1098    let mut local_var_req_builder =
1099        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1100
1101    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1102        local_var_req_builder =
1103            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1104    }
1105    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1106        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1107    };
1108    local_var_req_builder = local_var_req_builder.json(&patch_post_request);
1109
1110    let local_var_req = local_var_req_builder.build()?;
1111    let local_var_resp = local_var_client.execute(local_var_req).await?;
1112
1113    let local_var_status = local_var_resp.status();
1114    let local_var_content = local_var_resp.text().await?;
1115
1116    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1117        serde_json::from_str(&local_var_content).map_err(Error::from)
1118    } else {
1119        let local_var_entity: Option<PatchPostError> =
1120            serde_json::from_str(&local_var_content).ok();
1121        let local_var_error = ResponseContent {
1122            status: local_var_status,
1123            content: local_var_content,
1124            entity: local_var_entity,
1125        };
1126        Err(Error::ResponseError(local_var_error))
1127    }
1128}
1129
1130/// Pin a post to a channel it is in based from the provided post id string. ##### Permissions Must be authenticated and have the `read_channel` permission to the channel the post is in.
1131pub async fn pin_post(
1132    configuration: &configuration::Configuration,
1133    params: PinPostParams,
1134) -> Result<crate::openapi::models::StatusOk, Error<PinPostError>> {
1135    let local_var_configuration = configuration;
1136
1137    // unbox the parameters
1138    let post_id = params.post_id;
1139
1140    let local_var_client = &local_var_configuration.client;
1141
1142    let local_var_uri_str = format!(
1143        "{}/api/v4/posts/{post_id}/pin",
1144        local_var_configuration.base_path,
1145        post_id = super::urlencode(post_id)
1146    );
1147    let mut local_var_req_builder =
1148        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1149
1150    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1151        local_var_req_builder =
1152            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1153    }
1154    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1155        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1156    };
1157
1158    let local_var_req = local_var_req_builder.build()?;
1159    let local_var_resp = local_var_client.execute(local_var_req).await?;
1160
1161    let local_var_status = local_var_resp.status();
1162    let local_var_content = local_var_resp.text().await?;
1163
1164    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1165        serde_json::from_str(&local_var_content).map_err(Error::from)
1166    } else {
1167        let local_var_entity: Option<PinPostError> = serde_json::from_str(&local_var_content).ok();
1168        let local_var_error = ResponseContent {
1169            status: local_var_status,
1170            content: local_var_content,
1171            entity: local_var_entity,
1172        };
1173        Err(Error::ResponseError(local_var_error))
1174    }
1175}
1176
1177/// Acknowledge a post that has a request for acknowledgements. ##### Permissions Must have `read_channel` permission for the channel the post is in.<br/> Must be logged in as the user or have `edit_other_users` permission.  __Minimum server version__: 7.7
1178pub async fn save_acknowledgement_for_post(
1179    configuration: &configuration::Configuration,
1180    params: SaveAcknowledgementForPostParams,
1181) -> Result<crate::openapi::models::PostAcknowledgement, Error<SaveAcknowledgementForPostError>> {
1182    let local_var_configuration = configuration;
1183
1184    // unbox the parameters
1185    let user_id = params.user_id;
1186    let post_id = params.post_id;
1187
1188    let local_var_client = &local_var_configuration.client;
1189
1190    let local_var_uri_str = format!(
1191        "{}/api/v4/users/{user_id}/posts/{post_id}/ack",
1192        local_var_configuration.base_path,
1193        user_id = super::urlencode(user_id),
1194        post_id = super::urlencode(post_id)
1195    );
1196    let mut local_var_req_builder =
1197        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1198
1199    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1200        local_var_req_builder =
1201            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1202    }
1203    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1204        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1205    };
1206
1207    let local_var_req = local_var_req_builder.build()?;
1208    let local_var_resp = local_var_client.execute(local_var_req).await?;
1209
1210    let local_var_status = local_var_resp.status();
1211    let local_var_content = local_var_resp.text().await?;
1212
1213    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1214        serde_json::from_str(&local_var_content).map_err(Error::from)
1215    } else {
1216        let local_var_entity: Option<SaveAcknowledgementForPostError> =
1217            serde_json::from_str(&local_var_content).ok();
1218        let local_var_error = ResponseContent {
1219            status: local_var_status,
1220            content: local_var_content,
1221            entity: local_var_entity,
1222        };
1223        Err(Error::ResponseError(local_var_error))
1224    }
1225}
1226
1227/// Delete an acknowledgement form a post that you had previously acknowledged. ##### Permissions Must have `read_channel` permission for the channel the post is in.<br/> Must be logged in as the user or have `edit_other_users` permission.<br/> The post must have been acknowledged in the previous 5 minutes.  __Minimum server version__: 7.7
1228pub async fn save_acknowledgement_for_post_0(
1229    configuration: &configuration::Configuration,
1230    params: SaveAcknowledgementForPost0Params,
1231) -> Result<crate::openapi::models::StatusOk, Error<SaveAcknowledgementForPost0Error>> {
1232    let local_var_configuration = configuration;
1233
1234    // unbox the parameters
1235    let user_id = params.user_id;
1236    let post_id = params.post_id;
1237
1238    let local_var_client = &local_var_configuration.client;
1239
1240    let local_var_uri_str = format!(
1241        "{}/api/v4/users/{user_id}/posts/{post_id}/ack",
1242        local_var_configuration.base_path,
1243        user_id = super::urlencode(user_id),
1244        post_id = super::urlencode(post_id)
1245    );
1246    let mut local_var_req_builder =
1247        local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
1248
1249    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1250        local_var_req_builder =
1251            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1252    }
1253    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1254        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1255    };
1256
1257    let local_var_req = local_var_req_builder.build()?;
1258    let local_var_resp = local_var_client.execute(local_var_req).await?;
1259
1260    let local_var_status = local_var_resp.status();
1261    let local_var_content = local_var_resp.text().await?;
1262
1263    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1264        serde_json::from_str(&local_var_content).map_err(Error::from)
1265    } else {
1266        let local_var_entity: Option<SaveAcknowledgementForPost0Error> =
1267            serde_json::from_str(&local_var_content).ok();
1268        let local_var_error = ResponseContent {
1269            status: local_var_status,
1270            content: local_var_content,
1271            entity: local_var_entity,
1272        };
1273        Err(Error::ResponseError(local_var_error))
1274    }
1275}
1276
1277/// Search posts in the team and from the provided terms string. ##### Permissions Must be authenticated and have the `view_team` permission.
1278pub async fn search_posts(
1279    configuration: &configuration::Configuration,
1280    params: SearchPostsParams,
1281) -> Result<crate::openapi::models::PostListWithSearchMatches, Error<SearchPostsError>> {
1282    let local_var_configuration = configuration;
1283
1284    // unbox the parameters
1285    let team_id = params.team_id;
1286    let search_posts_request = params.search_posts_request;
1287
1288    let local_var_client = &local_var_configuration.client;
1289
1290    let local_var_uri_str = format!(
1291        "{}/api/v4/teams/{team_id}/posts/search",
1292        local_var_configuration.base_path,
1293        team_id = super::urlencode(team_id)
1294    );
1295    let mut local_var_req_builder =
1296        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1297
1298    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1299        local_var_req_builder =
1300            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1301    }
1302    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1303        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1304    };
1305    local_var_req_builder = local_var_req_builder.json(&search_posts_request);
1306
1307    let local_var_req = local_var_req_builder.build()?;
1308    let local_var_resp = local_var_client.execute(local_var_req).await?;
1309
1310    let local_var_status = local_var_resp.status();
1311    let local_var_content = local_var_resp.text().await?;
1312
1313    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1314        serde_json::from_str(&local_var_content).map_err(Error::from)
1315    } else {
1316        let local_var_entity: Option<SearchPostsError> =
1317            serde_json::from_str(&local_var_content).ok();
1318        let local_var_error = ResponseContent {
1319            status: local_var_status,
1320            content: local_var_content,
1321            entity: local_var_entity,
1322        };
1323        Err(Error::ResponseError(local_var_error))
1324    }
1325}
1326
1327/// Set a reminder for the user for the post. ##### Permissions Must have `read_channel` permission for the channel the post is in.  __Minimum server version__: 7.2
1328pub async fn set_post_reminder(
1329    configuration: &configuration::Configuration,
1330    params: SetPostReminderParams,
1331) -> Result<crate::openapi::models::StatusOk, Error<SetPostReminderError>> {
1332    let local_var_configuration = configuration;
1333
1334    // unbox the parameters
1335    let user_id = params.user_id;
1336    let post_id = params.post_id;
1337    let set_post_reminder_request = params.set_post_reminder_request;
1338
1339    let local_var_client = &local_var_configuration.client;
1340
1341    let local_var_uri_str = format!(
1342        "{}/api/v4/users/{user_id}/posts/{post_id}/reminder",
1343        local_var_configuration.base_path,
1344        user_id = super::urlencode(user_id),
1345        post_id = super::urlencode(post_id)
1346    );
1347    let mut local_var_req_builder =
1348        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1349
1350    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1351        local_var_req_builder =
1352            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1353    }
1354    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1355        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1356    };
1357    local_var_req_builder = local_var_req_builder.json(&set_post_reminder_request);
1358
1359    let local_var_req = local_var_req_builder.build()?;
1360    let local_var_resp = local_var_client.execute(local_var_req).await?;
1361
1362    let local_var_status = local_var_resp.status();
1363    let local_var_content = local_var_resp.text().await?;
1364
1365    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1366        serde_json::from_str(&local_var_content).map_err(Error::from)
1367    } else {
1368        let local_var_entity: Option<SetPostReminderError> =
1369            serde_json::from_str(&local_var_content).ok();
1370        let local_var_error = ResponseContent {
1371            status: local_var_status,
1372            content: local_var_content,
1373            entity: local_var_entity,
1374        };
1375        Err(Error::ResponseError(local_var_error))
1376    }
1377}
1378
1379/// Mark a channel as being unread from a given post. ##### Permissions Must have `read_channel` permission for the channel the post is in or if the channel is public, have the `read_public_channels` permission for the team. Must have `edit_other_users` permission if the user is not the one marking the post for himself.  __Minimum server version__: 5.18
1380pub async fn set_post_unread(
1381    configuration: &configuration::Configuration,
1382    params: SetPostUnreadParams,
1383) -> Result<crate::openapi::models::ChannelUnreadAt, Error<SetPostUnreadError>> {
1384    let local_var_configuration = configuration;
1385
1386    // unbox the parameters
1387    let user_id = params.user_id;
1388    let post_id = params.post_id;
1389
1390    let local_var_client = &local_var_configuration.client;
1391
1392    let local_var_uri_str = format!(
1393        "{}/api/v4/users/{user_id}/posts/{post_id}/set_unread",
1394        local_var_configuration.base_path,
1395        user_id = super::urlencode(user_id),
1396        post_id = super::urlencode(post_id)
1397    );
1398    let mut local_var_req_builder =
1399        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1400
1401    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1402        local_var_req_builder =
1403            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1404    }
1405    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1406        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1407    };
1408
1409    let local_var_req = local_var_req_builder.build()?;
1410    let local_var_resp = local_var_client.execute(local_var_req).await?;
1411
1412    let local_var_status = local_var_resp.status();
1413    let local_var_content = local_var_resp.text().await?;
1414
1415    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1416        serde_json::from_str(&local_var_content).map_err(Error::from)
1417    } else {
1418        let local_var_entity: Option<SetPostUnreadError> =
1419            serde_json::from_str(&local_var_content).ok();
1420        let local_var_error = ResponseContent {
1421            status: local_var_status,
1422            content: local_var_content,
1423            entity: local_var_entity,
1424        };
1425        Err(Error::ResponseError(local_var_error))
1426    }
1427}
1428
1429/// Unpin a post to a channel it is in based from the provided post id string. ##### Permissions Must be authenticated and have the `read_channel` permission to the channel the post is in.
1430pub async fn unpin_post(
1431    configuration: &configuration::Configuration,
1432    params: UnpinPostParams,
1433) -> Result<crate::openapi::models::StatusOk, Error<UnpinPostError>> {
1434    let local_var_configuration = configuration;
1435
1436    // unbox the parameters
1437    let post_id = params.post_id;
1438
1439    let local_var_client = &local_var_configuration.client;
1440
1441    let local_var_uri_str = format!(
1442        "{}/api/v4/posts/{post_id}/unpin",
1443        local_var_configuration.base_path,
1444        post_id = super::urlencode(post_id)
1445    );
1446    let mut local_var_req_builder =
1447        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1448
1449    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1450        local_var_req_builder =
1451            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1452    }
1453    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1454        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1455    };
1456
1457    let local_var_req = local_var_req_builder.build()?;
1458    let local_var_resp = local_var_client.execute(local_var_req).await?;
1459
1460    let local_var_status = local_var_resp.status();
1461    let local_var_content = local_var_resp.text().await?;
1462
1463    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1464        serde_json::from_str(&local_var_content).map_err(Error::from)
1465    } else {
1466        let local_var_entity: Option<UnpinPostError> =
1467            serde_json::from_str(&local_var_content).ok();
1468        let local_var_error = ResponseContent {
1469            status: local_var_status,
1470            content: local_var_content,
1471            entity: local_var_entity,
1472        };
1473        Err(Error::ResponseError(local_var_error))
1474    }
1475}
1476
1477/// Update a post. Only the fields listed below are updatable, omitted fields will be treated as blank. ##### Permissions Must have `edit_post` permission for the channel the post is in.
1478pub async fn update_post(
1479    configuration: &configuration::Configuration,
1480    params: UpdatePostParams,
1481) -> Result<crate::openapi::models::Post, Error<UpdatePostError>> {
1482    let local_var_configuration = configuration;
1483
1484    // unbox the parameters
1485    let post_id = params.post_id;
1486    let update_post_request = params.update_post_request;
1487
1488    let local_var_client = &local_var_configuration.client;
1489
1490    let local_var_uri_str = format!(
1491        "{}/api/v4/posts/{post_id}",
1492        local_var_configuration.base_path,
1493        post_id = super::urlencode(post_id)
1494    );
1495    let mut local_var_req_builder =
1496        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1497
1498    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1499        local_var_req_builder =
1500            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1501    }
1502    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1503        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1504    };
1505    local_var_req_builder = local_var_req_builder.json(&update_post_request);
1506
1507    let local_var_req = local_var_req_builder.build()?;
1508    let local_var_resp = local_var_client.execute(local_var_req).await?;
1509
1510    let local_var_status = local_var_resp.status();
1511    let local_var_content = local_var_resp.text().await?;
1512
1513    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1514        serde_json::from_str(&local_var_content).map_err(Error::from)
1515    } else {
1516        let local_var_entity: Option<UpdatePostError> =
1517            serde_json::from_str(&local_var_content).ok();
1518        let local_var_error = ResponseContent {
1519            status: local_var_status,
1520            content: local_var_content,
1521            entity: local_var_entity,
1522        };
1523        Err(Error::ResponseError(local_var_error))
1524    }
1525}