Package discord4j.rest.request
Class DiscordWebRequest
- java.lang.Object
-
- discord4j.rest.request.DiscordWebRequest
-
public class DiscordWebRequest extends Object
Template encoding all of the needed information to make an HTTP request to Discord.
-
-
Constructor Summary
Constructors Constructor Description DiscordWebRequest(Route route, Object... uriVars)Create a newDiscordWebRequesttemplate based on aRouteand its compiled URI.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DiscordWebRequestbody(Object body)Set the given synchronousObjectas the body for the request.DiscordWebResponseexchange(Router router)Exchange this request through the givenRouter.ObjectgetBody()Return the body of this request, if present.StringgetCompleteUri()Return the compiled URI of this request.StringgetDescription()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.RoutegetRoute()Return the API endpoint targeted by this request.DiscordWebRequestheader(String key, String value)Adds the given key and value to the headers of this request.DiscordWebRequestoptionalHeader(String key, String value)Adds the given key and value to the headers of this request if and only ifvalueis notnull.DiscordWebRequestquery(Multimap<String,Object> params)Add the given names and values as request query parameters.DiscordWebRequestquery(String key, Object value)Add the given name and value as a request query parameter.DiscordWebRequestquery(Map<String,Object> params)Adds the given names and values as request query parameters.StringtoString()
-
-
-
Constructor Detail
-
DiscordWebRequest
public DiscordWebRequest(Route route, Object... uriVars)
Create a newDiscordWebRequesttemplate based on aRouteand its compiled URI.- Parameters:
route- the API resource targeted by this requesturiVars- the values to expand each template parameter
-
-
Method Detail
-
getRoute
public Route getRoute()
Return the API endpoint targeted by this request.- Returns:
- the
Routeof thisDiscordWebRequest
-
getCompleteUri
public String getCompleteUri()
Return the compiled URI of this request.- Returns:
- the compiled URI, containing the actual path variables
-
getBody
@Nullable public Object getBody()
Return the body of this request, if present.- Returns:
- the body of this request, or
nullif this request carries no HTTP body
-
getQueryParams
@Nullable public Multimap<String,Object> getQueryParams()
Return the query parameters saved in this request, if present.- Returns:
- a map representing query parameters, or
nullif none are defined
-
getHeaders
@Nullable public Map<String,Set<String>> getHeaders()
Return the request headers, if present.- Returns:
- a map representing HTTP headers, or
nullif none are defined
-
body
public DiscordWebRequest body(Object body)
Set the given synchronousObjectas the body for the request.- Parameters:
body- the object to set as request body- Returns:
- this request
-
query
public DiscordWebRequest query(String key, Object value)
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
public DiscordWebRequest query(Map<String,Object> params)
Adds the given names and values as request query parameters.- Parameters:
params- a map of query parameter names to values- Returns:
- this request
-
query
public DiscordWebRequest query(Multimap<String,Object> params)
Add the given names and values as request query parameters.- Parameters:
params- a map of query parameter names to values- Returns:
- this request
-
header
public DiscordWebRequest header(String key, String value)
Adds the given key and value to the headers of this request.- Parameters:
key- the header keyvalue- the header value- Returns:
- this request
-
optionalHeader
public DiscordWebRequest optionalHeader(String key, @Nullable String value)
Adds the given key and value to the headers of this request if and only ifvalueis notnull.- Parameters:
key- the header keyvalue- the header value- Returns:
- this request
-
exchange
public DiscordWebResponse exchange(Router router)
Exchange this request through the givenRouter.- Parameters:
router- a router that performs this request- Returns:
- the result of this request
-
getDescription
public String getDescription()
-
-