File: ApiMethods.pm

package info (click to toggle)
libtwitter-api-perl 1.0006-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 424 kB
  • sloc: perl: 2,868; makefile: 7
file content (1897 lines) | stat: -rw-r--r-- 57,983 bytes parent folder | download
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
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
package Twitter::API::Trait::ApiMethods;
# ABSTRACT: Convenient API Methods
$Twitter::API::Trait::ApiMethods::VERSION = '1.0006';
use 5.14.1;
use Carp;
use Moo::Role;
use MooX::Aliases;
use Ref::Util qw/is_hashref is_arrayref/;
use namespace::clean;

requires 'request';

with 'Twitter::API::Role::RequestArgs';

#pod =method account_settings([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-account-settings>
#pod
#pod =cut

sub account_settings {
    shift->request(get => 'account/settings', @_);
}

#pod =method blocking([ \%args ])
#pod
#pod Aliases: blocks_list
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/get-blocks-list>
#pod
#pod =cut

sub blocking {
    shift->request(get => 'blocks/list', @_);
}
alias blocks_list => 'blocking';

#pod =method blocking_ids([ \%args ])
#pod
#pod Aliases: blocks_ids
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/get-blocks-ids>
#pod
#pod =cut

sub blocking_ids {
    shift->request(get => 'blocks/ids', @_);
}
alias blocks_ids => 'blocking_ids';

#pod =method collection_entries([ $id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/get-collections-entries>
#pod
#pod =cut

sub collection_entries {
    shift->request_with_pos_args(id => get => 'collections/entries', @_);
}

#pod =method collections([ $screen_name | $user_id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/get-collections-list>
#pod
#pod =cut

sub collections {
    shift->request_with_pos_args(':ID', get => 'collections/list', @_);
}

sub direct_messages { croak 'DEPRECATED - use direct_messages_events instead' }

#pod =method favorites([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-favorites-list>
#pod
#pod =cut

sub favorites {
    shift->request(get => 'favorites/list', @_);
}

#pod =method followers([ \%args ])
#pod
#pod Aliases: followers_list
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-followers-list>
#pod
#pod =cut

sub followers {
    shift->request(get => 'followers/list', @_);
}
alias followers_list => 'followers';

#pod =method followers_ids([ $screen_name | $user_id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-followers-ids>
#pod
#pod =cut

sub followers_ids {
    shift->request_with_pos_args(':ID', get => 'followers/ids', @_);
}

#pod =method friends([ \%args ])
#pod
#pod Aliases: friends_list
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friends-list>
#pod
#pod =cut

sub friends {
    shift->request(get => 'friends/list', @_);
}
alias friends_list => 'friends';

#pod =method friends_ids([ \%args ])
#pod
#pod Aliases: following_ids
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friends-ids>
#pod
#pod =cut

sub friends_ids {
    shift->request_with_id(get => 'friends/ids', @_);
}
alias following_ids => 'friends_ids';

#pod =method friendships_incoming([ \%args ])
#pod
#pod Aliases: incoming_friendships
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friendships-incoming>
#pod
#pod =cut

sub friendships_incoming {
    shift->request(get => 'friendships/incoming', @_);
}
alias incoming_friendships => 'friendships_incoming';

#pod =method friendships_outgoing([ \%args ])
#pod
#pod Aliases: outgoing_friendships
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friendships-outgoing>
#pod
#pod =cut

sub friendships_outgoing {
    shift->request(get => 'friendships/outgoing', @_);
}
alias outgoing_friendships => 'friendships_outgoing';

#pod =method geo_id([ $place_id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/geo/place-information/api-reference/get-geo-id-place_id>
#pod
#pod =cut

# NT incompatibility
sub geo_id {
    shift->request_with_pos_args(place_id => get => 'geo/id/:place_id', @_);
}

#pod =method geo_search([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/geo/places-near-location/api-reference/get-geo-search>
#pod
#pod =cut

sub geo_search {
    shift->request(get => 'geo/search', @_);
}

#pod =method get_configuration([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/developer-utilities/configuration/api-reference/get-help-configuration>
#pod
#pod =cut

sub get_configuration {
    shift->request(get => 'help/configuration', @_);
}

#pod =method get_languages([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/developer-utilities/supported-languages/api-reference/get-help-languages>
#pod
#pod =cut

sub get_languages {
    shift->request(get => 'help/languages', @_);
}

#pod =method get_list([ \%args ])
#pod
#pod Aliases: show_list
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-show>
#pod
#pod =cut

sub get_list {
    shift->request(get => 'lists/show', @_);
}
alias show_list => 'get_list';

#pod =method get_lists([ \%args ])
#pod
#pod Aliases: list_lists, all_subscriptions
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-list>
#pod
#pod =cut

sub get_lists {
    shift->request(get => 'lists/list', @_);
}
alias $_ => 'get_lists' for qw/list_lists all_subscriptions/;

#pod =method get_privacy_policy([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/developer-utilities/privacy-policy/api-reference/get-help-privacy>
#pod
#pod =cut

sub get_privacy_policy {
    shift->request(get => 'help/privacy', @_);
}

#pod =method get_tos([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/developer-utilities/terms-of-service/api-reference/get-help-tos>
#pod
#pod =cut

