 (defasync base-query
   "GET query to wikidata with the given parameters"
   [params callback]
-  (println "aboot to query" params)
   (http/get base-url {:query-params (merge {:language "en"
                                             :format "json"}
                                            params)}
-            (comp callback id-print)))
+            callback))
 
 (defn body [http-response]
   (-> http-response (:body) (json/decode true)))

   TODO: figure out why promise is super broken, just use callback for now"
  [id callback]
  (base-query {:action "wbgetclaims" :entity id}
              (comp callback :claims id-print body)))

            [clojure.string :as str]
            [cheshire.core :as json]))

(declare lookup-nation lookup-city)

(def ^:const base-url "https://www.wikidata.org/w/api.php")

(def ^:const property-keys
  {:place-of-birth :P19
   :date-of-birth :P569
   :title :P373 ;; technically "Commons Category". Regardless, seems to be a
   ;; good way to cut to the chase and get an identifier
   })

(defn property
  ([key properties]
     (property key properties nil))
  ([key properties default]
     (get properties
          (or (get property-keys key)
              (throw (ex-info "Property key doesn't exist"
                              {:key key
                               :properties property
                               :property-keys property-keys})))
          default)))

(defmacro defasync [name doc args & body]
  `(defn ~name ~doc
     ([~@(drop-last args)]
        (let [p# (promise)]
          (~name ~@(drop-last args) (fn [val#] (p# val#) val#))
          p#))
     ([~@args] ~@body)))

