Package com.sparkpost
Class Client
java.lang.Object
com.sparkpost.Client
public class Client extends Object
The Client class stores everything specific to the SparkPost client:
- The Authorization Key
- The "From:" email address
- Author:
- grava
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description StringgetAuthKey()StringgetBaseUrl()StringgetFromEmail()intgetHttpConnectTimeout()intgetHttpReadTimeout()StringgetPassword()ProxygetProxy()StringgetUsername()booleanisDisconnectAfterRequest()If true will be more aggressive about disconnecting idle HTTP connectionsResponsesendMessage(String from, String recipient, String subject, String text, String html)ResponsesendMessage(String from, List<String> recipients, String subject, String text, String html)voidsetAuthKey(String key)You can create and API Key here SparkPostvoidsetBaseUrl(String baseUrl)voidsetDisconnectAfterRequest(boolean disconnectAfterRequest)If true the underlying HTTP transport will be more aggressive about closing idle HTTP connection so may not resuse TCP sockets as much.voidsetFromEmail(String fromEmail)voidsetHttpConnectTimeout(int timeout)Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by this URLConnection.voidsetHttpReadTimeout(int httpReadTimeout)voidsetPassword(String password)voidsetProxy(String hostname, int port)voidsetUsername(String username)StringtoString()
-
Constructor Details
-
Client
public Client() -
Client
-
Client
-
-
Method Details
-
setAuthKey
You can create and API Key here SparkPost- Parameters:
key- SparkPost API Key
-
getAuthKey
-
setBaseUrl
-
getBaseUrl
-
getUsername
-
setUsername
-
getPassword
-
setPassword
-
getFromEmail
- Returns:
- the fromEmail
-
isDisconnectAfterRequest
public boolean isDisconnectAfterRequest()If true will be more aggressive about disconnecting idle HTTP connections- Returns:
- true
-
setDisconnectAfterRequest
public void setDisconnectAfterRequest(boolean disconnectAfterRequest)If true the underlying HTTP transport will be more aggressive about closing idle HTTP connection so may not resuse TCP sockets as much.- Parameters:
disconnectAfterRequest- default is false
-
getHttpConnectTimeout
public int getHttpConnectTimeout() -
setProxy
-
getProxy
-
setHttpConnectTimeout
public void setHttpConnectTimeout(int timeout)Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by this URLConnection. If the timeout expires before the connection can be established, a java.net.SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout. -
getHttpReadTimeout
public int getHttpReadTimeout() -
setHttpReadTimeout
public void setHttpReadTimeout(int httpReadTimeout) -
setFromEmail
- Parameters:
fromEmail- the fromEmail to set
-
sendMessage
public Response sendMessage(String from, String recipient, String subject, String text, String html) throws SparkPostException- Throws:
SparkPostException
-
sendMessage
public Response sendMessage(String from, List<String> recipients, String subject, String text, String html) throws SparkPostException- Throws:
SparkPostException
-
toString
-