sub get_tos {
    shift->request(get => 'help/tos', @_);
}

#pod =method home_timeline([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-home_timeline>
#pod
#pod =cut

sub home_timeline {
    shift->request(get => 'statuses/home_timeline', @_);
}

#pod =method list_members([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-members>
#pod
#pod =cut

sub list_members {
    shift->request(get => 'lists/members', @_);
}

#pod =method list_memberships([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-memberships>
#pod
#pod =cut

sub list_memberships {
    shift->request(get => 'lists/memberships', @_);
}

#pod =method list_ownerships([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-ownerships>
#pod
#pod =cut

sub list_ownerships {
    shift->request(get => 'lists/ownerships', @_);
}

#pod =method list_statuses([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-statuses>
#pod
#pod =cut

sub list_statuses {
    shift->request(get => 'lists/statuses', @_);
}

#pod =method list_subscribers([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-subscribers>
#pod
#pod =cut

sub list_subscribers {
    shift->request(get => 'lists/subscribers', @_);
}

#pod =method list_subscriptions([ \%args ])
#pod
#pod Aliases: subscriptions
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-subscriptions>
#pod
#pod =cut

sub list_subscriptions {
    shift->request(get => 'lists/subscriptions', @_);
}
alias subscriptions => 'list_subscriptions';

#pod =method lookup_friendships([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friendships-lookup>
#pod
#pod =cut

sub lookup_friendships {
    shift->request(get => 'friendships/lookup', @_);
}

#pod =method lookup_statuses([ $id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-lookup>
#pod
#pod =cut

sub lookup_statuses {
    shift->request_with_pos_args(id => get => 'statuses/lookup', @_);
}

#pod =method lookup_users([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-lookup>
#pod
#pod =cut

sub lookup_users {
    shift->request(get => 'users/lookup', @_);
}

#pod =method mentions([ \%args ])
#pod
#pod Aliases: replies, mentions_timeline
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-mentions_timeline>
#pod
#pod =cut

sub mentions {
    shift->request(get => 'statuses/mentions_timeline', @_);
}
alias $_ => 'mentions' for qw/replies mentions_timeline/;

#pod =method mutes([ \%args ])
#pod
#pod Aliases: muting_ids, muted_ids
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/get-mutes-users-ids>
#pod
#pod =cut

sub mutes {
    shift->request(get => 'mutes/users/ids', @_);
}
alias $_ => 'mutes' for qw/muting_ids muted_ids/;

#pod =method muting([ \%args ])
#pod
#pod Aliases: mutes_list
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/get-mutes-users-list>
#pod
#pod =cut

sub muting {
    shift->request(get => 'mutes/users/list', @_);
}
alias mutes_list => 'muting';

#pod =method no_retweet_ids([ \%args ])
#pod
#pod Aliases: no_retweets_ids
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friendships-no_retweets-ids>
#pod
#pod =cut

sub no_retweet_ids {
    shift->request(get => 'friendships/no_retweets/ids', @_);
}
alias no_retweets_ids => 'no_retweet_ids';

#pod =method oembed([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-oembed>
#pod
#pod =cut

sub oembed {
    shift->request(get => 'statuses/oembed', @_);
}

#pod =method profile_banner([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-users-profile_banner>
#pod
#pod =cut

sub profile_banner {
    shift->request(get => 'users/profile_banner', @_);
}

#pod =method rate_limit_status([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/developer-utilities/rate-limit-status/api-reference/get-application-rate_limit_status>
#pod
#pod =cut

sub rate_limit_status {
    shift->request(get => 'application/rate_limit_status', @_);
}

#pod =method retweeters_ids([ $id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-retweeters-ids>
#pod
#pod =cut

sub retweeters_ids {
    shift->request_with_pos_args(id => get => 'statuses/retweeters/ids', @_);
}

#pod =method retweets([ $id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-retweets-id>
#pod
#pod =cut

sub retweets {
    shift->request_with_pos_args(id => get => 'statuses/retweets/:id', @_);
}

#pod =method retweets_of_me([ \%args ])
#pod
#pod Aliases: retweeted_of_me
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-retweets_of_me>
#pod
#pod =cut

sub retweets_of_me {
    shift->request(get => 'statuses/retweets_of_me', @_);
}
alias retweeted_of_me => 'retweets_of_me';

#pod =method reverse_geocode([ $lat, [ $long, ]][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/geo/places-near-location/api-reference/get-geo-reverse_geocode>
#pod
#pod =cut

sub reverse_geocode {
    shift->request_with_pos_args([ qw/lat long/ ], get => 'geo/reverse_geocode', @_);
}

#pod =method saved_searches([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-saved_searches-list>
#pod
#pod =cut

sub saved_searches {
    shift->request(get => 'saved_searches/list', @_);
}

#pod =method search([ $q, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets>
#pod
#pod =cut

sub search {
    shift->request_with_pos_args(q => get => 'search/tweets', @_);
}

#pod =method sent_direct_messages([ \%args ])
#pod
#pod Aliases: direct_messages_sent
#pod
#pod L<https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/get-sent-message>
#pod
#pod =cut

