Class DiscordWebRequest


  • public class DiscordWebRequest
    extends Object
    Template encoding all of the needed information to make an HTTP request to Discord.
    • Constructor Detail

      • DiscordWebRequest

        public DiscordWebRequest​(Route route,
                                 Object... uriVars)
        Create a new DiscordWebRequest template based on a Route and its compiled URI.
        Parameters:
        route - the API resource targeted by this request
        uriVars - the values to expand each template parameter
    • Method Detail

      • 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 null if 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 null if none are defined
      • getHeaders

        @Nullable
        public Map<String,​Set<String>> getHeaders()
        Return the request headers, if present.
        Returns:
        a map representing HTTP headers, or null if none are defined
      • body

        public DiscordWebRequest body​(Object body)
        Set the given synchronous Object as 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 name
        value - 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 key
        value - 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 if value is not null.
        Parameters:
        key - the header key
        value - the header value
        Returns:
        this request
      • exchange

        public DiscordWebResponse exchange​(Router router)
        Exchange this request through the given Router.
        Parameters:
        router - a router that performs this request
        Returns:
        the result of this request
      • getDescription

        public String getDescription()