ghl-sdk 0.5.2

Unofficial async Rust SDK for the GoHighLevel (HighLevel) API 2.0 — OAuth 2.0, Private Integration Tokens, rate-limit-aware retries, paginated streams
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
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
// @generated by xtask/generate_services.py — do not edit by hand.
//! `social-planner` — typed methods for all 45 API v3 operations
//! in this module.
//!
//! Access via [`Ghl::v3`](crate::Ghl::v3)`().social_planner()`. These endpoints send `Version: v3`.
//!
//! Request and response types come from [`ghl_models::v3::social_planner`](https://docs.rs/ghl-models/latest/ghl_models/v3/social_planner/); every endpoint is also documented in the
//! [`social-planner` API reference](https://github.com/Shahroz/ghl-rs/blob/main/docs/api/social-planner.md).
//!
//! Enable with `features = ["social-planner"]`.

#![allow(clippy::too_many_arguments)]

use crate::client::Ghl;
use crate::error::Result;
use ghl_models::v3::social_planner as models;

/// Typed access to the `social-planner` API v3 surface (45 operations). Obtained via
/// [`Ghl::v3`](crate::Ghl::v3)`().social_planner()`.
#[derive(Debug, Clone)]
pub struct SocialPlannerService {
    pub(crate) client: Ghl,
}

impl SocialPlannerService {
    pub(crate) fn new(client: Ghl) -> Self {
        Self { client }
    }
}

/// Query parameters for
/// [`SocialPlannerService::get_all_categories_with_their_queue_status`].
#[derive(Debug, Clone, Default)]
pub struct GetAllCategoriesWithTheirQueueStatusParams {
    /// Location ID
    /// Required by the API.
    pub location_id: String,
    /// Number of items to skip
    pub skip: Option<String>,
    /// Maximum number of items to return
    pub limit: Option<String>,
    /// Search query
    pub q: Option<String>,
}

impl GetAllCategoriesWithTheirQueueStatusParams {
    /// Start from the parameters the API requires.
    pub fn new(location_id: impl Into<String>) -> Self {
        Self {
            location_id: location_id.into(),
            ..Default::default()
        }
    }

    /// Number of items to skip
    pub fn skip(mut self, v: impl Into<String>) -> Self {
        self.skip = Some(v.into());
        self
    }

    /// Maximum number of items to return
    pub fn limit(mut self, v: impl Into<String>) -> Self {
        self.limit = Some(v.into());
        self
    }

    /// Search query
    pub fn q(mut self, v: impl Into<String>) -> Self {
        self.q = Some(v.into());
        self
    }

    fn to_query(&self) -> Vec<(String, String)> {
        let mut q: Vec<(String, String)> = vec![("locationId".into(), self.location_id.clone())];
        if let Some(v) = &self.skip {
            q.push(("skip".into(), v.to_string()));
        }
        if let Some(v) = &self.limit {
            q.push(("limit".into(), v.to_string()));
        }
        if let Some(v) = &self.q {
            q.push(("q".into(), v.to_string()));
        }
        q
    }
}

/// Query parameters for
/// [`SocialPlannerService::delete_an_active_post_and_schedule_the_next_one`].
#[derive(Debug, Clone, Default)]
pub struct DeleteAnActivePostAndScheduleTheNextOneParams {
    /// Location ID
    /// Required by the API.
    pub location_id: String,
}

impl DeleteAnActivePostAndScheduleTheNextOneParams {
    /// Start from the parameters the API requires.
    pub fn new(location_id: impl Into<String>) -> Self {
        Self {
            location_id: location_id.into(),
        }
    }

    fn to_query(&self) -> Vec<(String, String)> {
        let q: Vec<(String, String)> = vec![("locationId".into(), self.location_id.clone())];
        q
    }
}

/// Query parameters for [`SocialPlannerService::fetch_a_category_queue_by_id`].
#[derive(Debug, Clone, Default)]
pub struct FetchACategoryQueueByIdParams {
    /// Location ID
    /// Required by the API.
    pub location_id: String,
}

impl FetchACategoryQueueByIdParams {
    /// Start from the parameters the API requires.
    pub fn new(location_id: impl Into<String>) -> Self {
        Self {
            location_id: location_id.into(),
        }
    }

    fn to_query(&self) -> Vec<(String, String)> {
        let q: Vec<(String, String)> = vec![("locationId".into(), self.location_id.clone())];
        q
    }
}

/// Query parameters for [`SocialPlannerService::delete_an_item_from_a_queue`].
#[derive(Debug, Clone, Default)]
pub struct DeleteAnItemFromAQueueParams {
    /// Location ID
    /// Required by the API.
    pub location_id: String,
    /// Edit session ID
    pub session_id: Option<String>,
}

impl DeleteAnItemFromAQueueParams {
    /// Start from the parameters the API requires.
    pub fn new(location_id: impl Into<String>) -> Self {
        Self {
            location_id: location_id.into(),
            ..Default::default()
        }
    }

    /// Edit session ID
    pub fn session_id(mut self, v: impl Into<String>) -> Self {
        self.session_id = Some(v.into());
        self
    }

    fn to_query(&self) -> Vec<(String, String)> {
        let mut q: Vec<(String, String)> = vec![("locationId".into(), self.location_id.clone())];
        if let Some(v) = &self.session_id {
            q.push(("sessionId".into(), v.to_string()));
        }
        q
    }
}

/// Query parameters for [`SocialPlannerService::create_a_comment_or_reply`].
#[derive(Debug, Clone, Default)]
pub struct CreateACommentOrReplyParams {
    /// Location ID
    /// Required by the API.
    pub location_id: String,
}

impl CreateACommentOrReplyParams {
    /// Start from the parameters the API requires.
    pub fn new(location_id: impl Into<String>) -> Self {
        Self {
            location_id: location_id.into(),
        }
    }

    fn to_query(&self) -> Vec<(String, String)> {
        let q: Vec<(String, String)> = vec![("locationId".into(), self.location_id.clone())];
        q
    }
}

/// Query parameters for [`SocialPlannerService::list_comments_for_a_post_or_thread`].
#[derive(Debug, Clone, Default)]
pub struct ListCommentsForAPostOrThreadParams {
    /// Location ID
    /// Required by the API.
    pub location_id: String,
}

