public class TwilioRestClient extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_VERSION
The Constant DEFAULT_VERSION.
|
| Constructor and Description |
|---|
TwilioRestClient(String accountSid,
String authToken)
Explcitly construct a TwilioRestClient with the given API credentials.
|
TwilioRestClient(String accountSid,
String authToken,
String endpoint)
Explcitly construct a TwilioRestClient with the given API credentials and
endpoint.
|
| Modifier and Type | Method and Description |
|---|---|
TwilioRestResponse |
get(String fullUri)
Perform a GET request against the given fully qualified uri.
|
Account |
getAccount()
A shortcut for the most common case, returning the Account object for
this authenticated client.
|
Account |
getAccount(String sid)
Get an account by account sid.
|
AccountList |
getAccounts()
Get all accounts.
|
AccountList |
getAccounts(Map<String,String> params)
Get a list of Account objects.
|
String |
getAccountSid() |
String |
getEndpoint()
Get the current endpoint this client is pointed at.
|
int |
getNumRetries()
Gets the num retries.
|
TwilioRestResponse |
request(String path,
String method,
Map<String,String> vars)
sendRequst Sends a REST Request to the Twilio REST API.
|
InputStream |
requestStream(String path,
String method,
Map<String,String> vars)
Request stream.
|
TwilioRestResponse |
safeRequest(String path,
String method,
Map<String,String> vars)
Make a request, handles retries + back-off for server/network errors
|
void |
setEndpoint(String endpoint)
Set the endpoint this rest client uses.
|
void |
setHttpclient(org.apache.http.client.HttpClient httpclient) |
void |
setNumRetries(int numRetries)
Sets the num retries.
|
public static final String DEFAULT_VERSION
public TwilioRestClient(String accountSid, String authToken)
accountSid - the 34 character Account identifier (starting with 'AC'). This
can be found on your Twilio dashboard page.authToken - the 32 character AuthToken. This can be found on your Twilio
dashboard page.public TwilioRestClient(String accountSid, String authToken, String endpoint)
accountSid - the 34 character Account identifier (starting with 'AC'). This
can be found on your Twilio dashboard page.authToken - the 32 character AuthToken. This can be found on your Twilio
dashboard page.endpoint - the url of API endpoint you wish to use. (e.g. -
'https://api.twilio.com')public int getNumRetries()
public void setNumRetries(int numRetries)
numRetries - the new num retriespublic void setHttpclient(org.apache.http.client.HttpClient httpclient)
public TwilioRestResponse request(String path, String method, Map<String,String> vars) throws TwilioRestException
path - the URL (absolute w.r.t. the endpoint URL - i.e.
/2010-04-01/Accounts)method - the HTTP method to use, defaults to GETvars - for POST or PUT, a map of data to send, for GET will be
appended to the URL as querystring params
This method is public for backwards compatibility with the old
twilio helper libraryTwilioRestExceptionpublic InputStream requestStream(String path, String method, Map<String,String> vars)
path - the pathmethod - the methodvars - the varspublic TwilioRestResponse safeRequest(String path, String method, Map<String,String> vars) throws TwilioRestException
path - the URL (absolute w.r.t. the endpoint URL - i.e.
/2010-04-01/Accounts)method - the HTTP method to use, defaults to GETvars - for POST or PUT, a map of data to send, for GET will be
appended to the URL as querystring paramsTwilioRestException - if there's an client exception returned by the TwilioApipublic TwilioRestResponse get(String fullUri) throws TwilioRestException
request(String, String, Map)
with method "GET" and no parametersfullUri - The full uri, including protocol://hostname/pathTwilioRestResponse the
response from the queryTwilioRestException - the twilio rest exceptionpublic String getEndpoint()
public void setEndpoint(String endpoint)
endpoint - The location of the endpoint (e.g. https://api.twilio.com)public AccountList getAccounts(Map<String,String> params)
params - Filter the list with the given params. See the Twilio docs for
available filters.public AccountList getAccounts()
public Account getAccount()
public Account getAccount(String sid)
sid - The sid of the account you want to fetch.public String getAccountSid()
Copyright © 2011 Twilio, Inc. All Rights Reserved.