public abstract class BaseInterface extends Object implements SendGridAPI
| Constructor and Description |
|---|
BaseInterface()
Construct a new API wrapper.
|
BaseInterface(Boolean test)
Construct a new API wrapper.
|
BaseInterface(com.sendgrid.Client client)
Construct a new 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/update a 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 host.
|
String |
getImpersonateSubuser()
Get the impersonated subuser or null if empty
|
String |
getLibraryVersion()
Get 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()
Get the request headers.
|
String |
getVersion()
Get the API version.
|
void |
initialize(String auth,
String host)
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 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 BaseInterface()
public BaseInterface(Boolean test)
test - is true if you are unit testingpublic BaseInterface(com.sendgrid.Client client)
client - the Client to use (allows to customize its configuration)public void initialize(String auth, String host)
initialize in interface SendGridAPIauth - authorization header valuehost - the base URL for the APIpublic String getLibraryVersion()
getLibraryVersion in interface SendGridAPIpublic String getVersion()
getVersion in interface SendGridAPIpublic void setVersion(String version)
setVersion in interface SendGridAPIversion - the new versionpublic Map<String,String> getRequestHeaders()
getRequestHeaders in interface SendGridAPIpublic Map<String,String> addRequestHeader(String key, String value)
addRequestHeader in interface SendGridAPIkey - the header keyvalue - the header valuepublic Map<String,String> removeRequestHeader(String key)
removeRequestHeader in interface SendGridAPIkey - the header key to removepublic String getHost()
getHost in interface SendGridAPIpublic void setHost(String host)
setHost in interface SendGridAPIhost - the new hostpublic int getRateLimitRetry()
public void setRateLimitRetry(int rateLimitRetry)
rateLimitRetry - the maximum retry countpublic int getRateLimitSleep()
public void setRateLimitSleep(int rateLimitSleep)
rateLimitSleep - the sleep durationpublic 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 makeIOException - in case of a network errorpublic com.sendgrid.Response api(com.sendgrid.Request request)
throws IOException
api in interface SendGridAPIrequest - the request objectIOException - in case of a network errorpublic void attempt(com.sendgrid.Request request)
request - the API requestpublic void attempt(com.sendgrid.Request request,
APICallback callback)
request - the API requestcallback - the callbackCopyright © 2022. All rights reserved.