Advertisement
Guest User

Untitled

a guest
Aug 12th, 2014
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (ns api.core
  2.   (:require [clj-http.client :as client])
  3.   (:require [cheshire.core :refer :all])
  4.   (:require [clojure.string :as str]))
  5.  
  6. (def all-categories
  7.   (-> (client/get
  8.         "http://companapi.com/categories/all"
  9.         {:query-params {:format "json"}})
  10.       :body
  11.       (parse-string true)
  12.       :categories))
  13.  
  14. ;; get list of all categories matching query
  15. (defn find-categories [query categories]
  16.   (let [query' (str/lower-case query)]
  17.     (for [cat categories
  18.           c (:children cat)
  19.       :when (.contains (str/lower-case (:name c)) query'))
  20.       c)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement