diff --git a/src/main/java/com/sendgrid/SendGrid.java b/src/main/java/com/sendgrid/SendGrid.java index 897728bc..d47fcedf 100644 --- a/src/main/java/com/sendgrid/SendGrid.java +++ b/src/main/java/com/sendgrid/SendGrid.java @@ -5,10 +5,10 @@ import java.util.Map; /** - * Class SendGrid allows for quick and easy access to the SendGrid API. - */ -public class SendGrid { - /** The current library version. */ + * Class SendGrid allows for quick and easy access to the SendGrid API. + */ +public class SendGrid implements SendGridAPI { + private static final String VERSION = "3.0.0"; /** The user agent string to return to SendGrid. */ diff --git a/src/main/java/com/sendgrid/SendGridAPI.java b/src/main/java/com/sendgrid/SendGridAPI.java new file mode 100644 index 00000000..32998459 --- /dev/null +++ b/src/main/java/com/sendgrid/SendGridAPI.java @@ -0,0 +1,92 @@ +package com.sendgrid; + +import java.io.IOException; +import java.util.Map; + +public interface SendGridAPI { + + /** + * Initializes SendGrid + * + * @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys + */ + public void initializeSendGrid(String apiKey); + + /** + * Returns the library version + * + * @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys + * @return the library version. + */ + public String getLibraryVersion(); + + /** + * Gets the version. + * + * @return returns the version. + */ + public String getVersion(); + + /** + * Sets the version. + * + * @param version the SendGrid version. + */ + public void setVersion(String version); + + /** + * Gets the request headers. + * @return returns a map of request headers. + */ + public Map getRequestHeaders(); + + /** + * Adds a request headers. + * + * @param key the key + * @param value the value + * @return returns a map of request headers. + */ + public Map addRequestHeader(String key, String value); + + /** + * Removes a request headers. + * + * @param key the key + * @return returns a map of request headers. + */ + public Map removeRequestHeader(String key); + + /** + * Gets the host. + * + * @return returns the host. + */ + public String getHost(); + + /** + * Sets the host. + * + * @param host the host to set + */ + public void setHost(String host); + + /** + * Class makeCall makes the call to the SendGrid API, override this method for + * testing. + * + * @param request the request + * @return returns a response. + * @throws IOException in case of network or marshal error. + */ + public Response makeCall(Request request) throws IOException; + + /** + * Class api sets up the request to the SendGrid API, this is main interface. + * + * @param request the request + * @return returns a response. + * @throws IOException in case of network or marshal error. + */ + public Response api(Request request) throws IOException; +}