55import com .rappytv .globaltags .wrapper .enums .GlobalIcon ;
66import com .rappytv .globaltags .wrapper .enums .GlobalPosition ;
77import com .rappytv .globaltags .wrapper .enums .ReferralLeaderboardType ;
8- import com .rappytv .globaltags .wrapper .http .schemas .MessageSchema ;
9- import com .rappytv .globaltags .wrapper .http .schemas .PlayerInfoSchema ;
10- import com .rappytv .globaltags .wrapper .http .schemas .ReferralLeaderboardsSchema ;
11- import com .rappytv .globaltags .wrapper .http .schemas .VerificationCodeSchema ;
8+ import com .rappytv .globaltags .wrapper .http .schemas .*;
129import com .rappytv .globaltags .wrapper .model .*;
1310import org .jetbrains .annotations .NotNull ;
1411import org .jetbrains .annotations .Nullable ;
@@ -360,6 +357,28 @@ public void resetTag(UUID uuid, Consumer<ApiResponse<String>> consumer) {
360357 });
361358 }
362359
360+ /**
361+ * A request to get a player's watchlist status
362+ *
363+ * @param uuid The uuid you want to get the watchlist status of
364+ * @param consumer The action to be executed on response.
365+ */
366+ public void getWatchlistStatus (UUID uuid , Consumer <ApiResponse <Boolean >> consumer ) {
367+ new ApiRequest <>(
368+ this .api ,
369+ "GET" ,
370+ Routes .watchlist (uuid ),
371+ emptyBody ,
372+ WatchlistSchema .class
373+ ).sendRequestAsync ((response ) -> {
374+ if (!response .isSuccessful ()) {
375+ consumer .accept (new ApiResponse <>(false , null , response .getError ()));
376+ return ;
377+ }
378+ consumer .accept (new ApiResponse <>(true , response .getData ().watched , null ));
379+ });
380+ }
381+
363382 /**
364383 * A request to add a player to the watchlist
365384 *
@@ -382,6 +401,120 @@ public void updateWatchlistStatus(UUID uuid, boolean watched, Consumer<ApiRespon
382401 });
383402 }
384403
404+ /**
405+ * A request to get a player's API keys
406+ *
407+ * @param uuid The uuid you want to get the API keys of
408+ * @param consumer The action to be executed on response
409+ */
410+ public void getApiKeys (UUID uuid , Consumer <ApiResponse <List <ApiKey >>> consumer ) {
411+ new ApiRequest <>(
412+ this .api ,
413+ "GET" ,
414+ Routes .apiKeys (uuid ),
415+ emptyBody ,
416+ ApiKey [].class
417+ ).sendRequestAsync ((response ) -> {
418+ if (!response .isSuccessful ()) {
419+ consumer .accept (new ApiResponse <>(false , null , response .getError ()));
420+ return ;
421+ }
422+ consumer .accept (new ApiResponse <>(true , Arrays .asList (response .getData ()), null ));
423+ });
424+ }
425+
426+ /**
427+ * A request to get a player's API key
428+ *
429+ * @param uuid The uuid you want to get the API key of
430+ * @param name The name of the API key
431+ * @param consumer The action to be executed on response.
432+ */
433+ public void getApiKey (UUID uuid , String name , Consumer <ApiResponse <ApiKey >> consumer ) {
434+ new ApiRequest <>(
435+ this .api ,
436+ "GET" ,
437+ Routes .apiKey (uuid , name ),
438+ emptyBody ,
439+ ApiKey .class
440+ ).sendRequestAsync ((response ) -> {
441+ if (!response .isSuccessful ()) {
442+ consumer .accept (new ApiResponse <>(false , null , response .getError ()));
443+ return ;
444+ }
445+ consumer .accept (new ApiResponse <>(true , response .getData (), null ));
446+ });
447+ }
448+
449+ /**
450+ * A request to create a player API key
451+ *
452+ * @param uuid The uuid you want to create the API key for
453+ * @param name The name of the API key
454+ * @param consumer The action to be executed on response.
455+ */
456+ public void createApiKey (UUID uuid , String name , Consumer <ApiResponse <ApiKeyCreationSchema >> consumer ) {
457+ new ApiRequest <>(
458+ this .api ,
459+ "POST" ,
460+ Routes .apiKeys (uuid ),
461+ Map .of ("name" , name ),
462+ ApiKeyCreationSchema .class
463+ ).sendRequestAsync ((response ) -> {
464+ if (!response .isSuccessful ()) {
465+ consumer .accept (new ApiResponse <>(false , null , response .getError ()));
466+ return ;
467+ }
468+ consumer .accept (new ApiResponse <>(true , response .getData (), null ));
469+ });
470+ }
471+
472+ /**
473+ * A request to regenerate a player's API key
474+ *
475+ * @param uuid The uuid you want to regenerate the API key of
476+ * @param name The name of the API key
477+ * @param consumer The action to be executed on response.
478+ */
479+ public void regenerateApiKey (UUID uuid , String name , Consumer <ApiResponse <ApiKeyRegenSchema >> consumer ) {
480+ new ApiRequest <>(
481+ this .api ,
482+ "PATCH" ,
483+ Routes .apiKey (uuid , name ),
484+ emptyBody ,
485+ ApiKeyRegenSchema .class
486+ ).sendRequestAsync ((response ) -> {
487+ if (!response .isSuccessful ()) {
488+ consumer .accept (new ApiResponse <>(false , null , response .getError ()));
489+ return ;
490+ }
491+ consumer .accept (new ApiResponse <>(true , response .getData (), null ));
492+ });
493+ }
494+
495+ /**
496+ * A request to delete a player's API key
497+ *
498+ * @param uuid The uuid you want to delete the API key of
499+ * @param name The name of the API key
500+ * @param consumer The action to be executed on response.
501+ */
502+ public void deleteApiKey (UUID uuid , String name , Consumer <ApiResponse <String >> consumer ) {
503+ new ApiRequest <>(
504+ this .api ,
505+ "DELETE" ,
506+ Routes .apiKey (uuid , name ),
507+ emptyBody ,
508+ MessageSchema .class
509+ ).sendRequestAsync ((response ) -> {
510+ if (!response .isSuccessful ()) {
511+ consumer .accept (new ApiResponse <>(false , null , response .getError ()));
512+ return ;
513+ }
514+ consumer .accept (new ApiResponse <>(true , response .getData ().message , null ));
515+ });
516+ }
517+
385518 /**
386519 * A request to mark a specific uuid as the inviter of {@link GlobalTagsAPI#getClientUUID()}
387520 *
@@ -582,16 +715,16 @@ public void unbanPlayer(UUID uuid, Consumer<ApiResponse<String>> consumer) {
582715 * A request to edit the ban of a specific uuid
583716 *
584717 * @param uuid The uuid you want to edit the ban of
585- * @param suspension The new {@link PlayerInfo.Suspension} object
718+ * @param reason The new reason for the ban
719+ * @param appealable If the ban should be appealable or not
586720 * @param consumer The action to be executed on response.
587721 */
588- public void editBan (UUID uuid , PlayerInfo .Suspension suspension , Consumer <ApiResponse <String >> consumer ) {
589- Objects .requireNonNull (suspension .getReason (), "Reason must not be null" );
722+ public void editBan (UUID uuid , @ NotNull String reason , boolean appealable , Consumer <ApiResponse <String >> consumer ) {
590723 new ApiRequest <>(
591724 this .api ,
592725 "PATCH" ,
593726 Routes .bans (uuid ),
594- Map .of ("reason" , suspension . getReason () , "appealable" , suspension . isAppealable () ),
727+ Map .of ("reason" , reason , "appealable" , appealable ),
595728 MessageSchema .class
596729 ).sendRequestAsync ((response ) -> {
597730 if (!response .isSuccessful ()) {
@@ -864,63 +997,4 @@ public void deleteNote(UUID uuid, String noteId, Consumer<ApiResponse<String>> c
864997 consumer .accept (new ApiResponse <>(true , response .getData ().message , null ));
865998 });
866999 }
867-
868- /**
869- * An inline class containing response data for these requests
870- * @param <T> The type of the data
871- */
872- public static class ApiResponse <T > {
873-
874- private final boolean successful ;
875- private final T data ;
876- private final String error ;
877-
878- /**
879- * Constructs a new ApiResponse instance
880- *
881- * @param successful If the request was successful
882- * @param data The data returned if available
883- * @param error The error returned if available
884- */
885- public ApiResponse (boolean successful , T data , String error ) {
886- this .successful = successful ;
887- this .data = data ;
888- this .error = error ;
889- }
890-
891- /**
892- * Checks if the request was successful
893- *
894- * @return If the request was successful
895- */
896- public boolean isSuccessful () {
897- return this .successful ;
898- }
899-
900- /**
901- * Gets the data returned if available
902- *
903- * @return the data if available
904- */
905- public T getData () {
906- return this .data ;
907- }
908-
909- /**
910- * Get the error returned if available
911- * @return an error if available
912- */
913- public String getError () {
914- return this .error ;
915- }
916-
917- @ Override
918- public String toString () {
919- return "ApiResponse{" +
920- "successful=" + this .successful +
921- ", data=" + this .data +
922- ", error='" + this .error + '\'' +
923- '}' ;
924- }
925- }
9261000}
0 commit comments