Package com.twilio
Class Twilio
- java.lang.Object
-
- com.twilio.Twilio
-
public class Twilio extends Object
Singleton class to initialize Twilio environment.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
destroy()
Attempts to gracefully shutdown the ExecutorService if it is present.static ExecutorService
getExecutorService()
Returns the Twilio executor service.static TwilioRestClient
getRestClient()
Returns (and initializes if not initialized) the Twilio Rest Client.static void
init(String username, String password)
Initialize the Twilio environment.static void
init(String username, String password, String accountSid)
Initialize the Twilio environment.static void
setAccountSid(String accountSid)
Set the account sid.static void
setEdge(String edge)
Set the edge.static void
setExecutorService(ExecutorService executorService)
Use a custom executor service.static void
setPassword(String password)
Set the auth token.static void
setRegion(String region)
Set the region.static void
setRestClient(TwilioRestClient restClient)
Use a custom rest client.static void
setUserAgentExtensions(List<String> userAgentExtensions)
static void
setUsername(String username)
Set the username.static void
validateSslCertificate()
Validate that we can connect to the new SSL certificate posted on api.twilio.com.static void
validateSslCertificate(NetworkHttpClient client)
-
-
-
Field Detail
-
VERSION
public static final String VERSION
- See Also:
- Constant Field Values
-
JAVA_VERSION
public static final String JAVA_VERSION
-
OS_NAME
public static final String OS_NAME
-
OS_ARCH
public static final String OS_ARCH
-
-
Method Detail
-
init
public static void init(String username, String password)
Initialize the Twilio environment.- Parameters:
username
- account to usepassword
- auth token for the account
-
init
public static void init(String username, String password, String accountSid)
Initialize the Twilio environment.- Parameters:
username
- account to usepassword
- auth token for the accountaccountSid
- account sid to use
-
setUsername
public static void setUsername(String username)
Set the username.- Parameters:
username
- account to use- Throws:
AuthenticationException
- if username is null
-
setPassword
public static void setPassword(String password)
Set the auth token.- Parameters:
password
- auth token to use- Throws:
AuthenticationException
- if password is null
-
setAccountSid
public static void setAccountSid(String accountSid)
Set the account sid.- Parameters:
accountSid
- account sid to use
-
setRegion
public static void setRegion(String region)
Set the region.- Parameters:
region
- region to make request
-
setEdge
public static void setEdge(String edge)
Set the edge.- Parameters:
edge
- edge to make request
-
getRestClient
public static TwilioRestClient getRestClient()
Returns (and initializes if not initialized) the Twilio Rest Client.- Returns:
- the Twilio Rest Client
- Throws:
AuthenticationException
- if initialization required and either accountSid or authToken is null
-
setRestClient
public static void setRestClient(TwilioRestClient restClient)
Use a custom rest client.- Parameters:
restClient
- rest client to use
-
getExecutorService
public static ExecutorService getExecutorService()
Returns the Twilio executor service.- Returns:
- the Twilio executor service
-
setExecutorService
public static void setExecutorService(ExecutorService executorService)
Use a custom executor service.- Parameters:
executorService
- executor service to use
-
validateSslCertificate
public static void validateSslCertificate()
Validate that we can connect to the new SSL certificate posted on api.twilio.com.- Throws:
CertificateValidationException
- if the connection fails
-
validateSslCertificate
public static void validateSslCertificate(NetworkHttpClient client)
-
destroy
public static void destroy()
Attempts to gracefully shutdown the ExecutorService if it is present.
-
-