public class SendGrid extends Object implements SendGridAPI
| Constructor and Description |
|---|
SendGrid(String apiKey)
Construct a new Twilio SendGrid API wrapper.
|
SendGrid(String apiKey,
Boolean test)
Construct a new Twilio SendGrid API wrapper.
|
SendGrid(String apiKey,
com.sendgrid.Client client)
Construct a new Twilio SendGrid API wrapper.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addImpersonateSubuser(String subuser)
Impersonate subuser for subsequent requests
|
Map<String,String> |
addRequestHeader(String key,
String value)
Add a new request header.
|
com.sendgrid.Response |
api(com.sendgrid.Request request)
Class api sets up the request to the Twilio 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.
|
String |
getHost()
Get the Twilio SendGrid host (api.sendgrid.com by default).
|
String |
getImpersonateSubuser()
Get the impersonated subuser or null if empty
|
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.
|
Map<String,String> |
getRequestHeaders()
Obtain the request headers.
|
String |
getVersion()
Get the API version.
|
void |
initializeSendGrid(String apiKey)
Initialize the client.
|
com.sendgrid.Response |
makeCall(com.sendgrid.Request request)
Makes the call to the Twilio SendGrid API, override this method for testing.
|
void |
removeImpersonateSubuser()
Stop Impersonating the subuser
|
Map<String,String> |
removeRequestHeader(String key)
Remove a request header.
|
void |
setHost(String host)
Set the Twilio 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(String version)
Set the API version.
|
public SendGrid(String apiKey)
apiKey - is your Twilio SendGrid API Key: https://app.sendgrid.com/settings/api_keyspublic SendGrid(String apiKey, Boolean test)
apiKey - is your Twilio SendGrid API Key: https://app.sendgrid.com/settings/api_keystest - is true if you are unit testingpublic SendGrid(String apiKey, com.sendgrid.Client client)
apiKey - is your Twilio SendGrid API Key: https://app.sendgrid.com/settings/api_keysclient - the Client to use (allows to customize its configuration)public void initializeSendGrid(String apiKey)
initializeSendGrid in interface SendGridAPIapiKey - the user's API key.public String getLibraryVersion()
getLibraryVersion in interface SendGridAPIpublic String getVersion()
getVersion in interface SendGridAPIpublic void setVersion(String version)
setVersion in interface SendGridAPIversion - the new version.public Map<String,String> getRequestHeaders()
getRequestHeaders in interface SendGridAPIpublic Map<String,String> addRequestHeader(String key, String value)
addRequestHeader in interface SendGridAPIkey - the header key.value - the header value.public Map<String,String> removeRequestHeader(String key)
removeRequestHeader in interface SendGridAPIkey - the header key to remove.public String getHost()
getHost in interface SendGridAPIpublic void setHost(String host)
setHost in interface SendGridAPIhost - the new Twilio 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 void addImpersonateSubuser(String subuser)
subuser - the subuser to be impersonatedpublic void removeImpersonateSubuser()
public String getImpersonateSubuser()
public com.sendgrid.Response makeCall(com.sendgrid.Request request)
throws IOException
makeCall in interface SendGridAPIrequest - the request to make.IOException - in case of a network error.public com.sendgrid.Response api(com.sendgrid.Request request)
throws IOException
api in interface SendGridAPIrequest - the request object.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.Copyright © 2020. All rights reserved.