impl ListCommentsForAPostOrThreadParams {
    /// Start from the parameters the API requires.
    pub fn new(location_id: impl Into<String>) -> Self {
        Self {
            location_id: location_id.into(),
        }
    }

    fn to_query(&self) -> Vec<(String, String)> {
        let q: Vec<(String, String)> = vec![("locationId".into(), self.location_id.clone())];
        q
    }
}

/// Query parameters for [`SocialPlannerService::unlike_a_comment`].
#[derive(Debug, Clone, Default)]
pub struct UnlikeACommentParams {
    /// Location ID
    /// Required by the API.
    pub location_id: String,
}

impl UnlikeACommentParams {
    /// Start from the parameters the API requires.
    pub fn new(location_id: impl Into<String>) -> Self {
        Self {
            location_id: location_id.into(),
        }
    }

    fn to_query(&self) -> Vec<(String, String)> {
        let q: Vec<(String, String)> = vec![("locationId".into(), self.location_id.clone())];
        q
    }
}

/// Query parameters for [`SocialPlannerService::like_a_comment`].
#[derive(Debug, Clone, Default)]
pub struct LikeACommentParams {
    /// Location ID
    /// Required by the API.
    pub location_id: String,
}

impl LikeACommentParams {
    /// Start from the parameters the API requires.
    pub fn new(location_id: impl Into<String>) -> Self {
        Self {
            location_id: location_id.into(),
        }
    }

    fn to_query(&self) -> Vec<(String, String)> {
        let q: Vec<(String, String)> = vec![("locationId".into(), self.location_id.clone())];
        q
    }
}

/// Query parameters for [`SocialPlannerService::get_available_accounts_step_2_of_3`].
#[derive(Debug, Clone, Default)]
pub struct GetAvailableAccountsStep2Of3Params {
    /// Search term to filter accounts/pages by name. Useful when the user has many pages to
    /// choose from.
    pub search: Option<String>,
}

impl GetAvailableAccountsStep2Of3Params {
    /// Start from the parameters the API requires.
    pub fn new() -> Self {
        Self {
            ..Default::default()
        }
    }

    /// Search term to filter accounts/pages by name. Useful when the user has many pages to
    /// choose from.
    pub fn search(mut self, v: impl Into<String>) -> Self {
        self.search = Some(v.into());
        self
    }

    fn to_query(&self) -> Vec<(String, String)> {
        let mut q: Vec<(String, String)> = Vec::new();
        if let Some(v) = &self.search {
            q.push(("search".into(), v.to_string()));
        }
        q
    }
}

/// Query parameters for [`SocialPlannerService::start_o_auth_flow_step_1_of_3`].
#[derive(Debug, Clone, Default)]
pub struct StartOAuthFlowStep1Of3Params {
    /// Location Id
    /// Required by the API.
    pub location_id: String,
    /// User Id
    /// Required by the API.
    pub user_id: String,
    /// Page
    pub page: Option<String>,
    /// Reconnect
    pub reconnect: Option<String>,
}

impl StartOAuthFlowStep1Of3Params {
    /// Start from the parameters the API requires.
    pub fn new(location_id: impl Into<String>, user_id: impl Into<String>) -> Self {
        Self {
            location_id: location_id.into(),
            user_id: user_id.into(),
            ..Default::default()
        }
    }

    /// Page
    pub fn page(mut self, v: impl Into<String>) -> Self {
        self.page = Some(v.into());
        self
    }

    /// Reconnect
    pub fn reconnect(mut self, v: impl Into<String>) -> Self {
        self.reconnect = Some(v.into());
        self
    }

    fn to_query(&self) -> Vec<(String, String)> {
        let mut q: Vec<(String, String)> = vec![
            ("locationId".into(), self.location_id.clone()),
            ("userId".into(), self.user_id.clone()),
        ];
        if let Some(v) = &self.page {
            q.push(("page".into(), v.to_string()));
        }
        if let Some(v) = &self.reconnect {
            q.push(("reconnect".into(), v.to_string()));
        }
        q
    }
}

/// Query parameters for [`SocialPlannerService::get_social_media_statistics`].
#[derive(Debug, Clone, Default)]
pub struct GetSocialMediaStatisticsParams {
    /// Location ID
    /// Required by the API.
    pub location_id: String,
}

impl GetSocialMediaStatisticsParams {
    /// Start from the parameters the API requires.
    pub fn new(location_id: impl Into<String>) -> Self {
        Self {
            location_id: location_id.into(),
        }
    }

    fn to_query(&self) -> Vec<(String, String)> {
        let q: Vec<(String, String)> = vec![("locationId".into(), self.location_id.clone())];
        q
    }
}

/// Query parameters for [`SocialPlannerService::delete_account`].
#[derive(Debug, Clone, Default)]
pub struct DeleteAccountParams {
    /// Company ID
    pub company_id: Option<String>,
    /// User ID
    pub user_id: Option<String>,
}

impl DeleteAccountParams {
    /// Start from the parameters the API requires.
    pub fn new() -> Self {
        Self {
            ..Default::default()
        }
    }

    /// Company ID
    pub fn company_id(mut self, v: impl Into<String>) -> Self {
        self.company_id = Some(v.into());
        self
    }

    /// User ID
    pub fn user_id(mut self, v: impl Into<String>) -> Self {
        self.user_id = Some(v.into());
        self
    }

    fn to_query(&self) -> Vec<(String, String)> {
        let mut q: Vec<(String, String)> = Vec::new();
        if let Some(v) = &self.company_id {
            q.push(("companyId".into(), v.to_string()));
        }
        if let Some(v) = &self.user_id {
            q.push(("userId".into(), v.to_string()));
        }
        q
    }
}

/// Query parameters for [`SocialPlannerService::get_categories_by_location_id`].
#[derive(Debug, Clone, Default)]
pub struct GetCategoriesByLocationIdParams {
    /// Search text string
    pub search_text: Option<String>,
    /// Limit
    pub limit: Option<String>,
    /// Skip
    pub skip: Option<String>,
}

impl GetCategoriesByLocationIdParams {
    /// Start from the parameters the API requires.
    pub fn new() -> Self {
        Self {
            ..Default::default()
        }
    }

    /// Search text string
    pub fn search_text(mut self, v: impl Into<String>) -> Self {
        self.search_text = Some(v.into());
        self
    }

    /// Limit
    pub fn limit(mut self, v: impl Into<String>) -> Self {
        self.limit = Some(v.into());
        self
    }

