1919package org .botblock .javabotblockapi .requests ;
2020
2121import org .botblock .javabotblockapi .Site ;
22- import org .botblock .javabotblockapi .annotations .DeprecatedSince ;
23- import org .botblock .javabotblockapi .annotations .PlannedRemoval ;
2422import org .jetbrains .annotations .Nullable ;
2523import org .json .JSONArray ;
2624import org .json .JSONObject ;
3129 * Class used to perform GET actions on the <a href="https://botblock.org/api/docs#lists" target="_blank">{@code /api/lists}</a>
3230 * and <a href="https://botblock.org/api/docs#list" target="_blank">{@code /api/lists/:id}</a> endpoints.
3331 *
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)}.
3534 *
3635 * @since 5.0.0
3736 */
@@ -40,37 +39,6 @@ public class GetListAction{
4039 private final RequestHandler REQUEST_HANDLER ;
4140 private final boolean disableCache ;
4241
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-
7442 /**
7543 * Constructor to get an instance of GetListAction.
7644 *
@@ -155,7 +123,7 @@ public String getApiField(@Nonnull String id, @Nonnull Site site, @Nonnull ApiFi
155123 CheckUtil .notEmpty (id , "id" );
156124 JSONObject json = getList (id , site );
157125
158- return json .getString (field .name (). toLowerCase ());
126+ return json .getString (field .getApiField ());
159127 }
160128
161129 /**
@@ -176,7 +144,7 @@ public String getApiField(@Nonnull String id, @Nonnull String site, @Nonnull Api
176144 CheckUtil .notEmpty (site , "site" );
177145 JSONObject json = getList (id , site );
178146
179- return json .getString (field .name (). toLowerCase ());
147+ return json .getString (field .getApiField ());
180148 }
181149
182150 /**
@@ -721,127 +689,35 @@ public boolean isDiscordOnly(@Nonnull String id, @Nonnull String site){
721689 * @since 5.0.0
722690 */
723691 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-
816692 // String API field
817693
818694 /**
819695 * Name of the field for the server count. Example: {@code server_count}
820696 *
821697 * @since 5.2.0
822698 */
823- STRING_SERVER_COUNT ,
699+ STRING_SERVER_COUNT ( "api_field" ) ,
824700
825701 /**
826702 * Name of the field for the shard id. Example: {@code shard_id}
827703 *
828704 * @since 5.2.0
829705 */
830- STRING_SHARD_ID ,
706+ STRING_SHARD_ID ( "api_shard_id" ) ,
831707
832708 /**
833709 * Name of the field for the shard count. Example: {@code shard_count}
834710 *
835711 * @since 5.2.0
836712 */
837- STRING_SHARD_COUNT ,
713+ STRING_SHARD_COUNT ( "api_shard_count" ) ,
838714
839715 /**
840716 * Name of the field for the shards. Example: {@code shards}
841717 *
842718 * @since 5.2.0
843719 */
844- STRING_SHARDS ,
720+ STRING_SHARDS ( "api_shards" ) ,
845721
846722 // URL API field
847723
@@ -850,27 +726,43 @@ public enum ApiField{
850726 *
851727 * @since 5.2.0
852728 */
853- URL_ALL ,
729+ URL_ALL ( "api_all" ) ,
854730
855731 /**
856732 * URL to view the API documentation of the bot list
857733 *
858734 * @since 5.2.0
859735 */
860- URL_DOCS ,
736+ URL_DOCS ( "api_docs" ) ,
861737
862738 /**
863739 * URL to GET information about a single bot listed on the bot list.
864740 *
865741 * @since 5.2.0
866742 */
867- URL_GET ,
743+ URL_GET ( "api_get" ) ,
868744
869745 /**
870746 * URL to POST the server count to a bot list.
871747 *
872748 * @since 5.2.0
873749 */
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+ }
875767 }
876768}
0 commit comments