diff --git a/build.gradle b/build.gradle index ee92c8cf..2a021ee9 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,7 @@ allprojects { apply plugin: 'java' dependencies { + compile 'javax.inject:javax.inject:1' compile 'com.squareup.retrofit2:retrofit:2.1.0' compile 'com.squareup.retrofit2:converter-jackson:2.1.0' compile 'com.squareup.okhttp3:logging-interceptor:3.4.1' diff --git a/lib-rx/src/main/java/com/constantcontact/v2/CCApiInterceptor.java b/components/src/main/java/com/constantcontact/v2/CCApiInterceptor.java similarity index 95% rename from lib-rx/src/main/java/com/constantcontact/v2/CCApiInterceptor.java rename to components/src/main/java/com/constantcontact/v2/CCApiInterceptor.java index 0c054f49..d450032c 100755 --- a/lib-rx/src/main/java/com/constantcontact/v2/CCApiInterceptor.java +++ b/components/src/main/java/com/constantcontact/v2/CCApiInterceptor.java @@ -30,7 +30,7 @@ public Response intercept(Chain chain) throws IOException { .addHeader("Authorization", "Bearer " + _token) .addHeader("Content-Type", "application/json") .addHeader("User-Agent", - "Constant Contact Java Library v5.1.1") // TODO: Add version # dynamically + "Constant Contact Java Library v5.1.6") // TODO: Add version # dynamically .build(); return chain.proceed(newRequest); } diff --git a/components/src/main/java/com/constantcontact/v2/DefaultOkHttpClientBuilderFactory.java b/components/src/main/java/com/constantcontact/v2/DefaultOkHttpClientBuilderFactory.java new file mode 100644 index 00000000..88f4db33 --- /dev/null +++ b/components/src/main/java/com/constantcontact/v2/DefaultOkHttpClientBuilderFactory.java @@ -0,0 +1,37 @@ +package com.constantcontact.v2; + +import okhttp3.OkHttpClient; +import okhttp3.logging.HttpLoggingInterceptor; + +import javax.inject.Inject; +import java.util.concurrent.TimeUnit; + +/** + */ +public class DefaultOkHttpClientBuilderFactory { + + @Inject + public DefaultOkHttpClientBuilderFactory() { + } + + public OkHttpClient.Builder create(String apiKey, String token) { + return create(apiKey, token, HttpLoggingInterceptor.Level.NONE); + } + + public OkHttpClient.Builder create(String apiKey, String token, HttpLoggingInterceptor.Level loggingLevel) { + OkHttpClient.Builder + builder = + new OkHttpClient().newBuilder() + .readTimeout(10, TimeUnit.SECONDS) + .connectTimeout(5, TimeUnit.SECONDS) + .addInterceptor(new CCApiInterceptor(apiKey, token)); + + if (loggingLevel != HttpLoggingInterceptor.Level.NONE) { + HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); + interceptor.setLevel(loggingLevel); + builder.addInterceptor(interceptor); + } + + return builder; + } +} diff --git a/components/src/main/java/com/constantcontact/v2/DefaultRetrofitBuilderFactory.java b/components/src/main/java/com/constantcontact/v2/DefaultRetrofitBuilderFactory.java new file mode 100644 index 00000000..458ff8b2 --- /dev/null +++ b/components/src/main/java/com/constantcontact/v2/DefaultRetrofitBuilderFactory.java @@ -0,0 +1,66 @@ +package com.constantcontact.v2; + +import com.constantcontact.v2.converter.jackson.JacksonConverterFactory; +import com.fasterxml.jackson.databind.ObjectMapper; +import okhttp3.OkHttpClient; +import retrofit2.Retrofit; + +import javax.inject.Inject; +import javax.inject.Named; + +/** + * A factory for creating the default {@link Retrofit.Builder}. + *
+ * NOTE: Can be used with dependency injection since the constructor
+ * is marked with {@code @Inject}, and requires a {@link OkHttpClient} dependency named "ccapi2". If you aren't using DI
+ * then the annotations will not affect you.
+ */
+public class DefaultRetrofitBuilderFactory {
+ public static final String BASE_URL = "https://api.constantcontact.com/";
+
+ private final OkHttpClient _okHttpClient;
+
+ /**
+ * Creates an instance of the factory.
+ *
+ * @param client the client used to initialize the created builder
+ */
+ @Inject
+ public DefaultRetrofitBuilderFactory(@Named("ccapi2") OkHttpClient client) {
+ _okHttpClient = client;
+ }
+
+ /**
+ * Creates a new builder instance with the default base url. Initialized with a default Jackson JSON converter.
+ *
+ * @return a builder instance initialized for use with service classes
+ */
+ public Retrofit.Builder create() {
+ return create(BASE_URL);
+ }
+
+ /**
+ * Creates a new builder instance with the provided base url. Initialized with a default Jackson JSON converter.
+ *
+ * @param baseUrl the base url
+ * @return a builder instance initialized for use with service classes
+ */
+ public Retrofit.Builder create(String baseUrl) {
+ return create(baseUrl, new ObjectMapper());
+ }
+
+ /**
+ * Creates a new builder instance with the provided base url. Initialized with a Jackson JSON converter using the
+ * provided object mapper.
+ *
+ * @param baseUrl the base url
+ * @param objectMapper the object mapper
+ * @return a builder instance initialized for use with service classes
+ */
+ public Retrofit.Builder create(String baseUrl, ObjectMapper objectMapper) {
+ return new Retrofit.Builder()
+ .baseUrl(baseUrl)
+ .client(_okHttpClient)
+ .addConverterFactory(JacksonConverterFactory.create(objectMapper));
+ }
+}
diff --git a/components/src/main/java/com/constantcontact/v2/QueryDate.java b/components/src/main/java/com/constantcontact/v2/QueryDate.java
new file mode 100644
index 00000000..cac5f782
--- /dev/null
+++ b/components/src/main/java/com/constantcontact/v2/QueryDate.java
@@ -0,0 +1,29 @@
+package com.constantcontact.v2;
+
+import java.util.Date;
+
+import static com.constantcontact.v2.converter.jackson.JacksonConverterFactory.ISO_8601_DATE_FORMAT;
+
+/**
+ * A date wrapper to Constant Contact API specific ISO-8601 date format for query parameters.
+ */
+public class QueryDate {
+ private final Date date;
+
+ public QueryDate() {
+ date = new Date();
+ }
+
+ public QueryDate(long dateInMilliseconds) {
+ date = new Date(dateInMilliseconds);
+ }
+
+ public QueryDate(Date date) {
+ this.date = date;
+ }
+
+ @Override
+ public String toString() {
+ return ISO_8601_DATE_FORMAT.format(date);
+ }
+}
diff --git a/components/src/main/java/com/constantcontact/v2/account/AccountAddress.java b/components/src/main/java/com/constantcontact/v2/account/AccountAddress.java
index c4bf8488..89a21ab8 100644
--- a/components/src/main/java/com/constantcontact/v2/account/AccountAddress.java
+++ b/components/src/main/java/com/constantcontact/v2/account/AccountAddress.java
@@ -25,7 +25,6 @@
/**
* Account Address, which is part of the {@link AccountSummaryInformation}
*
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
public class AccountAddress implements Serializable {
diff --git a/components/src/main/java/com/constantcontact/v2/account/AccountEmailAddress.java b/components/src/main/java/com/constantcontact/v2/account/AccountEmailAddress.java
index 65c25f62..95e10b67 100644
--- a/components/src/main/java/com/constantcontact/v2/account/AccountEmailAddress.java
+++ b/components/src/main/java/com/constantcontact/v2/account/AccountEmailAddress.java
@@ -9,7 +9,6 @@
import java.io.Serializable;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
public class AccountEmailAddress implements Serializable {
diff --git a/components/src/main/java/com/constantcontact/v2/account/AccountEmailAddressStatus.java b/components/src/main/java/com/constantcontact/v2/account/AccountEmailAddressStatus.java
index 9bd4bf8e..3f35b98b 100644
--- a/components/src/main/java/com/constantcontact/v2/account/AccountEmailAddressStatus.java
+++ b/components/src/main/java/com/constantcontact/v2/account/AccountEmailAddressStatus.java
@@ -1,7 +1,6 @@
package com.constantcontact.v2.account;
/**
- * @author woogienoogie
*/
public enum AccountEmailAddressStatus {
CONFIRMED,
diff --git a/components/src/main/java/com/constantcontact/v2/account/AccountSummaryInformation.java b/components/src/main/java/com/constantcontact/v2/account/AccountSummaryInformation.java
index 36a529cf..0ee52e66 100644
--- a/components/src/main/java/com/constantcontact/v2/account/AccountSummaryInformation.java
+++ b/components/src/main/java/com/constantcontact/v2/account/AccountSummaryInformation.java
@@ -21,7 +21,6 @@
import java.io.Serializable;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
public class AccountSummaryInformation implements Serializable {
diff --git a/components/src/main/java/com/constantcontact/v2/campaigns/Campaign.java b/components/src/main/java/com/constantcontact/v2/campaigns/Campaign.java
index 3ad42111..8ea16e6e 100644
--- a/components/src/main/java/com/constantcontact/v2/campaigns/Campaign.java
+++ b/components/src/main/java/com/constantcontact/v2/campaigns/Campaign.java
@@ -13,7 +13,6 @@
import java.util.Date;
/**
- * @author woogienoogie
*/
@JsonFilter("CampaignCreateUpdateFilter")
@JsonInclude(JsonInclude.Include.NON_NULL)
diff --git a/components/src/main/java/com/constantcontact/v2/campaigns/CampaignPreview.java b/components/src/main/java/com/constantcontact/v2/campaigns/CampaignPreview.java
index 654f3180..8804292c 100644
--- a/components/src/main/java/com/constantcontact/v2/campaigns/CampaignPreview.java
+++ b/components/src/main/java/com/constantcontact/v2/campaigns/CampaignPreview.java
@@ -9,7 +9,6 @@
import java.io.Serializable;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
public class CampaignPreview implements Serializable {
diff --git a/components/src/main/java/com/constantcontact/v2/campaigns/CampaignSchedule.java b/components/src/main/java/com/constantcontact/v2/campaigns/CampaignSchedule.java
index 72a187d1..84be4c60 100644
--- a/components/src/main/java/com/constantcontact/v2/campaigns/CampaignSchedule.java
+++ b/components/src/main/java/com/constantcontact/v2/campaigns/CampaignSchedule.java
@@ -2,6 +2,7 @@
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
+import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
@@ -10,8 +11,8 @@
import java.util.Date;
/**
- * @author woogienoogie
*/
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
public class CampaignSchedule implements Serializable {
@JsonProperty("id")
diff --git a/components/src/main/java/com/constantcontact/v2/campaigns/ClickThroughDetail.java b/components/src/main/java/com/constantcontact/v2/campaigns/ClickThroughDetail.java
index 0eb43ed5..0bdf61cb 100644
--- a/components/src/main/java/com/constantcontact/v2/campaigns/ClickThroughDetail.java
+++ b/components/src/main/java/com/constantcontact/v2/campaigns/ClickThroughDetail.java
@@ -10,7 +10,6 @@
import java.util.Comparator;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
public class ClickThroughDetail implements Serializable {
diff --git a/components/src/main/java/com/constantcontact/v2/campaigns/EmailFormat.java b/components/src/main/java/com/constantcontact/v2/campaigns/EmailFormat.java
index 8dfc709c..4674e039 100644
--- a/components/src/main/java/com/constantcontact/v2/campaigns/EmailFormat.java
+++ b/components/src/main/java/com/constantcontact/v2/campaigns/EmailFormat.java
@@ -1,7 +1,6 @@
package com.constantcontact.v2.campaigns;
/**
- * @author woogienoogie
*/
public enum EmailFormat {
HTML,
diff --git a/components/src/main/java/com/constantcontact/v2/campaigns/MessageFooter.java b/components/src/main/java/com/constantcontact/v2/campaigns/MessageFooter.java
index 84b8b882..55ac3971 100644
--- a/components/src/main/java/com/constantcontact/v2/campaigns/MessageFooter.java
+++ b/components/src/main/java/com/constantcontact/v2/campaigns/MessageFooter.java
@@ -11,7 +11,6 @@
import java.io.Serializable;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
public class MessageFooter implements Serializable {
diff --git a/components/src/main/java/com/constantcontact/v2/campaigns/SentToContactList.java b/components/src/main/java/com/constantcontact/v2/campaigns/SentToContactList.java
index 2b56f3eb..598cb67a 100644
--- a/components/src/main/java/com/constantcontact/v2/campaigns/SentToContactList.java
+++ b/components/src/main/java/com/constantcontact/v2/campaigns/SentToContactList.java
@@ -9,7 +9,6 @@
import java.io.Serializable;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
public class SentToContactList implements Serializable {
diff --git a/components/src/main/java/com/constantcontact/v2/campaigns/TestSend.java b/components/src/main/java/com/constantcontact/v2/campaigns/TestSend.java
index 0bae9bc3..674797b7 100644
--- a/components/src/main/java/com/constantcontact/v2/campaigns/TestSend.java
+++ b/components/src/main/java/com/constantcontact/v2/campaigns/TestSend.java
@@ -9,7 +9,6 @@
import java.io.Serializable;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
public class TestSend implements Serializable {
diff --git a/components/src/main/java/com/constantcontact/v2/contacts/Address.java b/components/src/main/java/com/constantcontact/v2/contacts/Address.java
index 26de9aa6..afefb4db 100644
--- a/components/src/main/java/com/constantcontact/v2/contacts/Address.java
+++ b/components/src/main/java/com/constantcontact/v2/contacts/Address.java
@@ -9,7 +9,6 @@
import java.io.Serializable;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
public class Address implements Serializable {
diff --git a/components/src/main/java/com/constantcontact/v2/contacts/AddressType.java b/components/src/main/java/com/constantcontact/v2/contacts/AddressType.java
index af2cebf4..15c02d43 100644
--- a/components/src/main/java/com/constantcontact/v2/contacts/AddressType.java
+++ b/components/src/main/java/com/constantcontact/v2/contacts/AddressType.java
@@ -1,7 +1,6 @@
package com.constantcontact.v2.contacts;
/**
- * @author woogienoogie
*/
public enum AddressType {
PERSONAL,
diff --git a/components/src/main/java/com/constantcontact/v2/contacts/ConfirmStatus.java b/components/src/main/java/com/constantcontact/v2/contacts/ConfirmStatus.java
index 6d0d4f2a..dbb1bcd8 100644
--- a/components/src/main/java/com/constantcontact/v2/contacts/ConfirmStatus.java
+++ b/components/src/main/java/com/constantcontact/v2/contacts/ConfirmStatus.java
@@ -1,7 +1,6 @@
package com.constantcontact.v2.contacts;
/**
- * @author woogienoogie
*/
public enum ConfirmStatus {
CONFIRMED,
diff --git a/components/src/main/java/com/constantcontact/v2/contacts/Contact.java b/components/src/main/java/com/constantcontact/v2/contacts/Contact.java
index d9f7f78c..451b62e4 100644
--- a/components/src/main/java/com/constantcontact/v2/contacts/Contact.java
+++ b/components/src/main/java/com/constantcontact/v2/contacts/Contact.java
@@ -12,7 +12,6 @@
import java.util.Date;
/**
- * @author woogienoogie
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
diff --git a/components/src/main/java/com/constantcontact/v2/contacts/ContactList.java b/components/src/main/java/com/constantcontact/v2/contacts/ContactList.java
index 8fff7cd6..9c16e2b5 100644
--- a/components/src/main/java/com/constantcontact/v2/contacts/ContactList.java
+++ b/components/src/main/java/com/constantcontact/v2/contacts/ContactList.java
@@ -11,7 +11,6 @@
import java.util.Date;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
public class ContactList implements Serializable {
diff --git a/components/src/main/java/com/constantcontact/v2/contacts/ContactListMetaData.java b/components/src/main/java/com/constantcontact/v2/contacts/ContactListMetaData.java
index 56a62d89..9f67a861 100644
--- a/components/src/main/java/com/constantcontact/v2/contacts/ContactListMetaData.java
+++ b/components/src/main/java/com/constantcontact/v2/contacts/ContactListMetaData.java
@@ -9,7 +9,6 @@
import java.io.Serializable;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
public class ContactListMetaData implements Serializable {
diff --git a/components/src/main/java/com/constantcontact/v2/contacts/ContactListStatus.java b/components/src/main/java/com/constantcontact/v2/contacts/ContactListStatus.java
index e81aac10..55d13021 100644
--- a/components/src/main/java/com/constantcontact/v2/contacts/ContactListStatus.java
+++ b/components/src/main/java/com/constantcontact/v2/contacts/ContactListStatus.java
@@ -1,7 +1,6 @@
package com.constantcontact.v2.contacts;
/**
- * @author woogienoogie
*/
public enum ContactListStatus {
ACTIVE,
diff --git a/components/src/main/java/com/constantcontact/v2/contacts/ContactStatus.java b/components/src/main/java/com/constantcontact/v2/contacts/ContactStatus.java
index f5f38e92..f87a0a12 100644
--- a/components/src/main/java/com/constantcontact/v2/contacts/ContactStatus.java
+++ b/components/src/main/java/com/constantcontact/v2/contacts/ContactStatus.java
@@ -1,7 +1,6 @@
package com.constantcontact.v2.contacts;
/**
- * @author woogienoogie
*/
public enum ContactStatus {
ALL,
diff --git a/components/src/main/java/com/constantcontact/v2/contacts/CustomField.java b/components/src/main/java/com/constantcontact/v2/contacts/CustomField.java
index 93d6ff7f..4c5124d7 100644
--- a/components/src/main/java/com/constantcontact/v2/contacts/CustomField.java
+++ b/components/src/main/java/com/constantcontact/v2/contacts/CustomField.java
@@ -9,7 +9,6 @@
import java.io.Serializable;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
public class CustomField implements Serializable {
diff --git a/components/src/main/java/com/constantcontact/v2/contacts/EmailAddress.java b/components/src/main/java/com/constantcontact/v2/contacts/EmailAddress.java
index fba389f9..2fc0ef00 100644
--- a/components/src/main/java/com/constantcontact/v2/contacts/EmailAddress.java
+++ b/components/src/main/java/com/constantcontact/v2/contacts/EmailAddress.java
@@ -10,7 +10,6 @@
import java.util.Date;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
public class EmailAddress implements Serializable {
diff --git a/components/src/main/java/com/constantcontact/v2/contacts/Note.java b/components/src/main/java/com/constantcontact/v2/contacts/Note.java
index 5368cb98..6264070a 100644
--- a/components/src/main/java/com/constantcontact/v2/contacts/Note.java
+++ b/components/src/main/java/com/constantcontact/v2/contacts/Note.java
@@ -10,7 +10,6 @@
import java.util.Date;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
public class Note implements Serializable {
diff --git a/components/src/main/java/com/constantcontact/v2/contacts/OptInSource.java b/components/src/main/java/com/constantcontact/v2/contacts/OptInSource.java
index a93160b7..c908518e 100644
--- a/components/src/main/java/com/constantcontact/v2/contacts/OptInSource.java
+++ b/components/src/main/java/com/constantcontact/v2/contacts/OptInSource.java
@@ -1,7 +1,6 @@
package com.constantcontact.v2.contacts;
/**
- * @author woogienoogie
*/
public enum OptInSource {
ACTION_BY_VISITOR,
diff --git a/components/src/main/java/com/constantcontact/v2/contacts/SignupFormRequest.java b/components/src/main/java/com/constantcontact/v2/contacts/SignupFormRequest.java
index e07af8cf..3f3a9992 100644
--- a/components/src/main/java/com/constantcontact/v2/contacts/SignupFormRequest.java
+++ b/components/src/main/java/com/constantcontact/v2/contacts/SignupFormRequest.java
@@ -11,7 +11,6 @@
* Payload to give the server when requesting a signup form
* @see Signup Form Creation
*
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
public class SignupFormRequest implements Serializable {
diff --git a/components/src/main/java/com/constantcontact/v2/contacts/SignupFormResponse.java b/components/src/main/java/com/constantcontact/v2/contacts/SignupFormResponse.java
index f22ec725..b31e90f3 100644
--- a/components/src/main/java/com/constantcontact/v2/contacts/SignupFormResponse.java
+++ b/components/src/main/java/com/constantcontact/v2/contacts/SignupFormResponse.java
@@ -11,7 +11,6 @@
* Generated response from the server after requesting a signup form.
* @see Signup Form Creation
*
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
public class SignupFormResponse implements Serializable {
diff --git a/components/src/main/java/com/constantcontact/v2/converter/jackson/JacksonConverterFactory.java b/components/src/main/java/com/constantcontact/v2/converter/jackson/JacksonConverterFactory.java
index 2164bc2b..68521ead 100644
--- a/components/src/main/java/com/constantcontact/v2/converter/jackson/JacksonConverterFactory.java
+++ b/components/src/main/java/com/constantcontact/v2/converter/jackson/JacksonConverterFactory.java
@@ -1,9 +1,6 @@
package com.constantcontact.v2.converter.jackson;
-import com.fasterxml.jackson.databind.JavaType;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectReader;
-import com.fasterxml.jackson.databind.ObjectWriter;
+import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
import okhttp3.RequestBody;
@@ -13,11 +10,16 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
+import java.text.SimpleDateFormat;
/**
* The converter factory used for Jackson JSON conversion
*/
public class JacksonConverterFactory extends Converter.Factory {
+ public final static String ISO_8601_DATE_PATTERN = "yyyy-MM-dd'T'hh:mm:ss.ss'Z'";
+
+ public final static SimpleDateFormat ISO_8601_DATE_FORMAT = new SimpleDateFormat(ISO_8601_DATE_PATTERN);
+
private static String[] CAMPAIGN_CREATE_UPDATE_FIELDS = {
"name",
"subject",
@@ -65,6 +67,8 @@ private JacksonConverterFactory(ObjectMapper mapper) {
throw new NullPointerException("mapper == null");
}
this.mapper = mapper;
+ mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).disable(SerializationFeature.WRITE_DATE_KEYS_AS_TIMESTAMPS);
+ mapper.getSerializationConfig().with(ISO_8601_DATE_FORMAT);
final SimpleBeanPropertyFilter campaignCreateUpdateFilter = SimpleBeanPropertyFilter.filterOutAllExcept(CAMPAIGN_CREATE_UPDATE_FIELDS);
this.writerFilterProvider = new SimpleFilterProvider().addFilter("CampaignCreateUpdateFilter", campaignCreateUpdateFilter);
diff --git a/components/src/main/java/com/constantcontact/v2/library/File.java b/components/src/main/java/com/constantcontact/v2/library/File.java
index 11c6613b..cbc3deb9 100644
--- a/components/src/main/java/com/constantcontact/v2/library/File.java
+++ b/components/src/main/java/com/constantcontact/v2/library/File.java
@@ -10,7 +10,6 @@
import java.util.Date;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
public final class File implements Serializable {
diff --git a/components/src/main/java/com/constantcontact/v2/library/FileSource.java b/components/src/main/java/com/constantcontact/v2/library/FileSource.java
index 06bdcf2d..87f6fc1e 100644
--- a/components/src/main/java/com/constantcontact/v2/library/FileSource.java
+++ b/components/src/main/java/com/constantcontact/v2/library/FileSource.java
@@ -4,7 +4,6 @@
import com.fasterxml.jackson.annotation.JsonValue;
/**
- * @author woogienoogie
*/
public enum FileSource {
ALL,
diff --git a/components/src/main/java/com/constantcontact/v2/library/FileStatus.java b/components/src/main/java/com/constantcontact/v2/library/FileStatus.java
index 9f720c75..2375561d 100644
--- a/components/src/main/java/com/constantcontact/v2/library/FileStatus.java
+++ b/components/src/main/java/com/constantcontact/v2/library/FileStatus.java
@@ -4,7 +4,6 @@
import com.fasterxml.jackson.annotation.JsonValue;
/**
- * @author woogienoogie
*/
public enum FileStatus {
ACTIVE,
diff --git a/components/src/main/java/com/constantcontact/v2/library/FileType.java b/components/src/main/java/com/constantcontact/v2/library/FileType.java
index e0e16c56..b7c9a22d 100644
--- a/components/src/main/java/com/constantcontact/v2/library/FileType.java
+++ b/components/src/main/java/com/constantcontact/v2/library/FileType.java
@@ -3,7 +3,6 @@
import com.fasterxml.jackson.annotation.JsonCreator;
/**
- * @author woogienoogie
*/
public enum FileType {
JPG,
diff --git a/components/src/main/java/com/constantcontact/v2/library/FileTypeQuery.java b/components/src/main/java/com/constantcontact/v2/library/FileTypeQuery.java
index a55366d0..c459d7f9 100644
--- a/components/src/main/java/com/constantcontact/v2/library/FileTypeQuery.java
+++ b/components/src/main/java/com/constantcontact/v2/library/FileTypeQuery.java
@@ -1,7 +1,6 @@
package com.constantcontact.v2.library;
/**
- * @author woogienoogie
*/
public enum FileTypeQuery {
IMAGES,
diff --git a/components/src/main/java/com/constantcontact/v2/library/Folder.java b/components/src/main/java/com/constantcontact/v2/library/Folder.java
index 628fd541..5d3054f7 100644
--- a/components/src/main/java/com/constantcontact/v2/library/Folder.java
+++ b/components/src/main/java/com/constantcontact/v2/library/Folder.java
@@ -11,7 +11,6 @@
import java.util.Date;
/**
- * @author woogienoogie
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
diff --git a/components/src/main/java/com/constantcontact/v2/library/FolderSortOrder.java b/components/src/main/java/com/constantcontact/v2/library/FolderSortOrder.java
index 552f2f54..b216f51c 100644
--- a/components/src/main/java/com/constantcontact/v2/library/FolderSortOrder.java
+++ b/components/src/main/java/com/constantcontact/v2/library/FolderSortOrder.java
@@ -1,7 +1,6 @@
package com.constantcontact.v2.library;
/**
- * @author woogienoogie
*/
public enum FolderSortOrder {
CREATED_DATE,
diff --git a/components/src/main/java/com/constantcontact/v2/library/QueryType.java b/components/src/main/java/com/constantcontact/v2/library/QueryType.java
index c758aeef..3b4fcbdc 100644
--- a/components/src/main/java/com/constantcontact/v2/library/QueryType.java
+++ b/components/src/main/java/com/constantcontact/v2/library/QueryType.java
@@ -1,7 +1,6 @@
package com.constantcontact.v2.library;
/**
- * @author woogienoogie
*/
public enum QueryType {
ALL,
diff --git a/components/src/main/java/com/constantcontact/v2/library/Thumbnail.java b/components/src/main/java/com/constantcontact/v2/library/Thumbnail.java
index efb02846..6de78132 100644
--- a/components/src/main/java/com/constantcontact/v2/library/Thumbnail.java
+++ b/components/src/main/java/com/constantcontact/v2/library/Thumbnail.java
@@ -9,7 +9,6 @@
import java.io.Serializable;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
public class Thumbnail implements Serializable {
diff --git a/components/src/main/java/com/constantcontact/v2/tracking/BaseTrackingReport.java b/components/src/main/java/com/constantcontact/v2/tracking/BaseTrackingReport.java
index b017ab16..2d8293ce 100644
--- a/components/src/main/java/com/constantcontact/v2/tracking/BaseTrackingReport.java
+++ b/components/src/main/java/com/constantcontact/v2/tracking/BaseTrackingReport.java
@@ -8,7 +8,6 @@
import java.io.Serializable;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "activity_type")
diff --git a/components/src/main/java/com/constantcontact/v2/tracking/BounceCode.java b/components/src/main/java/com/constantcontact/v2/tracking/BounceCode.java
index fcea3cb6..061c012a 100644
--- a/components/src/main/java/com/constantcontact/v2/tracking/BounceCode.java
+++ b/components/src/main/java/com/constantcontact/v2/tracking/BounceCode.java
@@ -1,7 +1,6 @@
package com.constantcontact.v2.tracking;
/**
- * @author woogienoogie
*/
public enum BounceCode {
/**
diff --git a/components/src/main/java/com/constantcontact/v2/tracking/ClickReport.java b/components/src/main/java/com/constantcontact/v2/tracking/ClickReport.java
index 48d30b0b..a30e870f 100644
--- a/components/src/main/java/com/constantcontact/v2/tracking/ClickReport.java
+++ b/components/src/main/java/com/constantcontact/v2/tracking/ClickReport.java
@@ -9,7 +9,6 @@
import java.util.Date;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "activity_type")
diff --git a/components/src/main/java/com/constantcontact/v2/tracking/ForwardReport.java b/components/src/main/java/com/constantcontact/v2/tracking/ForwardReport.java
index a4830c59..41603fe0 100644
--- a/components/src/main/java/com/constantcontact/v2/tracking/ForwardReport.java
+++ b/components/src/main/java/com/constantcontact/v2/tracking/ForwardReport.java
@@ -9,7 +9,6 @@
import java.util.Date;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "activity_type")
diff --git a/components/src/main/java/com/constantcontact/v2/tracking/OpenReport.java b/components/src/main/java/com/constantcontact/v2/tracking/OpenReport.java
index 55cb447a..4b2a95e3 100644
--- a/components/src/main/java/com/constantcontact/v2/tracking/OpenReport.java
+++ b/components/src/main/java/com/constantcontact/v2/tracking/OpenReport.java
@@ -9,7 +9,6 @@
import java.util.Date;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "activity_type")
diff --git a/components/src/main/java/com/constantcontact/v2/tracking/OptOutReport.java b/components/src/main/java/com/constantcontact/v2/tracking/OptOutReport.java
index a5f8a387..3bfa8203 100644
--- a/components/src/main/java/com/constantcontact/v2/tracking/OptOutReport.java
+++ b/components/src/main/java/com/constantcontact/v2/tracking/OptOutReport.java
@@ -9,7 +9,6 @@
import java.util.Date;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "activity_type")
diff --git a/components/src/main/java/com/constantcontact/v2/tracking/SendReport.java b/components/src/main/java/com/constantcontact/v2/tracking/SendReport.java
index 1316bfac..065938b7 100644
--- a/components/src/main/java/com/constantcontact/v2/tracking/SendReport.java
+++ b/components/src/main/java/com/constantcontact/v2/tracking/SendReport.java
@@ -8,7 +8,6 @@
import java.util.Date;
/**
- * @author woogienoogie
*/
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "activity_type")
public class SendReport extends BaseTrackingReport {
diff --git a/components/src/main/java/com/constantcontact/v2/tracking/TrackingReportType.java b/components/src/main/java/com/constantcontact/v2/tracking/TrackingReportType.java
index ed809cff..eadf7980 100644
--- a/components/src/main/java/com/constantcontact/v2/tracking/TrackingReportType.java
+++ b/components/src/main/java/com/constantcontact/v2/tracking/TrackingReportType.java
@@ -1,7 +1,6 @@
package com.constantcontact.v2.tracking;
/**
- * @author woogienoogie
*/
public enum TrackingReportType {
EMAIL_BOUNCE,
diff --git a/components/src/main/java/com/constantcontact/v2/tracking/TrackingSummary.java b/components/src/main/java/com/constantcontact/v2/tracking/TrackingSummary.java
index 6c60084a..f5a7231e 100644
--- a/components/src/main/java/com/constantcontact/v2/tracking/TrackingSummary.java
+++ b/components/src/main/java/com/constantcontact/v2/tracking/TrackingSummary.java
@@ -8,7 +8,6 @@
import java.io.Serializable;
/**
- * @author woogienoogie
*/
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
public class TrackingSummary implements Serializable {
diff --git a/components/src/main/java/com/constantcontact/v2/tracking/UnsubscribeSource.java b/components/src/main/java/com/constantcontact/v2/tracking/UnsubscribeSource.java
index 79583292..116e81a5 100644
--- a/components/src/main/java/com/constantcontact/v2/tracking/UnsubscribeSource.java
+++ b/components/src/main/java/com/constantcontact/v2/tracking/UnsubscribeSource.java
@@ -1,7 +1,6 @@
package com.constantcontact.v2.tracking;
/**
- * @author woogienoogie
*/
public enum UnsubscribeSource {
ACTION_BY_CUSTOMER,
diff --git a/components/src/test/java/com/constantcontact/v2/account/AccountAddressTest.java b/components/src/test/java/com/constantcontact/v2/account/AccountAddressTest.java
index 8e7b7ee4..18835ab6 100644
--- a/components/src/test/java/com/constantcontact/v2/account/AccountAddressTest.java
+++ b/components/src/test/java/com/constantcontact/v2/account/AccountAddressTest.java
@@ -7,7 +7,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class AccountAddressTest {
private static final String LINE1 = "742 Evergreen Terrace";
diff --git a/components/src/test/java/com/constantcontact/v2/account/AccountEmailAddressTest.java b/components/src/test/java/com/constantcontact/v2/account/AccountEmailAddressTest.java
index 73bd5844..564e48a6 100644
--- a/components/src/test/java/com/constantcontact/v2/account/AccountEmailAddressTest.java
+++ b/components/src/test/java/com/constantcontact/v2/account/AccountEmailAddressTest.java
@@ -7,7 +7,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class AccountEmailAddressTest {
private static final String EMAIL = "null@dev.net";
diff --git a/components/src/test/java/com/constantcontact/v2/account/AccountSummaryInformationTest.java b/components/src/test/java/com/constantcontact/v2/account/AccountSummaryInformationTest.java
index eed6c75e..c9395cf9 100644
--- a/components/src/test/java/com/constantcontact/v2/account/AccountSummaryInformationTest.java
+++ b/components/src/test/java/com/constantcontact/v2/account/AccountSummaryInformationTest.java
@@ -7,7 +7,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class AccountSummaryInformationTest {
private static final String EMAIL = "null@dev.net";
diff --git a/components/src/test/java/com/constantcontact/v2/campaigns/CampaignPreviewTest.java b/components/src/test/java/com/constantcontact/v2/campaigns/CampaignPreviewTest.java
index 772a00b4..ffafc9f4 100644
--- a/components/src/test/java/com/constantcontact/v2/campaigns/CampaignPreviewTest.java
+++ b/components/src/test/java/com/constantcontact/v2/campaigns/CampaignPreviewTest.java
@@ -7,7 +7,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class CampaignPreviewTest {
private static final String SUBJECT = "MY TEST EMAIL WOAH";
diff --git a/components/src/test/java/com/constantcontact/v2/campaigns/CampaignScheduleTest.java b/components/src/test/java/com/constantcontact/v2/campaigns/CampaignScheduleTest.java
index 1afb716c..6494ea75 100644
--- a/components/src/test/java/com/constantcontact/v2/campaigns/CampaignScheduleTest.java
+++ b/components/src/test/java/com/constantcontact/v2/campaigns/CampaignScheduleTest.java
@@ -9,7 +9,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class CampaignScheduleTest {
private static final String ID = "123ABC";
diff --git a/components/src/test/java/com/constantcontact/v2/campaigns/CampaignTest.java b/components/src/test/java/com/constantcontact/v2/campaigns/CampaignTest.java
index 62eae529..d3377a55 100644
--- a/components/src/test/java/com/constantcontact/v2/campaigns/CampaignTest.java
+++ b/components/src/test/java/com/constantcontact/v2/campaigns/CampaignTest.java
@@ -11,7 +11,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class CampaignTest {
private static final String ID = "123ABC";
diff --git a/components/src/test/java/com/constantcontact/v2/campaigns/ClickThroughDetailTest.java b/components/src/test/java/com/constantcontact/v2/campaigns/ClickThroughDetailTest.java
index 4981138b..1db9ee64 100644
--- a/components/src/test/java/com/constantcontact/v2/campaigns/ClickThroughDetailTest.java
+++ b/components/src/test/java/com/constantcontact/v2/campaigns/ClickThroughDetailTest.java
@@ -7,7 +7,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class ClickThroughDetailTest {
private static final int COUNT = 1;
diff --git a/components/src/test/java/com/constantcontact/v2/campaigns/MessageFooterTest.java b/components/src/test/java/com/constantcontact/v2/campaigns/MessageFooterTest.java
index 9c894bd8..cf0abf43 100644
--- a/components/src/test/java/com/constantcontact/v2/campaigns/MessageFooterTest.java
+++ b/components/src/test/java/com/constantcontact/v2/campaigns/MessageFooterTest.java
@@ -7,7 +7,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class MessageFooterTest {
private static final String LINE1 = "742 Evergreen Terrace";
diff --git a/components/src/test/java/com/constantcontact/v2/campaigns/SentToContactListTest.java b/components/src/test/java/com/constantcontact/v2/campaigns/SentToContactListTest.java
index a6542217..7f679c09 100644
--- a/components/src/test/java/com/constantcontact/v2/campaigns/SentToContactListTest.java
+++ b/components/src/test/java/com/constantcontact/v2/campaigns/SentToContactListTest.java
@@ -7,7 +7,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class SentToContactListTest {
private static final String ID = "123";
diff --git a/components/src/test/java/com/constantcontact/v2/campaigns/TestSendTest.java b/components/src/test/java/com/constantcontact/v2/campaigns/TestSendTest.java
index 49758465..1d89f61f 100644
--- a/components/src/test/java/com/constantcontact/v2/campaigns/TestSendTest.java
+++ b/components/src/test/java/com/constantcontact/v2/campaigns/TestSendTest.java
@@ -7,7 +7,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class TestSendTest {
private static final String[] EMAILS = new String[]{"null@dev.net"};
diff --git a/components/src/test/java/com/constantcontact/v2/contacts/AddressTest.java b/components/src/test/java/com/constantcontact/v2/contacts/AddressTest.java
index 225c43ac..62140a11 100644
--- a/components/src/test/java/com/constantcontact/v2/contacts/AddressTest.java
+++ b/components/src/test/java/com/constantcontact/v2/contacts/AddressTest.java
@@ -7,7 +7,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class AddressTest {
private static final String ID = "123ABC";
diff --git a/components/src/test/java/com/constantcontact/v2/contacts/ContactListMetaDataTest.java b/components/src/test/java/com/constantcontact/v2/contacts/ContactListMetaDataTest.java
index 91b47bb4..6c89be5c 100644
--- a/components/src/test/java/com/constantcontact/v2/contacts/ContactListMetaDataTest.java
+++ b/components/src/test/java/com/constantcontact/v2/contacts/ContactListMetaDataTest.java
@@ -7,7 +7,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class ContactListMetaDataTest {
private static final String ID = "123ABC";
diff --git a/components/src/test/java/com/constantcontact/v2/contacts/ContactListTest.java b/components/src/test/java/com/constantcontact/v2/contacts/ContactListTest.java
index f57c8e0c..08672ebb 100644
--- a/components/src/test/java/com/constantcontact/v2/contacts/ContactListTest.java
+++ b/components/src/test/java/com/constantcontact/v2/contacts/ContactListTest.java
@@ -9,7 +9,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class ContactListTest {
private static final String ID = "123ABC";
diff --git a/components/src/test/java/com/constantcontact/v2/contacts/ContactTest.java b/components/src/test/java/com/constantcontact/v2/contacts/ContactTest.java
index 52ca7dcb..e8fd7369 100644
--- a/components/src/test/java/com/constantcontact/v2/contacts/ContactTest.java
+++ b/components/src/test/java/com/constantcontact/v2/contacts/ContactTest.java
@@ -9,7 +9,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class ContactTest {
private static final String ID = "123ABC";
diff --git a/components/src/test/java/com/constantcontact/v2/contacts/CustomFieldTest.java b/components/src/test/java/com/constantcontact/v2/contacts/CustomFieldTest.java
index 756cb985..d981d433 100644
--- a/components/src/test/java/com/constantcontact/v2/contacts/CustomFieldTest.java
+++ b/components/src/test/java/com/constantcontact/v2/contacts/CustomFieldTest.java
@@ -7,7 +7,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class CustomFieldTest {
private static final String LABEL = "green";
diff --git a/components/src/test/java/com/constantcontact/v2/contacts/EmailAddressTest.java b/components/src/test/java/com/constantcontact/v2/contacts/EmailAddressTest.java
index 1b1bc12b..d7c5d8c1 100644
--- a/components/src/test/java/com/constantcontact/v2/contacts/EmailAddressTest.java
+++ b/components/src/test/java/com/constantcontact/v2/contacts/EmailAddressTest.java
@@ -9,7 +9,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class EmailAddressTest {
private static final String ID = "123ABC";
diff --git a/components/src/test/java/com/constantcontact/v2/contacts/NoteTest.java b/components/src/test/java/com/constantcontact/v2/contacts/NoteTest.java
index 4cd6ef91..5bf18114 100644
--- a/components/src/test/java/com/constantcontact/v2/contacts/NoteTest.java
+++ b/components/src/test/java/com/constantcontact/v2/contacts/NoteTest.java
@@ -9,7 +9,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class NoteTest {
private static final String ID = "123ABC";
diff --git a/components/src/test/java/com/constantcontact/v2/contacts/SignupFormRequestTest.java b/components/src/test/java/com/constantcontact/v2/contacts/SignupFormRequestTest.java
index dd1b1a5f..b614e348 100644
--- a/components/src/test/java/com/constantcontact/v2/contacts/SignupFormRequestTest.java
+++ b/components/src/test/java/com/constantcontact/v2/contacts/SignupFormRequestTest.java
@@ -7,7 +7,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class SignupFormRequestTest {
private static final String[] LISTS = new String[]{"123ABC"};
diff --git a/components/src/test/java/com/constantcontact/v2/contacts/SignupFormResponseTest.java b/components/src/test/java/com/constantcontact/v2/contacts/SignupFormResponseTest.java
index fd5f1b5c..52dc8ffa 100644
--- a/components/src/test/java/com/constantcontact/v2/contacts/SignupFormResponseTest.java
+++ b/components/src/test/java/com/constantcontact/v2/contacts/SignupFormResponseTest.java
@@ -7,7 +7,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class SignupFormResponseTest {
private static final String[] LISTS = new String[]{"123ABC"};
diff --git a/components/src/test/java/com/constantcontact/v2/library/FileTest.java b/components/src/test/java/com/constantcontact/v2/library/FileTest.java
index e940ff6f..7060d8fe 100644
--- a/components/src/test/java/com/constantcontact/v2/library/FileTest.java
+++ b/components/src/test/java/com/constantcontact/v2/library/FileTest.java
@@ -9,7 +9,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class FileTest {
private static final String ID = "123ABC";
diff --git a/components/src/test/java/com/constantcontact/v2/library/FileUploadStatusTest.java b/components/src/test/java/com/constantcontact/v2/library/FileUploadStatusTest.java
index c1a46219..32e56b81 100644
--- a/components/src/test/java/com/constantcontact/v2/library/FileUploadStatusTest.java
+++ b/components/src/test/java/com/constantcontact/v2/library/FileUploadStatusTest.java
@@ -7,7 +7,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class FileUploadStatusTest {
private static final long ID = 1L;
diff --git a/components/src/test/java/com/constantcontact/v2/library/FolderTest.java b/components/src/test/java/com/constantcontact/v2/library/FolderTest.java
index ad77d2fc..40bab81c 100644
--- a/components/src/test/java/com/constantcontact/v2/library/FolderTest.java
+++ b/components/src/test/java/com/constantcontact/v2/library/FolderTest.java
@@ -9,7 +9,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class FolderTest {
private static final String ID = "123ABC";
diff --git a/components/src/test/java/com/constantcontact/v2/library/LibraryInfoTest.java b/components/src/test/java/com/constantcontact/v2/library/LibraryInfoTest.java
index 62e25517..d127e7f0 100644
--- a/components/src/test/java/com/constantcontact/v2/library/LibraryInfoTest.java
+++ b/components/src/test/java/com/constantcontact/v2/library/LibraryInfoTest.java
@@ -7,7 +7,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class LibraryInfoTest {
private static final String ROOT = "rooted";
diff --git a/components/src/test/java/com/constantcontact/v2/library/ThumbnailTest.java b/components/src/test/java/com/constantcontact/v2/library/ThumbnailTest.java
index b5d1d1e7..5efe5f3f 100644
--- a/components/src/test/java/com/constantcontact/v2/library/ThumbnailTest.java
+++ b/components/src/test/java/com/constantcontact/v2/library/ThumbnailTest.java
@@ -7,7 +7,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class ThumbnailTest {
private static final String URL = "http://constantcontact.com";
diff --git a/components/src/test/java/com/constantcontact/v2/library/UsageSummaryTest.java b/components/src/test/java/com/constantcontact/v2/library/UsageSummaryTest.java
index 68d6f123..6a648481 100644
--- a/components/src/test/java/com/constantcontact/v2/library/UsageSummaryTest.java
+++ b/components/src/test/java/com/constantcontact/v2/library/UsageSummaryTest.java
@@ -7,7 +7,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class UsageSummaryTest {
private static final int DOCUMENTS_BYTES_USED = 5;
diff --git a/components/src/test/java/com/constantcontact/v2/tracking/BounceReportTest.java b/components/src/test/java/com/constantcontact/v2/tracking/BounceReportTest.java
index 72e78b05..56eb90e0 100644
--- a/components/src/test/java/com/constantcontact/v2/tracking/BounceReportTest.java
+++ b/components/src/test/java/com/constantcontact/v2/tracking/BounceReportTest.java
@@ -9,7 +9,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class BounceReportTest {
private static final String EMAIL = "null@dev.net";
diff --git a/components/src/test/java/com/constantcontact/v2/tracking/ClickReportTest.java b/components/src/test/java/com/constantcontact/v2/tracking/ClickReportTest.java
index 4e371aa7..1a0341b7 100644
--- a/components/src/test/java/com/constantcontact/v2/tracking/ClickReportTest.java
+++ b/components/src/test/java/com/constantcontact/v2/tracking/ClickReportTest.java
@@ -9,7 +9,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class ClickReportTest {
private static final String EMAIL = "null@dev.net";
diff --git a/components/src/test/java/com/constantcontact/v2/tracking/ForwardReportTest.java b/components/src/test/java/com/constantcontact/v2/tracking/ForwardReportTest.java
index 1206abdb..6fda59b5 100644
--- a/components/src/test/java/com/constantcontact/v2/tracking/ForwardReportTest.java
+++ b/components/src/test/java/com/constantcontact/v2/tracking/ForwardReportTest.java
@@ -9,7 +9,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class ForwardReportTest {
private static final String EMAIL = "null@dev.net";
diff --git a/components/src/test/java/com/constantcontact/v2/tracking/OpenReportTest.java b/components/src/test/java/com/constantcontact/v2/tracking/OpenReportTest.java
index 8cd699f6..ffaf6105 100644
--- a/components/src/test/java/com/constantcontact/v2/tracking/OpenReportTest.java
+++ b/components/src/test/java/com/constantcontact/v2/tracking/OpenReportTest.java
@@ -9,7 +9,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class OpenReportTest {
private static final String EMAIL = "null@dev.net";
diff --git a/components/src/test/java/com/constantcontact/v2/tracking/OptOutReportTest.java b/components/src/test/java/com/constantcontact/v2/tracking/OptOutReportTest.java
index 4e70b296..5ba1c534 100644
--- a/components/src/test/java/com/constantcontact/v2/tracking/OptOutReportTest.java
+++ b/components/src/test/java/com/constantcontact/v2/tracking/OptOutReportTest.java
@@ -9,7 +9,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class OptOutReportTest {
private static final String EMAIL = "null@dev.net";
diff --git a/components/src/test/java/com/constantcontact/v2/tracking/SendReportTest.java b/components/src/test/java/com/constantcontact/v2/tracking/SendReportTest.java
index 4eb09dbb..385fcf91 100644
--- a/components/src/test/java/com/constantcontact/v2/tracking/SendReportTest.java
+++ b/components/src/test/java/com/constantcontact/v2/tracking/SendReportTest.java
@@ -9,7 +9,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class SendReportTest {
private static final String EMAIL = "null@dev.net";
diff --git a/components/src/test/java/com/constantcontact/v2/tracking/TrackingSummaryTest.java b/components/src/test/java/com/constantcontact/v2/tracking/TrackingSummaryTest.java
index 542ea982..794a73de 100644
--- a/components/src/test/java/com/constantcontact/v2/tracking/TrackingSummaryTest.java
+++ b/components/src/test/java/com/constantcontact/v2/tracking/TrackingSummaryTest.java
@@ -7,7 +7,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
/**
- * @author woogienoogie
*/
public class TrackingSummaryTest {
private static final int BOUNCE_COUNT = 1;
diff --git a/gradle.properties b/gradle.properties
index 4776bb75..a575f4c6 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -2,4 +2,4 @@ org.gradle.daemon=true
VERSION_MAJOR=5
VERSION_MINOR=1
-VERSION_PATCH=3
+VERSION_PATCH=5
diff --git a/lib-rx/src/main/java/com/constantcontact/v2/AccountService.java b/lib-rx/src/main/java/com/constantcontact/v2/AccountService.java
index 8db4aad4..dcf69109 100755
--- a/lib-rx/src/main/java/com/constantcontact/v2/AccountService.java
+++ b/lib-rx/src/main/java/com/constantcontact/v2/AccountService.java
@@ -13,7 +13,6 @@
/**
* Retrofit interface for Account calls against the Constant Contact API.
*
- * @author woogienoogie
*/
public interface AccountService {
/**
diff --git a/lib-rx/src/main/java/com/constantcontact/v2/CCApi2.java b/lib-rx/src/main/java/com/constantcontact/v2/CCApi2.java
index 81636a11..c06e6503 100755
--- a/lib-rx/src/main/java/com/constantcontact/v2/CCApi2.java
+++ b/lib-rx/src/main/java/com/constantcontact/v2/CCApi2.java
@@ -1,58 +1,49 @@
package com.constantcontact.v2;
-import com.constantcontact.v2.converter.jackson.JacksonConverterFactory;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
-import java.util.concurrent.TimeUnit;
-
/**
- * @author woogienoogie
*/
public class CCApi2 {
/**
- * The correct formatting of a Date using SimpleDateFormat
+ * Deprecated. Please use {@link DefaultOkHttpClientBuilderFactory} instead.
*/
- public final static String DATE_FORMAT = "yyyy-MM-dd'T'hh:mm:ss.ss'Z'";
-
+ @Deprecated
public static OkHttpClient.Builder createDefaultOkHttpClientBuilder(final String apiKey, final String token) {
- return createDefaultOkHttpClientBuilder(apiKey, token, false);
+ DefaultOkHttpClientBuilderFactory factory = new DefaultOkHttpClientBuilderFactory();
+ return factory.create(apiKey, token);
}
+ /**
+ * Deprecated. Please use {@link DefaultOkHttpClientBuilderFactory} instead.
+ */
+ @Deprecated
public static OkHttpClient.Builder createDefaultOkHttpClientBuilder(final String apiKey, final String token,
boolean debug) {
- OkHttpClient.Builder
- builder =
- new OkHttpClient().newBuilder()
- .readTimeout(10, TimeUnit.SECONDS)
- .connectTimeout(5, TimeUnit.SECONDS)
- .addInterceptor(createDefaultInterceptor(apiKey, token));
-
- if (debug) {
- HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
- interceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
- builder.addInterceptor(interceptor);
- }
-
- return builder;
+ DefaultOkHttpClientBuilderFactory factory = new DefaultOkHttpClientBuilderFactory();
+ return factory.create(apiKey, token, debug ? HttpLoggingInterceptor.Level.BASIC : HttpLoggingInterceptor.Level.NONE);
}
+ @Deprecated
public static Interceptor createDefaultInterceptor(final String apiKey, final String token) {
return new CCApiInterceptor(apiKey, token);
}
+ /**
+ * Deprecated. Please use {@link DefaultRetrofitBuilderFactory} instead.
+ */
+ @Deprecated
public static Retrofit.Builder createDefaultRetrofitBuilder(OkHttpClient client) {
- return new Retrofit.Builder().baseUrl(BASE_URL)
- .client(client)
- .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
- .addConverterFactory(JacksonConverterFactory.create());
+ DefaultRetrofitBuilderFactory factory = new DefaultRetrofitBuilderFactory(client);
+ Retrofit.Builder builder = factory.create();
+ builder.addCallAdapterFactory(RxJavaCallAdapterFactory.create());
+ return builder;
}
- private static final String BASE_URL = "https://api.constantcontact.com/";
-
private final Retrofit _retrofit;
protected AccountService _accountService;
@@ -67,55 +58,139 @@ public static Retrofit.Builder createDefaultRetrofitBuilder(OkHttpClient client)
protected ContactTrackingService _contactTrackingService;
+ /**
+ * A convenience constructor that handles all initialization of api wrappers.
+ *
+ * @param apiKey the api key
+ * @param token the logged in user's oauth2 token
+ */
public CCApi2(final String apiKey, final String token) {
- OkHttpClient client = createDefaultOkHttpClientBuilder(apiKey, token).build();
-
- _retrofit = createDefaultRetrofitBuilder(client).build();
+ DefaultOkHttpClientBuilderFactory okHttpClientBuilderFactory = new DefaultOkHttpClientBuilderFactory();
+ OkHttpClient client = okHttpClientBuilderFactory.create(apiKey, token).build();
- _accountService = _retrofit.create(AccountService.class);
- _campaignService = _retrofit.create(CampaignService.class);
- _contactService = _retrofit.create(ContactService.class);
- _libraryService = _retrofit.create(LibraryService.class);
- _campaignTrackingService = _retrofit.create(CampaignTrackingService.class);
- _contactTrackingService = _retrofit.create(ContactTrackingService.class);
+ DefaultRetrofitBuilderFactory retrofitBuilderFactory = new DefaultRetrofitBuilderFactory(client);
+ _retrofit = retrofitBuilderFactory.create().build();
}
+ /**
+ * A simple constructor where all initialization is left up to the developer. Requires use of {@link DefaultOkHttpClientBuilderFactory}
+ * and {@link DefaultRetrofitBuilderFactory} in order to assure that the {@link Retrofit} instance is set up with
+ * the necessary minimal setup.
+ *
+ * @param retrofit an initialized instance
+ */
public CCApi2(Retrofit retrofit) {
_retrofit = retrofit;
-
- _accountService = _retrofit.create(AccountService.class);
- _campaignService = _retrofit.create(CampaignService.class);
- _contactService = _retrofit.create(ContactService.class);
- _libraryService = _retrofit.create(LibraryService.class);
- _campaignTrackingService = _retrofit.create(CampaignTrackingService.class);
- _contactTrackingService = _retrofit.create(ContactTrackingService.class);
}
+ /**
+ * Gets the rest adapter.
+ *
+ * @return the rest adapter
+ */
public Retrofit getRestAdapter() {
return _retrofit;
}
+ /**
+ * Gets the account service.
+ *
+ * @return the account service
+ */
public AccountService getAccountService() {
+ if (_accountService == null) {
+ synchronized (CCApi2.class) {
+ if (_accountService == null) {
+ _accountService = _retrofit.create(AccountService.class);
+ }
+ }
+ }
+
return _accountService;
}
+ /**
+ * Gets the campaign service.
+ *
+ * @return the campaign service
+ */
public CampaignService getCampaignService() {
+ if (_campaignService == null) {
+ synchronized (CCApi2.class) {
+ if (_campaignService == null) {
+ _campaignService = _retrofit.create(CampaignService.class);
+ }
+ }
+ }
+
return _campaignService;
}
+ /**
+ * Gets the contact service.
+ *
+ * @return the contact service
+ */
public ContactService getContactService() {
+ if (_contactService == null) {
+ synchronized (CCApi2.class) {
+ if (_contactService == null) {
+ _contactService = _retrofit.create(ContactService.class);
+ }
+ }
+ }
+
return _contactService;
}
+ /**
+ * Gets the library service.
+ *
+ * @return the library service
+ */
public LibraryService getLibraryService() {
+ if (_libraryService == null) {
+ synchronized (CCApi2.class) {
+ if (_libraryService == null) {
+ _libraryService = _retrofit.create(LibraryService.class);
+ }
+ }
+ }
+
return _libraryService;
}
+ /**
+ * Gets the campaign tracking service.
+ *
+ * @return the campaign tracking service
+ */
public CampaignTrackingService getCampaignTrackingService() {
+ if (_campaignTrackingService == null) {
+ synchronized (CCApi2.class) {
+ if (_campaignTrackingService == null) {
+ _campaignTrackingService = _retrofit.create(CampaignTrackingService.class);
+ }
+ }
+ }
+
return _campaignTrackingService;
}
+ /**
+ * Gets the contact tracking service.
+ *
+ * @return the contact tracking service
+ */
public ContactTrackingService getContactTrackingService() {
+ if (_contactTrackingService == null) {
+ synchronized (CCApi2.class) {
+ if (_contactTrackingService == null) {
+ _contactTrackingService = _retrofit.create(ContactTrackingService.class);
+ }
+ }
+ }
+
return _contactTrackingService;
}
}
diff --git a/lib-rx/src/main/java/com/constantcontact/v2/CampaignService.java b/lib-rx/src/main/java/com/constantcontact/v2/CampaignService.java
index d83fed6e..ab94b7a4 100755
--- a/lib-rx/src/main/java/com/constantcontact/v2/CampaignService.java
+++ b/lib-rx/src/main/java/com/constantcontact/v2/CampaignService.java
@@ -13,9 +13,18 @@
* See Using Email Campaigns
* on the Constant Contact Developer Website
*
- * @author woogienoogie
*/
public interface CampaignService {
+ /**
+ * The maximum page size for tracking queries.
+ */
+ int MAX_PAGE_LIMIT = 50;
+
+ /**
+ * The default page size for tracking queries.
+ */
+ int DEFAULT_PAGE_LIMIT = 50;
+
/**
* Get a {@link Campaign}
*
@@ -45,7 +54,7 @@ public interface CampaignService {
* @return an Observable that emits Paged Campaigns
*/
@GET("v2/emailmarketing/campaigns")
- Observable
* See Working With Contacts
* on the Constant Contact Developer Website
- *
- * @author woogienoogie
*/
public interface ContactService {
+ /**
+ * The maximum page size for tracking queries.
+ */
+ int MAX_PAGE_LIMIT = 500;
+
+ /**
+ * The default page size for tracking queries.
+ */
+ int DEFAULT_PAGE_LIMIT = 50;
+
/**
* Get a {@link Paged} collection of {@link Contact}
*
* @param email Email to search for
- * @return an Observable that emits Paged Contacts
+ * @return an Observable that emits Paged Contacts
*/
@GET("v2/contacts")
Observable
* See Using Email Campaigns
* on the Constant Contact Developer Website
- *
- * @author woogienoogie
*/
public interface CampaignService {
+ /**
+ * The maximum page size for tracking queries.
+ */
+ int MAX_PAGE_LIMIT = 50;
+
+ /**
+ * The default page size for tracking queries.
+ */
+ int DEFAULT_PAGE_LIMIT = 50;
+
/**
* Get a {@link Campaign}
*
* @param campaignId ID of the campaign
* @param updateSummary Set to true to ask the server to get the newest tracking info
- * @return an Observable that emits a Campaign
+ * @return an Observable that emits a Campaign
*/
@GET("v2/emailmarketing/campaigns/{campaignId}")
Call
* See Working With Contacts
* on the Constant Contact Developer Website
- *
- * @author woogienoogie
*/
public interface ContactService {
+ /**
+ * The maximum page size for tracking queries.
+ */
+ int MAX_PAGE_LIMIT = 500;
+
+ /**
+ * The default page size for tracking queries.
+ */
+ int DEFAULT_PAGE_LIMIT = 50;
+
/**
* Get a {@link Paged} collection of {@link Contact}
*
* @param email Email to search for
- * @return an Observable that emits Paged Contacts
+ * @return an Observable that emits Paged Contacts
*/
@GET("v2/contacts")
Call> getContactLists(@Query("modified_since") String date);
+ Observable
> getContactLists(@Query("modified_since") QueryDate modifiedSince);
/**
* Create a new {@link ContactList}
*
* @param contactList ContactList object (requires only name and status to create)
- * @return an Observable that emits a new ContactList object, with changes by the server, such as adding an ID
+ * @return an Observable that emits a new ContactList object, with changes by the server, such as adding an ID
*/
@POST("v2/lists")
Observable
> getCampaignSchedules(@Path("campaignId") String campaignId);
@@ -131,7 +139,7 @@ public interface CampaignService {
*
* @param campaignId ID of the Campaign
* @param scheduleId ID of the CampaignSchedule
- * @return an Observable that emits a CampaignSchedule
+ * @return an Observable that emits a CampaignSchedule
*/
@GET("v2/emailmarketing/campaigns/{campaignId}/schedules/{scheduleId}")
Call
> getContactLists(@Query("modified_since") String date);
+ Call
> getContactLists(@Query("modified_since") QueryDate modifiedSince);
/**
* Create a new {@link ContactList}
*
* @param contactList ContactList object (requires only name and status to create)
- * @return an Observable that emits a new ContactList object, with changes by the server, such as adding an ID
+ * @return an Observable that emits a new ContactList object, with changes by the server, such as adding an ID
*/
@POST("v2/lists")
Call