sub sent_direct_messages { croak 'DEPRECATED - use direct_messages_events instead' }
alias direct_messages_sent => 'sent_direct_messages';

sub show_direct_message { croak 'DEPRECATED - show_direct_messages_event instead' }

#pod =method show_friendship([ \%args ])
#pod
#pod Aliases: show_relationship
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friendships-show>
#pod
#pod =cut

sub show_friendship {
    shift->request(get => 'friendships/show', @_);
}
alias show_relationship => 'show_friendship';

#pod =method show_list_member([ \%args ])
#pod
#pod Aliases: is_list_member
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-members-show>
#pod
#pod =cut

sub show_list_member {
    shift->request(get => 'lists/members/show', @_);
}
alias is_list_member => 'show_list_member';

#pod =method show_list_subscriber([ \%args ])
#pod
#pod Aliases: is_list_subscriber, is_subscriber_lists
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-subscribers-show>
#pod
#pod =cut

sub show_list_subscriber {
    shift->request(get => 'lists/subscribers/show', @_);
}
alias $_ => 'show_list_subscriber' for qw/is_list_subscriber is_subscriber_lists/;

#pod =method show_saved_search([ $id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-saved_searches-show-id>
#pod
#pod =cut

sub show_saved_search {
    shift->request_with_pos_args(id => get => 'saved_searches/show/:id', @_);
}

#pod =method show_status([ $id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-show-id>
#pod
#pod =cut

sub show_status {
    shift->request_with_pos_args(id => get => 'statuses/show/:id', @_);
}

#pod =method show_user([ $screen_name | $user_id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-show>
#pod
#pod =cut

sub show_user {
    shift->request_with_pos_args(':ID', get => 'users/show', @_);
}

#pod =method suggestion_categories([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-suggestions>
#pod
#pod =cut

sub suggestion_categories {
    shift->request(get => 'users/suggestions', @_);
}

#pod =method trends_available([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/trends/locations-with-trending-topics/api-reference/get-trends-available>
#pod
#pod =cut

sub trends_available {
    my ( $self, $args ) = @_;

    goto &trends_closest if exists $$args{lat} || exists $$args{long};

    shift->request(get => 'trends/available', @_);
}

#pod =method trends_closest([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/trends/locations-with-trending-topics/api-reference/get-trends-closest>
#pod
#pod =cut

sub trends_closest {
    shift->request(get => 'trends/closest', @_);
}

#pod =method trends_place([ $id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/trends/trends-for-location/api-reference/get-trends-place>
#pod
#pod =cut

sub trends_place {
    shift->request_with_pos_args(id => get => 'trends/place', @_);
}
alias trends_location => 'trends_place';

#pod =method user_suggestions([ $slug, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-suggestions-slug-members>
#pod
#pod =cut

# Net::Twitter compatibility - rename category to slug
my $rename_category = sub {
    my $self = shift;

    my $args = is_hashref($_[-1]) ? pop : {};
    $args->{slug} = delete $args->{category} if exists $args->{category};
    return ( @_, $args );
};

sub user_suggestions {
    my $self = shift;

    $self->request_with_pos_args(slug => get => 'users/suggestions/:slug/members',
        $self->$rename_category(@_));
}
alias follow_suggestions => 'user_suggestions';

#pod =method user_suggestions_for([ $slug, ][ \%args ])
#pod
#pod Aliases: follow_suggestions
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-suggestions-slug>
#pod
#pod =cut

sub user_suggestions_for {
    my $self = shift;

    $self->request_with_pos_args(slug => get => 'users/suggestions/:slug',
        $self->$rename_category(@_));
}
alias follow_suggestions_for => 'user_suggestions_for';

#pod =method user_timeline([ $screen_name | $user_id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-user_timeline>
#pod
#pod =cut

sub user_timeline {
    shift->request_with_id(get => 'statuses/user_timeline', @_);
}

#pod =method users_search([ $q, ][ \%args ])
#pod
#pod Aliases: find_people, search_users
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-search>
#pod
#pod =cut

sub users_search {
    shift->request_with_pos_args(q => get => 'users/search', @_);
}
alias $_ => 'users_search' for qw/find_people search_users/;

#pod =method verify_credentials([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials>
#pod
#pod =cut

sub verify_credentials {
    shift->request(get => 'account/verify_credentials', @_);
}

#pod =method add_collection_entry([ $id, [ $tweet_id, ]][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/post-collections-entries-add>
#pod
#pod =cut

sub add_collection_entry {
    shift->request_with_pos_args([ qw/id tweet_id /],
        post => 'collections/entries/add', @_);
}

#pod =method add_list_member([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-members-create>
#pod
#pod =cut

sub add_list_member {
    shift->request(post => 'lists/members/create', @_);
}

# deprecated: https://dev.twitter.com/rest/reference/post/geo/place
sub add_place {
    shift->request_with_pos_args([ qw/name contained_within token lat long/ ],
        post => 'geo/place', @_);
}

#pod =method create_block([ $screen_name | $user_id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/post-blocks-create>
#pod
#pod =cut

sub create_block {
    shift->request_with_pos_args(':ID', post => 'blocks/create', @_);
}

