mattermost-client 0.2.0

A sane Rust interface to the Mattermost API
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
/*
 * Mattermost API Reference
 *
 * There is also a work-in-progress [Postman API reference](https://documenter.getpostman.com/view/4508214/RW8FERUn).
 *
 * The version of the OpenAPI document: 4.0.0
 * Contact: feedback@mattermost.com
 * Generated by: https://openapi-generator.tech
 */

use reqwest;

use super::ResponseContent;
use super::{Error, configuration};

/// struct for passing parameters to the method [`create_post`]
#[derive(Clone, Debug, Default)]
pub struct CreatePostParams {
    /// Post object to create
    pub create_post_request: crate::openapi::models::CreatePostRequest,
    /// Whether to set the user status as online or not.
    pub set_online: Option<bool>,
}

/// struct for passing parameters to the method [`create_post_ephemeral`]
#[derive(Clone, Debug, Default)]
pub struct CreatePostEphemeralParams {
    /// Ephemeral Post object to send
    pub create_post_ephemeral_request: crate::openapi::models::CreatePostEphemeralRequest,
}

/// struct for passing parameters to the method [`delete_post`]
#[derive(Clone, Debug, Default)]
pub struct DeletePostParams {
    /// ID of the post to delete
    pub post_id: String,
}

/// struct for passing parameters to the method [`do_post_action`]
#[derive(Clone, Debug, Default)]
pub struct DoPostActionParams {
    /// Post GUID
    pub post_id: String,
    /// Action GUID
    pub action_id: String,
}

/// struct for passing parameters to the method [`get_file_infos_for_post`]
#[derive(Clone, Debug, Default)]
pub struct GetFileInfosForPostParams {
    /// ID of the post
    pub post_id: String,
    /// Defines if result should include deleted posts, must have 'manage_system' (admin) permission.
    pub include_deleted: Option<bool>,
}

/// struct for passing parameters to the method [`get_flagged_posts_for_user`]
#[derive(Clone, Debug, Default)]
pub struct GetFlaggedPostsForUserParams {
    /// ID of the user
    pub user_id: String,
    /// Team ID
    pub team_id: Option<String>,
    /// Channel ID
    pub channel_id: Option<String>,
    /// The page to select
    pub page: Option<i32>,
    /// The number of posts per page
    pub per_page: Option<i32>,
}

/// struct for passing parameters to the method [`get_post`]
#[derive(Clone, Debug, Default)]
pub struct GetPostParams {
    /// ID of the post to get
    pub post_id: String,
    /// Defines if result should include deleted posts, must have 'manage_system' (admin) permission.
    pub include_deleted: Option<bool>,
}

/// struct for passing parameters to the method [`get_post_thread`]
#[derive(Clone, Debug, Default)]
pub struct GetPostThreadParams {
    /// ID of a post in the thread
    pub post_id: String,
    /// The number of posts per page
    pub per_page: Option<i32>,
    /// The post_id to return the next page of posts from
    pub from_post: Option<String>,
    /// The create_at timestamp to return the next page of posts from
    pub from_create_at: Option<i32>,
    /// The direction to return the posts. Either up or down.
    pub direction: Option<String>,
    /// Whether to skip fetching threads or not
    pub skip_fetch_threads: Option<bool>,
    /// Whether the client uses CRT or not
    pub collapsed_threads: Option<bool>,
    /// Whether to return the associated users as part of the response or not
    pub collapsed_threads_extended: Option<bool>,
}

/// struct for passing parameters to the method [`get_posts_around_last_unread`]
#[derive(Clone, Debug, Default)]
pub struct GetPostsAroundLastUnreadParams {
    /// ID of the user
    pub user_id: String,
    /// The channel ID to get the posts for
    pub channel_id: String,
    /// Number of posts before the oldest unread posts. Maximum is 200 posts if limit is set greater than that.
    pub limit_before: Option<u32>,
    /// Number of posts after and including the oldest unread post. Maximum is 200 posts if limit is set greater than that.
    pub limit_after: Option<u32>,
    /// Whether to skip fetching threads or not
    pub skip_fetch_threads: Option<bool>,
    /// Whether the client uses CRT or not
    pub collapsed_threads: Option<bool>,
    /// Whether to return the associated users as part of the response or not
    pub collapsed_threads_extended: Option<bool>,
}

/// struct for passing parameters to the method [`get_posts_by_ids`]
#[derive(Clone, Debug, Default)]
pub struct GetPostsByIdsParams {
    /// List of post ids
    pub request_body: Vec<String>,
}

