I am trying to write a wrapper for the google adwords api in Clojure but struggle with constants and Interfaces. The java code looks like this :
CampaignServiceInterface campaignService =
user.getService(AdWordsService.V201109.CAMPAIGN_SERVICE);
Usually you can call constants in Clojure with e.g. (Math/PI) but when I write:
(def user (AdWordsUser. ))
(.getService user (AdWordsService/V201109/CAMPAIGN_SERVICE))
I just get "no such namespace". Also I am a bit clueless on how to implement the interface correct. I think I should use "reify" but I get stuck.
Link to Interface: http://google-api-adwords-java.googlecode.com/svn-history/r234/trunk/docs/com/google/api/adwords/v201003/cm/CampaignServiceInterface.html
(defn campaign-service [ ]
(reify
com.google.adwords.api.v201109.cm.CampaignServiceInterface
(get [this] ??))))
If I read it correctly,
AdWordsService.V201109.CAMPAIGN_SERVICE
is a static constant of an inner class of class AdWordsService.To access inner classes you need to use java's internal name mangling scheme **; separate the inner class from its outer class with a $ sign:
AdWordsService$V201109/CAMPAIGN_SERVICE
** the JVM doesn't actually have a notion of inner classes, so java "fakes" it by creating a standalone class
AdWordsService$V201109