Permalink
Browse files

Merge branch 'master' into pull_branch

  • Loading branch information...
kasz committed Apr 16, 2012
2 parents 5472cc8 + 0ed34c3 commit b36ec80dd19f52b2cf6c5ca0690dd13f599f7bb2
Showing with 24 additions and 7 deletions.
  1. +2 −2 project.clj
  2. +22 −5 src/fablo/api_client.clj
View
@@ -1,9 +1,9 @@
-(defproject fablo/api-client "1.0.4"
+(defproject fablo/api-client "1.1.0"
:description "Fablo API client"
:dependencies [[org.clojure/clojure "1.3.0"]
[clj-json "0.5.0"]
[commons-io/commons-io "2.0.1"]
[commons-codec "1.4"]
- [clj-http "0.2.7"]
+ [clj-http "0.3.6"]
[ring/ring-core "0.3.11"]]
:dev-dependencies [[swank-clojure "1.3.2"]])
View
@@ -17,19 +17,22 @@
uri (gensym "uri-")]
`(defn ~name [~@required-args & {:keys ~(vec (conj optional-args 'api-server 'api-customer 'api-auth-info 'throw-exceptions))}]
(let [~uri (string/join "/" ["/api/2" (or ~'api-customer ~'*api-customer*) (format ~url-template ~@url-template-args)])
+ api-server# (or ~'api-server ~'*api-server*)
request-map# (merge
- {:url (str "http://" (or ~'api-server ~'*api-server*) ~uri) ; TODO: extract "or"
+ {:url (str "http://" api-server# ~uri)
:method ~(or request-method :get)
:query-params (merge ~(into {} (map #(vector (str %) %) (remove url-parameters required-args)))
~@(map (fn [x] `(if ~x {~(str x) (if (string? ~x) ~x (json/generate-string ~x))} {}))
optional-args))
- :headers {"host" (or ~'api-server ~'*api-server*)}
- :throw-exceptions (or ~'throw-exceptions false)}
+ :headers {"host" api-server#}
+ :throw-exceptions (or ~'throw-exceptions false)
+ :throw-entire-message? true}
~(when signature-required
`(when-let [auth-info# (or ~'api-auth-info ~'*api-auth-info*)]
{:amazon-aws-auth [(or (:key-id auth-info#) "default") (:key auth-info#)]
:uri ~uri})))]
- (select-keys (api-request request-map#) [:status :body])))))
+ (select-keys (api-request request-map#)
+ [:status :body])))))
(def-api-fn products-query "products/query" :optional-args [search-string start results category prefilter attributes return sort weak-sort])
(def-api-fn product "products/id/%s" :required-args [id] :optional-args [return] :url-template-args [id])
@@ -47,13 +50,27 @@
(def-api-fn special-offers "special-offers")
(def-api-fn special-offers-random "special-offers/random" :optional-args [number])
+(def-api-fn version "admin/version")
+(def-api-fn status "admin/status")
+
;;; functions requiring authentication
;;; GET functions
(def-api-fn indexing-status "admin/indexing-status" :signature-required true)
(def-api-fn config "admin/config" :signature-required true)
+(def-api-fn features "admin/features" :signature-required true)
;;; POST functions
+(def-api-fn config-set "admin/config" :request-method :post, :signature-required true
+ :required-args [config])
(def-api-fn switch-db "admin/switch-db" :request-method :post, :signature-required true)
(def-api-fn upload-db "admin/upload-db" :request-method :post, :signature-required true
- :required-args [data-url] :optional-args [format check autoswitch])
+ :required-args [data-url] :optional-args [format autoswitch])
+(def-api-fn feedback "recommendations/feedback/%s" :request-method :post :signature-required true
+ :required-args [feedback-type user products] :optional-args [session-id] :url-template-args [feedback-type])
+
+;;; DELETE functions
+(def-api-fn config-delete-key "admin/config/%s" :request-method :delete, :signature-required true
+ :required-args [config-key] :url-template-args [config-key]) ; not really sure how this should work
+(def-api-fn config-delete-subkey "admin/config/%s/%s" :request-method :delete, :signature-required true
+ :required-args [config-key config-subkey] :url-template-args [config-key config-subkey])

0 comments on commit b36ec80

Please sign in to comment.