From 8bb27a9164ac3340544c7ded3fcba7ee9cac34ee Mon Sep 17 00:00:00 2001 From: Gyuri Grell Date: Thu, 12 Jan 2017 09:45:36 -0500 Subject: [PATCH] Updated queries to use the new QueryDate to assure correct date formats --- .../com/constantcontact/v2/QueryDate.java | 29 ++++++++++ .../jackson/JacksonConverterFactory.java | 6 ++- .../java/com/constantcontact/v2/CCApi2.java | 6 --- .../constantcontact/v2/CampaignService.java | 12 ++++- .../v2/CampaignTrackingService.java | 24 ++++++--- .../constantcontact/v2/ContactService.java | 53 +++++++++++-------- .../v2/ContactTrackingService.java | 26 ++++++--- .../java/com/constantcontact/v2/CCApi2.java | 6 --- .../constantcontact/v2/CampaignService.java | 41 ++++++++------ .../v2/CampaignTrackingService.java | 26 ++++++--- .../constantcontact/v2/ContactService.java | 53 +++++++++++-------- .../v2/ContactTrackingService.java | 26 ++++++--- 12 files changed, 202 insertions(+), 106 deletions(-) create mode 100644 components/src/main/java/com/constantcontact/v2/QueryDate.java 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/converter/jackson/JacksonConverterFactory.java b/components/src/main/java/com/constantcontact/v2/converter/jackson/JacksonConverterFactory.java index e9b53e81..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 @@ -16,7 +16,9 @@ * The converter factory used for Jackson JSON conversion */ public class JacksonConverterFactory extends Converter.Factory { - private final static String DATE_FORMAT = "yyyy-MM-dd'T'hh:mm:ss.ss'Z'"; + 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", @@ -66,7 +68,7 @@ private JacksonConverterFactory(ObjectMapper mapper) { } this.mapper = mapper; mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).disable(SerializationFeature.WRITE_DATE_KEYS_AS_TIMESTAMPS); - mapper.getSerializationConfig().with(new SimpleDateFormat(DATE_FORMAT)); + 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/lib-rx/src/main/java/com/constantcontact/v2/CCApi2.java b/lib-rx/src/main/java/com/constantcontact/v2/CCApi2.java index 946c0f30..c06e6503 100755 --- a/lib-rx/src/main/java/com/constantcontact/v2/CCApi2.java +++ b/lib-rx/src/main/java/com/constantcontact/v2/CCApi2.java @@ -9,12 +9,6 @@ /** */ public class CCApi2 { - /** - * Deprecated. The correct formatting of a Date using SimpleDateFormat - */ - @Deprecated - public final static String DATE_FORMAT = "yyyy-MM-dd'T'hh:mm:ss.ss'Z'"; - /** * Deprecated. Please use {@link DefaultOkHttpClientBuilderFactory} instead. */ 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 46064e0c..ab94b7a4 100755 --- a/lib-rx/src/main/java/com/constantcontact/v2/CampaignService.java +++ b/lib-rx/src/main/java/com/constantcontact/v2/CampaignService.java @@ -15,6 +15,16 @@ * */ 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} * @@ -44,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 8eb13404..1ef595a0 100755 --- a/lib-rx/src/main/java/com/constantcontact/v2/CampaignTrackingService.java +++ b/lib-rx/src/main/java/com/constantcontact/v2/CampaignTrackingService.java @@ -16,6 +16,16 @@ * */ 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} * @@ -34,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); /** @@ -57,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); /** @@ -72,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 @@ -95,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 @@ -117,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); /** @@ -140,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); /** @@ -163,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 c09e0748..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,14 +12,23 @@ *

* See Working With Contacts * on the Constant Contact Developer Website - * */ 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); @@ -29,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); @@ -40,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); /** @@ -52,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); @@ -73,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); @@ -82,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); @@ -93,7 +102,7 @@ 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}") Observable updateContact(@Body Contact contact, @Path("contactId") String contactId, @@ -103,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); @@ -111,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); @@ -130,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); @@ -140,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); @@ -149,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); @@ -158,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 f7350bcd..8f73be97 100644 --- a/lib-rx/src/main/java/com/constantcontact/v2/ContactTrackingService.java +++ b/lib-rx/src/main/java/com/constantcontact/v2/ContactTrackingService.java @@ -16,6 +16,16 @@ * */ 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} * @@ -34,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 @@ -56,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} @@ -69,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 @@ -91,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 @@ -113,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 @@ -135,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 @@ -157,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 @@ -179,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/src/main/java/com/constantcontact/v2/CCApi2.java b/lib/src/main/java/com/constantcontact/v2/CCApi2.java index 325293a9..cb1d2c37 100644 --- a/lib/src/main/java/com/constantcontact/v2/CCApi2.java +++ b/lib/src/main/java/com/constantcontact/v2/CCApi2.java @@ -8,12 +8,6 @@ /** */ public class CCApi2 { - /** - * The correct formatting of a Date using SimpleDateFormat - */ - @Deprecated - public final static String DATE_FORMAT = "yyyy-MM-dd'T'hh:mm:ss.ss'Z'"; - /** * Deprecated. Please use {@link DefaultOkHttpClientBuilderFactory} instead. */ diff --git a/lib/src/main/java/com/constantcontact/v2/CampaignService.java b/lib/src/main/java/com/constantcontact/v2/CampaignService.java index 179c8fc4..5cc31734 100644 --- a/lib/src/main/java/com/constantcontact/v2/CampaignService.java +++ b/lib/src/main/java/com/constantcontact/v2/CampaignService.java @@ -12,15 +12,24 @@ *

* See Using Email Campaigns * on the Constant Contact Developer Website - * */ 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); @@ -30,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); @@ -41,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); @@ -59,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); @@ -69,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); @@ -80,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); @@ -90,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); @@ -99,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); @@ -109,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); @@ -120,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); @@ -130,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); @@ -140,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); @@ -150,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 c43f2b01..00e7e02c 100644 --- a/lib/src/main/java/com/constantcontact/v2/CampaignTrackingService.java +++ b/lib/src/main/java/com/constantcontact/v2/CampaignTrackingService.java @@ -16,6 +16,16 @@ * */ 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} * @@ -34,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 @@ -56,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} @@ -69,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 @@ -91,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 @@ -113,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 @@ -135,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 @@ -157,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 @@ -179,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 4535d2b6..02bc8810 100644 --- a/lib/src/main/java/com/constantcontact/v2/ContactService.java +++ b/lib/src/main/java/com/constantcontact/v2/ContactService.java @@ -12,14 +12,23 @@ *

* See Working With Contacts * on the Constant Contact Developer Website - * */ 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); @@ -29,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); @@ -40,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} @@ -51,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); @@ -72,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); @@ -81,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); @@ -92,7 +101,7 @@ 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}") Call updateContact(@Body Contact contact, @Path("contactId") String contactId, @Query("action_by") OptInSource optInSource); @@ -101,7 +110,7 @@ public interface ContactService { * 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); @@ -109,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); @@ -128,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); @@ -138,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); @@ -147,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); @@ -156,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 6d9cbd27..6a4756b7 100644 --- a/lib/src/main/java/com/constantcontact/v2/ContactTrackingService.java +++ b/lib/src/main/java/com/constantcontact/v2/ContactTrackingService.java @@ -16,6 +16,16 @@ * */ 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} * @@ -34,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 @@ -56,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} @@ -69,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 @@ -91,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 @@ -113,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 @@ -135,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 @@ -157,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 @@ -179,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