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 |
setDataResidency(String region) |
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 SendGridAPI
auth
- authorization header valuehost
- the base URL for the APIpublic String getLibraryVersion()
getLibraryVersion
in interface SendGridAPI
public String getVersion()
getVersion
in interface SendGridAPI
public void setVersion(String version)
setVersion
in interface SendGridAPI
version
- the new versionpublic Map<String,String> getRequestHeaders()
getRequestHeaders
in interface SendGridAPI
public Map<String,String> addRequestHeader(String key, String value)
addRequestHeader
in interface SendGridAPI
key
- the header keyvalue
- the header valuepublic Map<String,String> removeRequestHeader(String key)
removeRequestHeader
in interface SendGridAPI
key
- the header key to removepublic String getHost()
getHost
in interface SendGridAPI
public void setHost(String host)
setHost
in interface SendGridAPI
host
- 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 SendGridAPI
request
- the request to makeIOException
- in case of a network errorpublic com.sendgrid.Response api(com.sendgrid.Request request) throws IOException
api
in interface SendGridAPI
request
- 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 callbackpublic void setDataResidency(String region)
Copyright © 2023. All rights reserved.