Package com.twilio.http
Class Request
- java.lang.Object
-
- com.twilio.http.Request
-
public class Request extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
QUERY_STRING_DATE_FORMAT
static String
QUERY_STRING_DATE_TIME_FORMAT
-
Constructor Summary
Constructors Constructor Description Request(HttpMethod method, String url)
Create a new API request.Request(HttpMethod method, String domain, String uri)
Create a new API request.Request(HttpMethod method, String domain, String uri, String region)
Create a new API request.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addHeaderParam(String name, String value)
Add a header parameter.void
addPostParam(String name, String value)
Add a form parameter.void
addQueryDateRange(String name, LocalDate lowerBound, LocalDate upperBound)
Add query parameters for date ranges.void
addQueryDateTimeRange(String name, ZonedDateTime lowerBound, ZonedDateTime upperBound)
Add query parameters for date ranges.void
addQueryParam(String name, String value)
Add a query parameter.URL
constructURL()
Build the URL for the request.String
encodeFormBody()
Encode the form body.String
encodeQueryParams()
Encode the query parameters.boolean
equals(Object o)
String
getAuthString()
Create auth string from username and password.Map<String,List<String>>
getHeaderParams()
HttpMethod
getMethod()
String
getPassword()
Map<String,List<String>>
getPostParams()
Map<String,List<String>>
getQueryParams()
String
getUrl()
List<String>
getUserAgentExtensions()
String
getUsername()
boolean
requiresAuthentication()
void
setAuth(String username, String password)
void
setEdge(String edge)
void
setRegion(String region)
void
setUserAgentExtensions(List<String> userAgentExtensions)
-
-
-
Field Detail
-
QUERY_STRING_DATE_TIME_FORMAT
public static final String QUERY_STRING_DATE_TIME_FORMAT
- See Also:
- Constant Field Values
-
QUERY_STRING_DATE_FORMAT
public static final String QUERY_STRING_DATE_FORMAT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Request
public Request(HttpMethod method, String url)
Create a new API request.- Parameters:
method
- HTTP methodurl
- url of request
-
Request
public Request(HttpMethod method, String domain, String uri)
Create a new API request.- Parameters:
method
- HTTP methoddomain
- Twilio domainuri
- uri of request
-
Request
public Request(HttpMethod method, String domain, String uri, String region)
Create a new API request.- Parameters:
method
- HTTP Methoddomain
- Twilio domainuri
- uri of requestregion
- region to make request
-
-
Method Detail
-
getMethod
public HttpMethod getMethod()
-
getUrl
public String getUrl()
-
setRegion
public void setRegion(String region)
-
setEdge
public void setEdge(String edge)
-
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 parameterlowerBound
- lower bound of LocalDate rangeupperBound
- 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 parameterlowerBound
- lower bound of ZonedDateTime rangeupperBound
- upper bound of ZonedDateTime range
-
addQueryParam
public void addQueryParam(String name, String value)
Add a query parameter.- Parameters:
name
- name of parametervalue
- value of parameter
-
addPostParam
public void addPostParam(String name, String value)
Add a form parameter.- Parameters:
name
- name of parametervalue
- value of parameter
-
addHeaderParam
public void addHeaderParam(String name, String value)
Add a header parameter.- Parameters:
name
- name of parametervalue
- 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
-
-