Ecwid / ecwid-mailchimp

MailChimp API Wrapper for Java
Apache License 2.0
86 stars 83 forks source link

Added campaign/list and reports/summary v2.0 method #20

Closed bwarncke closed 6 years ago

bwarncke commented 10 years ago

Added links to function description. Campaigns/list extends MailChimpMethod directly now.

bwarncke commented 10 years ago

Hit wrong button....

bwarncke commented 10 years ago

"saved_segment" and "type_opts" have to be lists. Otherwise this exceptions is thrown:

INFO: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at com.google.gson.Gson.fromJson(Gson.java:815) at com.google.gson.Gson.fromJson(Gson.java:868) at com.ecwid.mailchimp.MailChimpClient.execute(MailChimpClient.java:104) at com.liveyearbook.app.MailChimp.listCampaigns(MailChimp.java:111) at org.apache.jsp.lybAdmin.api.mailChimp.campaignListing_jsp._jspService(campaignListing_jsp.java:125) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:444) at org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:372) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:396) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at com.google.gson.internal.bind.JsonTreeReader.expect(JsonTreeReader.java:139) at com.google.gson.internal.bind.JsonTreeReader.beginObject(JsonTreeReader.java:70) at com.ecwid.mailchimp.internal.gson.MailChimpObjectTypeAdapter.read(MailChimpObjectTypeAdapter.java:86) at com.ecwid.mailchimp.internal.gson.MailChimpObjectTypeAdapter.read(MailChimpObjectTypeAdapter.java:1) at com.ecwid.mailchimp.internal.gson.MailChimpObjectTypeAdapter.read(MailChimpObjectTypeAdapter.java:99) at com.ecwid.mailchimp.internal.gson.MailChimpObjectTypeAdapter.read(MailChimpObjectTypeAdapter.java:1) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:81) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:60) at com.ecwid.mailchimp.internal.gson.MailChimpObjectTypeAdapter.read(MailChimpObjectTypeAdapter.java:99) at com.ecwid.mailchimp.internal.gson.MailChimpObjectTypeAdapter.read(MailChimpObjectTypeAdapter.java:1) at com.google.gson.Gson.fromJson(Gson.java:803) ... 24 more

bwarncke commented 10 years ago

Expected BEGIN_OBJECT but was BEGIN_ARRAY: saved_segment should be of type object. But MailChimp api returns an empty array when saved_segment is empty for this campaign. So an object is expected by array was provided.

If one would change saved_segment to list, one would get the opposite exception "Expected BEGIN_ARRAY but was BEGIN_OBJECT" next time the MailChimp api returns values for saved_segment.

Any suggestions? Maybe additional checking for empty arrays/values in MailChimpObjectTypeApapter?

basiliscus commented 10 years ago

saved_segment should be of type object. But MailChimp api returns an empty array when saved_segment is empty for this campaign.

This seems like a bug in the API. Is the field really needed for practical usage? If not, I'd prefer leaving the field unimplemented rather than hacking MailChimpObjectTypeApapter.

basiliscus commented 10 years ago

Fuh, I must say the API is really a mess.

Can we simple remove the arguable fields? Or they are really needed? If someone really needs the field values, they should be able to obtain them using the http://ecwid.github.io/ecwid-mailchimp/site/apidocs/com/ecwid/mailchimp/MailChimpObject.html#get(java.lang.Object) method.

cemana commented 10 years ago

Hi, I have a question. I want to create a jar file with this wrapper, and use it in my web application created with Netbeans. Is it possible? or which will be the correct way to do that. Thanks.