#pod =method create_collection([ $name, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/post-collections-create>
#pod
#pod =cut

sub create_collection {
    shift->request_with_pos_args(name => post => 'collections/create', @_);
}

#pod =method create_favorite([ $id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-favorites-create>
#pod
#pod =cut

sub create_favorite {
    shift->request_with_pos_args(id => post => 'favorites/create', @_);
}

#pod =method create_friend([ $screen_name | $user_id, ][ \%args ])
#pod
#pod Aliases: follow, follow_new, create_friendship
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/post-friendships-create>
#pod
#pod =cut

sub create_friend {
    shift->request_with_pos_args(':ID', post => 'friendships/create', @_);
}
alias $_ => 'create_friend' for qw/follow follow_new create_friendship/;

#pod =method create_list([ $name, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-create>
#pod
#pod =cut

sub create_list {
    shift->request_with_pos_args(name => post => 'lists/create', @_);
}

#pod =method create_media_metadata([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-metadata-create>
#pod
#pod =cut

# E.g.:
# create_media_metadata({ media_id => $id, alt_text => { text => $text } })
sub create_media_metadata {
    my ( $self, $to_json ) = @_;

    croak 'expected a single hashref argument'
        unless @_ == 2 && is_hashref($_[1]);

    $self->request(post => 'media/metadata/create', {
        -to_json => $to_json,
    });
}

#pod =method create_mute([ $screen_name | $user_id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/post-mutes-users-create>
#pod
#pod Alias: mute
#pod
#pod =cut

sub create_mute {
    shift->request_with_pos_args(':ID' => post => 'mutes/users/create', @_);
}
alias mute => 'create_mute';

#pod =method create_saved_search([ $query, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-saved_searches-create>
#pod
#pod =cut

sub create_saved_search {
    shift->request_with_pos_args(query => post => 'saved_searches/create', @_);
}

#pod =method curate_collection([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/post-collections-entries-curate>
#pod
#pod =cut

sub curate_collection {
    my ( $self, $to_json ) = @_;

    croak 'unexpected extra args' if @_ > 2;
    $self->request(post => 'collections/entries/curate', {
        -to_json => $to_json,
    });
}

#pod =method delete_list([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-destroy>
#pod
#pod =cut

sub delete_list {
    shift->request(post => 'lists/destroy', @_);
}

#pod =method delete_list_member([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-members-destroy>
#pod
#pod =cut

sub delete_list_member {
    shift->request(post => 'lists/members/destroy', @_);
}
alias remove_list_member => 'delete_list_member';

#pod =method destroy_block([ $screen_name | $user_id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/post-blocks-destroy>
#pod
#pod =cut

sub destroy_block {
    shift->request_with_pos_args(':ID', post => 'blocks/destroy', @_);
}

#pod =method destroy_collection([ $id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/post-collections-destroy>
#pod
#pod =cut

sub destroy_collection {
    shift->request_with_pos_args(id => post => 'collections/destroy', @_);
}

sub destroy_direct_message { croak 'DEPRECATED - use destroy_direct_messages_event instead' }

#pod =method destroy_favorite([ $id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-favorites-destroy>
#pod
#pod =cut

sub destroy_favorite {
    shift->request_with_pos_args(id => post => 'favorites/destroy', @_);
}

#pod =method destroy_friend([ $screen_name | $user_id, ][ \%args ])
#pod
#pod Aliases: unfollow, destroy_friendship
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/post-friendships-destroy>
#pod
#pod =cut

sub destroy_friend {
    shift->request_with_pos_args(':ID', post => 'friendships/destroy', @_);
}
alias $_ => 'destroy_friend' for qw/unfollow destroy_friendship/;

#pod =method destroy_mute([ $screen_name | $user_id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/post-mutes-users-destroy>
#pod
#pod Alias: unmute
#pod
#pod =cut

sub destroy_mute {
    shift->request_with_pos_args(':ID' => post => 'mutes/users/destroy', @_);
}
alias unmute => 'destroy_mute';

#pod =method destroy_saved_search([ $id, ][ \%args ])
#pod
#pod Aliases: delete_saved_search
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-saved_searches-destroy-id>
#pod
#pod =cut

sub destroy_saved_search {
    shift->request_with_pos_args(id => post => 'saved_searches/destroy/:id', @_);
}
alias delete_saved_search => 'destroy_saved_search';

#pod =method destroy_status([ $id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-destroy-id>
#pod
#pod =cut

sub destroy_status {
    shift->request_with_pos_args(id => post => 'statuses/destroy/:id', @_);
}

#pod =method members_create_all([ \%args ])
#pod
#pod Aliases: add_list_members
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-members-create_all>
#pod
#pod =cut

sub members_create_all {
    shift->request(post => 'lists/members/create_all', @_);
}
alias add_list_members => 'members_create_all';

#pod =method members_destroy_all([ \%args ])
#pod
#pod Aliases: remove_list_members
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-members-destroy_all>
#pod
#pod =cut

sub members_destroy_all {
    shift->request(post => 'lists/members/destroy_all', @_);
}
alias remove_list_members => 'members_destroy_all';

#pod =method move_collection_entry([ $id, [ $tweet_id, [ $relative_to, ]]][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/post-collections-entries-move>
#pod
#pod =cut