    /// Skip
    pub fn skip(mut self, v: impl Into<String>) -> Self {
        self.skip = Some(v.into());
        self
    }

    fn to_query(&self) -> Vec<(String, String)> {
        let mut q: Vec<(String, String)> = Vec::new();
        if let Some(v) = &self.search_text {
            q.push(("searchText".into(), v.to_string()));
        }
        if let Some(v) = &self.limit {
            q.push(("limit".into(), v.to_string()));
        }
        if let Some(v) = &self.skip {
            q.push(("skip".into(), v.to_string()));
        }
        q
    }
}

/// Query parameters for [`SocialPlannerService::get_upload_status`].
#[derive(Debug, Clone, Default)]
pub struct GetUploadStatusParams {
    /// Number of records to skip
    pub skip: Option<String>,
    /// Maximum number of records to return
    pub limit: Option<String>,
    /// Include user data in response
    pub include_users: Option<String>,
    /// Filter CSVs imported from template library
    pub is_from_template: Option<String>,
    /// User ID
    /// Required by the API.
    pub user_id: String,
}

impl GetUploadStatusParams {
    /// Start from the parameters the API requires.
    pub fn new(user_id: impl Into<String>) -> Self {
        Self {
            user_id: user_id.into(),
            ..Default::default()
        }
    }

    /// Number of records to skip
    pub fn skip(mut self, v: impl Into<String>) -> Self {
        self.skip = Some(v.into());
        self
    }

    /// Maximum number of records to return
    pub fn limit(mut self, v: impl Into<String>) -> Self {
        self.limit = Some(v.into());
        self
    }

    /// Include user data in response
    pub fn include_users(mut self, v: impl Into<String>) -> Self {
        self.include_users = Some(v.into());
        self
    }

    /// Filter CSVs imported from template library
    pub fn is_from_template(mut self, v: impl Into<String>) -> Self {
        self.is_from_template = Some(v.into());
        self
    }

    fn to_query(&self) -> Vec<(String, String)> {
        let mut q: Vec<(String, String)> = vec![("userId".into(), self.user_id.clone())];
        if let Some(v) = &self.skip {
            q.push(("skip".into(), v.to_string()));
        }
        if let Some(v) = &self.limit {
            q.push(("limit".into(), v.to_string()));
        }
        if let Some(v) = &self.include_users {
            q.push(("includeUsers".into(), v.to_string()));
        }
        if let Some(v) = &self.is_from_template {
            q.push(("isFromTemplate".into(), v.to_string()));
        }
        q
    }
}

/// Query parameters for [`SocialPlannerService::get_csv_post`].
#[derive(Debug, Clone, Default)]
pub struct GetCsvPostParams {
    /// Number of records to skip
    pub skip: Option<String>,
    /// Maximum number of records to return
    pub limit: Option<String>,
}

impl GetCsvPostParams {
    /// Start from the parameters the API requires.
    pub fn new() -> Self {
        Self {
            ..Default::default()
        }
    }

    /// Number of records to skip
    pub fn skip(mut self, v: impl Into<String>) -> Self {
        self.skip = Some(v.into());
        self
    }

    /// Maximum number of records to return
    pub fn limit(mut self, v: impl Into<String>) -> Self {
        self.limit = Some(v.into());
        self
    }

    fn to_query(&self) -> Vec<(String, String)> {
        let mut q: Vec<(String, String)> = Vec::new();
        if let Some(v) = &self.skip {
            q.push(("skip".into(), v.to_string()));
        }
        if let Some(v) = &self.limit {
            q.push(("limit".into(), v.to_string()));
        }
        q
    }
}

/// Query parameters for [`SocialPlannerService::get_tags_by_location_id`].
#[derive(Debug, Clone, Default)]
pub struct GetTagsByLocationIdParams {
    /// Search text string
    pub search_text: Option<String>,
    /// Limit
    pub limit: Option<String>,
    /// Skip
    pub skip: Option<String>,
}

impl GetTagsByLocationIdParams {
    /// Start from the parameters the API requires.
    pub fn new() -> Self {
        Self {
            ..Default::default()
        }
    }

    /// Search text string
    pub fn search_text(mut self, v: impl Into<String>) -> Self {
        self.search_text = Some(v.into());
        self
    }

    /// Limit
    pub fn limit(mut self, v: impl Into<String>) -> Self {
        self.limit = Some(v.into());
        self
    }

    /// Skip
    pub fn skip(mut self, v: impl Into<String>) -> Self {
        self.skip = Some(v.into());
        self
    }

    fn to_query(&self) -> Vec<(String, String)> {
        let mut q: Vec<(String, String)> = Vec::new();
        if let Some(v) = &self.search_text {
            q.push(("searchText".into(), v.to_string()));
        }
        if let Some(v) = &self.limit {
            q.push(("limit".into(), v.to_string()));
        }
        if let Some(v) = &self.skip {
            q.push(("skip".into(), v.to_string()));
        }
        q
    }
}

impl SocialPlannerService {
    /// Create a new category queue
    ///
    /// Creates a queue in draft status for a category. Published posts are auto-added. Use
    /// update endpoint to activate.
    ///
    /// `POST /social-media-posting/category/queues`
    ///
    /// Requires scope: `socialplanner/category.write`.
    pub async fn create_a_new_category_queue(
        &self,
        body: &models::CreateCategoryQueueDTO,
    ) -> Result<models::WrappedCreateCategoryQueueResponseDTO> {
        let query = Vec::new();
        self.client
            .send_versioned(
                reqwest::Method::POST,
                "/social-media-posting/category/queues",
                &query,
                Some(body),
                Some("v3"),
            )
            .await
    }

    /// Get all categories with their queue status
    ///
    /// Returns categories with status: "available" (no queue), "in_queue" (active/paused
    /// queue), or "draft" (queue in draft).
    ///
    /// `GET /social-media-posting/category/queues/available-categories`
    ///
    /// Requires scope: `socialplanner/category.readonly`.
    pub async fn get_all_categories_with_their_queue_status(
        &self,
        params: &GetAllCategoriesWithTheirQueueStatusParams,
    ) -> Result<models::WrappedFetchAvailableCategoriesResponseDTO> {
        let query = params.to_query();
        self.client
            .send_versioned(
                reqwest::Method::GET,
                "/social-media-posting/category/queues/available-categories",
                &query,
                None::<&()>,
                Some("v3"),
            )
            .await
    }

