T - The response type.public class DiscordRequest<T> extends Object
| Constructor and Description |
|---|
DiscordRequest(Route<T> route,
Object... uriVars)
Create a new
DiscordRequest template based on a Route and its compiled URI. |
| Modifier and Type | Method and Description |
|---|---|
DiscordRequest<T> |
body(Object body)
Set the given synchronous
Object as the body for the request. |
Mono<T> |
exchange(Router router)
Exchange this request through the given
Router. |
Object |
getBody()
Return the body of this request, if present.
|
String |
getCompleteUri()
Return the compiled URI of this request.
|
Map<String,Set<String>> |
getHeaders()
Return the request headers, if present.
|
Map<String,Object> |
getQueryParams()
Return the query parameters saved in this request, if present.
|
Route<T> |
getRoute()
Return the API endpoint targeted by this request.
|
DiscordRequest<T> |
header(String key,
String value)
Adds the given key and value to the headers of this request.
|
DiscordRequest<T> |
optionalHeader(String key,
String value)
Adds the given key and value to the headers of this request
if and only if
value is not null. |
DiscordRequest<T> |
query(Map<String,Object> params)
Adds the given names and values as request query parameters.
|
DiscordRequest<T> |
query(String key,
Object value)
Add the given name and value as a request query parameter.
|
String |
toString() |
public DiscordRequest(Route<T> route, Object... uriVars)
DiscordRequest template based on a Route and its compiled URI.route - the API resource targeted by this requesturiVars - the values to expand each template parameterpublic Route<T> getRoute()
Route of this DiscordRequestpublic String getCompleteUri()
@Nullable public Object getBody()
null if this request carries no HTTP body@Nullable public Map<String,Object> getQueryParams()
null if none are defined@Nullable public Map<String,Set<String>> getHeaders()
null if none are definedpublic DiscordRequest<T> body(Object body)
Object as the body for the request.body - the object to set as request bodypublic DiscordRequest<T> query(String key, Object value)
key - the query parameter namevalue - the query parameter valuepublic DiscordRequest<T> query(Map<String,Object> params)
params - a map of query parameter names to valuespublic DiscordRequest<T> header(String key, String value)
key - the header keyvalue - the header valuepublic DiscordRequest<T> optionalHeader(String key, @Nullable String value)
value is not null.key - the header keyvalue - the header valuepublic Mono<T> exchange(Router router)
Router.router - a router that performs this request