public class SendGrid extends java.lang.Object implements SendGridAPI
| 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.
|
void |
attempt(com.sendgrid.Request request)
Attempt an API call.
|
void |
attempt(com.sendgrid.Request request,
APICallback callback)
Attempt an API call.
|
java.lang.String |
getHost()
Get the SendGrid host (api.sendgrid.com by default).
|
java.lang.String |
getLibraryVersion()
Retrieve the current library version.
|
int |
getRateLimitRetry()
Get the maximum number of retries on a rate limit response.
|
int |
getRateLimitSleep()
Get the duration of time (in milliseconds) to sleep between
consecutive rate limit retries.
|
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)
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 |
setRateLimitRetry(int rateLimitRetry)
Set the maximum number of retries on a rate limit response.
|
void |
setRateLimitSleep(int rateLimitSleep)
Set the duration of time (in milliseconds) to sleep between
consecutive rate limit retries.
|
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)
initializeSendGrid in interface SendGridAPIapiKey - the user's API key.public java.lang.String getLibraryVersion()
getLibraryVersion in interface SendGridAPIpublic java.lang.String getVersion()
getVersion in interface SendGridAPIpublic void setVersion(java.lang.String version)
setVersion in interface SendGridAPIversion - the new version.public java.util.Map<java.lang.String,java.lang.String> getRequestHeaders()
getRequestHeaders in interface SendGridAPIpublic java.util.Map<java.lang.String,java.lang.String> addRequestHeader(java.lang.String key,
java.lang.String value)
addRequestHeader in interface SendGridAPIkey - the header key.value - the header value.public java.util.Map<java.lang.String,java.lang.String> removeRequestHeader(java.lang.String key)
removeRequestHeader in interface SendGridAPIkey - the header key to remove.public java.lang.String getHost()
getHost in interface SendGridAPIpublic void setHost(java.lang.String host)
setHost in interface SendGridAPIhost - the new SendGrid host.public int getRateLimitRetry()
public void setRateLimitRetry(int rateLimitRetry)
rateLimitRetry - the maximum retry count.public int getRateLimitSleep()
public void setRateLimitSleep(int rateLimitSleep)
rateLimitSleep - the sleep duration.public com.sendgrid.Response makeCall(com.sendgrid.Request request)
throws java.io.IOException
makeCall in interface SendGridAPIrequest - 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
api in interface SendGridAPIrequest - the request object.java.io.IOException - in case of a network error.public void attempt(com.sendgrid.Request request)
request - the API request.public void attempt(com.sendgrid.Request request,
APICallback callback)
request - the API request.callback - the callback.