public class SendGrid
extends java.lang.Object
| Constructor and Description |
|---|
SendGrid(java.lang.String apiKey)
Construct a new SendGrid API wrapper.
|
SendGrid(java.lang.String apiKey,
java.lang.Boolean test)
Construct a new SendGrid API wrapper.
|
SendGrid(java.lang.String apiKey,
com.sendgrid.Client client)
Construct a new SendGrid API wrapper.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.Map<java.lang.String,java.lang.String> |
addRequestHeader(java.lang.String key,
java.lang.String value)
Add a new request header.
|
com.sendgrid.Response |
api(com.sendgrid.Request request)
Class api sets up the request to the SendGrid API, this is main interface.
|
java.lang.String |
getHost()
Get the SendGrid host (api.sendgrid.com by default).
|
java.lang.String |
getLibraryVersion()
Retrieve the current library version.
|
java.util.Map<java.lang.String,java.lang.String> |
getRequestHeaders()
Obtain the request headers.
|
java.lang.String |
getVersion()
Get the API version.
|
void |
initializeSendGrid(java.lang.String apiKey)
Initialize the client.
|
com.sendgrid.Response |
makeCall(com.sendgrid.Request request)
Class makeCall makes the call to the SendGrid API, override this method for testing.
|
java.util.Map<java.lang.String,java.lang.String> |
removeRequestHeader(java.lang.String key)
Remove a request header.
|
void |
setHost(java.lang.String host)
Set the SendGrid host.
|
void |
setVersion(java.lang.String version)
Set the API version.
|
public SendGrid(java.lang.String apiKey)
apiKey - is your SendGrid API Key: https://app.sendgrid.com/settings/api_keyspublic SendGrid(java.lang.String apiKey,
java.lang.Boolean test)
apiKey - is your SendGrid API Key: https://app.sendgrid.com/settings/api_keystest - is true if you are unit testingpublic SendGrid(java.lang.String apiKey,
com.sendgrid.Client client)
apiKey - is your SendGrid API Key: https://app.sendgrid.com/settings/api_keysclient - the Client to use (allows to customize its configuration)public void initializeSendGrid(java.lang.String apiKey)
apiKey - the user's API key.public java.lang.String getLibraryVersion()
public java.lang.String getVersion()
public void setVersion(java.lang.String version)
version - the new version.public java.util.Map<java.lang.String,java.lang.String> getRequestHeaders()
public java.util.Map<java.lang.String,java.lang.String> addRequestHeader(java.lang.String key,
java.lang.String value)
key - the header key.value - the header value.public java.util.Map<java.lang.String,java.lang.String> removeRequestHeader(java.lang.String key)
key - the header key to remove.public java.lang.String getHost()
public void setHost(java.lang.String host)
host - the new SendGrid host.public com.sendgrid.Response makeCall(com.sendgrid.Request request)
throws java.io.IOException
request - the request to make.java.io.IOException - in case of a network error.public com.sendgrid.Response api(com.sendgrid.Request request)
throws java.io.IOException
request - the request object.java.io.IOException - in case of a network error.