Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Commit

Permalink
Merge pull request #55 from csciuto/master
Browse files Browse the repository at this point in the history
v2.2.0 Changing how we handle some properties. Larger changes should be ...
  • Loading branch information
csciuto committed Mar 18, 2015
2 parents 64ef085 + df2cb36 commit b7bc175
Show file tree
Hide file tree
Showing 14 changed files with 180 additions and 391 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public <T> ResultSet<T> getPage(String accessToken, Pagination pagination, Class
return null;
}
try {
String url = paginateUrl(Config.Endpoints.BASE_URL_HOST, pagination.getNextLink(), null);
String url = paginateUrl(Config.instance().getBaseUrl(), pagination.getNextLink(), null);
if(pagination.getNextLink() == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public List<VerifiedEmailAddress> getVerifiedEmailAddresses(String accessToken,
List<VerifiedEmailAddress> addresses = new ArrayList<VerifiedEmailAddress>();
try {

String url = appendParam(Config.Endpoints.BASE_URL + String.format(Config.Endpoints.VERIFIEDEMAILADDRESSES), "status", status);
String url = appendParam(Config.instance().getBaseUrl() + String.format(Config.Endpoints.VERIFIEDEMAILADDRESSES), "status", status);
// Get REST response
CUrlResponse response = getRestClient().get(url, accessToken);
if (response.hasData()) {
Expand Down Expand Up @@ -65,7 +65,7 @@ public List<VerifiedEmailAddress> getVerifiedEmailAddresses(String accessToken,
public AccountInfo getAccountInfo(String accessToken) throws ConstantContactServiceException {
AccountInfo accountInfo = null;
try {
String url = String.format("%1$s%2$s", Config.Endpoints.BASE_URL, Config.Endpoints.ACCOUNT_INFO);
String url = String.format("%1$s%2$s", Config.instance().getBaseUrl(), Config.Endpoints.ACCOUNT_INFO);

CUrlResponse response = getRestClient().get(url, accessToken);

Expand Down Expand Up @@ -96,7 +96,7 @@ public AccountInfo getAccountInfo(String accessToken) throws ConstantContactServ
public AccountInfo updateAccountInfo(String accessToken, AccountInfo accountInfo) throws ConstantContactServiceException {
AccountInfo updatedAccountInfo = null;
try {
String url = String.format("%1$s%2$s", Config.Endpoints.BASE_URL, Config.Endpoints.ACCOUNT_INFO);
String url = String.format("%1$s%2$s", Config.instance().getBaseUrl(), Config.Endpoints.ACCOUNT_INFO);
String json = accountInfo.toJSON();

CUrlResponse response = getRestClient().put(url, accessToken, json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ContactsResponse addContacts(String accessToken, AddContactsRequest reque

ContactsResponse contactsResponse = null;
try {
String url = Config.Endpoints.BASE_URL + Config.Endpoints.ACTIVITIES_ADD_CONTACTS;
String url = Config.instance().getBaseUrl() + Config.Endpoints.ACTIVITIES_ADD_CONTACTS;
String json = request.toJSON();
CUrlResponse response = getRestClient().post(url, accessToken, json);
if (response.hasData()) {
Expand All @@ -65,7 +65,7 @@ public ContactsResponse addContacts(String accessToken, MultipartBody multipartR

ContactsResponse contactsResponse = null;
try {
String url = Config.Endpoints.BASE_URL + Config.Endpoints.ACTIVITIES_ADD_CONTACTS;
String url = Config.instance().getBaseUrl() + Config.Endpoints.ACTIVITIES_ADD_CONTACTS;
CUrlResponse response = getRestClient().postMultipart(url, accessToken, multipartRequest);
if (response.hasData()) {
contactsResponse = Component.fromJSON(response.getBody(), ContactsResponse.class);
Expand Down Expand Up @@ -94,7 +94,7 @@ public ContactsResponse addContacts(String accessToken, MultipartBody multipartR
public ContactsResponse removeContactsFromLists(String accessToken, RemoveContactsRequest request) throws ConstantContactServiceException {
ContactsResponse contactsResponse = null;
try {
String url = Config.Endpoints.BASE_URL + Config.Endpoints.ACTIVITIES_REMOVE_FROM_LISTS;
String url = Config.instance().getBaseUrl() + Config.Endpoints.ACTIVITIES_REMOVE_FROM_LISTS;
String json = request.toJSON();
CUrlResponse response = getRestClient().post(url, accessToken, json);
if (response.hasData()) {
Expand All @@ -116,7 +116,7 @@ public ContactsResponse removeContactsFromLists(String accessToken, MultipartBod

ContactsResponse contactsResponse = null;
try {
String url = Config.Endpoints.BASE_URL + Config.Endpoints.ACTIVITIES_REMOVE_FROM_LISTS;
String url = Config.instance().getBaseUrl() + Config.Endpoints.ACTIVITIES_REMOVE_FROM_LISTS;
CUrlResponse response = getRestClient().postMultipart(url, accessToken, multipartRequest);
if (response.hasData()) {
contactsResponse = Component.fromJSON(response.getBody(), ContactsResponse.class);
Expand Down Expand Up @@ -147,7 +147,7 @@ public ContactsResponse removeContactsFromLists(String accessToken, MultipartBod
public ContactsResponse clearLists(String accessToken, ClearListsRequest request) throws ConstantContactServiceException {
ContactsResponse contactsResponse = null;
try {
String url = Config.Endpoints.BASE_URL + Config.Endpoints.ACTIVITIES_CLEAR_LISTS;
String url = Config.instance().getBaseUrl() + Config.Endpoints.ACTIVITIES_CLEAR_LISTS;
String json = request.toJSON();
CUrlResponse response = getRestClient().post(url, accessToken, json);
if (response.hasData()) {
Expand Down Expand Up @@ -177,7 +177,7 @@ public ContactsResponse clearLists(String accessToken, ClearListsRequest request
public ContactsResponse exportContacts(String accessToken, ExportContactsRequest request) throws ConstantContactServiceException {
ContactsResponse contactsResponse = null;
try {
String url = Config.Endpoints.BASE_URL + Config.Endpoints.ACTIVITIES_EXPORT_CONTACTS;
String url = Config.instance().getBaseUrl() + Config.Endpoints.ACTIVITIES_EXPORT_CONTACTS;
String json = request.toJSON();
CUrlResponse response = getRestClient().post(url, accessToken, json);
if (response.hasData()) {
Expand Down Expand Up @@ -206,7 +206,7 @@ public ContactsResponse exportContacts(String accessToken, ExportContactsRequest
public List<SummaryReport> getSummaryReport(String accessToken) throws ConstantContactServiceException {
List<SummaryReport> activitiesResponse = null;
try {
String url = Config.Endpoints.BASE_URL + Config.Endpoints.ACTIVITIES;
String url = Config.instance().getBaseUrl() + Config.Endpoints.ACTIVITIES;

CUrlResponse response = getRestClient().get(url, accessToken);
if (response.hasData()) {
Expand Down Expand Up @@ -239,7 +239,7 @@ public List<DetailedStatusReport> getDetailedStatusReport(String accessToken, St

List<DetailedStatusReport> detailedStatusReports = null;

String url = Config.Endpoints.BASE_URL + Config.Endpoints.ACTIVITIES;
String url = Config.instance().getBaseUrl() + Config.Endpoints.ACTIVITIES;
try {
if (status != null && status.length() > 0) {
url = appendParam(url, "status", status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ContactListService extends BaseService implements IContactListServi
public List<ContactList> getLists(String accessToken, String modifiedSinceTimestamp) throws ConstantContactServiceException {
List<ContactList> lists = null;
try {
String url = String.format("%1$s%2$s", Config.Endpoints.BASE_URL, Config.Endpoints.LISTS);
String url = String.format("%1$s%2$s", Config.instance().getBaseUrl(), Config.Endpoints.LISTS);

if(modifiedSinceTimestamp != null)
url = appendParam(url, "modified_since", modifiedSinceTimestamp);
Expand Down Expand Up @@ -68,7 +68,7 @@ public List<ContactList> getLists(String accessToken, String modifiedSinceTimest
public ContactList addList(String accessToken, ContactList list) throws ConstantContactServiceException {
ContactList newList = null;
try {
String url = String.format("%1$s%2$s", Config.Endpoints.BASE_URL, Config.Endpoints.LISTS);
String url = String.format("%1$s%2$s", Config.instance().getBaseUrl(), Config.Endpoints.LISTS);

String json = list.toJSON();
CUrlResponse response = getRestClient().post(url, accessToken, json);
Expand Down Expand Up @@ -99,7 +99,7 @@ public ContactList addList(String accessToken, ContactList list) throws Constant
public ContactList getList(String accessToken, String listId) throws ConstantContactServiceException {
ContactList list = null;
try {
String url = String.format("%1$s%2$s", Config.Endpoints.BASE_URL, String.format(Config.Endpoints.LIST, listId));
String url = String.format("%1$s%2$s", Config.instance().getBaseUrl(), String.format(Config.Endpoints.LIST, listId));

CUrlResponse response = getRestClient().get(url, accessToken);
if (response.hasData()) {
Expand Down Expand Up @@ -130,7 +130,7 @@ public ContactList updateList(String accessToken, ContactList list) throws Const

ContactList resultingList = null;
try {
String url = String.format("%1$s%2$s", Config.Endpoints.BASE_URL, String.format(Config.Endpoints.LIST, list.getId()));
String url = String.format("%1$s%2$s", Config.instance().getBaseUrl(), String.format(Config.Endpoints.LIST, list.getId()));

String json = list.toJSON();

Expand Down Expand Up @@ -167,7 +167,7 @@ public ContactList updateList(String accessToken, ContactList list) throws Const
public ResultSet<Contact> getContactsFromList(String accessToken, String listId, Integer limit, String modifiedSinceTimestamp) throws ConstantContactServiceException {
ResultSet<Contact> contacts = null;
try {
String url = String.format("%1$s%2$s", Config.Endpoints.BASE_URL, String.format(Config.Endpoints.LIST_CONTACTS, listId));
String url = String.format("%1$s%2$s", Config.instance().getBaseUrl(), String.format(Config.Endpoints.LIST_CONTACTS, listId));
url = paginateUrl(url, limit);

if (modifiedSinceTimestamp != null) {
Expand Down Expand Up @@ -201,7 +201,7 @@ public ResultSet<Contact> getContactsFromList(String accessToken, String listId,

public boolean deleteList(String accessToken, String listId) throws ConstantContactServiceException {
try {
String url = String.format("%1$s%2$s",Config.Endpoints.BASE_URL, String.format(Config.Endpoints.LIST, listId));
String url = String.format("%1$s%2$s",Config.instance().getBaseUrl(), String.format(Config.Endpoints.LIST, listId));

CUrlResponse response = getRestClient().delete(url, accessToken);
if (response.isError()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public ResultSet<Contact> getContacts(String accessToken, Integer limit, String

try {
// Construct access URL
String url = paginateUrl(String.format("%1$s%2$s", Config.Endpoints.BASE_URL, Config.Endpoints.CONTACTS), limit);
String url = paginateUrl(String.format("%1$s%2$s", Config.instance().getBaseUrl(), Config.Endpoints.CONTACTS), limit);

if(modifiedSinceTimestamp != null) {
url = appendParam(url, "modified_since", modifiedSinceTimestamp);
Expand Down Expand Up @@ -79,7 +79,7 @@ public ResultSet<Contact> getContacts(String accessToken, Integer limit, String
public Contact getContact(String accessToken, String contactId) throws ConstantContactServiceException {
Contact contact = null;
try {
String url = String.format("%1$s%2$s", Config.Endpoints.BASE_URL, String.format(Config.Endpoints.CONTACT, contactId));
String url = String.format("%1$s%2$s", Config.instance().getBaseUrl(), String.format(Config.Endpoints.CONTACT, contactId));

CUrlResponse response = getRestClient().get(url, accessToken);
if (response.hasData()) {
Expand Down Expand Up @@ -110,7 +110,7 @@ public Contact getContact(String accessToken, String contactId) throws ConstantC
public ResultSet<Contact> getContactByEmail(String accessToken, String email) throws ConstantContactServiceException {
ResultSet<Contact> contacts = null;
try {
String url = String.format("%1$s%2$s?email=%3$s", Config.Endpoints.BASE_URL, Config.Endpoints.CONTACTS, email);
String url = String.format("%1$s%2$s?email=%3$s", Config.instance().getBaseUrl(), Config.Endpoints.CONTACTS, email);

CUrlResponse response = getRestClient().get(url, accessToken);

Expand Down Expand Up @@ -141,7 +141,7 @@ public ResultSet<Contact> getContactByEmail(String accessToken, String email) th
public Contact addContact(String accessToken, Contact contact, Boolean actionByVisitor) throws ConstantContactServiceException {
Contact newContact = null;
try {
String url = String.format("%1$s%2$s", Config.Endpoints.BASE_URL, Config.Endpoints.CONTACTS);
String url = String.format("%1$s%2$s", Config.instance().getBaseUrl(), Config.Endpoints.CONTACTS);
String json = contact.toJSON();

if(actionByVisitor == true) {
Expand Down Expand Up @@ -176,7 +176,7 @@ public Contact addContact(String accessToken, Contact contact, Boolean actionByV

public boolean deleteContact(String accessToken, String contactId) throws ConstantContactServiceException {
try {
String url = String.format("%1$s%2$s", Config.Endpoints.BASE_URL, String.format(Config.Endpoints.CONTACT, contactId));
String url = String.format("%1$s%2$s", Config.instance().getBaseUrl(), String.format(Config.Endpoints.CONTACT, contactId));

CUrlResponse response = getRestClient().delete(url, accessToken);
if (response.isError()) {
Expand Down Expand Up @@ -204,7 +204,7 @@ public boolean deleteContact(String accessToken, String contactId) throws Consta

public boolean deleteContactFromLists(String accessToken, String contactId) throws ConstantContactServiceException {
try {
String url = String.format("%1$s%2$s", Config.Endpoints.BASE_URL, String.format(Config.Endpoints.CONTACT_LISTS, contactId));
String url = String.format("%1$s%2$s", Config.instance().getBaseUrl(), String.format(Config.Endpoints.CONTACT_LISTS, contactId));
CUrlResponse response = getRestClient().delete(url, accessToken);
if (response.isError()) {
throw ConstantContactExceptionFactory.createServiceException(response, url);
Expand Down Expand Up @@ -232,7 +232,7 @@ public boolean deleteContactFromLists(String accessToken, String contactId) thro

public boolean deleteContactFromList(String accessToken, String contactId, String listId) throws ConstantContactServiceException {
try {
String url = String.format("%1$s%2$s", Config.Endpoints.BASE_URL, String.format(Config.Endpoints.CONTACT_LIST, contactId, listId));
String url = String.format("%1$s%2$s", Config.instance().getBaseUrl(), String.format(Config.Endpoints.CONTACT_LIST, contactId, listId));

CUrlResponse response = getRestClient().delete(url, accessToken);
if (response.isError()) {
Expand Down Expand Up @@ -260,7 +260,7 @@ public boolean deleteContactFromList(String accessToken, String contactId, Strin
public Contact updateContact(String accessToken, Contact contact, Boolean actionByVisitor) throws ConstantContactServiceException {
Contact updateContact = null;
try {
String url = String.format("%1$s%2$s", Config.Endpoints.BASE_URL, String.format(Config.Endpoints.CONTACT, contact.getId()));
String url = String.format("%1$s%2$s", Config.instance().getBaseUrl(), String.format(Config.Endpoints.CONTACT, contact.getId()));
String json = contact.toJSON();

if(actionByVisitor == true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class ContactTrackingService extends BaseService implements IContactTrack
public ContactTrackingSummaryReport getSummary(String accessToken, String contactId, String createdSinceTimestamp) throws ConstantContactServiceException {
ContactTrackingSummaryReport summary = null;
try {
String url = String.format("%1$s%2$s", Config.Endpoints.BASE_URL, String.format(Config.Endpoints.CONTACTS_TRACKING_REPORTS_SUMMARY, contactId));
String url = String.format("%1$s%2$s", Config.instance().getBaseUrl(), String.format(Config.Endpoints.CONTACTS_TRACKING_REPORTS_SUMMARY, contactId));

if (createdSinceTimestamp != null) {
url = appendParam(url,"created_since", createdSinceTimestamp);
Expand Down Expand Up @@ -78,7 +78,7 @@ public List<ContactTrackingSummaryByCampaignReport> getSummaryByCampaign(String

try {
StringBuilder sb = new StringBuilder();
sb.append(Config.Endpoints.BASE_URL).append(String.format(Config.Endpoints.CONTACTS_TRACKING_REPORTS_BY_CAMPAIGN_SUMMARY, contactId));
sb.append(Config.instance().getBaseUrl()).append(String.format(Config.Endpoints.CONTACTS_TRACKING_REPORTS_BY_CAMPAIGN_SUMMARY, contactId));

String url = sb.toString();

Expand Down Expand Up @@ -114,7 +114,7 @@ public ResultSet<? extends TrackingContactsBase> getActivities(String accessToke

try {
StringBuilder sb = new StringBuilder();
sb.append(Config.Endpoints.BASE_URL).append(String.format(Config.Endpoints.CONTACTS_TRACKING_ALL, contactId));
sb.append(Config.instance().getBaseUrl()).append(String.format(Config.Endpoints.CONTACTS_TRACKING_ALL, contactId));

if (limit != null) {
sb.append("?limit=").append(limit);
Expand Down Expand Up @@ -157,7 +157,7 @@ public ResultSet<ContactTrackingBounce> getBounces(String accessToken, String co
ResultSet<ContactTrackingBounce> bounces = null;
try {
StringBuilder sb = new StringBuilder();
sb.append(Config.Endpoints.BASE_URL).append(String.format(Config.Endpoints.CONTACTS_TRACKING_BOUNCES, contactId));
sb.append(Config.instance().getBaseUrl()).append(String.format(Config.Endpoints.CONTACTS_TRACKING_BOUNCES, contactId));

if (limit != null) {
sb.append("?limit=").append(limit);
Expand Down Expand Up @@ -197,7 +197,7 @@ public ResultSet<ContactTrackingClick> getClicks(String accessToken, String cont
ResultSet<ContactTrackingClick> clicks = null;
try {
StringBuilder sb = new StringBuilder();
sb.append(Config.Endpoints.BASE_URL).append(String.format(Config.Endpoints.CONTACTS_TRACKING_CLICKS, contactId));
sb.append(Config.instance().getBaseUrl()).append(String.format(Config.Endpoints.CONTACTS_TRACKING_CLICKS, contactId));

if (limit != null) {
sb.append("?limit=").append(limit);
Expand Down Expand Up @@ -241,7 +241,7 @@ public ResultSet<ContactTrackingForward> getForwards(String accessToken, String
ResultSet<ContactTrackingForward> forwards = null;
try {
StringBuilder sb = new StringBuilder();
sb.append(Config.Endpoints.BASE_URL).append(String.format(Config.Endpoints.CONTACTS_TRACKING_FORWARDS, contactId));
sb.append(Config.instance().getBaseUrl()).append(String.format(Config.Endpoints.CONTACTS_TRACKING_FORWARDS, contactId));

if (limit != null) {
sb.append("?limit=").append(limit);
Expand Down Expand Up @@ -286,7 +286,7 @@ public ResultSet<ContactTrackingOpen> getOpens(String accessToken, String contac
ResultSet<ContactTrackingOpen> opens = null;
try {
StringBuilder sb = new StringBuilder();
sb.append(Config.Endpoints.BASE_URL).append(String.format(Config.Endpoints.CONTACTS_TRACKING_OPENS, contactId));
sb.append(Config.instance().getBaseUrl()).append(String.format(Config.Endpoints.CONTACTS_TRACKING_OPENS, contactId));

if (limit != null) {
sb.append("?limit=").append(limit);
Expand Down Expand Up @@ -331,7 +331,7 @@ public ResultSet<ContactTrackingSend> getSends(String accessToken, String contac
ResultSet<ContactTrackingSend> sends = null;
try {
StringBuilder sb = new StringBuilder();
sb.append(Config.Endpoints.BASE_URL).append(String.format(Config.Endpoints.CONTACTS_TRACKING_SENDS, contactId));
sb.append(Config.instance().getBaseUrl()).append(String.format(Config.Endpoints.CONTACTS_TRACKING_SENDS, contactId));

if (limit != null) {
sb.append("?limit=").append(limit);
Expand Down Expand Up @@ -377,7 +377,7 @@ public ResultSet<ContactTrackingUnsubscribe> getUnsubscribes(String accessToken,
ResultSet<ContactTrackingUnsubscribe> unsubscribes = null;
try {
StringBuilder sb = new StringBuilder();
sb.append(Config.Endpoints.BASE_URL).append(String.format(Config.Endpoints.CONTACTS_TRACKING_UNSUBSCRIBES, contactId));
sb.append(Config.instance().getBaseUrl()).append(String.format(Config.Endpoints.CONTACTS_TRACKING_UNSUBSCRIBES, contactId));

if (limit != null) {
sb.append("?limit=").append(limit);
Expand Down
Loading

0 comments on commit b7bc175

Please sign in to comment.