Class Endpoint<O,I>
java.lang.Object
masecla.modrinth4j.endpoints.generic.Endpoint<O,I>
- Type Parameters:
O- The output type.I- The input type.
- Direct Known Subclasses:
AddFilesToVersion,AddMemberToTeam,BulkModifyProjects,ChangeProjectIcon,ChangeUserIcon,CheckSlugAvailability,CreateGalleryImage,CreateProject,CreateVersion,DeleteFileByHash,DeleteGalleryImage,DeleteProject,DeleteProjectIcon,DeleteUser,DeleteVersion,FollowProject,GetCategories,GetDonationPlatforms,GetGameVersions,GetLicenses,GetLoaders,GetMultipleProjects,GetProject,GetProjectDependencies,GetProjectIdBySlug,GetProjectLatestVersionFromHash,GetProjectLatestVersionsFromHashes,GetProjectTeamMembers,GetProjectVersions,GetRandomProjects,GetReportTypes,GetSelf,GetTeamMembers,GetTeamsMembers,GetUser,GetUserFollowedProjects,GetUserNotifications,GetUserProjects,GetUsers,GetVersion,GetVersionByHash,GetVersionByVersionNumber,GetVersions,GetVersionsFromHashes,JoinTeam,ModifyGalleryImage,ModifyProject,ModifyTeamMemberInfo,ModifyUser,ModifyVersion,PaginatedEndpoint,RemoveMemberFromTeam,ReportProjectUserOrVersion,ScheduleProject,ScheduleVersion,TransferOwnership,UnfollowProject
Represents a generic endpoint.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected OcheckBodyForErrors(okhttp3.ResponseBody body) Checks a response body for errors.protected okhttp3.ResponseexecuteRequest(okhttp3.Request.Builder request) This will execute the given request with this endpoint's HTTP client.abstract StringReturns the endpoint of the request.Returns the method to use.protected StringgetReplacedUrl(I request, Map<String, String> parameters) This will replace the URL based on a certain request.abstract com.google.gson.reflect.TypeToken<I> Returns theTypeTokenof the request.abstract com.google.gson.reflect.TypeToken<O> Returns theTypeTokenof the response;booleanWhether or not the request body should be JSON.protected byte[]Reads a file into a byte array.protected byte[]readStream(InputStream stream) Reads a stream into a byte array.booleanIf this is false, the request will not have a body.sendRequest(I request) Sends the request.sendRequest(I request, Map<String, String> urlParams) Sends the request.
-
Constructor Details
-
Endpoint
public Endpoint()
-
-
Method Details
-
getEndpoint
Returns the endpoint of the request.- Returns:
- - The endpoint of the request.
-
isJsonBody
public boolean isJsonBody()Whether or not the request body should be JSON. If this is false, the request will embed the parameters in the URL.- Returns:
- - Whether or not the request body should be JSON.
-
requiresBody
public boolean requiresBody()If this is false, the request will not have a body.- Returns:
- - Whether or not the request requires a body.
-
getReplacedUrl
This will replace the URL based on a certain request.- Parameters:
request- - The request to use.parameters- - The parameters to use.- Returns:
- - The replaced URL.
-
sendRequest
Sends the request.- Parameters:
request- - The request to use- Returns:
- - A
CompletableFuturethat will return the response. - See Also:
-
sendRequest
Sends the request.- Parameters:
request- - The request to use.urlParams- - The URL parameters to use.- Returns:
- - A
CompletableFuturethat will return the response.
-
executeRequest
protected okhttp3.Response executeRequest(okhttp3.Request.Builder request) This will execute the given request with this endpoint's HTTP client.- Parameters:
request- - The request to execute.- Returns:
- - The response.
-
checkBodyForErrors
Checks a response body for errors.- Parameters:
body- - The body to check.- Returns:
- - The parsed response.
-
readStream
Reads a stream into a byte array.- Parameters:
stream- - The stream to read.- Returns:
- - The byte array.
-
readFile
Reads a file into a byte array.- Parameters:
file- - The file to read.- Returns:
- - The byte array.
-
getMethod
Returns the method to use.- Returns:
- - The method to use.
-
getResponseClass
Returns theTypeTokenof the response;- Returns:
- - The
TypeTokenof the response.
-
getRequestClass
Returns theTypeTokenof the request.- Returns:
- - The
TypeTokenof the request.
-