Package com.auth0.net
Class BaseRequest<T>
java.lang.Object
com.auth0.net.BaseRequest<T>
- Type Parameters:
T
- The type expected to be received as part of the response.
- All Implemented Interfaces:
Request<T>
- Direct Known Subclasses:
EmptyBodyRequest
,FormBodyRequest
,MultipartRequest
,SignUpRequest
,TokenRequest
,VoidRequest
A request class that is able to interact fluently with the Auth0 server.
The default content type of this request is "application/json".
This class is not thread-safe:
It makes use of HashMap
for storing the parameters. Make sure to not modify headers or the parameters
from a different or un-synchronized thread.
-
Constructor Summary
ConstructorsConstructorDescriptionBaseRequest
(Auth0HttpClient client, TokenProvider tokenProvider, String url, HttpMethod method, com.fasterxml.jackson.core.type.TypeReference<T> tType) -
Method Summary
Modifier and TypeMethodDescriptionAdds an HTTP header to the requestaddParameter
(String name, Object value) Adds an body parameter to the requestprotected Auth0HttpRequest
createRequest
(String apiToken) protected HttpRequestBody
Responsible for creating the payload that will be set as body on this request.protected Auth0Exception
createResponseException
(Auth0HttpResponse response) Responsible for parsing an unsuccessful request (status code other than 200) and generating a developer-friendly exception with the error details.execute()
Executes this request.Executes this request asynchronously.protected String
Getter for the content-type header value to use on this requestprotected T
parseResponseBody
(Auth0HttpResponse response) protected T
readResponseBody
(Auth0HttpResponse response) Responsible for parsing the payload that is received as part of the response.Sets the response's body directly
-
Constructor Details
-
BaseRequest
public BaseRequest(Auth0HttpClient client, TokenProvider tokenProvider, String url, HttpMethod method, com.fasterxml.jackson.core.type.TypeReference<T> tType)
-
-
Method Details
-
createRequest
- Throws:
Auth0Exception
-
parseResponseBody
- Throws:
Auth0Exception
-
createRequestBody
Responsible for creating the payload that will be set as body on this request.- Returns:
- the body to send as part of the request.
- Throws:
IOException
- if an error is raised during the creation of the body.
-
readResponseBody
Responsible for parsing the payload that is received as part of the response.- Parameters:
response
- the received response. The body buffer will automatically closed.- Returns:
- the instance of type T, result of interpreting the payload.
- Throws:
IOException
- if an error is raised during the parsing of the body.
-
getParameters
-
execute
Executes this request.- Specified by:
execute
in interfaceRequest<T>
- Returns:
- the response body JSON decoded as T
- Throws:
Auth0Exception
- if the request execution fails.
-
executeAsync
Description copied from interface:Request
Executes this request asynchronously.- Specified by:
executeAsync
in interfaceRequest<T>
- Returns:
- a CompletableFuture representing the specified request.
-
getContentType
Getter for the content-type header value to use on this request- Returns:
- the content-type
-
createResponseException
Responsible for parsing an unsuccessful request (status code other than 200) and generating a developer-friendly exception with the error details.- Parameters:
response
- the unsuccessful response, as received. If its body is accessed, the buffer must be closed.- Returns:
- the exception with the error details.
-
addHeader
Adds an HTTP header to the request -
addParameter
Description copied from interface:Request
Adds an body parameter to the request- Specified by:
addParameter
in interfaceRequest<T>
- Parameters:
name
- the name of the parametervalue
- the value of the parameter- Returns:
- this same request instance
-
setBody
Description copied from interface:Request
Sets the response's body directly
-