 (ns open-company.api.entry
   (:require [compojure.core :refer (defroutes GET OPTIONS)]
-            [liberator.core :refer (defresource by-method)]
+            [liberator.core :refer (defresource)]
             [open-company.api.common :as common]
             [open-company.resources.company :as company-res]
             [open-company.representations.common :as common-rep]

  :handle-not-acceptable (fn [_] (common/only-accept 406 "application/json"))
  :handle-unsupported-media-type (fn [_] (common/only-accept 415 "application/json"))

  :handle-ok handle-get

  :handle-options (common/options-response [:options :get]))


    user      (conj (common-rep/link-map "company-create" "POST" "/companies/" company-rep/media-type))
    companies (into (mapv company-link companies))))

(defn render-entry [{:keys [user] :as _ctx}]
  (let [companies (when user (company-res/get-companies-by-index "org-id" (:org-id user)))]
    (json/generate-string
      {:links (links user companies)}
      {:pretty true})))

;; ----- Resources - see: http://clojure-liberator.github.io/liberator/assets/img/decision-graph.svg

(defresource entry-point []
  common/anonymous-resource
