diff --git a/.gitignore b/.gitignore index 2a53469..8b18226 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,13 @@ target/ **/*.iml **/.idea bin/ + +mailjimp-core/src/test/resources/mailjimp-test.properties + +mailjimp-core/src/test/resources/mailjimp.properties + +.project + +.settings/org.eclipse.core.resources.prefs + +.settings/org.eclipse.m2e.core.prefs diff --git a/README.markdown b/README.markdown index 618481a..8624fd1 100644 --- a/README.markdown +++ b/README.markdown @@ -2,6 +2,10 @@ #### About +This fork is adapted from the original. My goal is to add in some missing service calls surrounding templates and campaigns. + +#### Original About. + MailJimp is a MailChimp library built in Java intended for use within Maven-enabled Spring-based applications. MailJimp was tested against version 1.3 of the MailChimp API though most of the methods will work with version 1.2. (But I really don't know why you would use it ;) The Maven part is not mandatory, of course - feel free to download the source and build yourself the library. The Spring part is also not mandatory, as long as you deploy the library in a container that understands the `@PostConstruct` annotation, or you manually invoke `MailJimpService::init()` after construction. diff --git a/mailjimp-core/pom.xml b/mailjimp-core/pom.xml index db7f441..4dca859 100644 --- a/mailjimp-core/pom.xml +++ b/mailjimp-core/pom.xml @@ -4,7 +4,7 @@ MailChimp Java API - Core Components - net.mailjimp + ca.morningstar.mailjimp mailjimp-parent 0.4-SNAPSHOT @@ -60,4 +60,5 @@ 2.1 + ca.morningstar.mailjimp diff --git a/mailjimp-core/src/main/java/mailjimp/dom/MailJimpConstants.java b/mailjimp-core/src/main/java/mailjimp/dom/MailJimpConstants.java index 1b3f6eb..b6bbc52 100644 --- a/mailjimp-core/src/main/java/mailjimp/dom/MailJimpConstants.java +++ b/mailjimp-core/src/main/java/mailjimp/dom/MailJimpConstants.java @@ -32,4 +32,23 @@ public interface MailJimpConstants extends Serializable { String MERGE_EMAIL_TYPE = "EMAIL_TYPE"; String MERGE_GROUPINGS = "GROUPINGS"; String MERGE_GROUPS = "groups"; + + // Campaign Consts + + final String CAMPAIGNTYPE_REGULAR = "regular"; + final String CAMPAIGNTYPE_PLAINTEXT = "plaintext"; + final String CAMPAIGNTYPE_ABSPLIT = "absplit"; + final String CAMPAIGNTYPE_RSS = "rss"; + final String CAMPAIGNTYPE_AUTO = "auto"; + + final String CAMPAIGNSTATUS_SENT = "sent"; + final String CAMPAIGNSTATUS_SAVE = "save"; + final String CAMPAIGNSTATUS_PAUSED = "paused"; + final String CAMPAIGNSTATUS_SCHEDULE = "schedule"; + final String CAMPAIGNSTATUS_SENDING = "sending"; + + final String CAMPAIGNMEMBER_STATUS_SENT = "sent"; + final String CAMPAIGNMEMBER_STATUS_HARDBOUNCE = "hard"; + final String CAMPAIGNMEMBER_STATUS_SOFTBOUNCE = "soft"; + final String CAMPAIGNMEMBER_STATUS_ALL = ""; } \ No newline at end of file diff --git a/mailjimp-core/src/main/java/mailjimp/dom/request/MailJimpRequest.java b/mailjimp-core/src/main/java/mailjimp/dom/request/MailJimpRequest.java index 3c1c415..01de0bb 100644 --- a/mailjimp-core/src/main/java/mailjimp/dom/request/MailJimpRequest.java +++ b/mailjimp-core/src/main/java/mailjimp/dom/request/MailJimpRequest.java @@ -20,7 +20,7 @@ import java.io.Serializable; public abstract class MailJimpRequest implements Serializable { - protected String apikey; +protected String apikey; protected MailJimpRequest(String apikey) { this.apikey = apikey; diff --git a/mailjimp-core/src/main/java/mailjimp/dom/request/NamedBoolean.java b/mailjimp-core/src/main/java/mailjimp/dom/request/NamedBoolean.java new file mode 100644 index 0000000..bdd1a61 --- /dev/null +++ b/mailjimp-core/src/main/java/mailjimp/dom/request/NamedBoolean.java @@ -0,0 +1,54 @@ +/* + * Copyright 2011 Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ + +package mailjimp.dom.request; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class NamedBoolean { + + @JsonProperty + private String name; + + @JsonProperty + private Boolean value; + + public NamedBoolean(String name, Boolean value) + { + this.name = name; + this.value = value; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Boolean getValue() { + return value; + } + + public void setValue(Boolean value) { + this.value = value; + } + + +} diff --git a/mailjimp-core/src/main/java/mailjimp/dom/request/campaign/CampaignCreateRequest.java b/mailjimp-core/src/main/java/mailjimp/dom/request/campaign/CampaignCreateRequest.java new file mode 100644 index 0000000..442a20f --- /dev/null +++ b/mailjimp-core/src/main/java/mailjimp/dom/request/campaign/CampaignCreateRequest.java @@ -0,0 +1,117 @@ +/* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ +package mailjimp.dom.request.campaign; + +import java.util.HashMap; + +import mailjimp.dom.request.MailJimpRequest; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class CampaignCreateRequest extends MailJimpRequest { + + @JsonProperty + private String type; + + @JsonProperty + HashMap options; + + @JsonProperty + HashMap content; + + + public CampaignCreateRequest(String apikey, String type, HashMap options,HashMap content) { + super(apikey); + + this.type = type; + this.options = options; + this.content = content; + } + + static public HashMap buildOptions(String listId, String campaignName, String subject, String fromEmail, String fromName, String toName, String googleUA) + { + HashMap options = new HashMap(); + + options.put("list_id", listId); + options.put("title", campaignName); + options.put("subject", subject); + options.put("from_email",fromEmail); + options.put("from_name",fromName); + options.put("to_name",toName); + + if (googleUA != null) + { + HashMap googleua = new HashMap(1); + googleua.put("google", googleUA); + options.put("analytics", googleua); + } + + return options; + } + + static public HashMap buildContentFromString(String html, String text) + { + HashMap content = new HashMap(); + content.put("html", html); + content.put("text", text); + return content; + + } + + static public HashMap buildContentFromUrl(String url) + { + HashMap content = new HashMap(); + content.put("url", url); + return content; + } + + static public HashMap buildContentFromArchive(String archiveBase64, String archiveType) + { + HashMap content = new HashMap(); + content.put("archive", archiveBase64); + content.put("archive_type", archiveType); + return content; + } + + + + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public HashMap getOptions() { + return options; + } + + public void setOptions(HashMap options) { + this.options = options; + } + + public HashMap getContent() { + return content; + } + + public void setContent(HashMap content) { + this.content = content; + } +} \ No newline at end of file diff --git a/mailjimp-core/src/main/java/mailjimp/dom/request/campaign/CampaignDeleteRequest.java b/mailjimp-core/src/main/java/mailjimp/dom/request/campaign/CampaignDeleteRequest.java new file mode 100644 index 0000000..bfb6668 --- /dev/null +++ b/mailjimp-core/src/main/java/mailjimp/dom/request/campaign/CampaignDeleteRequest.java @@ -0,0 +1,44 @@ +/* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ +package mailjimp.dom.request.campaign; + +import mailjimp.dom.request.MailJimpRequest; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class CampaignDeleteRequest extends MailJimpRequest { + + + @JsonProperty("cid") + private String campaignId; + + public CampaignDeleteRequest(String apikey, String campaignId) { + super(apikey); + this.campaignId = campaignId; + + } + + public String getCampaignId() { + return campaignId; + } + + public void setCampaignId(String campaignId) { + this.campaignId = campaignId; + } + +} \ No newline at end of file diff --git a/mailjimp-core/src/main/java/mailjimp/dom/request/campaign/CampaignListRequest.java b/mailjimp-core/src/main/java/mailjimp/dom/request/campaign/CampaignListRequest.java new file mode 100644 index 0000000..2914b50 --- /dev/null +++ b/mailjimp-core/src/main/java/mailjimp/dom/request/campaign/CampaignListRequest.java @@ -0,0 +1,135 @@ + /* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ + package mailjimp.dom.request.campaign; + + import java.util.Date; + import java.util.HashMap; + import java.util.Locale; + import java.util.TimeZone; + + import mailjimp.dom.request.MailJimpRequest; + + import org.codehaus.jackson.annotate.JsonProperty; + import org.springframework.format.datetime.DateFormatter; + + public class CampaignListRequest extends MailJimpRequest { + + @JsonProperty + private int start; + + @JsonProperty + private int limit; + + @JsonProperty + HashMap filters; + + //TODO //TMG MailJimpConstant uses SimpleDateFormat, perhaps I should drop this and use that. + static DateFormatter df = null; + + + public CampaignListRequest(String apikey, HashMap filters, int start, int limit) { + super(apikey); + this.filters = filters; + this.start = start; + this.limit = limit; + + if (df == null) + { + df = new DateFormatter("yyyy-MM-dd HH:mm:ss"); + df.setTimeZone(TimeZone.getTimeZone("GMT")); + } + } + + static public HashMap buildFilters(String campaignId, String listId, Integer folderId, Integer templateId, String status, + String type, String fromName, String fromEmail, String title, String subject, Date sendTimeStart, Date sendTimeEnd, Boolean exact) + { + HashMap options = new HashMap(); + + if (campaignId != null) + options.put("campaign_id", campaignId); + + if (listId != null) + options.put("list_id", listId); + + if (folderId != 0) + options.put("folderId", (int) folderId); + + if (templateId != null) + options.put("template_id", templateId); + + + if (status != null) + options.put("status", status); + + if (type != null) + options.put("type", type); + + if (fromName != null) + options.put("from_name", fromName); + + if (fromEmail!= null) + options.put("from_email", fromEmail); + + if (title != null) + options.put("title", title); + + if (subject != null) + options.put("subject", subject); + + if (sendTimeStart != null) + options.put("sendtime_start", df.print(sendTimeStart, Locale.US)); + + if (sendTimeEnd != null) + options.put("sendtime_end", df.print(sendTimeStart, Locale.US)); + + if (exact != null) + options.put("exact", (boolean) exact); + + return options; + } + + + + + + + + public int getStart() { + return start; + } + + public void setStart(int start) { + this.start = start; + } + + public int getLimit() { + return limit; + } + + public void setLimit(int limit) { + this.limit = limit; + } + + public HashMap getFilters() { + return filters; + } + + public void setFilters(HashMap filters) { + this.filters = filters; + } + } diff --git a/mailjimp-core/src/main/java/mailjimp/dom/request/campaign/CampaignMembersRequest.java b/mailjimp-core/src/main/java/mailjimp/dom/request/campaign/CampaignMembersRequest.java new file mode 100644 index 0000000..e0b1590 --- /dev/null +++ b/mailjimp-core/src/main/java/mailjimp/dom/request/campaign/CampaignMembersRequest.java @@ -0,0 +1,90 @@ + /* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ + package mailjimp.dom.request.campaign; + + import mailjimp.dom.request.MailJimpRequest; + +import org.codehaus.jackson.annotate.JsonProperty; + + public class CampaignMembersRequest extends MailJimpRequest { + + @JsonProperty("cid") + String campaignId; + + @JsonProperty + private int start; + + @JsonProperty + private int limit; + + @JsonProperty + String status; + + public CampaignMembersRequest(String apikey, String campaignId, String status, int start, int limit) { + super(apikey); + this.start = start; + this.limit = limit; + this.campaignId = campaignId; + this.status = status; + } + + + + + + + public String getCampaignId() { + return campaignId; + } + + + public void setCampaignId(String campaignId) { + this.campaignId = campaignId; + } + + + public int getStart() { + return start; + } + + + public void setStart(int start) { + this.start = start; + } + + + public int getLimit() { + return limit; + } + + + public void setLimit(int limit) { + this.limit = limit; + } + + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + + } diff --git a/mailjimp-core/src/main/java/mailjimp/dom/request/list/ListBatchSubscribeRequestWithVars.java b/mailjimp-core/src/main/java/mailjimp/dom/request/list/ListBatchSubscribeRequestWithVars.java new file mode 100644 index 0000000..f2bb5a2 --- /dev/null +++ b/mailjimp-core/src/main/java/mailjimp/dom/request/list/ListBatchSubscribeRequestWithVars.java @@ -0,0 +1,109 @@ +/* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ +package mailjimp.dom.request.list; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import mailjimp.dom.MailJimpConstants; +import mailjimp.dom.request.MailJimpRequest; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ListBatchSubscribeRequestWithVars extends MailJimpRequest { + @JsonProperty("id") + private String listId; + + private List> batch; + + @JsonProperty("double_optin") + private boolean doubleOptin; + + @JsonProperty("update_existing") + private boolean updateExisting; + + @JsonProperty("replace_interests") + private boolean replaceInterests; + + public ListBatchSubscribeRequestWithVars(String apikey, String listId, List batch, boolean doubleOptin, boolean updateExisting, boolean replaceInterests) { + super(apikey); + this.listId = listId; + this.doubleOptin = doubleOptin; + this.updateExisting = updateExisting; + this.replaceInterests = replaceInterests; + + this.batch = new ArrayList>(batch.size()); + for (ListBatchSubscribeStructWithVars v : batch) + { + HashMap data = new HashMap(); + + data.put(MailJimpConstants.MERGE_EMAIL, v.getEmailAddress()); + data.put(MailJimpConstants.MERGE_EMAIL_TYPE, v.getEmailType()); + data.put(MailJimpConstants.MERGE_FNAME, v.getFirstName()); + data.put(MailJimpConstants.MERGE_LNAME, v.getLastName()); + + data.putAll(v.getMergeVars()); + + this.batch.add(data); + } + } + + public String getListId() { + return listId; + } + + public void setListId(String listId) { + this.listId = listId; + } + + + + public boolean isDoubleOptin() { + return doubleOptin; + } + + public void setDoubleOptin(boolean doubleOptin) { + this.doubleOptin = doubleOptin; + } + + public boolean isUpdateExisting() { + return updateExisting; + } + + public void setUpdateExisting(boolean updateExisting) { + this.updateExisting = updateExisting; + } + + public boolean isReplaceInterests() { + return replaceInterests; + } + + public void setReplaceInterests(boolean replaceInterests) { + this.replaceInterests = replaceInterests; + } + +public List> getBatch() { + return batch; +} + +public void setBatch(List> batch) { + this.batch = batch; +} +} \ No newline at end of file diff --git a/mailjimp-core/src/main/java/mailjimp/dom/request/list/ListBatchSubscribeStruct.java b/mailjimp-core/src/main/java/mailjimp/dom/request/list/ListBatchSubscribeStruct.java index 43629ed..97a1b85 100644 --- a/mailjimp-core/src/main/java/mailjimp/dom/request/list/ListBatchSubscribeStruct.java +++ b/mailjimp-core/src/main/java/mailjimp/dom/request/list/ListBatchSubscribeStruct.java @@ -13,6 +13,12 @@ public class ListBatchSubscribeStruct implements Serializable { @JsonProperty("EMAIL_TYPE") private EmailType emailType; + @JsonProperty("FNAME") + private String firstName; + + @JsonProperty("LNAME") + private String lastName; + public ListBatchSubscribeStruct() { // empty } @@ -38,4 +44,21 @@ public EmailType getEmailType() { public void setEmailType(EmailType emailType) { this.emailType = emailType; } + + +public String getFirstName() { + return firstName; +} + +public void setFirstName(String firstName) { + this.firstName = firstName; +} + +public String getLastName() { + return lastName; +} + +public void setLastName(String lastName) { + this.lastName = lastName; +} } diff --git a/mailjimp-core/src/main/java/mailjimp/dom/request/list/ListBatchSubscribeStructWithVars.java b/mailjimp-core/src/main/java/mailjimp/dom/request/list/ListBatchSubscribeStructWithVars.java new file mode 100644 index 0000000..eff5ff3 --- /dev/null +++ b/mailjimp-core/src/main/java/mailjimp/dom/request/list/ListBatchSubscribeStructWithVars.java @@ -0,0 +1,46 @@ +/* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ +package mailjimp.dom.request.list; + +import java.io.Serializable; +import java.util.Map; + +import mailjimp.dom.enums.EmailType; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ListBatchSubscribeStructWithVars extends ListBatchSubscribeStruct { + @JsonProperty("merge_vars") + private Map mergeVars; + + public ListBatchSubscribeStructWithVars(String emailAddress, EmailType emailType, Map mergeVars) + { + super(emailAddress, emailType); + setMergeVars(mergeVars); + } + + + public Map getMergeVars() { + return mergeVars; + } + + public void setMergeVars(Map mergeVars) { + this.mergeVars = mergeVars; + } + +} diff --git a/mailjimp-core/src/main/java/mailjimp/dom/request/template/TemplateAddRequest.java b/mailjimp-core/src/main/java/mailjimp/dom/request/template/TemplateAddRequest.java new file mode 100644 index 0000000..e942380 --- /dev/null +++ b/mailjimp-core/src/main/java/mailjimp/dom/request/template/TemplateAddRequest.java @@ -0,0 +1,55 @@ +/* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ +package mailjimp.dom.request.template; + +import org.codehaus.jackson.annotate.JsonProperty; + +import mailjimp.dom.request.MailJimpRequest; + + +public class TemplateAddRequest extends MailJimpRequest { + + @JsonProperty + private String name; + + @JsonProperty + private String html; + + public TemplateAddRequest(String apikey, String name, String html) { + super(apikey); + this.name =name; + this.html = html; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getHtml() { + return html; + } + + public void setHtml(String html) { + this.html = html; + } + +} diff --git a/mailjimp-core/src/main/java/mailjimp/dom/request/template/TemplateDelRequest.java b/mailjimp-core/src/main/java/mailjimp/dom/request/template/TemplateDelRequest.java new file mode 100644 index 0000000..6594722 --- /dev/null +++ b/mailjimp-core/src/main/java/mailjimp/dom/request/template/TemplateDelRequest.java @@ -0,0 +1,42 @@ +/* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ +package mailjimp.dom.request.template; + +import org.codehaus.jackson.annotate.JsonProperty; + +import mailjimp.dom.request.MailJimpRequest; + +public class TemplateDelRequest extends MailJimpRequest { + + @JsonProperty + private int id; + + public TemplateDelRequest(String apikey, int id) { + super(apikey); + this.id = id; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + +} diff --git a/mailjimp-core/src/main/java/mailjimp/dom/request/template/TemplateInfoRequest.java b/mailjimp-core/src/main/java/mailjimp/dom/request/template/TemplateInfoRequest.java new file mode 100644 index 0000000..1267b49 --- /dev/null +++ b/mailjimp-core/src/main/java/mailjimp/dom/request/template/TemplateInfoRequest.java @@ -0,0 +1,71 @@ +/* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ +package mailjimp.dom.request.template; + +import mailjimp.dom.request.MailJimpRequest; + +import org.codehaus.jackson.annotate.JsonProperty; + + +public class TemplateInfoRequest extends MailJimpRequest { + private static final long serialVersionUID = 1L; + + @JsonProperty + private int tid; + + @JsonProperty + private String type; + + public TemplateInfoRequest(String apikey, int id, String type) { + super(apikey); + this.tid = id; + + if (type == null) + this.type = "user"; + else + this.type = type; + } + + + public int getId() { + return tid; + } + + + public void setId(int id) { + this.tid = id; + } + + + public String getType() { + return type; + } + + + public void setType(String type) { + this.type = type; + } + + + public static long getSerialversionuid() { + return serialVersionUID; + } + + + +} diff --git a/mailjimp-core/src/main/java/mailjimp/dom/request/template/TemplateListRequest.java b/mailjimp-core/src/main/java/mailjimp/dom/request/template/TemplateListRequest.java new file mode 100644 index 0000000..42b276c --- /dev/null +++ b/mailjimp-core/src/main/java/mailjimp/dom/request/template/TemplateListRequest.java @@ -0,0 +1,78 @@ +/* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ +package mailjimp.dom.request.template; + +import java.util.List; + +import mailjimp.dom.request.MailJimpRequest; +import mailjimp.dom.request.NamedBoolean; + +import org.codehaus.jackson.annotate.JsonProperty; + + +public class TemplateListRequest extends MailJimpRequest { + + @JsonProperty + private List types; + + @JsonProperty + private String category; + + @JsonProperty + private List inactives; + + + public TemplateListRequest(String apikey, String category, List types, List inactives) { + super(apikey); + + this.category = category; + this.types = types; + this.inactives = inactives; + + } + + + public List getTypes() { + return types; + } + + + public void setTypes(List types) { + this.types = types; + } + + + public String getCategory() { + return category; + } + + + public void setCategory(String category) { + this.category = category; + } + + + public List getInactives() { + return inactives; + } + + + public void setInactives(List inactives) { + this.inactives = inactives; + } +} diff --git a/mailjimp-core/src/main/java/mailjimp/dom/request/template/TemplateUpdateRequest.java b/mailjimp-core/src/main/java/mailjimp/dom/request/template/TemplateUpdateRequest.java new file mode 100644 index 0000000..5ea7c18 --- /dev/null +++ b/mailjimp-core/src/main/java/mailjimp/dom/request/template/TemplateUpdateRequest.java @@ -0,0 +1,73 @@ +/* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ +package mailjimp.dom.request.template; + +import java.util.HashMap; +import java.util.Map; + +import mailjimp.dom.request.MailJimpRequest; + +import org.codehaus.jackson.annotate.JsonProperty; + + +public class TemplateUpdateRequest extends MailJimpRequest { + private static final long serialVersionUID = 1L; + + @JsonProperty + private int id; + + @JsonProperty + private Map values = null; + + public TemplateUpdateRequest(String apikey, int id, String name, String html) { + super(apikey); + + if (values == null) + values = new HashMap(); + else + values.clear(); + + this.id = id; + + if (name != null) + values.put("name", name); + + if (html != null) + values.put("html", html); + + + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Map getValues() { + return values; + } + + public void setValues(Map values) { + this.values = values; + } + + +} diff --git a/mailjimp-core/src/main/java/mailjimp/dom/response/campaign/CampaignListResponse.java b/mailjimp-core/src/main/java/mailjimp/dom/response/campaign/CampaignListResponse.java new file mode 100644 index 0000000..b519af4 --- /dev/null +++ b/mailjimp-core/src/main/java/mailjimp/dom/response/campaign/CampaignListResponse.java @@ -0,0 +1,54 @@ +/* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ +package mailjimp.dom.response.campaign; + +import java.io.Serializable; +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class CampaignListResponse implements Serializable{ + + @JsonProperty + int total; + + @JsonProperty("data") + List items; + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } + + @Override + public String toString() + { + return "CampaignListResponse: [total=" + total+"];"; + } +} diff --git a/mailjimp-core/src/main/java/mailjimp/dom/response/campaign/CampaignListResponseItem.java b/mailjimp-core/src/main/java/mailjimp/dom/response/campaign/CampaignListResponseItem.java new file mode 100644 index 0000000..6729ef8 --- /dev/null +++ b/mailjimp-core/src/main/java/mailjimp/dom/response/campaign/CampaignListResponseItem.java @@ -0,0 +1,364 @@ +/* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ +package mailjimp.dom.response.campaign; + +import java.io.Serializable; + +import java.util.HashMap; +import java.util.List; + +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.annotate.JsonProperty; + +@JsonIgnoreProperties({ "segment_opts", "type_opts" }) //TODO +public class CampaignListResponseItem implements Serializable{ + + @JsonProperty + String id; + + @JsonProperty("web_id") + Integer webId; + + @JsonProperty("list_id") + String listId; + + @JsonProperty("folder_id") + Integer folderId; + + @JsonProperty + int template_id; + + @JsonProperty + String content_type; + + @JsonProperty + String title; + + @JsonProperty + String type; + + @JsonProperty + String create_time; + + @JsonProperty + String send_time; + + @JsonProperty + int emails_sent; + + @JsonProperty + String status; + + @JsonProperty + String from_name; + + @JsonProperty + String from_email; + + @JsonProperty + String subject; + + @JsonProperty + String to_name; + + @JsonProperty + String archive_url; + + @JsonProperty + boolean inline_css; + + @JsonProperty + String analytics; + + @JsonProperty + String analytics_tag; + + @JsonProperty + boolean authenticate; + + @JsonProperty + boolean ecomm360; + + @JsonProperty + boolean auto_tweet; + + @JsonProperty + String auto_fb_post; + + @JsonProperty + boolean auto_footer; + + @JsonProperty + boolean timewarp; + + @JsonProperty + String timewarp_schedule; + + @JsonProperty + HashMap tracking; + + @JsonProperty + boolean html_clicks; + + @JsonProperty + boolean text_clicks; + + @JsonProperty + boolean opens; + + @JsonProperty + String segment_text; + + @JsonProperty + String parent_id; + + + +// @JsonProperty +// List segment_opts; +// +// @JsonProperty +// List type_opts; + + + @Override + public String toString() + { + return "CampaignListResponseItem: [id=" + this.id + ", listId=" + this.listId + ", templateId=" + template_id + ", title=" + this.title +"];"; + } + + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public Integer getWebId() { + return webId; + } + public void setWebId(Integer webId) { + this.webId = webId; + } + public String getListId() { + return listId; + } + public void setListId(String listId) { + this.listId = listId; + } + public Integer getFolderId() { + return folderId; + } + public void setFolderId(Integer folderId) { + this.folderId = folderId; + } + public int getTemplate_id() { + return template_id; + } + public void setTemplate_id(int template_id) { + this.template_id = template_id; + } + public String getContent_type() { + return content_type; + } + public void setContent_type(String content_type) { + this.content_type = content_type; + } + public String getTitle() { + return title; + } + public void setTitle(String title) { + this.title = title; + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public String getCreate_time() { + return create_time; + } + public void setCreate_time(String create_time) { + this.create_time = create_time; + } + public String getSend_time() { + return send_time; + } + public void setSend_time(String send_time) { + this.send_time = send_time; + } + public int getEmails_sent() { + return emails_sent; + } + public void setEmails_sent(int emails_sent) { + this.emails_sent = emails_sent; + } + public String getStatus() { + return status; + } + public void setStatus(String status) { + this.status = status; + } + public String getFrom_name() { + return from_name; + } + public void setFrom_name(String from_name) { + this.from_name = from_name; + } + public String getFrom_email() { + return from_email; + } + public void setFrom_email(String from_email) { + this.from_email = from_email; + } + public String getSubject() { + return subject; + } + public void setSubject(String subject) { + this.subject = subject; + } + public String getTo_name() { + return to_name; + } + public void setTo_name(String to_name) { + this.to_name = to_name; + } + public String getArchive_url() { + return archive_url; + } + public void setArchive_url(String archive_url) { + this.archive_url = archive_url; + } + public boolean isInline_css() { + return inline_css; + } + public void setInline_css(boolean inline_css) { + this.inline_css = inline_css; + } + public String getAnalytics() { + return analytics; + } + public void setAnalytics(String analytics) { + this.analytics = analytics; + } + public String getAnalytics_tag() { + return analytics_tag; + } + public void setAnalytics_tag(String analytics_tag) { + this.analytics_tag = analytics_tag; + } + public boolean isAuthenticate() { + return authenticate; + } + public void setAuthenticate(boolean authenticate) { + this.authenticate = authenticate; + } + public boolean isEcomm360() { + return ecomm360; + } + public void setEcomm360(boolean ecomm360) { + this.ecomm360 = ecomm360; + } + public boolean isAuto_tweet() { + return auto_tweet; + } + public void setAuto_tweet(boolean auto_tweet) { + this.auto_tweet = auto_tweet; + } + public String getAuto_fb_post() { + return auto_fb_post; + } + public void setAuto_fb_post(String auto_fb_post) { + this.auto_fb_post = auto_fb_post; + } + public boolean isAuto_footer() { + return auto_footer; + } + public void setAuto_footer(boolean auto_footer) { + this.auto_footer = auto_footer; + } + public boolean isTimewarp() { + return timewarp; + } + public void setTimewarp(boolean timewarp) { + this.timewarp = timewarp; + } + public String getTimewarp_schedule() { + return timewarp_schedule; + } + public void setTimewarp_schedule(String timewarp_schedule) { + this.timewarp_schedule = timewarp_schedule; + } + public HashMap getTracking() { + return tracking; + } + public void setTracking(HashMap tracking) { + this.tracking = tracking; + } + public boolean isHtml_clicks() { + return html_clicks; + } + public void setHtml_clicks(boolean html_clicks) { + this.html_clicks = html_clicks; + } + public boolean isText_clicks() { + return text_clicks; + } + public void setText_clicks(boolean text_clicks) { + this.text_clicks = text_clicks; + } + public boolean isOpens() { + return opens; + } + public void setOpens(boolean opens) { + this.opens = opens; + } + public String getSegment_text() { + return segment_text; + } + public void setSegment_text(String segment_text) { + this.segment_text = segment_text; + } +// public List getSegment_opts() { +// return segment_opts; +// } +// public void setSegment_opts(List segment_opts) { +// this.segment_opts = segment_opts; +// } +// public List getType_opts() { +// return type_opts; +// } +// public void setType_opts(List type_opts) { +// this.type_opts = type_opts; +// } +// + + + public String getParent_id() { + return parent_id; + } + + + public void setParent_id(String parent_id) { + this.parent_id = parent_id; + } + + + + } diff --git a/mailjimp-core/src/main/java/mailjimp/dom/response/campaign/CampaignMembersResponse.java b/mailjimp-core/src/main/java/mailjimp/dom/response/campaign/CampaignMembersResponse.java new file mode 100644 index 0000000..440adfc --- /dev/null +++ b/mailjimp-core/src/main/java/mailjimp/dom/response/campaign/CampaignMembersResponse.java @@ -0,0 +1,54 @@ +/* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ +package mailjimp.dom.response.campaign; + +import java.io.Serializable; +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class CampaignMembersResponse implements Serializable{ + + @JsonProperty + int total; + + @JsonProperty("data") + List items; + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } + + @Override + public String toString() + { + return "CampaignBounceMessageResponse: [total=" + total+"];"; + } +} diff --git a/mailjimp-core/src/main/java/mailjimp/dom/response/campaign/CampaignMembersResponseItem.java b/mailjimp-core/src/main/java/mailjimp/dom/response/campaign/CampaignMembersResponseItem.java new file mode 100644 index 0000000..cb2213e --- /dev/null +++ b/mailjimp-core/src/main/java/mailjimp/dom/response/campaign/CampaignMembersResponseItem.java @@ -0,0 +1,88 @@ +/* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ +package mailjimp.dom.response.campaign; + +import java.io.Serializable; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class CampaignMembersResponseItem implements Serializable{ + + + @JsonProperty + String email; + + @JsonProperty + String status; + + @JsonProperty + String absplit_group; + + @JsonProperty + String tz_group; + + + @Override + public String toString() + { + return "CampaignBoucneMessageResponseItem [tz_group=" + tz_group + ", email=" + email + ", absplit_group=" + absplit_group + "];"; + } + + + public String getEmail() { + return email; + } + + + public void setEmail(String email) { + this.email = email; + } + + + public String getStatus() { + return status; + } + + + public void setStatus(String status) { + this.status = status; + } + + + public String getAbsplit_group() { + return absplit_group; + } + + + public void setAbsplit_group(String absplit_group) { + this.absplit_group = absplit_group; + } + + + public String getTz_group() { + return tz_group; + } + + + public void setTz_group(String tz_group) { + this.tz_group = tz_group; + } + + + +} diff --git a/mailjimp-core/src/main/java/mailjimp/dom/response/list/MailingList.java b/mailjimp-core/src/main/java/mailjimp/dom/response/list/MailingList.java index ff96b81..c26b1cb 100644 --- a/mailjimp-core/src/main/java/mailjimp/dom/response/list/MailingList.java +++ b/mailjimp-core/src/main/java/mailjimp/dom/response/list/MailingList.java @@ -63,6 +63,9 @@ public class MailingList { @JsonProperty("beamer_address") private String beamerAddress; + @JsonProperty("visibility") + private String visibility; + private MailingListStats stats; private List modules; @@ -203,4 +206,12 @@ public void setModules(List modules) { public String toString() { return "MailingList [id=" + id + ", webId=" + webId + ", name=" + name + ", dateCreated=" + dateCreated + ", emailTypeOption=" + emailTypeOption + ", useAwesomebar=" + useAwesomebar + ", defaultFromName=" + defaultFromName + ", defaultFromEmail=" + defaultFromEmail + ", defaultSubject=" + defaultSubject + ", defaultLanguage=" + defaultLanguage + ", listRating=" + listRating + ", subscribeUrlShort=" + subscribeUrlShort + ", subscribeUrlLong=" + subscribeUrlLong + ", beamerAddress=" + beamerAddress + ", stats=" + stats + ", modules=" + modules + "]"; } + +public String getVisibility() { + return visibility; +} + +public void setVisibility(String visibility) { + this.visibility = visibility; +} } \ No newline at end of file diff --git a/mailjimp-core/src/main/java/mailjimp/dom/response/template/TemplateInfoResponse.java b/mailjimp-core/src/main/java/mailjimp/dom/response/template/TemplateInfoResponse.java new file mode 100644 index 0000000..3b3e2c6 --- /dev/null +++ b/mailjimp-core/src/main/java/mailjimp/dom/response/template/TemplateInfoResponse.java @@ -0,0 +1,83 @@ +/* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ +package mailjimp.dom.response.template; + +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +import mailjimp.dom.response.MailJimpResponse; + +public class TemplateInfoResponse extends MailJimpResponse { + + @JsonProperty("default_content") + private List defaultContent; + + @JsonProperty("sections") + private List sections; + + @JsonProperty + private String source; + + @JsonProperty + private String preview; + + + public TemplateInfoResponse() { + // empty + } + + @Override + public String toString() { + return "TemplateInfoResponse [default_content=" + defaultContent +", sections=" + sections + ", source=" + source +", preview="+preview+"]"; + } + +public List getDefaultContent() { + return defaultContent; +} + +public void setDefaultContent(List defaultContent) { + this.defaultContent = defaultContent; +} + +public List getSections() { + return sections; +} + +public void setSections(List sections) { + this.sections = sections; +} + +public String getSource() { + return source; +} + +public void setSource(String source) { + this.source = source; +} + +public String getPreview() { + return preview; +} + +public void setPreview(String preview) { + this.preview = preview; +} + + +} \ No newline at end of file diff --git a/mailjimp-core/src/main/java/mailjimp/dom/response/template/TemplateListItemResponse.java b/mailjimp-core/src/main/java/mailjimp/dom/response/template/TemplateListItemResponse.java new file mode 100644 index 0000000..6d35334 --- /dev/null +++ b/mailjimp-core/src/main/java/mailjimp/dom/response/template/TemplateListItemResponse.java @@ -0,0 +1,125 @@ +/* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ +package mailjimp.dom.response.template; + +import mailjimp.dom.response.MailJimpResponse; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class TemplateListItemResponse extends MailJimpResponse { + + + @JsonProperty("id") + private int id; + + @JsonProperty("name") + private String name; + + @JsonProperty("category") + private String category; + + @JsonProperty("layout") + private String layout; + + @JsonProperty("preview_image") + private String previewImage; + + @JsonProperty("date_created") + private String dateCreated; + + @JsonProperty("edit_source") + private Boolean editSource; + + @JsonProperty("active") + private String active; + + + public TemplateListItemResponse() { + // empty + } + + @Override + public String toString() { + return "TemplateListItemResponse [id=" + id + ", name=" + name + ", layout=" + layout +", preview_image=" + previewImage + + ", date_created="+ dateCreated + ",edit_source=" + editSource + "]"; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLayout() { + return layout; + } + + public void setLayout(String layout) { + this.layout = layout; + } + + public String getPreviewImage() { + return previewImage; + } + + public void setPreviewImage(String previewImage) { + this.previewImage = previewImage; + } + + public String getDateCreated() { + return dateCreated; + } + + public void setDateCreated(String dateCreated) { + this.dateCreated = dateCreated; + } + + public Boolean getEditSource() { + return editSource; + } + + public void setEditSource(Boolean editSource) { + this.editSource = editSource; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } +} \ No newline at end of file diff --git a/mailjimp-core/src/main/java/mailjimp/dom/response/template/TemplateListResponse.java b/mailjimp-core/src/main/java/mailjimp/dom/response/template/TemplateListResponse.java new file mode 100644 index 0000000..7dece67 --- /dev/null +++ b/mailjimp-core/src/main/java/mailjimp/dom/response/template/TemplateListResponse.java @@ -0,0 +1,39 @@ +/* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ +package mailjimp.dom.response.template; + +import java.util.List; + +import mailjimp.dom.response.MailJimpResponse; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class TemplateListResponse extends MailJimpResponse { + + @JsonProperty("user") + List listItems; + + public List getListItems() { + return listItems; + } + + public void setListItems(List listItems) { + this.listItems = listItems; + } + +} diff --git a/mailjimp-core/src/main/java/mailjimp/service/IMailJimpService.java b/mailjimp-core/src/main/java/mailjimp/service/IMailJimpService.java index ea0f65b..c3a8cf4 100644 --- a/mailjimp-core/src/main/java/mailjimp/service/IMailJimpService.java +++ b/mailjimp-core/src/main/java/mailjimp/service/IMailJimpService.java @@ -19,6 +19,7 @@ import java.io.Serializable; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -26,13 +27,19 @@ import mailjimp.dom.enums.InterestGroupingType; import mailjimp.dom.enums.InterestGroupingUpdateType; import mailjimp.dom.enums.MemberStatus; +import mailjimp.dom.request.NamedBoolean; import mailjimp.dom.request.list.ListBatchSubscribeStruct; +import mailjimp.dom.request.list.ListBatchSubscribeStructWithVars; +import mailjimp.dom.response.campaign.CampaignMembersResponse; +import mailjimp.dom.response.campaign.CampaignListResponse; +import mailjimp.dom.response.list.InterestGrouping; import mailjimp.dom.response.list.ListBatchSubscribeResponse; import mailjimp.dom.response.list.ListBatchUnsubscribeResponse; -import mailjimp.dom.response.list.InterestGrouping; import mailjimp.dom.response.list.MailingList; import mailjimp.dom.response.list.MemberInfo; import mailjimp.dom.response.list.MemberResponseInfo; +import mailjimp.dom.response.template.TemplateInfoResponse; +import mailjimp.dom.response.template.TemplateListResponse; import mailjimp.dom.security.ApiKey; /** @@ -140,9 +147,29 @@ public interface IMailJimpService extends Serializable { * * @throws MailJimpException */ - public ListBatchSubscribeResponse listBatchSubscribe(String listId, List batch, boolean doubleOptin, boolean updateExisting, boolean replaceInterests) throws MailJimpException; + public ListBatchSubscribeResponse listBatchSubscribe (String listId,List batch, boolean doubleOptin,boolean updateExisting, boolean replaceInterests) throws MailJimpException; + + /** + * Batch subscribe a user to a mailing list while allowing you to pass a List of List Variables. + * See the MailChimp API for more info. + * + * + * @param listId + * @param batch + * @param doubleOptin + * @param updateExisting + * @param replaceInterests + * + * @return The result of this call. Containing add, update and error counts. + * In case of errors contains additional information. + * + * @throws MailJimpException + */ + public ListBatchSubscribeResponse listBatchSubscribeWithVars(String listId,List batch, boolean doubleOptin,boolean updateExisting, boolean replaceInterests) throws MailJimpException; + /** * Batch subscribe many users to a list. See the options, HashMap content) throws MailJimpException; + + /** + Parameters + * campaignId The Campaign Id + * @return boolean success + * @throws MailJimpException + */ + Boolean campaignDelete(String campaignId) throws MailJimpException; + + /** + Parameters + * filters Filters for returning campaigns see http://apidocs.mailchimp.com/api/rtfm/campaigns.func.php + * start Start position (0 beginning) + * limit number of returns to return (start + limit support pagination) + * @return Object containing a list of campaign items. + * @throws MailJimpException + */ + CampaignListResponse campaignList(HashMap filters, int start, int limit) throws MailJimpException; + + /** + * Allows you to pull lists of members from a particular campaign, used to pull bounces, unsubscribes, etc via status field. + Parameters + * filters Filters for returning campaigns see http://apidocs.mailchimp.com/api/rtfm/campaigns.func.php + * start Start position (0 beginning) + * limit number of returns to return (start + limit support pagination) + * @return Object containing a list of campaign items. + * @throws MailJimpException + */ + public CampaignMembersResponse campaignMembers(String campaignId, String status, int start, int limit) throws MailJimpException; + } \ No newline at end of file diff --git a/mailjimp-core/src/main/java/mailjimp/service/impl/AbstractMailJimpService.java b/mailjimp-core/src/main/java/mailjimp/service/impl/AbstractMailJimpService.java deleted file mode 100644 index a6c1fcc..0000000 --- a/mailjimp-core/src/main/java/mailjimp/service/impl/AbstractMailJimpService.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2011 Michael Laccetti - * - * This file is part of MailJimp. - * - * MailJimp is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, version 3 of the License. - * - * MailJimp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with MailJimp. If not, see . - */ -package mailjimp.service.impl; - -import mailjimp.service.IMailJimpService; - -abstract class AbstractMailJimpService implements IMailJimpService { - protected static final String SERVER_URL_PREFIX_HTTP = "http://"; - protected static final String SERVER_URL_PREFIX_HTTPS = "https://"; - protected static final String SERVER_URL_MAIN = ".api.mailchimp.com/"; - - //Credentials - protected String username; - protected String password; - protected String apiKey; - protected String apiVersion; - protected boolean ssl = true; - - protected AbstractMailJimpService() { - // empty - } - - protected AbstractMailJimpService(String username, String password, String apiKey, String apiVersion, boolean ssl) { - this.username = username; - this.password = password; - this.apiKey = apiKey; - this.apiVersion = apiVersion; - this.ssl = ssl; - } - - public void setUsername(String username) { - this.username = username; - } - - public void setPassword(String password) { - this.password = password; - } - - public void setApiKey(String apiKey) { - this.apiKey = apiKey; - } - - public void setApiVersion(String apiVersion) { - this.apiVersion = apiVersion; - } - - public void setSsl(boolean ssl) { - this.ssl = ssl; - } - - protected void checkConfig() { - if (apiKey == null || apiKey.isEmpty()) { - throw new IllegalArgumentException("API key cannot be null/empty."); - } - if (apiVersion == null || apiVersion.isEmpty()) { - throw new IllegalArgumentException("API version cannot be null/empty."); - } - } - - /** - * Constructs the url of the MailChimp server to talk to. This takes the data - * center out of the api key and knows if the connection should get secured - * via ssl. - * - * @return The URL of the MailChimp server to use. - */ - protected String buildServerURL() { - StringBuilder serverURL = new StringBuilder(); - // choose the protocol - if (ssl) { - serverURL.append(SERVER_URL_PREFIX_HTTPS); - } else { - serverURL.append(SERVER_URL_PREFIX_HTTP); - } - - final int dcSeparater = apiKey.lastIndexOf('-'); - final String dcLocation = dcSeparater != -1 ? apiKey.substring(dcSeparater + 1) : "us1"; - - serverURL - // parse the data center - .append(dcLocation) - // bring in the clue - .append(SERVER_URL_MAIN) - // add the version - .append(apiVersion) - // and finish with a slash. - .append('/'); - return serverURL.toString(); - } -} \ No newline at end of file diff --git a/mailjimp-core/src/main/java/mailjimp/service/impl/MailJimpJsonService.java b/mailjimp-core/src/main/java/mailjimp/service/impl/MailJimpJsonService.java index 2bcc453..519b85d 100644 --- a/mailjimp-core/src/main/java/mailjimp/service/impl/MailJimpJsonService.java +++ b/mailjimp-core/src/main/java/mailjimp/service/impl/MailJimpJsonService.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -31,7 +32,9 @@ import mailjimp.dom.enums.InterestGroupingUpdateType; import mailjimp.dom.enums.MemberStatus; import mailjimp.dom.request.list.ListBatchSubscribeRequest; +import mailjimp.dom.request.list.ListBatchSubscribeRequestWithVars; import mailjimp.dom.request.list.ListBatchSubscribeStruct; +import mailjimp.dom.request.list.ListBatchSubscribeStructWithVars; import mailjimp.dom.request.list.ListBatchUnsubscribeRequest; import mailjimp.dom.request.list.ListInterestGroupAddRequest; import mailjimp.dom.request.list.ListInterestGroupDelRequest; @@ -50,8 +53,10 @@ import mailjimp.dom.request.security.ApiKeyExpireRequest; import mailjimp.dom.request.security.ApiKeyRequest; import mailjimp.dom.response.MailJimpErrorResponse; -import mailjimp.dom.response.list.ListBatchSubscribeResponse; +import mailjimp.dom.response.campaign.CampaignMembersResponse; +import mailjimp.dom.response.campaign.CampaignListResponse; import mailjimp.dom.response.list.InterestGrouping; +import mailjimp.dom.response.list.ListBatchSubscribeResponse; import mailjimp.dom.response.list.ListBatchUnsubscribeResponse; import mailjimp.dom.response.list.ListMemberInfoResponse; import mailjimp.dom.response.list.ListMembersResponse; @@ -59,7 +64,10 @@ import mailjimp.dom.response.list.MailingList; import mailjimp.dom.response.list.MemberInfo; import mailjimp.dom.response.list.MemberResponseInfo; +import mailjimp.dom.response.template.TemplateInfoResponse; +import mailjimp.dom.response.template.TemplateListResponse; import mailjimp.dom.security.ApiKey; +import mailjimp.service.AbstractMailJimpService; import mailjimp.service.MailJimpException; import org.apache.commons.io.IOUtils; @@ -113,7 +121,7 @@ public void init() { m.setDateFormat(new SimpleDateFormat("yyyy-MM-MM HH:mm:ss")); } - private V performRequest(String method, Object param, TypeReference typeRef) throws MailJimpException { + protected V performRequest(String method, Object param, TypeReference typeRef) throws MailJimpException { String requestJson = null; try { requestJson = m.writeValueAsString(param); @@ -150,7 +158,8 @@ private V performRequest(String method, Object param, TypeReference typeR } try { - V val = m.readValue(responseJson, typeRef); + //TMG Added cast to fix bug in JavaC: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302954 + V val = (V) m.readValue(responseJson, typeRef); return val; } catch (Exception ex) { log.error(String.format("Could not convert JSON to expected type (%s).", typeRef.getType().getClass().getCanonicalName()), ex); @@ -213,6 +222,15 @@ public ListBatchSubscribeResponse listBatchSubscribe(String listId, List batch, boolean doubleOptin, boolean updateExisting, boolean replaceInterests) throws MailJimpException { + ListBatchSubscribeResponse response = performRequest("listBatchSubscribe", new ListBatchSubscribeRequestWithVars(apiKey, listId, batch, doubleOptin, updateExisting, replaceInterests), new TypeReference() {/* empty */}); + log.debug("List batch subscribe response: {}", response); + return response; + } + + @Override public ListBatchUnsubscribeResponse listBatchUnsubscribe(String listId, List emails, boolean deleteMember, boolean sendGoodbye, boolean sendNotify) throws MailJimpException { @@ -283,4 +301,80 @@ public Boolean listInterestGroupingDelete(Integer groupingId) throws MailJimpExc log.debug("Delete interesting grouping status: {}", response); return response; } + + + @Override + public int templateAdd(String name, String html) throws MailJimpException { + int response = performRequest("templateAdd", new mailjimp.dom.request.template.TemplateAddRequest(apiKey, name, html), new TypeReference() {/* empty */}); + log.debug("Tempate Add: {}", response); + return response; + } + + + @Override + public boolean templateDel(int id) throws MailJimpException { + boolean response = performRequest("templateDel", new mailjimp.dom.request.template.TemplateDelRequest(apiKey, id), new TypeReference() {/* empty */}); + log.debug("Tempate delete: {}", response); + return response; + } + + + @Override + public boolean templateUndel(int id) throws MailJimpException { + boolean response = performRequest("templateUndel", new mailjimp.dom.request.template.TemplateDelRequest(apiKey, id), new TypeReference() {/* empty */}); + log.debug("Tempate undelete: {}", response); + return response; + } + + @Override + public boolean templateUpdate(int id, String name, String html) throws MailJimpException { + boolean response = performRequest("templateUpdate", new mailjimp.dom.request.template.TemplateUpdateRequest(apiKey, id, name, html), new TypeReference() {/* empty */}); + log.debug("Tempate Update: {}", response); + return response; + } + + @Override + public TemplateInfoResponse templateInfo(int templateId, String type) throws MailJimpException { + TemplateInfoResponse response = performRequest("templateInfo", new mailjimp.dom.request.template.TemplateInfoRequest(apiKey, templateId, type), new TypeReference() {/* empty */}); + log.debug("Tempate Info: {}", response); + return response; + } + + @Override + public TemplateListResponse templateList() throws MailJimpException { //int templateId, String category, List types, List inactives) throws MailJimpException { + TemplateListResponse response = performRequest("templates", new mailjimp.dom.request.template.TemplateListRequest(apiKey, null, null, null), new TypeReference() {/* empty */}); + log.debug("Tempate List: {}", response); + return response; + } + + @Override + public String campaignCreate(String type, HashMap options, HashMap content) throws MailJimpException { //int templateId, String category, List types, List inactives) throws MailJimpException { + String response = performRequest("campaignCreate", new mailjimp.dom.request.campaign.CampaignCreateRequest(apiKey, type, options, content), new TypeReference() {/* empty */}); + log.debug("capaign Create: {}", response); + return response; + } + + @Override + public Boolean campaignDelete(String campaignId) throws MailJimpException { + Boolean response = performRequest("campaignDelete", new mailjimp.dom.request.campaign.CampaignDeleteRequest(apiKey, campaignId), new TypeReference() {/* empty */}); + log.debug("campaign Delete: {}", response); + return response; + } + + + @Override + public CampaignListResponse campaignList(HashMap filters, int start, int limit) throws MailJimpException { + CampaignListResponse response = performRequest("campaigns", new mailjimp.dom.request.campaign.CampaignListRequest(apiKey, filters, start, limit), new TypeReference() {/* empty */}); + log.debug("campaign List: {}", response); + + return response; + } + + @Override + public CampaignMembersResponse campaignMembers(String campaignId, String status, int start, int limit) throws MailJimpException { + CampaignMembersResponse response = performRequest("campaignMembers", new mailjimp.dom.request.campaign.CampaignMembersRequest(apiKey, campaignId, status, start, limit), new TypeReference() {/* empty */}); + log.debug("campaign members: {}", response); + + return response; + } } \ No newline at end of file diff --git a/mailjimp-core/src/test/java/mailjimp/service/TestMailJimpJsonService.java b/mailjimp-core/src/test/java/mailjimp/service/TestMailJimpJsonService.java index ffc5e8f..aff42ac 100644 --- a/mailjimp-core/src/test/java/mailjimp/service/TestMailJimpJsonService.java +++ b/mailjimp-core/src/test/java/mailjimp/service/TestMailJimpJsonService.java @@ -32,6 +32,7 @@ import mailjimp.dom.enums.InterestGroupingUpdateType; import mailjimp.dom.enums.MemberStatus; import mailjimp.dom.request.list.ListBatchSubscribeStruct; +import mailjimp.dom.request.list.ListBatchSubscribeStructWithVars; import mailjimp.dom.response.list.InterestGrouping; import mailjimp.dom.response.list.ListBatchSubscribeResponse; import mailjimp.dom.response.list.ListBatchUnsubscribeResponse; @@ -42,6 +43,7 @@ import org.apache.commons.lang3.RandomStringUtils; import org.junit.After; +import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; @@ -94,6 +96,8 @@ public class TestMailJimpJsonService extends AbstractServiceTester { */ private static String groupName = RandomStringUtils.randomAlphabetic(8); private static String newGroupName = RandomStringUtils.randomAlphabetic(8); + + private static String templateName = RandomStringUtils.randomAlphabetic(8); @BeforeClass public static void setup() { @@ -106,7 +110,7 @@ public static void setup() { public void after() { System.out.println("\n\n\n"); } - + @Test public void testLists() { try { @@ -223,6 +227,50 @@ public void testListSubscribeMergeVars() { } } + + @Test + public void testListBatchSubscribeMergeVars() { + final int NUM_EMAILS = 10; + + List data = new ArrayList(); + + for (int ndx = 0; ndx < NUM_EMAILS; ndx++) + { + String name = "test" + RandomStringUtils.randomNumeric(5); + String email = name + "@laccetti.com"; + Map merges = new HashMap(); + merges.put(MailJimpConstants.MERGE_EMAIL, email); + merges.put(MailJimpConstants.MERGE_FNAME, name); + merges.put(MailJimpConstants.MERGE_LNAME, "TestMergeVars"); + merges.put("MMERGE3", "test merge"); + + List> groupings = new ArrayList>(); + Map groups = new HashMap(); + groups.put("name", "Test Group"); + groups.put("groups", "Group 1"); + groupings.add(groups); + merges.put("GROUPINGS", groupings); + + data.add(new ListBatchSubscribeStructWithVars(email, EmailType.HTML, merges)); + } + + + try { + log.debug("Test list subscribe with merges"); + ListBatchSubscribeResponse response = mSvc.listBatchSubscribeWithVars(listId, data, false, true, true); + log.debug("Batch Submitted subscribed: {}", response); + + int count = response.getAddCount() + response.getUpdateCount(); + Assert.assertTrue(count == NUM_EMAILS); + Assert.assertTrue(response.getErrorCount() == 0); + } catch (MailJimpException mje) { + processError(mje); + } + } + + + + @Test public void testListUpdateMember() { try { @@ -374,7 +422,7 @@ public void testListInterestGroupAdd() { try { log.debug("Test list interest group add"); Boolean response = mSvc.listInterestGroupAdd(listId, groupName, groupingId); - log.debug("List interest group add: {}", response); + log.debug("List interest group atdd: {}", response); } catch (MailJimpException mje) { processError(mje); } @@ -401,4 +449,4 @@ public void testListInterestGroupDelete() { processError(mje); } } -} \ No newline at end of file + } \ No newline at end of file diff --git a/mailjimp-core/src/test/java/mailjimp/service/TestMailJimpJsonServiceCampaign.java b/mailjimp-core/src/test/java/mailjimp/service/TestMailJimpJsonServiceCampaign.java new file mode 100644 index 0000000..2b29cc7 --- /dev/null +++ b/mailjimp-core/src/test/java/mailjimp/service/TestMailJimpJsonServiceCampaign.java @@ -0,0 +1,153 @@ +/* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ +package mailjimp.service; + +import java.util.Date; + +import mailjimp.dom.MailJimpConstants; +import mailjimp.dom.request.campaign.CampaignCreateRequest; +import mailjimp.dom.response.campaign.CampaignMembersResponse; +import mailjimp.dom.response.campaign.CampaignMembersResponseItem; +import mailjimp.dom.response.campaign.CampaignListResponse; +import mailjimp.dom.response.campaign.CampaignListResponseItem; + +import org.junit.After; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Configurable; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration({ "/mailjimp-test-spring-config.xml" }) +@Configurable +public class TestMailJimpJsonServiceCampaign extends AbstractServiceTester { + + +@Autowired + private IMailJimpService mSvc; + + @Value("${mj.test.listId}") + private String listId; + + @Value("${mj.test.templateId}") + private Integer templateId; + + private static final String TEMPLATEHTML = "Test Case Template NEW"; + private static final String TEMPLATETEXT = "Test Case Template NEW"; + + private static String campaignId; + + @BeforeClass + public static void setup() { + } + + @After + public void after() { + System.out.println("\n\n\n"); + } + + + @Test + public void testCreateCampaign() + { + try { + log.debug("Test campaign create"); + String response = mSvc.campaignCreate(MailJimpConstants.CAMPAIGNTYPE_REGULAR, + CampaignCreateRequest.buildOptions(listId, "Test Campaign created by Test case", "Test Subject", "tim.gilbert@morningstar.com", "TestCase User", "Dear Customer", null), + CampaignCreateRequest.buildContentFromString(TEMPLATEHTML, TEMPLATETEXT)); + campaignId = response; + log.debug("Template updateTemplate: {}", response); + Assert.assertTrue(response != null); + } catch (MailJimpException mje) { + processError(mje); + } + } + + @Test + public void testListCampaign() throws InterruptedException + { + try { + boolean found = false; + log.debug("Test campaign list"); + + CampaignListResponse response = mSvc.campaignList(null, 0, 10); + + // find the campaign I just created + for (CampaignListResponseItem item : response.getItems()) + { + log.debug(item.toString()); + if (item.getId().equals(campaignId)) + found = true; + } + + + log.debug("Template list campaigns: {}", response); + Assert.assertTrue(response != null); + Assert.assertTrue(found); + } catch (MailJimpException mje) { + processError(mje); + } + } + + + //@Test //TODO test after campaign has been sent. + public void testBounceCampaign() throws InterruptedException + { + try { + boolean found = false; + log.debug("Test campaign bounce messages"); + + CampaignMembersResponse response = mSvc.campaignMembers(campaignId, MailJimpConstants.CAMPAIGNMEMBER_STATUS_HARDBOUNCE, 0,10); + + // find the campaign I just created + for (CampaignMembersResponseItem item : response.getItems()) + { + log.debug(item.toString()); + } + + + log.debug("Bounce list campaigns: {}", response); + Assert.assertTrue(response != null); + Assert.assertTrue(found); + } catch (MailJimpException mje) { + processError(mje); + } + } + + + + @Test + public void testDeleteCampaign() + { + try { + log.debug("Test campaign delete :" + campaignId); + Boolean response = mSvc.campaignDelete(campaignId); + + log.debug("Template updateTemplate: {}", response); + Assert.assertTrue(response); + } catch (MailJimpException mje) { + processError(mje); + } + } + +} \ No newline at end of file diff --git a/mailjimp-core/src/test/java/mailjimp/service/TestMailJimpJsonServiceTemplate.java b/mailjimp-core/src/test/java/mailjimp/service/TestMailJimpJsonServiceTemplate.java new file mode 100644 index 0000000..910f96e --- /dev/null +++ b/mailjimp-core/src/test/java/mailjimp/service/TestMailJimpJsonServiceTemplate.java @@ -0,0 +1,156 @@ +/* + * Copyright 2011 Michael Laccetti and Tim Gilbert + * + * This file is part of MailJimp and forked MailJimp under https://github.com/knaak/MailJimp + * + * MailJimp is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * MailJimp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with MailJimp. If not, see . + */ +package mailjimp.service; + +import java.util.Arrays; +import java.util.List; + +import mailjimp.dom.request.NamedBoolean; +import mailjimp.dom.response.template.TemplateInfoResponse; +import mailjimp.dom.response.template.TemplateListResponse; + +import org.apache.commons.lang3.RandomStringUtils; +import org.junit.After; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Configurable; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration({ "/mailjimp-test-spring-config.xml" }) +@Configurable +public class TestMailJimpJsonServiceTemplate extends AbstractServiceTester { + private static final String TEMPLATEHTML = "Test Case Template NEW"; + + +@Autowired + private IMailJimpService mSvc; + + + private static String templateName = RandomStringUtils.randomAlphabetic(8); + private static String templateNewName = RandomStringUtils.randomAlphabetic(8); + private static Integer templateId = -1; + + @BeforeClass + public static void setup() { + } + + @After + public void after() { + System.out.println("\n\n\n"); + } + + + @Test + public void testTemplateAdd(){ + try { + log.debug("Test template add"); + Integer response = mSvc.templateAdd(templateName, "Test Case Template"); // note not TEMPLATEHTML + templateId = response; + log.debug("Template addTemplate: {}", response); + } catch (MailJimpException mje) { + processError(mje); + } + } + + @Test + public void testTemplateList(){ + try { + log.debug("Test template list"); + TemplateListResponse response = mSvc.templateList(); + Assert.assertNotNull(response); + Assert.assertNotNull(response.getListItems()); + log.debug("Template addTemplate: {}", response); + } catch (MailJimpException mje) { + processError(mje); + } + } + + + + @Test + public void testTemplateUpdate(){ + try { + log.debug("Test template add"); + Boolean response = mSvc.templateUpdate(templateId, templateNewName, TEMPLATEHTML); + log.debug("Template updateTemplate: {}", response); + Assert.assertTrue(response); + } catch (MailJimpException mje) { + processError(mje); + } + } + + @Test + public void testTemplateInfo(){ + try { + log.debug("Test template info"); + TemplateInfoResponse response = mSvc.templateInfo(templateId, null); + log.debug("Template infoTemplate: {}", response); + + Assert.assertTrue(response.getSource().equals(TEMPLATEHTML)); + Assert.assertTrue(response.getPreview().equals(TEMPLATEHTML)); + + } catch (MailJimpException mje) { + processError(mje); + } + } + + + @Test + public void testTemplateDel(){ + try { + log.debug("Test template del"); + boolean response = mSvc.templateDel(templateId); + log.debug("Template delTemplate: {}", response); + Assert.assertTrue(response); + } catch (MailJimpException mje) { + processError(mje); + } + } + + @Test + public void testTemplateUnDel(){ + try { + log.debug("Test template undel"); + boolean response = mSvc.templateUndel(templateId); + log.debug("Template undelTemplate: {}", response); + Assert.assertTrue(response); + } catch (MailJimpException mje) { + processError(mje); + } + } + + + + // cleanup too. + @Test + public void testTemplateFinalDelete(){ + try { + boolean response = mSvc.templateDel(templateId); + Assert.assertTrue(response); + } catch (MailJimpException mje) { + processError(mje); + } + } + + +} \ No newline at end of file diff --git a/mailjimp-core/src/test/resources/.gitignore b/mailjimp-core/src/test/resources/.gitignore new file mode 100644 index 0000000..d762c98 --- /dev/null +++ b/mailjimp-core/src/test/resources/.gitignore @@ -0,0 +1,2 @@ +/mailjimp.properties +/mailjimp-test.properties diff --git a/mailjimp-core/src/test/resources/mailjimp-test.properties b/mailjimp-core/src/test/resources/mailjimp-test.properties deleted file mode 100644 index c58cb00..0000000 --- a/mailjimp-core/src/test/resources/mailjimp-test.properties +++ /dev/null @@ -1,14 +0,0 @@ -################################################################################################################### -# # -# Set up some extra properties for the tests. You will need some extra information and setup in your # -# MailChimp account to run the integration tests. # -# # -# The properties file needs to contain the following: # -# mj.test.listId=a_list_id_you_like_to_test # -# mj.test.subscribedUserEMailAddress=an_email_address_of_an_subscribed_user_of_that_list # -# # -################################################################################################################### - -mj.test.listId= -mj.test.groupingId= -mj.test.subscribedUserEMailAddress= \ No newline at end of file diff --git a/mailjimp-core/src/test/resources/mailjimp.properties b/mailjimp-core/src/test/resources/mailjimp.properties deleted file mode 100644 index 98e08f4..0000000 --- a/mailjimp-core/src/test/resources/mailjimp.properties +++ /dev/null @@ -1,23 +0,0 @@ -################################################################################################################### -# # -# We use this to inject the username, password and API key information into the bean directly. # -# Please note that you can also inject them directly via constructor args, if you desire - check out the bean # -# definition for a sample. # -# # -# If you do not provide the username and password, you cannot perform any security-related changes, but that is # -# not a big deal. Right? # -# # -# The properties file needs to contain the following: # -# mj.username=your_username # -# mj.password=your_password # -# mj.apiKey=your_api_key # -# mj.apiVersion=version_to_use # -# mj.ssl=(true|false) # -# # -################################################################################################################### - -mj.username= -mj.password= -mj.apiKey= -mj.apiVersion=1.3 -mj.ssl=true \ No newline at end of file diff --git a/mailjimp-webhook/pom.xml b/mailjimp-webhook/pom.xml index 8b9369b..687732b 100644 --- a/mailjimp-webhook/pom.xml +++ b/mailjimp-webhook/pom.xml @@ -6,7 +6,7 @@ MailChimp Java API - Webhook - net.mailjimp + ca.morningstar.mailjimp mailjimp-parent 0.4-SNAPSHOT @@ -45,4 +45,5 @@ provided + ca.morningstar.mailjimp diff --git a/pom.xml b/pom.xml index 67a6c4e..0098f95 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,6 @@ 4.0.0 - net.mailjimp + ca.morningstar.mailjimp mailjimp-parent 0.4-SNAPSHOT MailChimp Java API - Meta Project