sub move_collection_entry {
    shift->request_with_pos_args([ qw/id tweet_id relative_to /],
        post => 'collections/entries/move', @_);
}

sub new_direct_message { croak 'DEPRECATED - use new_direct_messages_event instead' }

#pod =method remove_collection_entry([ $id, [ $tweet_id, ]][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/post-collections-entries-remove>
#pod
#pod =cut

sub remove_collection_entry {
    shift->request_with_pos_args([ qw/id tweet_id/ ],
        post => 'collections/entries/remove', @_);
}

#pod =method remove_profile_banner([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-remove_profile_banner>
#pod
#pod =cut

sub remove_profile_banner {
    shift->request(post => 'account/remove_profile_banner', @_);
}

#pod =method report_spam([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/post-users-report_spam>
#pod
#pod =cut

sub report_spam {
    shift->request_with_id(post => 'users/report_spam', @_);
}

#pod =method retweet([ $id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-retweet-id>
#pod
#pod =cut

sub retweet {
    shift->request_with_pos_args(id => post => 'statuses/retweet/:id', @_);
}

#pod =method subscribe_list([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-subscribers-create>
#pod
#pod =cut

sub subscribe_list {
    shift->request(post => 'lists/subscribers/create', @_);
}

#pod =method unretweet([ $id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-unretweet-id>
#pod
#pod =cut

sub unretweet {
    shift->request_with_pos_args(id => post => 'statuses/unretweet/:id', @_);
}

#pod =method unsubscribe_list([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-subscribers-destroy>
#pod
#pod =cut

sub unsubscribe_list {
    shift->request(post => 'lists/subscribers/destroy', @_);
}

#pod =method update([ $status, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-update>
#pod
#pod =cut

sub update {
    my $self = shift;

    my ( $http_method, $path, $args, @rest ) =
        $self->normalize_pos_args(status => post => 'statuses/update', @_);

    $self->flatten_list_args(media_ids => $args);
    return $self->request($http_method, $path, $args, @rest);
}

#pod =method update_account_settings([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-settings>
#pod
#pod =cut

sub update_account_settings {
    shift->request(post => 'account/settings', @_);
}

#pod =method update_collection([ $id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/post-collections-update>
#pod
#pod =cut

sub update_collection {
    shift->request_with_pos_args(id => post => 'collections/update', @_);
}

#pod =method update_friendship([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/post-friendships-update>
#pod
#pod =cut

sub update_friendship {
    shift->request_with_id(post => 'friendships/update', @_);
}

#pod =method update_list([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-update>
#pod
#pod =cut

sub update_list {
    shift->request(post => 'lists/update', @_);
}

#pod =method update_profile([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile>
#pod
#pod =cut

sub update_profile {
    shift->request(post => 'account/update_profile', @_);
}

#pod =method update_profile_background_image([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_background_image>
#pod
#pod =cut

sub update_profile_background_image {
    shift->request(post => 'account/update_profile_background_image', @_);
}

#pod =method update_profile_banner([ $banner, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_banner>
#pod
#pod =cut

sub update_profile_banner {
    shift->request_with_pos_args(banner => post => 'account/update_profile_banner', @_);
}

#pod =method update_profile_image([ $image, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_image>
#pod
#pod =cut

sub update_profile_image {
    shift->request_with_pos_args(image => post => 'account/update_profile_image', @_);
}

#pod =method upload_media([ $media, ][ \%args ])
#pod
#pod Aliases: upload
#pod
#pod L<https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload>
#pod
#pod =cut

sub upload_media {
    my $self = shift;

    # Used to require media. Now requires media *or* media_data.
    # Handle either as a positional parameter, like we do with
    # screen_name or user_id on other methods.
    if ( @_ && !is_hashref($_[0]) ) {
        my $media = shift;
        my $key = is_arrayref($media) ? 'media' : 'media_data';
        my $args = @_ && is_hashref($_[0]) ? pop : {};
        $args->{$key} = $media;
        unshift @_, $args;
    }

    my $args = shift;
    $args->{-multipart_form_data} = 1;
    $self->flatten_list_args(additional_owners => $args);

    $self->request(post => $self->upload_url_for('media/upload'), $args, @_);
}
alias upload => 'upload_media';

#pod =method direct_messages_events([ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/list-events.html>
#pod
#pod =cut

sub direct_messages_events {
    shift->request(get => 'direct_messages/events/list', @_);
}

#pod =method show_direct_messages_event([ $id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/get-event>
#pod
#pod =cut

sub show_direct_messages_event {
    shift->request_with_pos_args(id => get => 'direct_messages/events/show', @_);
}

#pod =method destroy_direct_messages_event([ $id, ][ \%args ])
#pod
#pod L<https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/delete-message-event>
#pod
#pod =cut

sub destroy_direct_messages_event {
    shift->request_with_pos_args(id => delete => 'direct_messages/events/destroy', @_);
}

