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> getCampaigns(@Query("limit") int limit, @Query("modified_since") String date, + Observable> getCampaigns(@Query("limit") int limit, @Query("modified_since") QueryDate date, @Query("status") CampaignStatus status); /** diff --git a/lib-rx/src/main/java/com/constantcontact/v2/CampaignTrackingService.java b/lib-rx/src/main/java/com/constantcontact/v2/CampaignTrackingService.java index 6c88afd2..1ef595a0 100755 --- a/lib-rx/src/main/java/com/constantcontact/v2/CampaignTrackingService.java +++ b/lib-rx/src/main/java/com/constantcontact/v2/CampaignTrackingService.java @@ -14,9 +14,18 @@ * See Tracking Email Campaign Results * on the Constant Contact Developer Website * - * @author woogienoogie */ public interface CampaignTrackingService { + /** + * The maximum page size for tracking queries. + */ + int MAX_PAGE_LIMIT = 500; + + /** + * The default page size for tracking queries. + */ + int DEFAULT_PAGE_LIMIT = 500; + /** * Get the {@link TrackingSummary} of a {@link Campaign} * @@ -35,7 +44,7 @@ public interface CampaignTrackingService { * @return an Observable that emits Paged BounceReports */ @GET("v2/emailmarketing/campaigns/{campaignId}/tracking/bounces") - Observable> getBounceReports(@Path("campaignId") String campaignId, @Query("created_since") String createdSinceDate, + Observable> getBounceReports(@Path("campaignId") String campaignId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** @@ -58,7 +67,7 @@ Observable> getBounceReports(@Path("campaignId") String camp * @return an Observable that emits Paged ClickReports */ @GET("v2/emailmarketing/campaigns/{campaignId}/tracking/clicks") - Observable> getClickReports(@Path("campaignId") String campaignId, @Query("created_since") String createdSinceDate, + Observable> getClickReports(@Path("campaignId") String campaignId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** @@ -73,7 +82,7 @@ Observable> getClickReports(@Path("campaignId") String campai */ @GET("v2/emailmarketing/campaigns/{campaignId}/tracking/clicks/{linkId}") Observable> getClickReports(@Path("campaignId") String campaignId, @Path("linkId") String linkId, - @Query("created_since") String createdSinceDate, @Query("limit") int limit); + @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link ClickReport} from a {@link Campaign} from a previous call's @@ -96,7 +105,7 @@ Observable> getClickReports(@Path("campaignId") String campai */ @GET("v2/emailmarketing/campaigns/{campaignId}/tracking/forwards") Observable> getForwardReports(@Path("campaignId") String campaignId, - @Query("created_since") String createdSinceDate, @Query("limit") int limit); + @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link ForwardReport} from a {@link Campaign} from a previous call's @@ -118,7 +127,7 @@ Observable> getForwardReports(@Path("campaignId") String ca * @return an Observable that emits Paged OpenReports */ @GET("v2/emailmarketing/campaigns/{campaignId}/tracking/opens") - Observable> getOpenReports(@Path("campaignId") String campaignId, @Query("created_since") String createdSinceDate, + Observable> getOpenReports(@Path("campaignId") String campaignId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** @@ -141,7 +150,7 @@ Observable> getOpenReports(@Path("campaignId") String campaign * @return an Observable that emits Paged SendReports */ @GET("v2/emailmarketing/campaigns/{campaignId}/tracking/sends") - Observable> getSendReports(@Path("campaignId") String campaignId, @Query("created_since") String createdSinceDate, + Observable> getSendReports(@Path("campaignId") String campaignId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** @@ -164,7 +173,7 @@ Observable> getSendReports(@Path("campaignId") String campaign * @return an Observable that emits Paged OptOutReports */ @GET("v2/emailmarketing/campaigns/{campaignId}/tracking/unsubscribes") - Observable> getOptOutReports(@Path("campaignId") String campaignId, @Query("created_since") String createdSinceDate, + Observable> getOptOutReports(@Path("campaignId") String campaignId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** diff --git a/lib-rx/src/main/java/com/constantcontact/v2/ContactService.java b/lib-rx/src/main/java/com/constantcontact/v2/ContactService.java index 84150f81..0f8655c2 100755 --- a/lib-rx/src/main/java/com/constantcontact/v2/ContactService.java +++ b/lib-rx/src/main/java/com/constantcontact/v2/ContactService.java @@ -12,15 +12,23 @@ *

* 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> getContactsByEmail(@Query("email") String email); @@ -30,7 +38,7 @@ public interface ContactService { * * @param limit Size of page to return (1-500) * @param status Retrieve contacts with only the chosen {@link ContactStatus} - * @return an Observable that emits Paged Contacts + * @return an Observable that emits Paged Contacts */ @GET("v2/contacts") Observable> getContacts(@Query("limit") int limit, @Query("status") ContactStatus status); @@ -41,10 +49,10 @@ public interface ContactService { * @param limit Size of page to return (1-500) * @param date Date to specify retrieval of contacts that have been modified since then, in ISO-8601 format * @param status Retrieve contacts with only the chosen {@link ContactStatus} - * @return an Observable that emits Paged Contacts + * @return an Observable that emits Paged Contacts */ @GET("v2/contacts") - Observable> getContacts(@Query("limit") int limit, @Query("modified_since") String date, + Observable> getContacts(@Query("limit") int limit, @Query("modified_since") QueryDate date, @Query("status") ContactStatus status); /** @@ -53,18 +61,18 @@ Observable> getContacts(@Query("limit") int limit, @Query("modifi * @param listId ID of the ContactList to get Contacts from * @param limit Size of page to return (1-500) * @param date Date to specify retrieval of contacts that have been modified since then, in ISO-8601 format - * @return an Observable that emits Paged Contacts + * @return an Observable that emits Paged Contacts */ @GET("v2/lists/{listId}/contacts") - Observable> getContacts(@Path("listId") String listId, @Query("limit") int limit, @Query("modified_since") String date); + Observable> getContacts(@Path("listId") String listId, @Query("limit") int limit, @Query("modified_since") QueryDate date); /** * Get a {@link Paged} collection of {@link Contact} from a previous call's * next link. * * @param nextLink Value of the path found in the meta of the original call - * @return an Observable that emits Paged Contacts - * @see Paged + * @return an Observable that emits Paged Contacts + * @see Paged */ @GET Observable> getContacts(@Url String nextLink); @@ -74,7 +82,7 @@ Observable> getContacts(@Query("limit") int limit, @Query("modifi * * @param contact Contact * @param optInSource Specify who is creating this contact with {@link OptInSource} - * @return an Observable that emits a new Contact object, with changes by the server, such as adding an ID + * @return an Observable that emits a new Contact object, with changes by the server, such as adding an ID */ @POST("v2/contacts") Observable createContact(@Body Contact contact, @Query("action_by") OptInSource optInSource); @@ -83,7 +91,7 @@ Observable> getContacts(@Query("limit") int limit, @Query("modifi * Get an individual {@link Contact} * * @param contactId Contact's ID - * @return an Observable that emits a Contact + * @return an Observable that emits a Contact */ @GET("v2/contacts/{contactId}") Observable getContact(@Path("contactId") String contactId); @@ -94,9 +102,9 @@ Observable> getContacts(@Query("limit") int limit, @Query("modifi * @param contact Contact object with updated information * @param contactId Contact's ID * @param optInSource Specify who is updating this contact with {@link OptInSource} - * @return an Observable that emits an updated Contact + * @return an Observable that emits an updated Contact */ - @PUT("v2/contacts/{contactId") + @PUT("v2/contacts/{contactId}") Observable updateContact(@Body Contact contact, @Path("contactId") String contactId, @Query("action_by") OptInSource optInSource); @@ -104,7 +112,7 @@ Observable updateContact(@Body Contact contact, @Path("contactId") Stri * Opt out an individual {@link Contact} * * @param contactId Contact's ID - * @return an Observable that emits a {@link retrofit2.Response} + * @return an Observable that emits a {@link retrofit2.Response} */ @DELETE("v2/contacts/{contactId}") Observable> unsubscribeContact(@Path("contactId") String contactId); @@ -112,17 +120,17 @@ Observable updateContact(@Body Contact contact, @Path("contactId") Stri /** * Get all {@link ContactList} in the account * - * @param date Date to specify retrieval of contact lists that have been modified since then, in ISO-8601 format - * @return an Observable that emits a List of ContactLists + * @param modifiedSince optional date to specify latest modified lists, or null for all lists + * @return an Observable that emits a list of contact lists */ @GET("v2/lists") - Observable> 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 createContactList(@Body ContactList contactList); @@ -131,7 +139,7 @@ Observable updateContact(@Body Contact contact, @Path("contactId") Stri * Get a specific {@link ContactList} * * @param listId ID of the list - * @return an Observable that emits a ContactList + * @return an Observable that emits a ContactList */ @GET("v2/lists/{listId}") Observable getContactList(@Path("listId") String listId); @@ -141,7 +149,7 @@ Observable updateContact(@Body Contact contact, @Path("contactId") Stri * * @param contactList ContactList * @param listId ID of the list - * @return an Observable that emits an updated ContactList + * @return an Observable that emits an updated ContactList */ @PUT("v2/lists/{listId}") Observable updateContactList(@Body ContactList contactList, @Path("listId") String listId); @@ -150,7 +158,7 @@ Observable updateContact(@Body Contact contact, @Path("contactId") Stri * Delete a {@link ContactList} * * @param listId ID of the list - * @return an Observable that emits a {@link retrofit2.Response} + * @return an Observable that emits a {@link retrofit2.Response} */ @DELETE("v2/lists/{listId}") Observable> deleteContactList(@Path("listId") String listId); @@ -159,8 +167,8 @@ Observable updateContact(@Body Contact contact, @Path("contactId") Stri * Create a custom signup form * * @param signupFormRequest object that contains params for the signup form - * @return an Observable that emits a signup form response - * @see Signup Form Creation + * @return an Observable that emits a signup form response + * @see Signup Form Creation */ @POST("v2/signupform") Observable createCustomSignupForm(@Body SignupFormRequest signupFormRequest); diff --git a/lib-rx/src/main/java/com/constantcontact/v2/ContactTrackingService.java b/lib-rx/src/main/java/com/constantcontact/v2/ContactTrackingService.java index 4e441982..8f73be97 100644 --- a/lib-rx/src/main/java/com/constantcontact/v2/ContactTrackingService.java +++ b/lib-rx/src/main/java/com/constantcontact/v2/ContactTrackingService.java @@ -14,9 +14,18 @@ * See Tracking Contact Results * on the Constant Contact Developer Website * - * @author woogienoogie */ public interface ContactTrackingService { + /** + * The maximum page size for tracking queries. + */ + int MAX_PAGE_LIMIT = 500; + + /** + * The default page size for tracking queries. + */ + int DEFAULT_PAGE_LIMIT = 500; + /** * Get the {@link TrackingSummary} of a {@link Contact} * @@ -35,7 +44,7 @@ public interface ContactTrackingService { * @return an Observable that emits Paged BounceReports */ @GET("v2/emailmarketing/contacts/{contactId}/tracking/bounces") - Observable> getBounceReports(@Path("contactId") String contactId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Observable> getBounceReports(@Path("contactId") String contactId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link BounceReport} from a {@link Contact} from a previous call's @@ -57,7 +66,7 @@ public interface ContactTrackingService { * @return an Observable that emits Paged ClickReports */ @GET("v2/emailmarketing/contacts/{contactId}/tracking/clicks") - Observable> getClickReports(@Path("contactId") String contactId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Observable> getClickReports(@Path("contactId") String contactId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link ClickReport} from a specific URL in a {@link Contact} @@ -70,7 +79,7 @@ public interface ContactTrackingService { * @see Contact */ @GET("v2/emailmarketing/contacts/{contactId}/tracking/clicks/{linkId}") - Observable> getClickReports(@Path("contactId") String contactId, @Path("linkId") String linkId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Observable> getClickReports(@Path("contactId") String contactId, @Path("linkId") String linkId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link ClickReport} from a {@link Contact} from a previous call's @@ -92,7 +101,7 @@ public interface ContactTrackingService { * @return an Observable that emits Paged ForwardReports */ @GET("v2/emailmarketing/contacts/{contactId}/tracking/forwards") - Observable> getForwardReports(@Path("contactId") String contactId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Observable> getForwardReports(@Path("contactId") String contactId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link ForwardReport} from a {@link Contact} from a previous call's @@ -114,7 +123,7 @@ public interface ContactTrackingService { * @return an Observable that emits Paged OpenReports */ @GET("v2/emailmarketing/contacts/{contactId}/tracking/opens") - Observable> getOpenReports(@Path("contactId") String contactId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Observable> getOpenReports(@Path("contactId") String contactId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link OpenReport} from a {@link Contact} from a previous call's @@ -136,7 +145,7 @@ public interface ContactTrackingService { * @return an Observable that emits Paged SendReports */ @GET("v2/emailmarketing/contacts/{contactId}/tracking/sends") - Observable> getSendReports(@Path("contactId") String contactId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Observable> getSendReports(@Path("contactId") String contactId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link SendReport} from a {@link Contact} from a previous call's @@ -158,7 +167,7 @@ public interface ContactTrackingService { * @return an Observable that emits Paged OptOutReports */ @GET("v2/emailmarketing/contacts/{contactId}/tracking/unsubscribes") - Observable> getOptOutReports(@Path("contactId") String contactId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Observable> getOptOutReports(@Path("contactId") String contactId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link OptOutReport} from a {@link Contact} from a previous call's @@ -180,7 +189,7 @@ public interface ContactTrackingService { * @return an Observable that emits Paged BaseTrackingReports */ @GET("v2/contacts/{contactId}/tracking") - Observable> getAllReports(@Path("contactId") String contactId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Observable> getAllReports(@Path("contactId") String contactId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link BaseTrackingReport} from a {@link Contact} from a previous call's diff --git a/lib-rx/src/main/java/com/constantcontact/v2/LibraryService.java b/lib-rx/src/main/java/com/constantcontact/v2/LibraryService.java index e5495aa2..40656c03 100755 --- a/lib-rx/src/main/java/com/constantcontact/v2/LibraryService.java +++ b/lib-rx/src/main/java/com/constantcontact/v2/LibraryService.java @@ -9,7 +9,6 @@ /** * Retrofit interface for Library Information, File, and Folder calls against the Constant Contact API * - * @author woogienoogie */ public interface LibraryService { /** diff --git a/lib-rx/src/main/java/com/constantcontact/v2/Paged.java b/lib-rx/src/main/java/com/constantcontact/v2/Paged.java index 6d6b04b5..52f5ba5c 100755 --- a/lib-rx/src/main/java/com/constantcontact/v2/Paged.java +++ b/lib-rx/src/main/java/com/constantcontact/v2/Paged.java @@ -5,7 +5,6 @@ import java.util.List; /** - * @author woogienoogie */ public class Paged { @JsonProperty("meta") diff --git a/lib/src/main/java/com/constantcontact/v2/AccountService.java b/lib/src/main/java/com/constantcontact/v2/AccountService.java index bd9e3932..3bf0273a 100644 --- a/lib/src/main/java/com/constantcontact/v2/AccountService.java +++ b/lib/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/src/main/java/com/constantcontact/v2/CCApi2.java b/lib/src/main/java/com/constantcontact/v2/CCApi2.java index 1ea3d73e..cb1d2c37 100644 --- a/lib/src/main/java/com/constantcontact/v2/CCApi2.java +++ b/lib/src/main/java/com/constantcontact/v2/CCApi2.java @@ -1,56 +1,46 @@ 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 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) - .addConverterFactory(JacksonConverterFactory.create()); + DefaultRetrofitBuilderFactory factory = new DefaultRetrofitBuilderFactory(client); + return factory.create(); } - private static final String BASE_URL = "https://api.constantcontact.com/"; - private final Retrofit _retrofit; protected AccountService _accountService; @@ -65,55 +55,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(); + DefaultOkHttpClientBuilderFactory okHttpClientBuilderFactory = new DefaultOkHttpClientBuilderFactory(); + OkHttpClient client = okHttpClientBuilderFactory.create(apiKey, token).build(); - _retrofit = createDefaultRetrofitBuilder(client).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/src/main/java/com/constantcontact/v2/CCApiInterceptor.java b/lib/src/main/java/com/constantcontact/v2/CCApiInterceptor.java deleted file mode 100644 index 0c054f49..00000000 --- a/lib/src/main/java/com/constantcontact/v2/CCApiInterceptor.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.constantcontact.v2; - -import okhttp3.HttpUrl; -import okhttp3.Interceptor; -import okhttp3.Request; -import okhttp3.Response; - -import java.io.IOException; - -class CCApiInterceptor implements Interceptor { - private final String _apiKey; - - private final String _token; - - public CCApiInterceptor(String apiKey, String token) { - _apiKey = apiKey; - _token = token; - } - - @Override - public Response intercept(Chain chain) throws IOException { - final Request originalRequest = chain.request(); - final HttpUrl originalUrl = originalRequest.url(); - - final HttpUrl newUrl = originalUrl.newBuilder().addQueryParameter("api_key", _apiKey).build(); - final Request - newRequest = - originalRequest.newBuilder() - .url(newUrl) - .addHeader("Authorization", "Bearer " + _token) - .addHeader("Content-Type", "application/json") - .addHeader("User-Agent", - "Constant Contact Java Library v5.1.1") // TODO: Add version # dynamically - .build(); - return chain.proceed(newRequest); - } - } diff --git a/lib/src/main/java/com/constantcontact/v2/CampaignService.java b/lib/src/main/java/com/constantcontact/v2/CampaignService.java index 740c05ba..5cc31734 100644 --- a/lib/src/main/java/com/constantcontact/v2/CampaignService.java +++ b/lib/src/main/java/com/constantcontact/v2/CampaignService.java @@ -12,16 +12,24 @@ *

* 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 getCampaign(@Path("campaignId") String campaignId, @Query("updateSummary") boolean updateSummary); @@ -31,7 +39,7 @@ public interface CampaignService { * * @param limit Size of page to return (1-500) * @param status {@link CampaignStatus} to filter by - * @return an Observable that emits Paged Campaigns + * @return an Observable that emits Paged Campaigns */ @GET("v2/emailmarketing/campaigns") Call> getCampaigns(@Query("limit") int limit, @Query("status") CampaignStatus status); @@ -42,16 +50,16 @@ public interface CampaignService { * @param limit Size of page to return (1-500) * @param date Date to specify retrieval of campaigns that have been modified since then, in ISO-8601 format * @param status {@link CampaignStatus} to filter by - * @return an Observable that emits Paged Campaigns + * @return an Observable that emits Paged Campaigns */ @GET("v2/emailmarketing/campaigns") - Call> getCampaigns(@Query("limit") int limit, @Query("modified_since") String date, @Query("status") CampaignStatus status); + Call> getCampaigns(@Query("limit") int limit, @Query("modified_since") QueryDate date, @Query("status") CampaignStatus status); /** * Get a {@link Paged} collection of {@link Campaign} * * @param nextLink Next link that comes from a previous campaign collection call - * @return an Observable that emits Paged Campaigns + * @return an Observable that emits Paged Campaigns */ @GET Call> getCampaigns(@Url String nextLink); @@ -60,7 +68,7 @@ public interface CampaignService { * Create a {@link Campaign} * * @param campaign Campaign - * @return an Observable that emits a Campaign + * @return an Observable that emits a Campaign */ @POST("v2/emailmarketing/campaigns") Call createCampaign(@Body Campaign campaign); @@ -70,7 +78,7 @@ public interface CampaignService { * * @param campaign Campaign * @param campaignId ID of the Campaign - * @return an Observable that emits a Campaign + * @return an Observable that emits a Campaign */ @PUT("v2/emailmarketing/campaigns/{campaignId}") Call updateCampaign(@Body Campaign campaign, @Path("campaignId") String campaignId); @@ -81,7 +89,7 @@ public interface CampaignService { * (Note: the campaign will still exist in the account, and can be restored from the website.) * * @param campaignId String - ID of the Campaign - * @return an Observable that emits a {@link retrofit2.Response} + * @return an Observable that emits a {@link retrofit2.Response} */ @DELETE("v2/emailmarketing/campaigns/{campaignId}") Call> deleteCampaign(@Path("campaignId") String campaignId); @@ -91,7 +99,7 @@ public interface CampaignService { * * @param testSend TestSend * @param campaignId ID of the Campaign - * @return an Observable that emits a TestSend + * @return an Observable that emits a TestSend */ @POST("v2/emailmarketing/campaigns/{campaignId}/tests") Call sendTestCampaign(@Body TestSend testSend, @Path("campaignId") String campaignId); @@ -100,7 +108,7 @@ public interface CampaignService { * Generate a {@link CampaignPreview} of a {@link Campaign} * * @param campaignId ID of the Campaign - * @return an Observable that emits a CampaignPreview + * @return an Observable that emits a CampaignPreview */ @GET("v2/emailmarketing/campaigns/{campaignId}/preview") Call getCampaignPreview(@Path("campaignId") String campaignId); @@ -110,7 +118,7 @@ public interface CampaignService { * * @param campaignSchedule CampaignSchedule * @param campaignId ID of the campaign - * @return an Observable that emits a CampaignSchedule + * @return an Observable that emits a CampaignSchedule */ @POST("v2/emailmarketing/campaigns/{campaignId}/schedules") Call scheduleCampaign(@Body CampaignSchedule campaignSchedule, @Path("campaignId") String campaignId); @@ -121,7 +129,7 @@ public interface CampaignService { * (Note: Only scheduled campaigns will have schedules, no historical schedules currently exist) * * @param campaignId ID of the Campaign - * @return an Observable that emits a List of CampaignSchedules + * @return an Observable that emits a List of CampaignSchedules */ @GET("v2/emailmarketing/campaigns/{campaignId}/schedules") Call> 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 getCampaignSchedule(@Path("campaignId") String campaignId, @Path("scheduleId") String scheduleId); @@ -141,7 +149,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 */ @PUT("v2/emailmarketing/campaigns/{campaignId}/schedules/{scheduleId}") Call updateCampaignSchedule(@Path("campaignId") String campaignId, @Path("scheduleId") String scheduleId); @@ -151,7 +159,7 @@ public interface CampaignService { * * @param campaignId ID of the Campaign * @param scheduleId ID of the CampaignSchedule - * @return an Observable that emits a {@link retrofit2.Response} + * @return an Observable that emits a {@link retrofit2.Response} */ @DELETE("v2/emailmarketing/campaigns/{campaignId}/schedules/{scheduleId}") Call> deleteCampaignSchedule(@Path("campaignId") String campaignId, @Path("scheduleId") String scheduleId); diff --git a/lib/src/main/java/com/constantcontact/v2/CampaignTrackingService.java b/lib/src/main/java/com/constantcontact/v2/CampaignTrackingService.java index b2c095f5..00e7e02c 100644 --- a/lib/src/main/java/com/constantcontact/v2/CampaignTrackingService.java +++ b/lib/src/main/java/com/constantcontact/v2/CampaignTrackingService.java @@ -14,9 +14,18 @@ * See Tracking Email Campaign Results * on the Constant Contact Developer Website * - * @author woogienoogie */ public interface CampaignTrackingService { + /** + * The maximum page size for tracking queries. + */ + int MAX_PAGE_LIMIT = 500; + + /** + * The default page size for tracking queries. + */ + int DEFAULT_PAGE_LIMIT = 500; + /** * Get the {@link TrackingSummary} of a {@link Campaign} * @@ -35,7 +44,7 @@ public interface CampaignTrackingService { * @return an Observable that emits Paged BounceReports */ @GET("v2/emailmarketing/campaigns/{campaignId}/tracking/bounces") - Call> getBounceReports(@Path("campaignId") String campaignId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Call> getBounceReports(@Path("campaignId") String campaignId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link BounceReport} from a {@link Campaign} from a previous call's @@ -57,7 +66,7 @@ public interface CampaignTrackingService { * @return an Observable that emits Paged ClickReports */ @GET("v2/emailmarketing/campaigns/{campaignId}/tracking/clicks") - Call> getClickReports(@Path("campaignId") String campaignId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Call> getClickReports(@Path("campaignId") String campaignId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link ClickReport} from a specific URL in a {@link Campaign} @@ -70,7 +79,7 @@ public interface CampaignTrackingService { * @see Campaign */ @GET("v2/emailmarketing/campaigns/{campaignId}/tracking/clicks/{linkId}") - Call> getClickReports(@Path("campaignId") String campaignId, @Path("linkId") String linkId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Call> getClickReports(@Path("campaignId") String campaignId, @Path("linkId") String linkId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link ClickReport} from a {@link Campaign} from a previous call's @@ -92,7 +101,7 @@ public interface CampaignTrackingService { * @return an Observable that emits Paged ForwardReports */ @GET("v2/emailmarketing/campaigns/{campaignId}/tracking/forwards") - Call> getForwardReports(@Path("campaignId") String campaignId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Call> getForwardReports(@Path("campaignId") String campaignId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link ForwardReport} from a {@link Campaign} from a previous call's @@ -114,7 +123,7 @@ public interface CampaignTrackingService { * @return an Observable that emits Paged OpenReports */ @GET("v2/emailmarketing/campaigns/{campaignId}/tracking/opens") - Call> getOpenReports(@Path("campaignId") String campaignId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Call> getOpenReports(@Path("campaignId") String campaignId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link OpenReport} from a {@link Campaign} from a previous call's @@ -136,7 +145,7 @@ public interface CampaignTrackingService { * @return an Observable that emits Paged SendReports */ @GET("v2/emailmarketing/campaigns/{campaignId}/tracking/sends") - Call> getSendReports(@Path("campaignId") String campaignId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Call> getSendReports(@Path("campaignId") String campaignId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link SendReport} from a {@link Campaign} from a previous call's @@ -158,7 +167,7 @@ public interface CampaignTrackingService { * @return an Observable that emits Paged OptOutReports */ @GET("v2/emailmarketing/campaigns/{campaignId}/tracking/unsubscribes") - Call> getOptOutReports(@Path("campaignId") String campaignId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Call> getOptOutReports(@Path("campaignId") String campaignId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link OptOutReport} from a {@link Campaign} from a previous call's @@ -180,7 +189,7 @@ public interface CampaignTrackingService { * @return an Observable that emits Paged BaseTrackingReports */ @GET("v2/emailmarketing/campaigns/{campaignId}/tracking") - Call> getAllReports(@Path("campaignId") String campaignId, @Query("created_since") String createdSinceDate, + Call> getAllReports(@Path("campaignId") String campaignId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** diff --git a/lib/src/main/java/com/constantcontact/v2/ContactService.java b/lib/src/main/java/com/constantcontact/v2/ContactService.java index 37622d4b..02bc8810 100644 --- a/lib/src/main/java/com/constantcontact/v2/ContactService.java +++ b/lib/src/main/java/com/constantcontact/v2/ContactService.java @@ -12,15 +12,23 @@ *

* 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> getContactsByEmail(@Query("email") String email); @@ -30,7 +38,7 @@ public interface ContactService { * * @param limit Size of page to return (1-500) * @param status Retrieve contacts with only the chosen {@link ContactStatus} - * @return an Observable that emits Paged Contacts + * @return an Observable that emits Paged Contacts */ @GET("v2/contacts") Call> getContacts(@Query("limit") int limit, @Query("status") ContactStatus status); @@ -41,10 +49,10 @@ public interface ContactService { * @param limit Size of page to return (1-500) * @param date Date to specify retrieval of contacts that have been modified since then, in ISO-8601 format * @param status Retrieve contacts with only the chosen {@link ContactStatus} - * @return an Observable that emits Paged Contacts + * @return an Observable that emits Paged Contacts */ @GET("v2/contacts") - Call> getContacts(@Query("limit") int limit, @Query("modified_since") String date, @Query("status") ContactStatus status); + Call> getContacts(@Query("limit") int limit, @Query("modified_since") QueryDate date, @Query("status") ContactStatus status); /** * Get a {@link Paged} collection of {@link Contact} from a specific {@link ContactList} @@ -52,18 +60,18 @@ public interface ContactService { * @param listId ID of the ContactList to get Contacts from * @param limit Size of page to return (1-500) * @param date Date to specify retrieval of contacts that have been modified since then, in ISO-8601 format - * @return an Observable that emits Paged Contacts + * @return an Observable that emits Paged Contacts */ @GET("v2/lists/{listId}/contacts") - Call> getContacts(@Path("listId") String listId, @Query("limit") int limit, @Query("modified_since") String date); + Call> getContacts(@Path("listId") String listId, @Query("limit") int limit, @Query("modified_since") QueryDate date); /** * Get a {@link Paged} collection of {@link Contact} from a previous call's * next link. * * @param nextLink Value of the path found in the meta of the original call - * @return an Observable that emits Paged Contacts - * @see Paged + * @return an Observable that emits Paged Contacts + * @see Paged */ @GET Call> getContacts(@Url String nextLink); @@ -73,7 +81,7 @@ public interface ContactService { * * @param contact Contact * @param optInSource Specify who is creating this contact with {@link OptInSource} - * @return an Observable that emits a new Contact object, with changes by the server, such as adding an ID + * @return an Observable that emits a new Contact object, with changes by the server, such as adding an ID */ @POST("v2/contacts") Call createContact(@Body Contact contact, @Query("action_by") OptInSource optInSource); @@ -82,7 +90,7 @@ public interface ContactService { * Get an individual {@link Contact} * * @param contactId Contact's ID - * @return an Observable that emits a Contact + * @return an Observable that emits a Contact */ @GET("v2/contacts/{contactId}") Call getContact(@Path("contactId") String contactId); @@ -93,16 +101,16 @@ public interface ContactService { * @param contact Contact object with updated information * @param contactId Contact's ID * @param optInSource Specify who is updating this contact with {@link OptInSource} - * @return an Observable that emits an updated Contact + * @return an Observable that emits an updated Contact */ - @PUT("v2/contacts/{contactId") + @PUT("v2/contacts/{contactId}") Call updateContact(@Body Contact contact, @Path("contactId") String contactId, @Query("action_by") OptInSource optInSource); /** * Opt out an individual {@link Contact} * * @param contactId Contact's ID - * @return an Observable that emits a {@link retrofit2.Response} + * @return an Observable that emits a {@link retrofit2.Response} */ @DELETE("v2/contacts/{contactId}") Call> unsubscribeContact(@Path("contactId") String contactId); @@ -110,17 +118,17 @@ public interface ContactService { /** * Get all {@link ContactList} in the account * - * @param date Date to specify retrieval of contact lists that have been modified since then, in ISO-8601 format - * @return an Observable that emits a List of ContactLists + * @param modifiedSince Date to specify retrieval of contact lists that have been modified since then + * @return an Observable that emits a List of ContactLists */ @GET("v2/lists") - 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 createContactList(@Body ContactList contactList); @@ -129,7 +137,7 @@ public interface ContactService { * Get a specific {@link ContactList} * * @param listId ID of the list - * @return an Observable that emits a ContactList + * @return an Observable that emits a ContactList */ @GET("v2/lists/{listId}") Call getContactList(@Path("listId") String listId); @@ -139,7 +147,7 @@ public interface ContactService { * * @param contactList ContactList * @param listId ID of the list - * @return an Observable that emits an updated ContactList + * @return an Observable that emits an updated ContactList */ @PUT("v2/lists/{listId}") Call updateContactList(@Body ContactList contactList, @Path("listId") String listId); @@ -148,7 +156,7 @@ public interface ContactService { * Delete a {@link ContactList} * * @param listId ID of the list - * @return an Observable that emits a {@link retrofit2.Response} + * @return an Observable that emits a {@link retrofit2.Response} */ @DELETE("v2/lists/{listId}") Call> deleteContactList(@Path("listId") String listId); @@ -157,8 +165,8 @@ public interface ContactService { * Create a custom signup form * * @param signupFormRequest object that contains params for the signup form - * @return an Observable that emits a signup form response - * @see Signup Form Creation + * @return an Observable that emits a signup form response + * @see Signup Form Creation */ @POST("v2/signupform") Call createCustomSignupForm(@Body SignupFormRequest signupFormRequest); diff --git a/lib/src/main/java/com/constantcontact/v2/ContactTrackingService.java b/lib/src/main/java/com/constantcontact/v2/ContactTrackingService.java index 4bf6781e..6a4756b7 100644 --- a/lib/src/main/java/com/constantcontact/v2/ContactTrackingService.java +++ b/lib/src/main/java/com/constantcontact/v2/ContactTrackingService.java @@ -14,9 +14,18 @@ * See Tracking Contact Results * on the Constant Contact Developer Website * - * @author woogienoogie */ public interface ContactTrackingService { + /** + * The maximum page size for tracking queries. + */ + int MAX_PAGE_LIMIT = 500; + + /** + * The default page size for tracking queries. + */ + int DEFAULT_PAGE_LIMIT = 500; + /** * Get the {@link TrackingSummary} of a {@link Contact} * @@ -35,7 +44,7 @@ public interface ContactTrackingService { * @return an Observable that emits Paged BounceReports */ @GET("v2/contacts/{contactId}/tracking/bounces") - Call> getBounceReports(@Path("contactId") String contactId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Call> getBounceReports(@Path("contactId") String contactId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link BounceReport} from a {@link Contact} from a previous call's @@ -57,7 +66,7 @@ public interface ContactTrackingService { * @return an Observable that emits Paged ClickReports */ @GET("v2/contacts/{contactId}/tracking/clicks") - Call> getClickReports(@Path("contactId") String contactId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Call> getClickReports(@Path("contactId") String contactId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link ClickReport} from a specific URL in a {@link Contact} @@ -70,7 +79,7 @@ public interface ContactTrackingService { * @see Contact */ @GET("v2/contacts/{contactId}/tracking/clicks/{linkId}") - Call> getClickReports(@Path("contactId") String contactId, @Path("linkId") String linkId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Call> getClickReports(@Path("contactId") String contactId, @Path("linkId") String linkId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link ClickReport} from a {@link Contact} from a previous call's @@ -92,7 +101,7 @@ public interface ContactTrackingService { * @return an Observable that emits Paged ForwardReports */ @GET("v2/contacts/{contactId}/tracking/forwards") - Call> getForwardReports(@Path("contactId") String contactId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Call> getForwardReports(@Path("contactId") String contactId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link ForwardReport} from a {@link Contact} from a previous call's @@ -114,7 +123,7 @@ public interface ContactTrackingService { * @return an Observable that emits Paged OpenReports */ @GET("v2/contacts/{contactId}/tracking/opens") - Call> getOpenReports(@Path("contactId") String contactId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Call> getOpenReports(@Path("contactId") String contactId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link OpenReport} from a {@link Contact} from a previous call's @@ -136,7 +145,7 @@ public interface ContactTrackingService { * @return an Observable that emits Paged SendReports */ @GET("v2/contacts/{contactId}/tracking/sends") - Call> getSendReports(@Path("contactId") String contactId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Call> getSendReports(@Path("contactId") String contactId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link SendReport} from a {@link Contact} from a previous call's @@ -158,7 +167,7 @@ public interface ContactTrackingService { * @return an Observable that emits Paged OptOutReports */ @GET("v2/contacts/{contactId}/tracking/unsubscribes") - Call> getOptOutReports(@Path("contactId") String contactId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Call> getOptOutReports(@Path("contactId") String contactId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link OptOutReport} from a {@link Contact} from a previous call's @@ -180,7 +189,7 @@ public interface ContactTrackingService { * @return an Observable that emits Paged BaseTrackingReports */ @GET("v2/contacts/{contactId}/tracking") - Call> getAllReports(@Path("contactId") String contactId, @Query("created_since") String createdSinceDate, @Query("limit") int limit); + Call> getAllReports(@Path("contactId") String contactId, @Query("created_since") QueryDate createdSinceDate, @Query("limit") int limit); /** * Get a {@link Paged} collection of {@link BaseTrackingReport} from a {@link Contact} from a previous call's diff --git a/lib/src/main/java/com/constantcontact/v2/LibraryService.java b/lib/src/main/java/com/constantcontact/v2/LibraryService.java index b73d4841..8e5d58c4 100644 --- a/lib/src/main/java/com/constantcontact/v2/LibraryService.java +++ b/lib/src/main/java/com/constantcontact/v2/LibraryService.java @@ -9,7 +9,6 @@ /** * Retrofit interface for Library Information, File, and Folder calls against the Constant Contact API * - * @author woogienoogie */ public interface LibraryService { /** diff --git a/lib/src/main/java/com/constantcontact/v2/Paged.java b/lib/src/main/java/com/constantcontact/v2/Paged.java index 6d6b04b5..52f5ba5c 100644 --- a/lib/src/main/java/com/constantcontact/v2/Paged.java +++ b/lib/src/main/java/com/constantcontact/v2/Paged.java @@ -5,7 +5,6 @@ import java.util.List; /** - * @author woogienoogie */ public class Paged { @JsonProperty("meta")