public class DiscordWebRequest extends Object
| Constructor and Description |
|---|
DiscordWebRequest(Route route,
Object... uriVars)
Create a new
DiscordWebRequest template based on a Route and its compiled URI. |
| Modifier and Type | Method and Description |
|---|---|
DiscordWebRequest |
body(Object body)
Set the given synchronous
Object as the body for the request. |
DiscordWebResponse |
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.
|
String |
getDescription() |
Map<String,Set<String>> |
getHeaders()
Return the request headers, if present.
|
Multimap<String,Object> |
getQueryParams()
Return the query parameters saved in this request, if present.
|
Route |
getRoute()
Return the API endpoint targeted by this request.
|
DiscordWebRequest |
header(String key,
String value)
Adds the given key and value to the headers of this request.
|
DiscordWebRequest |
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. |
DiscordWebRequest |
query(Map<String,Object> params)
Adds the given names and values as request query parameters.
|
DiscordWebRequest |
query(Multimap<String,Object> params)
Add the given names and values as request query parameters.
|
DiscordWebRequest |
query(String key,
Object value)
Add the given name and value as a request query parameter.
|
String |
toString() |
public DiscordWebRequest(Route route, Object... uriVars)
DiscordWebRequest 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 getRoute()
Route of this DiscordWebRequestpublic String getCompleteUri()
@Nullable public Object getBody()
null if this request carries no HTTP body@Nullable public Multimap<String,Object> getQueryParams()
null if none are defined@Nullable public Map<String,Set<String>> getHeaders()
null if none are definedpublic DiscordWebRequest body(Object body)
Object as the body for the request.body - the object to set as request bodypublic DiscordWebRequest query(String key, Object value)
key - the query parameter namevalue - the query parameter valuepublic DiscordWebRequest query(Map<String,Object> params)
params - a map of query parameter names to valuespublic DiscordWebRequest query(Multimap<String,Object> params)
params - a map of query parameter names to valuespublic DiscordWebRequest header(String key, String value)
key - the header keyvalue - the header valuepublic DiscordWebRequest optionalHeader(String key, @Nullable String value)
value is not null.key - the header keyvalue - the header valuepublic DiscordWebResponse exchange(Router router)
Router.router - a router that performs this requestpublic String getDescription()