#pod =method new_direct_messages_event([$text, $recipient_id ] | [ \%event ], [ \%args ])
#pod
#pod For simple usage, pass text and recipient ID:
#pod
#pod     $client->new_dirrect_messages_event($text, $recipient_id)
#pod
#pod For more complex messages, pass a full event structure, for example:
#pod
#pod     $client->new_direct_massages_event({
#pod         type => 'message_create',
#pod         message_create => {
#pod             target => { recipient_id => $user_id },
#pod             message_data => {
#pod                 text => $text,
#pod                 attachment => {
#pod                     type  => 'media',
#pod                     media => { id => $media->{id} },
#pod                 },
#pod             },
#pod         },
#pod     })
#pod
#pod L<https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/new-message>
#pod
#pod =cut

sub new_direct_messages_event {
    my $self = shift;

    # The first argument is either an event hashref, or we'll create one with
    # the first two arguments: text and recipient_id.
    my $event = ref $_[0] ? shift : {
        type => 'message_create',
        message_create => {
            message_data => { text => shift },
            target => { recipient_id => shift },
        },
    };

    # only synthetic args are appropriate, here, e.g.
    # { -token => '...', -token_secret => '...' }
    my $args = shift // {};


    $self->request(post => 'direct_messages/events/new', {
        -to_json => { event => $event }, %$args
    });
}

#pod =method invalidate_access_token([ \%args ])
#pod
#pod Calling this method has the same effect as a user revoking access to the
#pod application via Twitter settings. The access token/secret pair will no longer
#pod be valid.
#pod
#pod This method can be called with client that has been initialized with
#pod C<access_token> and C<access_token_secret> attributes, by passing C<-token> and
#pod C<-token_secret> parameters, or by passing C<access_token> and
#pod C<access_token_secret> parameters.
#pod
#pod     $client->invalidate_access_token;
#pod     $client->invalidate_access_token({ -token => $token, -token_secret => $secret });
#pod     $client->invalidate_access_token({
#pod         access_token        => $token,
#pod         access_token_secret => $secret,
#pod     });
#pod
#pod Twitter added this method to the API on 2018-09-20.
#pod
#pod See
#pod L<https://developer.twitter.com/en/docs/basics/authentication/api-reference/invalidate_access_token>
#pod
#pod =cut

# We've already used invalidate_token for oauth2/invalidate_otkon in
# Trait::AppAuth, so we'll name this method invalidate_acccess_token to avoid
# any conflict.

