Skip to content

Commit

Permalink
Merge branch 'Java-SDK-Deprecate-Contact-Endpoint-Replace-With-New'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Thorley authored and EsendexDev committed Jan 7, 2016
2 parents 9a426dd + c3b45ac commit 285ae4e
Show file tree
Hide file tree
Showing 41 changed files with 540 additions and 742 deletions.
166 changes: 93 additions & 73 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,98 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<buildnumber>0</buildnumber>
</properties>
<groupId>esendex-java-sdk</groupId>
<artifactId>esendex-java-sdk</artifactId>
<version>1.0.1</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.17</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/dependency</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
</dependency>
</dependencies>
<modelVersion>4.0.0</modelVersion>
<properties>
<buildnumber>0</buildnumber>
</properties>
<groupId>esendex-java-sdk</groupId>
<artifactId>esendex-java-sdk</artifactId>
<version>2.0.1</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.17</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<configuration>
<destDir>${project.build.directory}/apidocs</destDir>
<reportOutputDirectory>${project.reporting.outputDirectory}/apidocs</reportOutputDirectory>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/dependency</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
</dependency>
</dependencies>

</project>
20 changes: 10 additions & 10 deletions src/main/java/esendex/sdk/java/ServiceFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
/**
* A factory for services. A service is the fundamental developer interface to
* the Esendex resources. A new ServiceFactory should be created for every
* Authentication identity.
*
* Authentication identity.
*
* @author Mike Whittaker
*/
public abstract class ServiceFactory implements IServiceFactory {

protected Authenticator authenticator;

/**
Expand All @@ -47,7 +47,7 @@ public static SessionServiceFactory createSessionAuthenticatingFactory(
UserPassword userPassword) throws EsendexException {
return new SessionServiceFactoryImpl(userPassword);
}

/**
* Create a ServiceFactory whose services will connect using Basic
* authentication.
Expand Down Expand Up @@ -83,13 +83,13 @@ public InboxService getInboxService() {
return new InboxServiceImpl(authenticator);
}

/**
* Obtains a service suitable for create, read, update and delete
* operations on the users contacts.
* @return the service
*/
/**
* Obtains a service suitable for create, read, update and delete
* operations on the users contacts.
* @return the service
*/
public ContactService getContactService() {
return new ContactServiceImpl(authenticator);
}

}
6 changes: 3 additions & 3 deletions src/main/java/esendex/sdk/java/http/HttpConnectorImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public HttpResponse connect(URL url,
HttpURLConnection uc = createHttpRequest(url, method, authenticator, data);

return executeHttpRequest(uc);

} catch (IOException ex) {

throw new HttpException("Failed connection to: " + url, ex);
}

Expand All @@ -55,7 +55,7 @@ private HttpResponse executeHttpRequest(HttpURLConnection uc) throws IOException
}

String response = null;
if (HttpURLConnection.HTTP_OK == respCode) {
if (HttpURLConnection.HTTP_OK == respCode || HttpURLConnection.HTTP_CREATED == respCode ) {

response = readHttpResponse(uc);
}
Expand Down
38 changes: 21 additions & 17 deletions src/main/java/esendex/sdk/java/http/HttpQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,49 @@
import java.net.URLEncoder;

public class HttpQuery {

private StringBuilder queryString = new StringBuilder();
public static final Key<Boolean> RETURN_MESSAGE_HEADERS

public static final Key<Boolean> RETURN_MESSAGE_HEADERS
= new Key<Boolean>("returnMessageHeaders");
public static final Key<Integer> COUNT

public static final Key<Integer> COUNT
= new Key<Integer>("count");

public static final Key<Integer> START_INDEX
public static final Key<Integer> START_INDEX
= new Key<Integer>("startIndex");

public static final Key<Action> ACTION
public static final Key<Action> ACTION
= new Key<Action>("action");
public static final Key<String> FILTER_VALUE

public static final Key<String> FILTER_VALUE
= new Key<String>("filterValue");
public static final Key<String> FILTER_BY

public static final Key<String> FILTER_BY
= new Key<String>("filterBy");


public static final Key<String> ACCOUNT_REFERENCE
= new Key<String>("accountreference");

public static final String ACCOUNT_FILTER = "account";



public enum Action {
READ,
UNREAD;
public String toString() {
return name().toLowerCase();
}
}

public enum FilterBy {
ACCOUNT ("");
String value;
private FilterBy(String v) {
this.value = v;
}
}

public <E> void addParameter(Key<E> key, E value) {
if (queryString.length() > 0) queryString.append('&');
queryString.append(key.name);
Expand All @@ -55,12 +59,12 @@ public <E> void addParameter(Key<E> key, E value) {
queryString.append(value.toString());
}
}

@Override
public String toString() {
return queryString.toString();
}

private static class Key<T> {
String name;
Key(String n) {
Expand Down
32 changes: 6 additions & 26 deletions src/main/java/esendex/sdk/java/model/domain/impl/BaseContact.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,20 @@
package esendex.sdk.java.model.domain.impl;

import esendex.sdk.java.model.types.ContactType;

public class BaseContact {

private String id;
private String concurrencyId;
private String uri;
private String firstName;
private String lastName;
private String quickName;
private String mobileNumber;
private ContactType type;
public BaseContact() {
private String accountReference;

public BaseContact() {
}

public String getId() {
return id;
}

public String getConcurrencyId() {
return concurrencyId;
}

public String getUri() {
return uri;
}

public String getFirstName() {
return firstName;
Expand All @@ -44,18 +32,14 @@ public String getMobileNumber() {
return mobileNumber;
}

public ContactType getType() {
return type;
}
public String getAccountReference() {return accountReference;}

protected void setId(String id) {
this.id = id;
}

protected void setConcurrencyId(String concurrencyId) {
this.concurrencyId = concurrencyId;
}

protected void setAccountReference(String accountReference) {this.accountReference = accountReference; }

protected void setFirstName(String firstName) {
this.firstName = firstName;
}
Expand All @@ -72,8 +56,4 @@ protected void setMobileNumber(String mobileNumber) {
this.mobileNumber = mobileNumber;
}

protected void setType(ContactType type) {
this.type = type;
}

}
Loading

0 comments on commit 285ae4e

Please sign in to comment.