-
Notifications
You must be signed in to change notification settings - Fork 0
Usage
Let's use Vouchley's API within your project.
Before using any of the methods available in the API, you must set up your API key using the main utility class.
If you do not have an API key, you can request one from Vouchley.
The method below will set up your API key for the entire project.
VouchleyAPI.setAPIKey(uuid);How do I retrieve a user by their ID?
You can retrieve a user by their ID by using the following code.
If this method fails, it will throw a VouchleyException to let you know.
This uses an external API, therefore you should handle any necessary logic around this code to make this thread-safe.
Method One (Using the main utility class)
final VouchleyUser user = VouchleyAPI.getUserById(uuid)Method Two (Using the user class directly)
final VouchleyUser user = VouchleyUser.getById(uuid);How do I retrieve a user by their username?
You can retrieve a user by their ID using the following code.
If this method fails, it will throw a VouchleyException to let you know.
This uses an external API, therefore you should handle any necessary logic around this code to make this thread-safe.
Method One (Using the main utility class)
final VouchleyUser user = VouchleyAPI.getUserByUsername(string);Method Two (Using the user class directly)
final VouchleyUser user = VouchleyUser.getByUsername(string);What can I do with a user?
You can use the following methods with a Vouchley User object.
final VouchleyUser user = VouchleyAPI.getUserByUsername(string); //Retrieve the Vouchley User (Using whatever method you prefer).
final UUID id = user.getId(); //Allows you to retrieve the user's id.
final String title = user.getTitle(); //Allows you to retrieve the user's title.
final String username = user.getUsername(); //Allows you to retrieve the user's username.
final String discordId = user.getDiscordId(); //Allows you to retrieve the user's discord id (May be empty).
final String displayName = user.getDisplayName(); //Allows you to retrieve the user's display name (May be empty).
final String avatarURL = user.getAvatarURL(); //Allows you to retrieve the user's avatar URL (May be the default Vouchley avatar).
final Double totalValueTraded = user.getTotalValueTraded(); //Allows you to retrieve the user's total value traded.
final Integer averageRating = user.getAverageRating(); //Allows you to retrieve the user's average rating.
final List<VouchleyUserReview> reviews = user.getReviews(); //Allows you to retrieve the user's reviews (May be an empty list).
final List<Integer> donatorBadges = user.getDonatorBadges(); //Allows you to retrieve the user's donator badges (May be an empty list).How do I retrieve a user's review by its ID?
You can retrieve a user's review via its ID by using the following code.
If this method fails, it will throw a Vouchley Exception to let you know.
This uses an external API, therefore you should handle any necessary logic around this code to make this thread-safe.
Method One (Using the main utility class)
final VouchleyUserReview review = VouchleyAPI.getUserReviewByID(uuid);Method Two (Using the user class directly)
final VouchleyUserReview review = VouchleyUserReview.getById(uuid);What can I do with a user review?
You can use the following methods with a Vouchley User Review object.
final VouchleyUserReview review = VouchleyAPI.getUserReviewById(id); //Retrieve the Vouchley User Review (Using whatever method you prefer).
final UUID id = review.getId(); //Allows you to retrieve the review's id.
final UUID sender = review.getSender(); //Allows you to retrieve the review's sender.
final UUID receiver = review.getReceiver(); //Allows you to retrieve the review's receiver.
final Long timeSent = review.getTimeSent(); //Allows you to retrieve the review's time sent.
final Integer rating = review.getRating(); //Allows you to retrieve the review's rating.
final Double value = review.getValue(); //Allows you to retrieve the review's value.
final String reply = review.getReply(); //Allows you to retrieve the review's reply.
final String message = review.getMessage(); //Allows you to retrieve the review's message.
final String product = review.getProduct(); //Allows you to retrieve the review's product.
final String platform = review.getPlatform(); //Allows you to retrieve the review's platform.A VouchleyException will be utilized and thrown if an error is encountered.
There's nothing extraordinary about the exception, it just serves as an effective way to distinguish our exceptions.
You can access the Javadocs for Vouchley on my software repository.
Replace version with your desired version in releases.
https://software.cameronbowe.net/javadoc/public/net/cameronbowe/VouchleyAPI/<version>