19
19
package org .botblock .javabotblockapi .requests ;
20
20
21
21
import org .botblock .javabotblockapi .Site ;
22
- import org .botblock .javabotblockapi .annotations .DeprecatedSince ;
23
- import org .botblock .javabotblockapi .annotations .PlannedRemoval ;
24
22
import org .jetbrains .annotations .Nullable ;
25
23
import org .json .JSONArray ;
26
24
import org .json .JSONObject ;
31
29
* Class used to perform GET actions on the <a href="https://botblock.org/api/docs#lists" target="_blank">{@code /api/lists}</a>
32
30
* and <a href="https://botblock.org/api/docs#list" target="_blank">{@code /api/lists/:id}</a> endpoints.
33
31
*
34
- * <p>GET requests are cached for 2 minutes unless disabled through {@link #GetListAction(boolean) GetListAction(true)}.
32
+ * <p>GET requests are cached for 2 minutes unless disabled through {@link #GetListAction(boolean, String) GetListAction(true, String)}
33
+ * or {@link #GetListAction(boolean, String, String) GetListAction(true, String, String)}.
35
34
*
36
35
* @since 5.0.0
37
36
*/
@@ -40,37 +39,6 @@ public class GetListAction{
40
39
private final RequestHandler REQUEST_HANDLER ;
41
40
private final boolean disableCache ;
42
41
43
- /**
44
- * Constructor to get an instance of GetListAction.
45
- *
46
- * @deprecated This Constructor can no longer be used and will throw an {@link java.lang.IllegalStateException IllegalStateException}
47
- * when used.
48
- */
49
- @ Deprecated
50
- @ DeprecatedSince (version = "5.2.0" )
51
- @ PlannedRemoval (version = "5.2.3" )
52
- public GetListAction (){
53
- throw new IllegalStateException ("This constructor may no longer be used." );
54
- }
55
-
56
- /**
57
- * Constructor to get an instance of GetListAction.
58
- * <br>Use this if you want to disable the caching of the GET requests.
59
- * <br><b>We do not recommend this without own caching/ratelimiting.</b>
60
- *
61
- * @param disableCache
62
- * Whether or not to disable caching. {@code true} means caching gets <b>disabled</b>!
63
- *
64
- * @deprecated This Constructor can no longer be used and will throw an {@link java.lang.IllegalStateException IllegalStateException}
65
- * when used.
66
- */
67
- @ Deprecated
68
- @ DeprecatedSince (version = "5.2.0" , replacements = {"GetListAction(String)" , "GetListAction(boolean, String)" , "GetListAction(boolean, String, String)" })
69
- @ PlannedRemoval (version = "5.2.3" )
70
- public GetListAction (boolean disableCache ){
71
- throw new IllegalStateException ("This constructor may no longer be used." );
72
- }
73
-
74
42
/**
75
43
* Constructor to get an instance of GetListAction.
76
44
*
@@ -155,7 +123,7 @@ public String getApiField(@Nonnull String id, @Nonnull Site site, @Nonnull ApiFi
155
123
CheckUtil .notEmpty (id , "id" );
156
124
JSONObject json = getList (id , site );
157
125
158
- return json .getString (field .name (). toLowerCase ());
126
+ return json .getString (field .getApiField ());
159
127
}
160
128
161
129
/**
@@ -176,7 +144,7 @@ public String getApiField(@Nonnull String id, @Nonnull String site, @Nonnull Api
176
144
CheckUtil .notEmpty (site , "site" );
177
145
JSONObject json = getList (id , site );
178
146
179
- return json .getString (field .name (). toLowerCase ());
147
+ return json .getString (field .getApiField ());
180
148
}
181
149
182
150
/**
@@ -721,127 +689,35 @@ public boolean isDiscordOnly(@Nonnull String id, @Nonnull String site){
721
689
* @since 5.0.0
722
690
*/
723
691
public enum ApiField {
724
- // URL fields
725
-
726
- /**
727
- * API field to return the URL to list all bots of a bot list.
728
- *
729
- * @deprecated Since: 5.2.0
730
- * <br>Replacement: {@link #URL_ALL URL_ALL}
731
- */
732
- @ Deprecated
733
- @ DeprecatedSince (version = "5.2.0" , replacements = {"#URL_ALL" })
734
- @ PlannedRemoval (version = "5.2.3" )
735
- API_ALL ,
736
-
737
- /**
738
- * API field to return the URL to the API documentation of the bot list.
739
- *
740
- * @deprecated Since: 5.2.0
741
- * <br>Replacement: {@link #URL_DOCS URL_DOCS}
742
- */
743
- @ Deprecated
744
- @ DeprecatedSince (version = "5.2.0" , replacements = {"#URL_DOCS" })
745
- @ PlannedRemoval (version = "5.2.3" )
746
- API_DOCS ,
747
-
748
- /**
749
- * API field to return the URL used to GET information about a bot.
750
- *
751
- * @deprecated Since: 5.2.0
752
- * <br>Replacement: {@link #URL_GET URL_GET}
753
- */
754
- @ Deprecated
755
- @ DeprecatedSince (version = "5.2.0" , replacements = {"#URL_GET" })
756
- @ PlannedRemoval (version = "5.2.3" )
757
- API_GET ,
758
-
759
- /**
760
- * API field to return the URL used to POST information from a bot.
761
- *
762
- * @deprecated Since: 5.2.0
763
- * <br>Replacement: {@link #URL_POST URL_POST}
764
- */
765
- @ Deprecated
766
- @ DeprecatedSince (version = "5.2.0" , replacements = {"#URL_POST" })
767
- @ PlannedRemoval (version = "5.2.3" )
768
- API_POST ,
769
-
770
- // Fields returning a String
771
-
772
- /**
773
- * Name of the field for posting the server count (i.e. {@code server_count})
774
- *
775
- * @deprecated Since: 5.2.0
776
- * <br>Replacement: {@link #STRING_SERVER_COUNT STRING_SERVER_COUNT}
777
- */
778
- @ Deprecated
779
- @ DeprecatedSince (version = "5.2.0" , replacements = {"#STRING_SERVER_COUNT" })
780
- @ PlannedRemoval (version = "5.2.3" )
781
- API_FIELD ,
782
-
783
- /**
784
- * Name of the field for posting the shard id (i.e. {@code shard_id})
785
- *
786
- * @deprecated Since: 5.2.0
787
- * <br>Replacement: {@link #STRING_SHARD_ID STRING_SHARD_ID}
788
- */
789
- @ Deprecated
790
- @ DeprecatedSince (version = "5.2.0" , replacements = {"#STRING_SHARD_ID" })
791
- @ PlannedRemoval (version = "5.2.3" )
792
- API_SHARD_ID ,
793
-
794
- /**
795
- * Name of the field for posting the shard count (i.e. {@code shard_count})
796
- *
797
- * @deprecated Since: 5.2.0
798
- * <br>Replacement: {@link #STRING_SHARD_COUNT STRING_SHARD_COUNT}
799
- */
800
- @ Deprecated
801
- @ DeprecatedSince (version = "5.2.0" , replacements = {"#STRING_SHARD_COUNT" })
802
- @ PlannedRemoval (version = "5.2.3" )
803
- API_SHARD_COUNT ,
804
-
805
- /**
806
- * Name of the field for posting the different shard info (i.e. {@code shards})
807
- *
808
- * @deprecated Since: 5.2.0
809
- * <br>Replacement: {@link #STRING_SHARDS STRING_SHARDS}
810
- */
811
- @ Deprecated
812
- @ DeprecatedSince (version = "5.2.0" , replacements = {"#STRING_SHARDS" })
813
- @ PlannedRemoval (version = "5.2.3" )
814
- API_SHARDS ,
815
-
816
692
// String API field
817
693
818
694
/**
819
695
* Name of the field for the server count. Example: {@code server_count}
820
696
*
821
697
* @since 5.2.0
822
698
*/
823
- STRING_SERVER_COUNT ,
699
+ STRING_SERVER_COUNT ( "api_field" ) ,
824
700
825
701
/**
826
702
* Name of the field for the shard id. Example: {@code shard_id}
827
703
*
828
704
* @since 5.2.0
829
705
*/
830
- STRING_SHARD_ID ,
706
+ STRING_SHARD_ID ( "api_shard_id" ) ,
831
707
832
708
/**
833
709
* Name of the field for the shard count. Example: {@code shard_count}
834
710
*
835
711
* @since 5.2.0
836
712
*/
837
- STRING_SHARD_COUNT ,
713
+ STRING_SHARD_COUNT ( "api_shard_count" ) ,
838
714
839
715
/**
840
716
* Name of the field for the shards. Example: {@code shards}
841
717
*
842
718
* @since 5.2.0
843
719
*/
844
- STRING_SHARDS ,
720
+ STRING_SHARDS ( "api_shards" ) ,
845
721
846
722
// URL API field
847
723
@@ -850,27 +726,43 @@ public enum ApiField{
850
726
*
851
727
* @since 5.2.0
852
728
*/
853
- URL_ALL ,
729
+ URL_ALL ( "api_all" ) ,
854
730
855
731
/**
856
732
* URL to view the API documentation of the bot list
857
733
*
858
734
* @since 5.2.0
859
735
*/
860
- URL_DOCS ,
736
+ URL_DOCS ( "api_docs" ) ,
861
737
862
738
/**
863
739
* URL to GET information about a single bot listed on the bot list.
864
740
*
865
741
* @since 5.2.0
866
742
*/
867
- URL_GET ,
743
+ URL_GET ( "api_get" ) ,
868
744
869
745
/**
870
746
* URL to POST the server count to a bot list.
871
747
*
872
748
* @since 5.2.0
873
749
*/
874
- URL_POST
750
+ URL_POST ("api_post" );
751
+
752
+ private final String apiField ;
753
+
754
+ ApiField (String apiField ){
755
+ this .apiField = apiField ;
756
+ }
757
+
758
+ public String getApiField (){
759
+ return apiField ;
760
+ }
761
+
762
+
763
+ @ Override
764
+ public String toString (){
765
+ return apiField ;
766
+ }
875
767
}
876
768
}
0 commit comments