/// struct for passing parameters to the method [`get_posts_for_channel`]
#[derive(Clone, Debug, Default)]
pub struct GetPostsForChannelParams {
    /// The channel ID to get the posts for
    pub channel_id: String,
    /// The page to select
    pub page: Option<i32>,
    /// The number of posts per page
    pub per_page: Option<i32>,
    /// Provide a non-zero value in Unix time milliseconds to select posts modified after that time
    pub since: Option<i32>,
    /// A post id to select the posts that came before this one
    pub before: Option<String>,
    /// A post id to select the posts that came after this one
    pub after: Option<String>,
    /// Whether to include deleted posts or not. Must have system admin permissions.
    pub include_deleted: Option<bool>,
}

/// struct for passing parameters to the method [`patch_post`]
#[derive(Clone, Debug, Default)]
pub struct PatchPostParams {
    /// Post GUID
    pub post_id: String,
    /// Post object that is to be updated
    pub patch_post_request: crate::openapi::models::PatchPostRequest,
}

/// struct for passing parameters to the method [`pin_post`]
#[derive(Clone, Debug, Default)]
pub struct PinPostParams {
    /// Post GUID
    pub post_id: String,
}

/// struct for passing parameters to the method [`save_acknowledgement_for_post`]
#[derive(Clone, Debug, Default)]
pub struct SaveAcknowledgementForPostParams {
    /// User GUID
    pub user_id: String,
    /// Post GUID
    pub post_id: String,
}

/// struct for passing parameters to the method [`save_acknowledgement_for_post_0`]
#[derive(Clone, Debug, Default)]
pub struct SaveAcknowledgementForPost0Params {
    /// User GUID
    pub user_id: String,
    /// Post GUID
    pub post_id: String,
}

/// struct for passing parameters to the method [`search_posts`]
#[derive(Clone, Debug, Default)]
pub struct SearchPostsParams {
    /// Team GUID
    pub team_id: String,
    /// The search terms and logic to use in the search.
    pub search_posts_request: crate::openapi::models::SearchPostsRequest,
}

/// struct for passing parameters to the method [`set_post_reminder`]
#[derive(Clone, Debug, Default)]
pub struct SetPostReminderParams {
    /// User GUID
    pub user_id: String,
    /// Post GUID
    pub post_id: String,
    /// Target time for the reminder
    pub set_post_reminder_request: crate::openapi::models::SetPostReminderRequest,
}

/// struct for passing parameters to the method [`set_post_unread`]
#[derive(Clone, Debug, Default)]
pub struct SetPostUnreadParams {
    /// User GUID
    pub user_id: String,
    /// Post GUID
    pub post_id: String,
}

/// struct for passing parameters to the method [`unpin_post`]
#[derive(Clone, Debug, Default)]
pub struct UnpinPostParams {
    /// Post GUID
    pub post_id: String,
}

/// struct for passing parameters to the method [`update_post`]
#[derive(Clone, Debug, Default)]
pub struct UpdatePostParams {
    /// ID of the post to update
    pub post_id: String,
    /// Post object that is to be updated
    pub update_post_request: crate::openapi::models::UpdatePostRequest,
}

/// struct for typed errors of method [`create_post`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum CreatePostError {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`create_post_ephemeral`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum CreatePostEphemeralError {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`delete_post`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum DeletePostError {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`do_post_action`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum DoPostActionError {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`get_file_infos_for_post`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetFileInfosForPostError {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`get_flagged_posts_for_user`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetFlaggedPostsForUserError {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`get_post`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetPostError {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`get_post_thread`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetPostThreadError {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`get_posts_around_last_unread`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetPostsAroundLastUnreadError {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`get_posts_by_ids`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetPostsByIdsError {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`get_posts_for_channel`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetPostsForChannelError {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`patch_post`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum PatchPostError {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`pin_post`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum PinPostError {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`save_acknowledgement_for_post`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum SaveAcknowledgementForPostError {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    Status404(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`save_acknowledgement_for_post_0`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum SaveAcknowledgementForPost0Error {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    Status404(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`search_posts`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum SearchPostsError {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`set_post_reminder`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum SetPostReminderError {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    Status404(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`set_post_unread`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum SetPostUnreadError {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    Status404(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`unpin_post`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum UnpinPostError {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`update_post`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum UpdatePostError {
    Status400(crate::openapi::models::AppError),
    Status401(crate::openapi::models::AppError),
    Status403(crate::openapi::models::AppError),
    UnknownValue(serde_json::Value),
}

