From a5082ae5989849a03e201adab87772c8d61e42db Mon Sep 17 00:00:00 2001 From: Daniel Deutsch Date: Fri, 17 Nov 2017 12:07:09 -0500 Subject: [PATCH] Adds simple interfaces for ETClient and ETRestConnection. Only method exposed on ETClient at the moment is getRestConnection, making it clear that this is the only use of the client for non-SOAP endpoints. --- pom.xml | 8 ++++++++ .../com/exacttarget/fuelsdk/ETClient.java | 20 +++++++------------ .../exacttarget/fuelsdk/ETRestConnection.java | 6 +++++- .../com/exacttarget/fuelsdk/IETClient.java | 5 +++++ .../fuelsdk/IETRestConnection.java | 10 ++++++++++ 5 files changed, 35 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/exacttarget/fuelsdk/IETClient.java create mode 100644 src/main/java/com/exacttarget/fuelsdk/IETRestConnection.java diff --git a/pom.xml b/pom.xml index 2beb6ea2..0bcaea95 100755 --- a/pom.xml +++ b/pom.xml @@ -249,6 +249,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 1.6 + 1.6 + + diff --git a/src/main/java/com/exacttarget/fuelsdk/ETClient.java b/src/main/java/com/exacttarget/fuelsdk/ETClient.java index 1f4c8785..a91fce15 100755 --- a/src/main/java/com/exacttarget/fuelsdk/ETClient.java +++ b/src/main/java/com/exacttarget/fuelsdk/ETClient.java @@ -55,7 +55,7 @@ * client library. */ -public class ETClient { +public class ETClient implements IETClient { private static Logger logger = Logger.getLogger(ETClient.class); private static final String DEFAULT_PROPERTIES_FILE_NAME = @@ -76,13 +76,6 @@ public class ETClient { private String clientId = null; private String clientSecret = null; - private String username = null; - private String password = null; - - private String endpoint = null; - private String authEndpoint = null; - private String soapEndpoint = null; - private Boolean autoHydrateObjects = true; private Gson gson = null; @@ -129,18 +122,18 @@ public ETClient(ETConfiguration configuration) clientId = configuration.get("clientId"); clientSecret = configuration.get("clientSecret"); - username = configuration.get("username"); - password = configuration.get("password"); + String username = configuration.get("username"); + String password = configuration.get("password"); - endpoint = configuration.get("endpoint"); + String endpoint = configuration.get("endpoint"); if (endpoint == null) { endpoint = DEFAULT_ENDPOINT; } - authEndpoint = configuration.get("authEndpoint"); + String authEndpoint = configuration.get("authEndpoint"); if (authEndpoint == null) { authEndpoint = DEFAULT_AUTH_ENDPOINT; } - soapEndpoint = configuration.get("soapEndpoint"); + String soapEndpoint = configuration.get("soapEndpoint"); GsonBuilder gsonBuilder = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() @@ -250,6 +243,7 @@ public Gson getGson() { * * @return The ETRestConnection */ + @Override public ETRestConnection getRestConnection() { return restConnection; } diff --git a/src/main/java/com/exacttarget/fuelsdk/ETRestConnection.java b/src/main/java/com/exacttarget/fuelsdk/ETRestConnection.java index 7d2ca499..7838bd40 100755 --- a/src/main/java/com/exacttarget/fuelsdk/ETRestConnection.java +++ b/src/main/java/com/exacttarget/fuelsdk/ETRestConnection.java @@ -58,7 +58,7 @@ * connection to the Salesforce Marketing Cloud REST API. */ -public class ETRestConnection { +public class ETRestConnection implements IETRestConnection { private static Logger logger = Logger.getLogger(ETRestConnection.class); private ETClient client = null; @@ -100,6 +100,7 @@ public ETRestConnection(ETClient client, String endpoint, boolean isAuthConnecti * @param path The path to GET the response * @return The Response object */ + @Override public Response get(String path) throws ETSdkException { @@ -126,6 +127,7 @@ public Response get(String path) * @param path The path to POST or create * @return The Response object */ + @Override public Response post(String path, String payload) throws ETSdkException { @@ -152,6 +154,7 @@ public Response post(String path, String payload) * @param path The path to PATCH or update * @return The Response object */ + @Override public Response patch(String path, String payload) throws ETSdkException { @@ -178,6 +181,7 @@ public Response patch(String path, String payload) * @param path The path to DELETE * @return The Response object */ + @Override public Response delete(String path) throws ETSdkException { diff --git a/src/main/java/com/exacttarget/fuelsdk/IETClient.java b/src/main/java/com/exacttarget/fuelsdk/IETClient.java new file mode 100644 index 00000000..15a1e85b --- /dev/null +++ b/src/main/java/com/exacttarget/fuelsdk/IETClient.java @@ -0,0 +1,5 @@ +package com.exacttarget.fuelsdk; + +public interface IETClient { + IETRestConnection getRestConnection(); +} diff --git a/src/main/java/com/exacttarget/fuelsdk/IETRestConnection.java b/src/main/java/com/exacttarget/fuelsdk/IETRestConnection.java new file mode 100644 index 00000000..e799cb21 --- /dev/null +++ b/src/main/java/com/exacttarget/fuelsdk/IETRestConnection.java @@ -0,0 +1,10 @@ +package com.exacttarget.fuelsdk; + +import com.exacttarget.fuelsdk.ETRestConnection.Response; + +public interface IETRestConnection { + Response get(String path) throws ETSdkException; + Response post(String path, String payload) throws ETSdkException; + Response patch(String path, String payload) throws ETSdkException; + Response delete(String path) throws ETSdkException; +}