sub invalidate_access_token {
    my ( $self, $args ) = @_;

    $args //= {};

    # For consistency with Twitter::API calling conventions:
    # - accept -token/-token_secret synthetic arguments
    # - or use access_token/access_token_secret attributes
    #
    # Or, allow passing access_token/access_token secrets parameters as
    # specified in Twitter's API documentation.

    my $access_token = $$args{'-token'} // $self->access_token
        // ( $$args{'-token'} = delete $$args{access_token} )
        // croak 'requires an oauth token';

    my $access_token_secret = $$args{'-token_secret'}
        // $self->access_token_secret
        // ( $$args{'-token_secret'} = delete $$args{access_token_secret} )
        // croak 'requires an oauth token secret';

    return $self->request(post => 'oauth/invalidate_token', {
        access_token        => $access_token,
        access_token_secret => $access_token_secret,
        %$args
    });
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Twitter::API::Trait::ApiMethods - Convenient API Methods

=head1 VERSION

version 1.0006

=head1 DESCRIPTION

This trait provides convenient methods for calling API endpoints. They are
L<Net::Twitter> compatible, with the same names and calling conventions.

Refer to L<Twitter's API documentation|https://developer.twitter.com/en/docs/api-reference-index>
for details about each method's parameters.

These methods are simply shorthand forms of C<get> and C<post>.  All methods
can be called with a parameters hashref. It can be omitted for endpoints that
do not require any parameters, such as C<mentions>. For example, all of these
calls are equivalent:

    $client->mentions;
    $client->mentions({});
    $client->get('statuses/mentions_timeline');
    $client->get('statuses/mentions_timeline', {});

Use the parameters hashref to pass optional parameters. For example,

    $client->mentions({ count => 200, trim_user=>'true' });

Some methods, with required parameters, can take positional parameters. For
example, C<geo_id> requires a C<place_id> parameter. These calls are
equivalent:

    $client->place_id($place);
    $client->place_id({ place_id => $place });

When positional parameters are allowed, they must be specified in the correct
order, but they don't all need to be specified. Those not specified
positionally can be added to the parameters hashref. For example, these calls
are equivalent:

    $client->add_collection_entry($id, $tweet_id);
    $client->add_collection_entry($id, { tweet_id => $tweet_id);
    $client->add_collection_entry({ id => $id, tweet_id => $tweet_id });

Many calls require a C<screen_name> or C<user_id>. Where noted, you may pass
either ID as the first positional parameter. Twitter::API will inspect the
value. If it contains only digits, it will be considered a C<user_id>.
Otherwise, it will be considered a C<screen_name>. Best practice is to
explicitly declare the ID type by passing it in the parameters hashref, because
it is possible to for users to set their screen names to a string of digits,
making the inferred ID ambiguous. These calls are equivalent:

   $client->create_block('realDonaldTrump');
   $client->create_block({ screen_name => 'realDonaldTrump' });

Since all of these methods simple resolve to a C<get> or C<post> call, see the
L<Twitter::API> for details about return values and error handling.

=head1 METHODS

=head2 account_settings([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-account-settings>

=head2 blocking([ \%args ])

Aliases: blocks_list

L<https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/get-blocks-list>

=head2 blocking_ids([ \%args ])

Aliases: blocks_ids

L<https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/get-blocks-ids>

=head2 collection_entries([ $id, ][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/get-collections-entries>

=head2 collections([ $screen_name | $user_id, ][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/get-collections-list>

=head2 favorites([ \%args ])

L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-favorites-list>

=head2 followers([ \%args ])

Aliases: followers_list

L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-followers-list>

=head2 followers_ids([ $screen_name | $user_id, ][ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-followers-ids>

=head2 friends([ \%args ])

Aliases: friends_list

L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friends-list>

=head2 friends_ids([ \%args ])

Aliases: following_ids

L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friends-ids>

=head2 friendships_incoming([ \%args ])

Aliases: incoming_friendships

L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friendships-incoming>

=head2 friendships_outgoing([ \%args ])

Aliases: outgoing_friendships

L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friendships-outgoing>

=head2 geo_id([ $place_id, ][ \%args ])

L<https://developer.twitter.com/en/docs/geo/place-information/api-reference/get-geo-id-place_id>

=head2 geo_search([ \%args ])

L<https://developer.twitter.com/en/docs/geo/places-near-location/api-reference/get-geo-search>

=head2 get_configuration([ \%args ])

L<https://developer.twitter.com/en/docs/developer-utilities/configuration/api-reference/get-help-configuration>

=head2 get_languages([ \%args ])

L<https://developer.twitter.com/en/docs/developer-utilities/supported-languages/api-reference/get-help-languages>

=head2 get_list([ \%args ])

Aliases: show_list

L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-show>

=head2 get_lists([ \%args ])

Aliases: list_lists, all_subscriptions

L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-list>

=head2 get_privacy_policy([ \%args ])

L<https://developer.twitter.com/en/docs/developer-utilities/privacy-policy/api-reference/get-help-privacy>

=head2 get_tos([ \%args ])

L<https://developer.twitter.com/en/docs/developer-utilities/terms-of-service/api-reference/get-help-tos>

=head2 home_timeline([ \%args ])

L<https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-home_timeline>

=head2 list_members([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-members>

=head2 list_memberships([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-memberships>

=head2 list_ownerships([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-ownerships>

=head2 list_statuses([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-statuses>

=head2 list_subscribers([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-subscribers>

=head2 list_subscriptions([ \%args ])

Aliases: subscriptions

L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-subscriptions>

=head2 lookup_friendships([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friendships-lookup>

=head2 lookup_statuses([ $id, ][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-lookup>

=head2 lookup_users([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-lookup>

=head2 mentions([ \%args ])

Aliases: replies, mentions_timeline

L<https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-mentions_timeline>

=head2 mutes([ \%args ])

Aliases: muting_ids, muted_ids

L<https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/get-mutes-users-ids>

=head2 muting([ \%args ])

Aliases: mutes_list

L<https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/get-mutes-users-list>

=head2 no_retweet_ids([ \%args ])

Aliases: no_retweets_ids

L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friendships-no_retweets-ids>

=head2 oembed([ \%args ])

L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-oembed>

=head2 profile_banner([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-users-profile_banner>

=head2 rate_limit_status([ \%args ])

L<https://developer.twitter.com/en/docs/developer-utilities/rate-limit-status/api-reference/get-application-rate_limit_status>

=head2 retweeters_ids([ $id, ][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-retweeters-ids>

=head2 retweets([ $id, ][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-retweets-id>

=head2 retweets_of_me([ \%args ])

Aliases: retweeted_of_me

L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-retweets_of_me>

=head2 reverse_geocode([ $lat, [ $long, ]][ \%args ])

L<https://developer.twitter.com/en/docs/geo/places-near-location/api-reference/get-geo-reverse_geocode>

=head2 saved_searches([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-saved_searches-list>

=head2 search([ $q, ][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets>

=head2 sent_direct_messages([ \%args ])

Aliases: direct_messages_sent

L<https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/get-sent-message>

=head2 show_friendship([ \%args ])

Aliases: show_relationship

L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friendships-show>

=head2 show_list_member([ \%args ])

Aliases: is_list_member

L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-members-show>

=head2 show_list_subscriber([ \%args ])

Aliases: is_list_subscriber, is_subscriber_lists

L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-subscribers-show>

=head2 show_saved_search([ $id, ][ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-saved_searches-show-id>

=head2 show_status([ $id, ][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-show-id>

=head2 show_user([ $screen_name | $user_id, ][ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-show>

=head2 suggestion_categories([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-suggestions>

=head2 trends_available([ \%args ])

L<https://developer.twitter.com/en/docs/trends/locations-with-trending-topics/api-reference/get-trends-available>

=head2 trends_closest([ \%args ])

L<https://developer.twitter.com/en/docs/trends/locations-with-trending-topics/api-reference/get-trends-closest>

=head2 trends_place([ $id, ][ \%args ])

L<https://developer.twitter.com/en/docs/trends/trends-for-location/api-reference/get-trends-place>

=head2 user_suggestions([ $slug, ][ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-suggestions-slug-members>

=head2 user_suggestions_for([ $slug, ][ \%args ])

Aliases: follow_suggestions

L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-suggestions-slug>

=head2 user_timeline([ $screen_name | $user_id, ][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-user_timeline>

=head2 users_search([ $q, ][ \%args ])

Aliases: find_people, search_users

L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-search>

=head2 verify_credentials([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials>

=head2 add_collection_entry([ $id, [ $tweet_id, ]][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/post-collections-entries-add>

=head2 add_list_member([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-members-create>

=head2 create_block([ $screen_name | $user_id, ][ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/post-blocks-create>

=head2 create_collection([ $name, ][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/post-collections-create>

=head2 create_favorite([ $id, ][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-favorites-create>

=head2 create_friend([ $screen_name | $user_id, ][ \%args ])

Aliases: follow, follow_new, create_friendship

L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/post-friendships-create>

=head2 create_list([ $name, ][ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-create>

=head2 create_media_metadata([ \%args ])

L<https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-metadata-create>

=head2 create_mute([ $screen_name | $user_id, ][ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/post-mutes-users-create>

Alias: mute

=head2 create_saved_search([ $query, ][ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-saved_searches-create>

=head2 curate_collection([ \%args ])

L<https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/post-collections-entries-curate>

=head2 delete_list([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-destroy>

=head2 delete_list_member([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-members-destroy>

=head2 destroy_block([ $screen_name | $user_id, ][ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/post-blocks-destroy>

=head2 destroy_collection([ $id, ][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/post-collections-destroy>

=head2 destroy_favorite([ $id, ][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-favorites-destroy>

=head2 destroy_friend([ $screen_name | $user_id, ][ \%args ])

Aliases: unfollow, destroy_friendship

L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/post-friendships-destroy>

=head2 destroy_mute([ $screen_name | $user_id, ][ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/post-mutes-users-destroy>

Alias: unmute

=head2 destroy_saved_search([ $id, ][ \%args ])

Aliases: delete_saved_search

L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-saved_searches-destroy-id>

=head2 destroy_status([ $id, ][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-destroy-id>

=head2 members_create_all([ \%args ])

Aliases: add_list_members

L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-members-create_all>

=head2 members_destroy_all([ \%args ])

Aliases: remove_list_members

L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-members-destroy_all>

=head2 move_collection_entry([ $id, [ $tweet_id, [ $relative_to, ]]][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/post-collections-entries-move>

=head2 remove_collection_entry([ $id, [ $tweet_id, ]][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/post-collections-entries-remove>

=head2 remove_profile_banner([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-remove_profile_banner>

=head2 report_spam([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/post-users-report_spam>

=head2 retweet([ $id, ][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-retweet-id>

=head2 subscribe_list([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-subscribers-create>

=head2 unretweet([ $id, ][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-unretweet-id>

=head2 unsubscribe_list([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-subscribers-destroy>

=head2 update([ $status, ][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-update>

=head2 update_account_settings([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-settings>

=head2 update_collection([ $id, ][ \%args ])

L<https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/post-collections-update>

=head2 update_friendship([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/post-friendships-update>

=head2 update_list([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-update>

=head2 update_profile([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile>

=head2 update_profile_background_image([ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_background_image>

=head2 update_profile_banner([ $banner, ][ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_banner>

=head2 update_profile_image([ $image, ][ \%args ])

L<https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_image>

=head2 upload_media([ $media, ][ \%args ])

Aliases: upload

L<https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload>

=head2 direct_messages_events([ \%args ])

L<https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/list-events.html>

=head2 show_direct_messages_event([ $id, ][ \%args ])

L<https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/get-event>

=head2 destroy_direct_messages_event([ $id, ][ \%args ])

L<https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/delete-message-event>

=head2 new_direct_messages_event([$text, $recipient_id ] | [ \%event ], [ \%args ])

For simple usage, pass text and recipient ID:

    $client->new_dirrect_messages_event($text, $recipient_id)

For more complex messages, pass a full event structure, for example:

    $client->new_direct_massages_event({
        type => 'message_create',
        message_create => {
            target => { recipient_id => $user_id },
            message_data => {
                text => $text,
                attachment => {
                    type  => 'media',
                    media => { id => $media->{id} },
                },
            },
        },
    })

L<https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/new-message>

=head2 invalidate_access_token([ \%args ])

Calling this method has the same effect as a user revoking access to the
application via Twitter settings. The access token/secret pair will no longer
be valid.

This method can be called with client that has been initialized with
C<access_token> and C<access_token_secret> attributes, by passing C<-token> and
C<-token_secret> parameters, or by passing C<access_token> and
C<access_token_secret> parameters.

    $client->invalidate_access_token;
    $client->invalidate_access_token({ -token => $token, -token_secret => $secret });
    $client->invalidate_access_token({
        access_token        => $token,
        access_token_secret => $secret,
    });

Twitter added this method to the API on 2018-09-20.

See
L<https://developer.twitter.com/en/docs/basics/authentication/api-reference/invalidate_access_token>

=head1 AUTHOR

Marc Mims <marc@questright.com>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2015-2021 by Marc Mims.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut