Class Request


  • public class Request
    extends Object
    • Constructor Detail

      • Request

        public Request​(HttpMethod method,
                       String url)
        Create a new API request.
        Parameters:
        method - HTTP method
        url - url of request
      • Request

        public Request​(HttpMethod method,
                       String domain,
                       String uri)
        Create a new API request.
        Parameters:
        method - HTTP method
        domain - Twilio domain
        uri - uri of request
      • Request

        public Request​(HttpMethod method,
                       String domain,
                       String uri,
                       String region)
        Create a new API request.
        Parameters:
        method - HTTP Method
        domain - Twilio domain
        uri - uri of request
        region - region to make request
    • Method Detail

      • getUrl

        public String getUrl()
      • setAuth

        public void setAuth​(String username,
                            String password)
      • setRegion

        public void setRegion​(String region)
      • setEdge

        public void setEdge​(String edge)
      • setUserAgentExtensions

        public void setUserAgentExtensions​(List<String> userAgentExtensions)
      • getUserAgentExtensions

        public List<String> getUserAgentExtensions()
      • getAuthString

        public String getAuthString()
        Create auth string from username and password.
        Returns:
        basic authentication string
      • getUsername

        public String getUsername()
      • getPassword

        public String getPassword()
      • requiresAuthentication

        public boolean requiresAuthentication()
      • constructURL

        public URL constructURL()
        Build the URL for the request.
        Returns:
        URL for the request
      • addQueryDateRange

        public void addQueryDateRange​(String name,
                                      LocalDate lowerBound,
                                      LocalDate upperBound)
        Add query parameters for date ranges.
        Parameters:
        name - name of query parameter
        lowerBound - lower bound of LocalDate range
        upperBound - upper bound of LocalDate range
      • addQueryDateTimeRange

        public void addQueryDateTimeRange​(String name,
                                          ZonedDateTime lowerBound,
                                          ZonedDateTime upperBound)
        Add query parameters for date ranges.
        Parameters:
        name - name of query parameter
        lowerBound - lower bound of ZonedDateTime range
        upperBound - upper bound of ZonedDateTime range
      • addQueryParam

        public void addQueryParam​(String name,
                                  String value)
        Add a query parameter.
        Parameters:
        name - name of parameter
        value - value of parameter
      • addPostParam

        public void addPostParam​(String name,
                                 String value)
        Add a form parameter.
        Parameters:
        name - name of parameter
        value - value of parameter
      • addHeaderParam

        public void addHeaderParam​(String name,
                                   String value)
        Add a header parameter.
        Parameters:
        name - name of parameter
        value - value of parameter
      • encodeFormBody

        public String encodeFormBody()
        Encode the form body.
        Returns:
        url encoded form body
      • encodeQueryParams

        public String encodeQueryParams()
        Encode the query parameters.
        Returns:
        url encoded query parameters