Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
Adds simple interfaces for ETClient and ETRestConnection.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
daniel-deutsch-zocdoc committed Nov 17, 2017
1 parent 258b410 commit 7c3f081
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,14 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
Expand Down
20 changes: 7 additions & 13 deletions src/main/java/com/exacttarget/fuelsdk/ETClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -250,6 +243,7 @@ public Gson getGson() {
*
* @return The ETRestConnection
*/
@Override
public ETRestConnection getRestConnection() {
return restConnection;
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/exacttarget/fuelsdk/ETRestConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/exacttarget/fuelsdk/IETClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.exacttarget.fuelsdk;

public interface IETClient {
IETRestConnection getRestConnection();
}
10 changes: 10 additions & 0 deletions src/main/java/com/exacttarget/fuelsdk/IETRestConnection.java
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 7c3f081

Please sign in to comment.