O - The output type.I - The input type.public abstract class Endpoint<O,I> extends Object
| Constructor and Description |
|---|
Endpoint() |
| Modifier and Type | Method and Description |
|---|---|
protected O |
checkBodyForErrors(okhttp3.ResponseBody body)
Checks a response body for errors.
|
protected okhttp3.Response |
executeRequest(okhttp3.Request.Builder request)
This will execute the given request with this endpoint's HTTP client.
|
abstract String |
getEndpoint()
Returns the endpoint of the request.
|
String |
getMethod()
Returns the method to use.
|
protected String |
getReplacedUrl(I request,
Map<String,String> parameters)
This will replace the URL based on a certain request.
|
abstract com.google.gson.reflect.TypeToken<I> |
getRequestClass()
Returns the
TypeToken of the request. |
abstract com.google.gson.reflect.TypeToken<O> |
getResponseClass()
Returns the
TypeToken of the response; |
boolean |
isJsonBody()
Whether or not the request body should be JSON.
|
protected byte[] |
readFile(File file)
Reads a file into a byte array.
|
protected byte[] |
readStream(InputStream stream)
Reads a stream into a byte array.
|
boolean |
requiresBody()
If this is false, the request will not have a body.
|
CompletableFuture<O> |
sendRequest(I request)
Sends the request.
|
CompletableFuture<O> |
sendRequest(I request,
Map<String,String> urlParams)
Sends the request.
|
public abstract String getEndpoint()
public boolean isJsonBody()
public boolean requiresBody()
protected String getReplacedUrl(I request, Map<String,String> parameters)
request - - The request to use.parameters - - The parameters to use.public CompletableFuture<O> sendRequest(I request)
request - - The request to useCompletableFuture that will return the response.sendRequest(Object, Map)public CompletableFuture<O> sendRequest(I request, Map<String,String> urlParams)
request - - The request to use.urlParams - - The URL parameters to use.CompletableFuture that will return the response.protected okhttp3.Response executeRequest(okhttp3.Request.Builder request)
request - - The request to execute.protected O checkBodyForErrors(okhttp3.ResponseBody body)
body - - The body to check.protected byte[] readStream(InputStream stream)
stream - - The stream to read.protected byte[] readFile(File file)
file - - The file to read.public String getMethod()
public abstract com.google.gson.reflect.TypeToken<O> getResponseClass()
TypeToken of the response;TypeToken of the response.public abstract com.google.gson.reflect.TypeToken<I> getRequestClass()
TypeToken of the request.TypeToken of the request.Copyright © 2026. All rights reserved.