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 Details

    • Client

      public Client()
    • Client

      public Client​(String key)
    • Client

      public Client​(String key, String baseUrl)
  • Method Details

    • setAuthKey

      public final void setAuthKey​(String key)
      You can create and API Key here SparkPost
      Parameters:
      key - SparkPost API Key
    • getAuthKey

      public String getAuthKey()
    • setBaseUrl

      public void setBaseUrl​(String baseUrl)
    • getBaseUrl

      public String getBaseUrl()
    • getUsername

      public String getUsername()
    • setUsername

      public void setUsername​(String username)
    • getPassword

      public String getPassword()
    • setPassword

      public void setPassword​(String password)
    • getFromEmail

      public String 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

      public void setProxy​(String hostname, int port)
    • getProxy

      public Proxy 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

      public void setFromEmail​(String fromEmail)
      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

      public String toString()
      Overrides:
      toString in class Object