    /// Fetch category queues for a location
    ///
    /// Retrieves a paginated list of all category queues for a given location, excluding
    /// any that have been marked as deleted.
    ///
    /// `POST /social-media-posting/category/queues/list`
    ///
    /// Requires scope: `socialplanner/category.readonly`.
    pub async fn fetch_category_queues_for_a_location(
        &self,
        body: &models::FetchCategoryQueuesDTO,
    ) -> Result<models::WrappedFetchCategoryQueuesResponseDTO> {
        let query = Vec::new();
        self.client
            .send_versioned(
                reqwest::Method::POST,
                "/social-media-posting/category/queues/list",
                &query,
                Some(body),
                Some("v3"),
            )
            .await
    }

    /// Get scheduled posts calendar view
    ///
    /// Returns scheduled posts from active queues within a date range. Supports filtering
    /// by categories and accounts.
    ///
    /// `POST /social-media-posting/category/queues/list/calendar`
    ///
    /// Requires scope: `socialplanner/category.readonly`.
    pub async fn get_scheduled_posts_calendar_view(
        &self,
        body: &models::CalendarListDTO,
    ) -> Result<models::WrappedFetchCalendarListResponseDTO> {
        let query = Vec::new();
        self.client
            .send_versioned(
                reqwest::Method::POST,
                "/social-media-posting/category/queues/list/calendar",
                &query,
                Some(body),
                Some("v3"),
            )
            .await
    }

    /// Delete an active post and schedule the next one
    ///
    /// Deletes a post that is currently scheduled and automatically triggers the scheduling
    /// of the next available post in the queue.
    ///
    /// `DELETE /social-media-posting/category/queues/{postId}/active-post`
    ///
    /// Requires scope: `socialplanner/category.write`.
    pub async fn delete_an_active_post_and_schedule_the_next_one(
        &self,
        post_id: &str,
        params: &DeleteAnActivePostAndScheduleTheNextOneParams,
    ) -> Result<models::WrappedDeleteActivePostResponseDTO> {
        let path = format!(
            "/social-media-posting/category/queues/{}/active-post",
            crate::services::encode(post_id)
        );
        let query = params.to_query();
        self.client
            .send_versioned(
                reqwest::Method::DELETE,
                &path,
                &query,
                None::<&()>,
                Some("v3"),
            )
            .await
    }

    /// Fetch a category queue by ID
    ///
    /// Retrieves the details of a single category queue by its unique ID. The response
    /// includes a count of posts within the queue that have errors.
    ///
    /// `GET /social-media-posting/category/queues/{queueId}`
    ///
    /// Requires scope: `socialplanner/category.readonly`.
    pub async fn fetch_a_category_queue_by_id(
        &self,
        queue_id: &str,
        params: &FetchACategoryQueueByIdParams,
    ) -> Result<models::WrappedFetchQueueByIdResponseDTO> {
        let path = format!(
            "/social-media-posting/category/queues/{}",
            crate::services::encode(queue_id)
        );
        let query = params.to_query();
        self.client
            .send_versioned(reqwest::Method::GET, &path, &query, None::<&()>, Some("v3"))
            .await
    }