/// 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.
pub async fn create_post(
    configuration: &configuration::Configuration,
    params: CreatePostParams,
) -> Result<crate::openapi::models::Post, Error<CreatePostError>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let create_post_request = params.create_post_request;
    let set_online = params.set_online;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/api/v4/posts", local_var_configuration.base_path);
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_str) = set_online {
        local_var_req_builder =
            local_var_req_builder.query(&[("set_online", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&create_post_request);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<CreatePostError> =
            serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}

/// Create a new ephemeral post in a channel. ##### Permissions Must have `create_post_ephemeral` permission (currently only given to system admin)
pub async fn create_post_ephemeral(
    configuration: &configuration::Configuration,
    params: CreatePostEphemeralParams,
) -> Result<crate::openapi::models::Post, Error<CreatePostEphemeralError>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let create_post_ephemeral_request = params.create_post_ephemeral_request;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!(
        "{}/api/v4/posts/ephemeral",
        local_var_configuration.base_path
    );
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&create_post_ephemeral_request);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<CreatePostEphemeralError> =
            serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}

/// 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.
pub async fn delete_post(
    configuration: &configuration::Configuration,
    params: DeletePostParams,
) -> Result<crate::openapi::models::StatusOk, Error<DeletePostError>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let post_id = params.post_id;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!(
        "{}/api/v4/posts/{post_id}",
        local_var_configuration.base_path,
        post_id = super::urlencode(post_id)
    );
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<DeletePostError> =
            serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}

/// 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.
pub async fn do_post_action(
    configuration: &configuration::Configuration,
    params: DoPostActionParams,
) -> Result<crate::openapi::models::StatusOk, Error<DoPostActionError>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let post_id = params.post_id;
    let action_id = params.action_id;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!(
        "{}/api/v4/posts/{post_id}/actions/{action_id}",
        local_var_configuration.base_path,
        post_id = super::urlencode(post_id),
        action_id = super::urlencode(action_id)
    );
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<DoPostActionError> =
            serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}

