Skip to content

Commit

Permalink
options to allow passing additional params
Browse files Browse the repository at this point in the history
this allows adding params for clj-http options
as well as the possibility of other options later on
  • Loading branch information
dsapala committed Sep 12, 2012
1 parent e394246 commit 78ba0ae
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/climp/core.clj
Expand Up @@ -24,13 +24,23 @@
(str (mailchimp-url) "?method=" method))

(defn call-mailchimp
"Call a method on MailChimp"
[method params]
(:body (client/post (method-url method) {
:as :json
:content-type :json
:body (generate-string (assoc params :apikey *mc-api-key*))
})))
"Call a method on MailChimp
The available options are:
:clj-http-options - extra options you would like passed through to clj-http
Example calls:
(call-mailchimp \"listActivity\" {:id \"a1a1a1a1a1\"})
(call-mailchimp \"listActivity\" {:id \"a1a1a1a1a1\"} {:clj-http-options {:socket-timeout 1000}})"
[method params & [opts]]
(let [base-params {:as :json
:content-type :json
:body (generate-string (assoc params :apikey *mc-api-key*))}
final-params (merge base-params (:clj-http-options opts))]
(:body (client/post (method-url method) final-params))))

(defn lists
"return lists"
Expand Down

0 comments on commit 78ba0ae

Please sign in to comment.