    /// Update queue settings or status
    ///
    /// Updates queue status (active/paused/deleted), time slots, or skip dates.
    ///
    /// `PUT /social-media-posting/category/queues/{queueId}`
    ///
    /// Requires scope: `socialplanner/category.write`.
    pub async fn update_queue_settings_or_status(
        &self,
        queue_id: &str,
        body: &models::UpdateCategoryQueueDTO,
    ) -> Result<models::WrappedUpdateCategoryQueueResponseDTO> {
        let path = format!(
            "/social-media-posting/category/queues/{}",
            crate::services::encode(queue_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::PUT, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// Create a new item in the queue
    ///
    /// Adds a new post item to a queue. Use sessionId for edit session or directToQueue for
    /// immediate addition.
    ///
    /// `POST /social-media-posting/category/queues/{queueId}/create/item`
    ///
    /// Requires scope: `socialplanner/category.write`.
    pub async fn create_a_new_item_in_the_queue(
        &self,
        queue_id: &str,
        body: &models::CreateQueueItemDTO,
    ) -> Result<models::WrappedCreateQueueItemResponseDTO> {
        let path = format!(
            "/social-media-posting/category/queues/{}/create/item",
            crate::services::encode(queue_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::POST, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// Fetch calendar view for an edit session
    ///
    /// Retrieves a calendar preview of scheduled posts based on draft items within an edit
    /// session. This shows how posts would be scheduled if changes were saved.
    ///
    /// `POST /social-media-posting/category/queues/{queueId}/edit/calendar`
    ///
    /// Requires scope: `socialplanner/category.readonly`.
    pub async fn fetch_calendar_view_for_an_edit_session(
        &self,
        queue_id: &str,
        body: &models::EditSessionCalendarDTO,
    ) -> Result<models::WrappedEditSessionCalendarResponseDTO> {
        let path = format!(
            "/social-media-posting/category/queues/{}/edit/calendar",
            crate::services::encode(queue_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::POST, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// Discard edit session changes
    ///
    /// Cancels the edit session and deletes all staged changes without affecting the live
    /// queue.
    ///
    /// `POST /social-media-posting/category/queues/{queueId}/edit/discard`
    ///
    /// Requires scope: `socialplanner/category.write`.
    pub async fn discard_edit_session_changes(
        &self,
        queue_id: &str,
        body: &models::DiscardEditSessionDTO,
    ) -> Result<models::WrappedDiscardEditSessionResponseDTO> {
        let path = format!(
            "/social-media-posting/category/queues/{}/edit/discard",
            crate::services::encode(queue_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::POST, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// Save edit session changes
    ///
    /// Applies all staged changes to the live queue and closes the edit session.
    ///
    /// `POST /social-media-posting/category/queues/{queueId}/edit/save`
    ///
    /// Requires scope: `socialplanner/category.write`.
    pub async fn save_edit_session_changes(
        &self,
        queue_id: &str,
        body: &models::SaveEditSessionDTO,
    ) -> Result<models::WrappedSaveEditSessionResponseDTO> {
        let path = format!(
            "/social-media-posting/category/queues/{}/edit/save",
            crate::services::encode(queue_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::POST, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// Start or resume an edit session
    ///
    /// Creates a draft copy of queue items for editing. Changes are staged until saved or
    /// discarded.
    ///
    /// `POST /social-media-posting/category/queues/{queueId}/edit/start`
    ///
    /// Requires scope: `socialplanner/category.write`.
    pub async fn start_or_resume_an_edit_session(
        &self,
        queue_id: &str,
        body: &models::StartEditSessionDTO,
    ) -> Result<models::WrappedStartEditSessionResponseDTO> {
        let path = format!(
            "/social-media-posting/category/queues/{}/edit/start",
            crate::services::encode(queue_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::POST, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// Fetch items from a queue
    ///
    /// Returns paginated queue items. Pass sessionId to get draft items from an edit
    /// session instead of live items.
    ///
    /// `POST /social-media-posting/category/queues/{queueId}/items`
    ///
    /// Requires scope: `socialplanner/category.readonly`.
    pub async fn fetch_items_from_a_queue(
        &self,
        queue_id: &str,
        body: &models::FetchQueueItemsDTO,
    ) -> Result<models::WrappedFetchQueueItemsResponseDTO> {
        let path = format!(
            "/social-media-posting/category/queues/{}/items",
            crate::services::encode(queue_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::POST, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// Delete an item from a queue
    ///
    /// Deletes an item from a specific category queue.
    ///
    /// `DELETE /social-media-posting/category/queues/{queueId}/items/{itemId}`
    ///
    /// Requires scope: `socialplanner/category.write`.
    pub async fn delete_an_item_from_a_queue(
        &self,
        queue_id: &str,
        item_id: &str,
        params: &DeleteAnItemFromAQueueParams,
    ) -> Result<models::WrappedGeneralSuccessResponseDTO> {
        let path = format!(
            "/social-media-posting/category/queues/{}/items/{}",
            crate::services::encode(queue_id),
            crate::services::encode(item_id)
        );
        let query = params.to_query();
        self.client
            .send_versioned(
                reqwest::Method::DELETE,
                &path,
                &query,
                None::<&()>,
                Some("v3"),
            )
            .await
    }

    /// Update an item in a queue
    ///
    /// Updates the content or variations of a specific item within a category queue.
    ///
    /// `PUT /social-media-posting/category/queues/{queueId}/items/{itemId}`
    ///
    /// Requires scope: `socialplanner/category.write`.
    pub async fn update_an_item_in_a_queue(
        &self,
        queue_id: &str,
        item_id: &str,
        body: &models::UpdateQueueItemDTO,
    ) -> Result<models::WrappedUpdateQueueItemResponseDTO> {
        let path = format!(
            "/social-media-posting/category/queues/{}/items/{}",
            crate::services::encode(queue_id),
            crate::services::encode(item_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::PUT, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// Clone a queue item
    ///
    /// Duplicates an existing queue item at a specified order position. Requires an active
    /// edit session.
    ///
    /// `POST /social-media-posting/category/queues/{queueId}/items/{itemId}/clone`
    ///
    /// Requires scope: `socialplanner/category.write`.
    pub async fn clone_a_queue_item(
        &self,
        queue_id: &str,
        item_id: &str,
        body: &models::CloneQueueItemDTO,
    ) -> Result<models::WrappedCloneQueueItemResponseDTO> {
        let path = format!(
            "/social-media-posting/category/queues/{}/items/{}/clone",
            crate::services::encode(queue_id),
            crate::services::encode(item_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::POST, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// Reset an item in a queue
    ///
    /// Resets a specific queue item to its original state, discarding any modifications
    /// made.
    ///
    /// `PUT /social-media-posting/category/queues/{queueId}/items/{itemId}/reset`
    ///
    /// Requires scope: `socialplanner/category.write`.
    pub async fn reset_an_item_in_a_queue(
        &self,
        queue_id: &str,
        item_id: &str,
        body: &models::ResetQueueItemDTO,
    ) -> Result<models::WrappedResetQueueItemResponseDTO> {
        let path = format!(
            "/social-media-posting/category/queues/{}/items/{}/reset",
            crate::services::encode(queue_id),
            crate::services::encode(item_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::PUT, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// Fetch slot information for queue items
    ///
    /// Returns paginated slot information (scheduledDateTime, isSkipped) for queue items.
    /// Pass sessionId to get slots for draft items, or omit for live items. Call this after
    /// mutations to refresh slot data.
    ///
    /// `POST /social-media-posting/category/queues/{queueId}/slots`
    ///
    /// Requires scope: `socialplanner/category.readonly`.
    pub async fn fetch_slot_information_for_queue_items(
        &self,
        queue_id: &str,
        body: &models::FetchSlotsDTO,
    ) -> Result<models::WrappedFetchSlotsResponseDTO> {
        let path = format!(
            "/social-media-posting/category/queues/{}/slots",
            crate::services::encode(queue_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::POST, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// Create a comment or reply
    ///
    /// Create a top-level comment on a post (`isParentThread: true`, `parentId` = postId)
    /// or a reply to an existing comment (`isParentThread: false`, `parentId` = commentId).
    /// Per-platform content max length: Facebook 8000, Instagram 2200, Linkedin 3000,
    /// Community 8000, Tiktok 150, Bluesky 300, Youtube 10000, Threads 500.
    /// **Optional-field platform support:** - `attachments` — supported on **Facebook
    /// only**. Ignored on Instagram, LinkedIn, TikTok, Bluesky, Community (Community
    /// processes the field but external URLs are not rendered due to its bucket
    /// restriction). - `mentions` — supported on **Facebook**
    ///
    /// `POST /social-media-posting/comments/{platform}`
    pub async fn create_a_comment_or_reply(
        &self,
        platform: &str,
        params: &CreateACommentOrReplyParams,
        body: &models::CommentsCreateBodyDTO,
    ) -> Result<models::CommentsCreateResponseDTO> {
        let path = format!(
            "/social-media-posting/comments/{}",
            crate::services::encode(platform)
        );
        let query = params.to_query();
        self.client
            .send_versioned(reqwest::Method::POST, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// List comments for a post or thread
    ///
    /// Paginated list of comments scoped to a post (`parentId` = postId) or a comment
    /// thread (`parentId` = commentId). Use `skip`/`limit` for pagination, `sortBy` for
    /// ordering, `originIds` to filter by connected account, and `search` for keyword
    /// search.
    ///
    /// `POST /social-media-posting/comments/{platform}/list`
    pub async fn list_comments_for_a_post_or_thread(
        &self,
        platform: &str,
        params: &ListCommentsForAPostOrThreadParams,
        body: &models::CommentsGetListBodyDTO,
    ) -> Result<models::CommentsGetListResponseDTO> {
        let path = format!(
            "/social-media-posting/comments/{}/list",
            crate::services::encode(platform)
        );
        let query = params.to_query();
        self.client
            .send_versioned(reqwest::Method::POST, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// Unlike a comment
    ///
    /// Remove a like from a comment by its **Highlevel** comment ID (the `_id` returned by
    /// the list-comments endpoint — not the native platform ID). Works for any comment
    /// level — top-level comments, replies, and replies-to-replies. **Supported
    /// platforms:** Facebook, LinkedIn, Community, TikTok, Bluesky. Instagram is not
    /// supported (passing `instagram` returns 400).
    ///
    /// `DELETE /social-media-posting/comments/{platform}/{id}/like`
    pub async fn unlike_a_comment(
        &self,
        platform: &str,
        id: &str,
        params: &UnlikeACommentParams,
    ) -> Result<models::DeleteLikeResponseDTO> {
        let path = format!(
            "/social-media-posting/comments/{}/{}/like",
            crate::services::encode(platform),
            crate::services::encode(id)
        );
        let query = params.to_query();
        self.client
            .send_versioned(
                reqwest::Method::DELETE,
                &path,
                &query,
                None::<&()>,
                Some("v3"),
            )
            .await
    }

    /// Like a comment
    ///
    /// Like a comment by its **Highlevel** comment ID (the `_id` returned by the
    /// list-comments endpoint — not the native platform ID). Works for any comment level —
    /// top-level comments, replies, and replies-to-replies. **Supported platforms:**
    /// Facebook, LinkedIn, Community, TikTok, Bluesky. Instagram is not supported (passing
    /// `instagram` returns 400).
    ///
    /// `POST /social-media-posting/comments/{platform}/{id}/like`
    pub async fn like_a_comment(
        &self,
        platform: &str,
        id: &str,
        params: &LikeACommentParams,
    ) -> Result<models::CommentsLikeResponseDTO> {
        let path = format!(
            "/social-media-posting/comments/{}/{}/like",
            crate::services::encode(platform),
            crate::services::encode(id)
        );
        let query = params.to_query();
        self.client
            .send_versioned(
                reqwest::Method::POST,
                &path,
                &query,
                None::<&()>,
                Some("v3"),
            )
            .await
    }

    /// Get Available Accounts (Step 2 of 3)
    ///
    /// ## OAuth Connection Flow - Step 2: Get Available Accounts After completing OAuth
    /// authentication (Step 1), use this endpoint to retrieve the list of available pages,
    /// channels, or locations that can be connected. ### OAuth Flow Position 1. **Start
    /// OAuth** → User authenticates, returns `accountId` 2. **Get Accounts** (this
    /// endpoint) → Lists available pages/channels to connect 3. **Attach Account** →
    /// Connect the selected account ### What This Returns The response varies by platform:
    /// | Platform | Returns | |----------|--------| | **facebook** | List of Facebook Pages
    /// the user manages | | **instagra
    ///
    /// `GET /social-media-posting/oauth/{locationId}/{platform}/accounts/{accountId}`
    pub async fn get_available_accounts_step_2_of_3(
        &self,
        location_id: &str,
        platform: &str,
        account_id: &str,
        params: &GetAvailableAccountsStep2Of3Params,
    ) -> Result<serde_json::Value> {
        let path = format!(
            "/social-media-posting/oauth/{}/{}/accounts/{}",
            crate::services::encode(location_id),
            crate::services::encode(platform),
            crate::services::encode(account_id)
        );
        let query = params.to_query();
        self.client
            .send_versioned(reqwest::Method::GET, &path, &query, None::<&()>, Some("v3"))
            .await
    }

    /// Connect Account (Step 3 of 3)
    ///
    /// ## OAuth Connection Flow - Step 3: Connect the Account This is the final step in the
    /// OAuth flow. After retrieving available accounts (Step 2), use this endpoint to
    /// connect the selected account to your location. ### OAuth Flow Summary 1. **Start
    /// OAuth** → User authenticates with platform 2. **Get Accounts** → Retrieved available
    /// pages/channels 3. **Attach Account** (this endpoint) → Connect the selected account
    /// ### Request Body by Platform The request body structure varies depending on the
    /// platform: #### Facebook / Instagram ```json { "type": "page", "originId":
    /// "244405XXXXX11687", "name": "My
    ///
    /// `POST /social-media-posting/oauth/{locationId}/{platform}/accounts/{accountId}`
    pub async fn connect_account_step_3_of_3(
        &self,
        location_id: &str,
        platform: &str,
        account_id: &str,
        body: &serde_json::Value,
    ) -> Result<serde_json::Value> {
        let path = format!(
            "/social-media-posting/oauth/{}/{}/accounts/{}",
            crate::services::encode(location_id),
            crate::services::encode(platform),
            crate::services::encode(account_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::POST, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// Start OAuth Flow (Step 1 of 3)
    ///
    /// ## OAuth Connection Flow - Step 1: Initiate OAuth This is the first step in the
    /// 3-step OAuth flow to connect a social media account: 1. **Start OAuth** (this
    /// endpoint) → User authenticates with the platform 2. **Get Accounts** → Retrieve
    /// available pages/channels to connect 3. **Attach Account** → Connect the selected
    /// account to your location ### How to Use Open this API in a browser window (not via
    /// cURL) with the required query parameters. The user will be redirected to the
    /// platform's OAuth login screen. ### Receiving the OAuth Response After successful
    /// authentication, the OAuth window will po
    ///
    /// `GET /social-media-posting/oauth/{platform}/start`
    pub async fn start_o_auth_flow_step_1_of_3(
        &self,
        platform: &str,
        params: &StartOAuthFlowStep1Of3Params,
    ) -> Result<serde_json::Value> {
        let path = format!(
            "/social-media-posting/oauth/{}/start",
            crate::services::encode(platform)
        );
        let query = params.to_query();
        self.client
            .send_versioned(reqwest::Method::GET, &path, &query, None::<&()>, Some("v3"))
            .await
    }

    /// Get Social Media Statistics
    ///
    /// Retrieve analytics data for multiple social media accounts. Supports custom date
    /// ranges for both the current period and a comparison period. If no date ranges are
    /// provided, defaults to the last 7 days (excluding today) with comparison to the
    /// previous 7 days.
    ///
    /// `POST /social-media-posting/statistics`
    ///
    /// Requires scope: `socialplanner/statistics.readonly`.
    pub async fn get_social_media_statistics(
        &self,
        params: &GetSocialMediaStatisticsParams,
        body: &serde_json::Value,
    ) -> Result<serde_json::Value> {
        let query = params.to_query();
        self.client
            .send_versioned(
                reqwest::Method::POST,
                "/social-media-posting/statistics",
                &query,
                Some(body),
                Some("v3"),
            )
            .await
    }

    /// Get Accounts
    ///
    /// Get list of accounts and groups
    ///
    /// `GET /social-media-posting/{locationId}/accounts`
    ///
    /// Requires scope: `socialplanner/account.readonly`.
    pub async fn get_accounts(&self, location_id: &str) -> Result<models::AccountsListResponseDTO> {
        let path = format!(
            "/social-media-posting/{}/accounts",
            crate::services::encode(location_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::GET, &path, &query, None::<&()>, Some("v3"))
            .await
    }

    /// Delete Account
    ///
    /// Delete account and account from group
    ///
    /// `DELETE /social-media-posting/{locationId}/accounts/{id}`
    pub async fn delete_account(
        &self,
        location_id: &str,
        id: &str,
        params: &DeleteAccountParams,
    ) -> Result<models::LocationAndAccountDeleteResponseDTO> {
        let path = format!(
            "/social-media-posting/{}/accounts/{}",
            crate::services::encode(location_id),
            crate::services::encode(id)
        );
        let query = params.to_query();
        self.client
            .send_versioned(
                reqwest::Method::DELETE,
                &path,
                &query,
                None::<&()>,
                Some("v3"),
            )
            .await
    }

    /// Get categories by location id
    ///
    /// Retrieve all categories for a specific location with optional search and pagination
    ///
    /// `GET /social-media-posting/{locationId}/categories`
    ///
    /// Requires scope: `socialplanner/category.readonly`.
    pub async fn get_categories_by_location_id(
        &self,
        location_id: &str,
        params: &GetCategoriesByLocationIdParams,
    ) -> Result<models::GetByLocationIdResponseDTO> {
        let path = format!(
            "/social-media-posting/{}/categories",
            crate::services::encode(location_id)
        );
        let query = params.to_query();
        self.client
            .send_versioned(reqwest::Method::GET, &path, &query, None::<&()>, Some("v3"))
            .await
    }

    /// Get categories by id
    ///
    /// Retrieve a specific category by its ID
    ///
    /// `GET /social-media-posting/{locationId}/categories/{id}`
    pub async fn get_categories_by_id(
        &self,
        location_id: &str,
        id: &str,
    ) -> Result<models::GetByIdResponseDTO> {
        let path = format!(
            "/social-media-posting/{}/categories/{}",
            crate::services::encode(location_id),
            crate::services::encode(id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::GET, &path, &query, None::<&()>, Some("v3"))
            .await
    }

    /// Get Upload Status
    ///
    /// Get the status of all CSV imports for a location
    ///
    /// `GET /social-media-posting/{locationId}/csv`
    pub async fn get_upload_status(
        &self,
        location_id: &str,
        params: &GetUploadStatusParams,
    ) -> Result<models::GetUploadStatusResponseDTO> {
        let path = format!(
            "/social-media-posting/{}/csv",
            crate::services::encode(location_id)
        );
        let query = params.to_query();
        self.client
            .send_versioned(reqwest::Method::GET, &path, &query, None::<&()>, Some("v3"))
            .await
    }

    /// Upload CSV
    ///
    /// Upload a CSV file containing social media posts for bulk scheduling
    ///
    /// `POST /social-media-posting/{locationId}/csv`
    ///
    /// Requires scope: `socialplanner/csv.write`.
    pub async fn upload_csv(
        &self,
        location_id: &str,
        body: &serde_json::Value,
    ) -> Result<models::UploadFileResponseDTO> {
        let path = format!(
            "/social-media-posting/{}/csv",
            crate::services::encode(location_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::POST, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// Delete CSV Post
    ///
    /// Delete a specific post from a CSV import
    ///
    /// `DELETE /social-media-posting/{locationId}/csv/{csvId}/post/{postId}`
    pub async fn delete_csv_post(
        &self,
        location_id: &str,
        csv_id: &str,
        post_id: &str,
    ) -> Result<models::DeletePostResponseDTO> {
        let path = format!(
            "/social-media-posting/{}/csv/{}/post/{}",
            crate::services::encode(location_id),
            crate::services::encode(csv_id),
            crate::services::encode(post_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(
                reqwest::Method::DELETE,
                &path,
                &query,
                None::<&()>,
                Some("v3"),
            )
            .await
    }

    /// Delete CSV
    ///
    /// Delete a CSV import and all its associated posts
    ///
    /// `DELETE /social-media-posting/{locationId}/csv/{id}`
    pub async fn delete_csv(
        &self,
        location_id: &str,
        id: &str,
    ) -> Result<models::DeleteCsvResponseDTO> {
        let path = format!(
            "/social-media-posting/{}/csv/{}",
            crate::services::encode(location_id),
            crate::services::encode(id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(
                reqwest::Method::DELETE,
                &path,
                &query,
                None::<&()>,
                Some("v3"),
            )
            .await
    }

    /// Get CSV Post
    ///
    /// Get details of a specific CSV import including its posts
    ///
    /// `GET /social-media-posting/{locationId}/csv/{id}`
    pub async fn get_csv_post(
        &self,
        location_id: &str,
        id: &str,
        params: &GetCsvPostParams,
    ) -> Result<models::GetCsvPostResponseDTO> {
        let path = format!(
            "/social-media-posting/{}/csv/{}",
            crate::services::encode(location_id),
            crate::services::encode(id)
        );
        let query = params.to_query();
        self.client
            .send_versioned(reqwest::Method::GET, &path, &query, None::<&()>, Some("v3"))
            .await
    }

    /// Start CSV Finalize
    ///
    /// Finalize a CSV import and schedule all posts for publishing
    ///
    /// `PATCH /social-media-posting/{locationId}/csv/{id}`
    pub async fn start_csv_finalize(
        &self,
        location_id: &str,
        id: &str,
        body: &models::CSVDefaultDTO,
    ) -> Result<models::CsvPostStatusResponseDTO> {
        let path = format!(
            "/social-media-posting/{}/csv/{}",
            crate::services::encode(location_id),
            crate::services::encode(id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(
                reqwest::Method::PATCH,
                &path,
                &query,
                Some(body),
                Some("v3"),
            )
            .await
    }

    /// Create post
    ///
    /// Create posts for all supported platforms. It is possible to create customized posts
    /// per channel by using the same platform account IDs in a request and hitting the
    /// create post API multiple times with different summaries and account IDs per
    /// platform. The content and media limitations, as well as platform rate limiters
    /// corresponding to the respective platforms, are provided in the following reference
    /// link: Link: [Platform
    /// Limitations](https://help.leadconnectorhq.com/support/solutions/articles/48001240003-social-planner-image-video-content-and-api-limitations
    /// "Social Planner Help")
    ///
    /// `POST /social-media-posting/{locationId}/posts`
    ///
    /// Requires scope: `socialplanner/post.write`.
    pub async fn create_post(
        &self,
        location_id: &str,
        body: &models::CreatePostDTO,
    ) -> Result<models::CreatePostSuccessfulResponseDTO> {
        let path = format!(
            "/social-media-posting/{}/posts",
            crate::services::encode(location_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::POST, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// Bulk Delete Social Planner Posts
    ///
    /// Deletes multiple posts based on the provided list of post IDs. This operation is
    /// useful for clearing up large numbers of posts efficiently. Note: 1.The maximum
    /// number of posts that can be deleted in a single request is '50'. 2.However, It will
    /// only get deleted in CRM database but still it is recommended to be cautious of this
    /// operation.
    ///
    /// `POST /social-media-posting/{locationId}/posts/bulk-delete`
    pub async fn bulk_delete_social_planner_posts(
        &self,
        location_id: &str,
        body: &models::DeletePostsDto,
    ) -> Result<models::BulkDeleteResponseDto> {
        let path = format!(
            "/social-media-posting/{}/posts/bulk-delete",
            crate::services::encode(location_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::POST, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// Get posts
    ///
    /// Get Posts
    ///
    /// `POST /social-media-posting/{locationId}/posts/list`
    ///
    /// Requires scope: `socialplanner/post.readonly`.
    pub async fn get_posts(
        &self,
        location_id: &str,
        body: &models::SearchPostDTO,
    ) -> Result<models::PostSuccessfulResponseDTO> {
        let path = format!(
            "/social-media-posting/{}/posts/list",
            crate::services::encode(location_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::POST, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// Delete Post
    ///
    /// `DELETE /social-media-posting/{locationId}/posts/{id}`
    pub async fn delete_post(
        &self,
        location_id: &str,
        id: &str,
    ) -> Result<models::DeletePostSuccessfulResponseDTO> {
        let path = format!(
            "/social-media-posting/{}/posts/{}",
            crate::services::encode(location_id),
            crate::services::encode(id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(
                reqwest::Method::DELETE,
                &path,
                &query,
                None::<&()>,
                Some("v3"),
            )
            .await
    }

    /// Get post
    ///
    /// `GET /social-media-posting/{locationId}/posts/{id}`
    pub async fn get_post(
        &self,
        location_id: &str,
        id: &str,
    ) -> Result<models::GetPostSuccessfulResponseDTO> {
        let path = format!(
            "/social-media-posting/{}/posts/{}",
            crate::services::encode(location_id),
            crate::services::encode(id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::GET, &path, &query, None::<&()>, Some("v3"))
            .await
    }

    /// Edit post
    ///
    /// Create posts for all supported platforms. It is possible to create customized posts
    /// per channel by using the same platform account IDs in a request and hitting the
    /// create post API multiple times with different summaries and account IDs per
    /// platform. The content and media limitations, as well as platform rate limiters
    /// corresponding to the respective platforms, are provided in the following reference
    /// link: Link: [Platform
    /// Limitations](https://help.leadconnectorhq.com/support/solutions/articles/48001240003-social-planner-image-video-content-and-api-limitations
    /// "Social Planner Help")
    ///
    /// `PUT /social-media-posting/{locationId}/posts/{id}`
    pub async fn edit_post(
        &self,
        location_id: &str,
        id: &str,
        body: &models::CreatePostDTO,
    ) -> Result<models::UpdatePostSuccessfulResponseDTO> {
        let path = format!(
            "/social-media-posting/{}/posts/{}",
            crate::services::encode(location_id),
            crate::services::encode(id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::PUT, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// Set Accounts
    ///
    /// Set social media accounts for a CSV import to publish posts to
    ///
    /// `POST /social-media-posting/{locationId}/set-accounts`
    ///
    /// Requires scope: `socialplanner/csv.write`.
    pub async fn set_accounts(
        &self,
        location_id: &str,
        body: &models::SetAccountsDTO,
    ) -> Result<models::SetAccountsResponseDTO> {
        let path = format!(
            "/social-media-posting/{}/set-accounts",
            crate::services::encode(location_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::POST, &path, &query, Some(body), Some("v3"))
            .await
    }

    /// Get tags by location id
    ///
    /// Retrieve all tags for a specific location with optional search and pagination
    ///
    /// `GET /social-media-posting/{locationId}/tags`
    pub async fn get_tags_by_location_id(
        &self,
        location_id: &str,
        params: &GetTagsByLocationIdParams,
    ) -> Result<models::GetTagsByLocationIdResponseDTO> {
        let path = format!(
            "/social-media-posting/{}/tags",
            crate::services::encode(location_id)
        );
        let query = params.to_query();
        self.client
            .send_versioned(reqwest::Method::GET, &path, &query, None::<&()>, Some("v3"))
            .await
    }

    /// Get tags by ids
    ///
    /// Retrieve specific tags by their IDs
    ///
    /// `POST /social-media-posting/{locationId}/tags/details`
    pub async fn get_tags_by_ids(
        &self,
        location_id: &str,
        body: &models::UpdateTagDTO,
    ) -> Result<models::GetTagsByIdResponseDTO> {
        let path = format!(
            "/social-media-posting/{}/tags/details",
            crate::services::encode(location_id)
        );
        let query = Vec::new();
        self.client
            .send_versioned(reqwest::Method::POST, &path, &query, Some(body), Some("v3"))
            .await
    }
}