/// 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.
pub async fn get_file_infos_for_post(
    configuration: &configuration::Configuration,
    params: GetFileInfosForPostParams,
) -> Result<Vec<crate::openapi::models::FileInfo>, Error<GetFileInfosForPostError>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let post_id = params.post_id;
    let include_deleted = params.include_deleted;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!(
        "{}/api/v4/posts/{post_id}/files/info",
        local_var_configuration.base_path,
        post_id = super::urlencode(post_id)
    );
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    if let Some(ref local_var_str) = include_deleted {
        local_var_req_builder =
            local_var_req_builder.query(&[("include_deleted", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<GetFileInfosForPostError> =
            serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}

/// 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.
pub async fn get_flagged_posts_for_user(
    configuration: &configuration::Configuration,
    params: GetFlaggedPostsForUserParams,
) -> Result<Vec<crate::openapi::models::PostList>, Error<GetFlaggedPostsForUserError>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let user_id = params.user_id;
    let team_id = params.team_id;
    let channel_id = params.channel_id;
    let page = params.page;
    let per_page = params.per_page;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!(
        "{}/api/v4/users/{user_id}/posts/flagged",
        local_var_configuration.base_path,
        user_id = super::urlencode(user_id)
    );
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    if let Some(ref local_var_str) = team_id {
        local_var_req_builder =
            local_var_req_builder.query(&[("team_id", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = channel_id {
        local_var_req_builder =
            local_var_req_builder.query(&[("channel_id", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = page {
        local_var_req_builder =
            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = per_page {
        local_var_req_builder =
            local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<GetFlaggedPostsForUserError> =
            serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}

/// 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.
pub async fn get_post(
    configuration: &configuration::Configuration,
    params: GetPostParams,
) -> Result<crate::openapi::models::Post, Error<GetPostError>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let post_id = params.post_id;
    let include_deleted = params.include_deleted;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!(
        "{}/api/v4/posts/{post_id}",
        local_var_configuration.base_path,
        post_id = super::urlencode(post_id)
    );
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    if let Some(ref local_var_str) = include_deleted {
        local_var_req_builder =
            local_var_req_builder.query(&[("include_deleted", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<GetPostError> = serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}

/// 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.
pub async fn get_post_thread(
    configuration: &configuration::Configuration,
    params: GetPostThreadParams,
) -> Result<crate::openapi::models::PostList, Error<GetPostThreadError>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let post_id = params.post_id;
    let per_page = params.per_page;
    let from_post = params.from_post;
    let from_create_at = params.from_create_at;
    let direction = params.direction;
    let skip_fetch_threads = params.skip_fetch_threads;
    let collapsed_threads = params.collapsed_threads;
    let collapsed_threads_extended = params.collapsed_threads_extended;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!(
        "{}/api/v4/posts/{post_id}/thread",
        local_var_configuration.base_path,
        post_id = super::urlencode(post_id)
    );
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    if let Some(ref local_var_str) = per_page {
        local_var_req_builder =
            local_var_req_builder.query(&[("perPage", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = from_post {
        local_var_req_builder =
            local_var_req_builder.query(&[("fromPost", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = from_create_at {
        local_var_req_builder =
            local_var_req_builder.query(&[("fromCreateAt", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = direction {
        local_var_req_builder =
            local_var_req_builder.query(&[("direction", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = skip_fetch_threads {
        local_var_req_builder =
            local_var_req_builder.query(&[("skipFetchThreads", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = collapsed_threads {
        local_var_req_builder =
            local_var_req_builder.query(&[("collapsedThreads", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = collapsed_threads_extended {
        local_var_req_builder = local_var_req_builder
            .query(&[("collapsedThreadsExtended", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<GetPostThreadError> =
            serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}

/// 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
pub async fn get_posts_around_last_unread(
    configuration: &configuration::Configuration,
    params: GetPostsAroundLastUnreadParams,
) -> Result<crate::openapi::models::PostList, Error<GetPostsAroundLastUnreadError>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let user_id = params.user_id;
    let channel_id = params.channel_id;
    let limit_before = params.limit_before;
    let limit_after = params.limit_after;
    let skip_fetch_threads = params.skip_fetch_threads;
    let collapsed_threads = params.collapsed_threads;
    let collapsed_threads_extended = params.collapsed_threads_extended;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!(
        "{}/api/v4/users/{user_id}/channels/{channel_id}/posts/unread",
        local_var_configuration.base_path,
        user_id = super::urlencode(user_id),
        channel_id = super::urlencode(channel_id)
    );
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    if let Some(ref local_var_str) = limit_before {
        local_var_req_builder =
            local_var_req_builder.query(&[("limit_before", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = limit_after {
        local_var_req_builder =
            local_var_req_builder.query(&[("limit_after", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = skip_fetch_threads {
        local_var_req_builder =
            local_var_req_builder.query(&[("skipFetchThreads", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = collapsed_threads {
        local_var_req_builder =
            local_var_req_builder.query(&[("collapsedThreads", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = collapsed_threads_extended {
        local_var_req_builder = local_var_req_builder
            .query(&[("collapsedThreadsExtended", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<GetPostsAroundLastUnreadError> =
            serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}

/// 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.
pub async fn get_posts_by_ids(
    configuration: &configuration::Configuration,
    params: GetPostsByIdsParams,
) -> Result<Vec<crate::openapi::models::Post>, Error<GetPostsByIdsError>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let request_body = params.request_body;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/api/v4/posts/ids", local_var_configuration.base_path);
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&request_body);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<GetPostsByIdsError> =
            serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}

/// 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.
pub async fn get_posts_for_channel(
    configuration: &configuration::Configuration,
    params: GetPostsForChannelParams,
) -> Result<crate::openapi::models::PostList, Error<GetPostsForChannelError>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let channel_id = params.channel_id;
    let page = params.page;
    let per_page = params.per_page;
    let since = params.since;
    let before = params.before;
    let after = params.after;
    let include_deleted = params.include_deleted;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!(
        "{}/api/v4/channels/{channel_id}/posts",
        local_var_configuration.base_path,
        channel_id = super::urlencode(channel_id)
    );
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    if let Some(ref local_var_str) = page {
        local_var_req_builder =
            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = per_page {
        local_var_req_builder =
            local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = since {
        local_var_req_builder =
            local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = before {
        local_var_req_builder =
            local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = after {
        local_var_req_builder =
            local_var_req_builder.query(&[("after", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = include_deleted {
        local_var_req_builder =
            local_var_req_builder.query(&[("include_deleted", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<GetPostsForChannelError> =
            serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}

/// 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.
pub async fn patch_post(
    configuration: &configuration::Configuration,
    params: PatchPostParams,
) -> Result<crate::openapi::models::Post, Error<PatchPostError>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let post_id = params.post_id;
    let patch_post_request = params.patch_post_request;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!(
        "{}/api/v4/posts/{post_id}/patch",
        local_var_configuration.base_path,
        post_id = super::urlencode(post_id)
    );
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&patch_post_request);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<PatchPostError> =
            serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}

/// 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.
pub async fn pin_post(
    configuration: &configuration::Configuration,
    params: PinPostParams,
) -> Result<crate::openapi::models::StatusOk, Error<PinPostError>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let post_id = params.post_id;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!(
        "{}/api/v4/posts/{post_id}/pin",
        local_var_configuration.base_path,
        post_id = super::urlencode(post_id)
    );
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<PinPostError> = serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}

/// 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
pub async fn save_acknowledgement_for_post(
    configuration: &configuration::Configuration,
    params: SaveAcknowledgementForPostParams,
) -> Result<crate::openapi::models::PostAcknowledgement, Error<SaveAcknowledgementForPostError>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let user_id = params.user_id;
    let post_id = params.post_id;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!(
        "{}/api/v4/users/{user_id}/posts/{post_id}/ack",
        local_var_configuration.base_path,
        user_id = super::urlencode(user_id),
        post_id = super::urlencode(post_id)
    );
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<SaveAcknowledgementForPostError> =
            serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}

/// 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
pub async fn save_acknowledgement_for_post_0(
    configuration: &configuration::Configuration,
    params: SaveAcknowledgementForPost0Params,
) -> Result<crate::openapi::models::StatusOk, Error<SaveAcknowledgementForPost0Error>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let user_id = params.user_id;
    let post_id = params.post_id;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!(
        "{}/api/v4/users/{user_id}/posts/{post_id}/ack",
        local_var_configuration.base_path,
        user_id = super::urlencode(user_id),
        post_id = super::urlencode(post_id)
    );
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<SaveAcknowledgementForPost0Error> =
            serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}

/// Search posts in the team and from the provided terms string. ##### Permissions Must be authenticated and have the `view_team` permission.
pub async fn search_posts(
    configuration: &configuration::Configuration,
    params: SearchPostsParams,
) -> Result<crate::openapi::models::PostListWithSearchMatches, Error<SearchPostsError>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let team_id = params.team_id;
    let search_posts_request = params.search_posts_request;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!(
        "{}/api/v4/teams/{team_id}/posts/search",
        local_var_configuration.base_path,
        team_id = super::urlencode(team_id)
    );
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&search_posts_request);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<SearchPostsError> =
            serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}

/// 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
pub async fn set_post_reminder(
    configuration: &configuration::Configuration,
    params: SetPostReminderParams,
) -> Result<crate::openapi::models::StatusOk, Error<SetPostReminderError>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let user_id = params.user_id;
    let post_id = params.post_id;
    let set_post_reminder_request = params.set_post_reminder_request;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!(
        "{}/api/v4/users/{user_id}/posts/{post_id}/reminder",
        local_var_configuration.base_path,
        user_id = super::urlencode(user_id),
        post_id = super::urlencode(post_id)
    );
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&set_post_reminder_request);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<SetPostReminderError> =
            serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}

/// 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
pub async fn set_post_unread(
    configuration: &configuration::Configuration,
    params: SetPostUnreadParams,
) -> Result<crate::openapi::models::ChannelUnreadAt, Error<SetPostUnreadError>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let user_id = params.user_id;
    let post_id = params.post_id;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!(
        "{}/api/v4/users/{user_id}/posts/{post_id}/set_unread",
        local_var_configuration.base_path,
        user_id = super::urlencode(user_id),
        post_id = super::urlencode(post_id)
    );
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<SetPostUnreadError> =
            serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}

/// 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.
pub async fn unpin_post(
    configuration: &configuration::Configuration,
    params: UnpinPostParams,
) -> Result<crate::openapi::models::StatusOk, Error<UnpinPostError>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let post_id = params.post_id;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!(
        "{}/api/v4/posts/{post_id}/unpin",
        local_var_configuration.base_path,
        post_id = super::urlencode(post_id)
    );
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<UnpinPostError> =
            serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}

/// 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.
pub async fn update_post(
    configuration: &configuration::Configuration,
    params: UpdatePostParams,
) -> Result<crate::openapi::models::Post, Error<UpdatePostError>> {
    let local_var_configuration = configuration;

    // unbox the parameters
    let post_id = params.post_id;
    let update_post_request = params.update_post_request;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!(
        "{}/api/v4/posts/{post_id}",
        local_var_configuration.base_path,
        post_id = super::urlencode(post_id)
    );
    let mut local_var_req_builder =
        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder =
            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&update_post_request);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<UpdatePostError> =
            serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent {
            status: local_var_status,
            content: local_var_content,
            entity: local_var_entity,
        };
        Err(Error::ResponseError(local_var_error))
    }
}