Package discord4j.rest.request
Class DiscordWebRequest
java.lang.Object
discord4j.rest.request.DiscordWebRequest
Template encoding all the needed information to make an HTTP request to Discord.
-
Constructor Summary
ConstructorDescriptionDiscordWebRequest
(Route route, Object... uriVars) Create a newDiscordWebRequest
template based on aRoute
and its compiled URI. -
Method Summary
Modifier and TypeMethodDescriptionUse the given value as basic authentication.bearerAuth
(String accessToken) Use the given token as authentication value using the Bearer prefix.Set the given synchronousObject
as the body for the request.copy()
Create a new instance using the values from this one.Exchange this request through the givenRouter
.getBody()
Return the body of this request, if present.Return the compiled URI of this request.Return the request headers, if present.Return the query parameters saved in this request, if present.getRoute()
Return the API endpoint targeted by this request.Adds the given key and value to the headers of this request.optionalHeader
(String key, String value) Adds the given key and value to the headers of this request if and only ifvalue
is notnull
.Add the given names and values as request query parameters.Add the given name and value as a request query parameter.Adds the given names and values as request query parameters.toString()
Use no authorization mechanism with this request.
-
Constructor Details
-
DiscordWebRequest
Create a newDiscordWebRequest
template based on aRoute
and its compiled URI.- Parameters:
route
- the API resource targeted by this requesturiVars
- the values to expand each template parameter
-
-
Method Details
-
copy
Create a new instance using the values from this one.- Returns:
- a new request
-
getRoute
Return the API endpoint targeted by this request.- Returns:
- the
Route
of thisDiscordWebRequest
-
getCompleteUri
Return the compiled URI of this request.- Returns:
- the compiled URI, containing the actual path variables
-
getBody
Return the body of this request, if present.- Returns:
- the body of this request, or
null
if this request carries no HTTP body
-
getQueryParams
Return the query parameters saved in this request, if present.- Returns:
- a map representing query parameters, or
null
if none are defined
-
getHeaders
Return the request headers, if present.- Returns:
- a map representing HTTP headers, or
null
if none are defined
-
getAuthorizationScheme
-
getAuthorizationValue
-
body
Set the given synchronousObject
as the body for the request.- Parameters:
body
- the object to set as request body- Returns:
- this request
-
query
Add the given name and value as a request query parameter.- Parameters:
key
- the query parameter namevalue
- the query parameter value- Returns:
- this request
-
query
Adds the given names and values as request query parameters.- Parameters:
params
- a map of query parameter names to values- Returns:
- this request
-
query
Add the given names and values as request query parameters.- Parameters:
params
- a map of query parameter names to values- Returns:
- this request
-
header
Adds the given key and value to the headers of this request.- Parameters:
key
- the header keyvalue
- the header value- Returns:
- this request
-
optionalHeader
Adds the given key and value to the headers of this request if and only ifvalue
is notnull
.- Parameters:
key
- the header keyvalue
- the header value- Returns:
- this request
-
bearerAuth
Use the given token as authentication value using the Bearer prefix.- Parameters:
accessToken
- the bearer token to use- Returns:
- this request
-
basicAuth
Use the given value as basic authentication.- Parameters:
base64EncodedValue
- the base64 encoded value to use- Returns:
- this request
-
unauthenticated
Use no authorization mechanism with this request.- Returns:
- this request
-
exchange
Exchange this request through the givenRouter
.- Parameters:
router
- a router that performs this request- Returns:
- the result of this request
-
getDescription
-
toString
-