   :limit is the maxium number of tracks to return, default is 20.
   :offset is the index of the first track to return, default is 0.
 
-  Example: (get-a-list-of-featured-playlists {:locale \"sv_SE\" :country \"SE\" :timestamp \"2015-10-23T09:00:00\" :limit 50 :offset 50} \"BQBw-JtC..._7GvA\")")
-
-(def-spotify-api-call get-a-list-of-new-releases client/get (str spotify-api-url "browse/new-releases")
+  Example: (get-a-list-of-featured-playlists {:locale \"sv_SE\" :country \"SE\" :timestamp \"2015-10-23T09:00:00\" :limit 50 :offset 50} \"BQBw-JtC..._7GvA\")" (spotify-api-call client/get (str spotify-api-url "browse/featured-playlists")))
+
+(def get-a-list-of-new-releases  
   " Takes two arguments, a map m with query parameters and an optional oauth-token t.
   There are no compulsary keys in m, optional keys are :country, :limit and :offset.
   :country is an ISO 3166-1 alpha-2 country code.
   :limit is the maxium number of tracks to return, default is 20.
   :offset is the index of the first track to return, default is 0.
 
-  Example: (get-a-list-of-new-releases {:country \"SE\" :limit 50 :offset 50} \"BQBw-JtC..._7GvA\")")
-
-(def-spotify-api-call get-a-list-of-categories client/get (str spotify-api-url "browse/categories")
+  Example: (get-a-list-of-new-releases {:country \"SE\" :limit 50 :offset 50} \"BQBw-JtC..._7GvA\")"
+  (spotify-api-call client/get (str spotify-api-url "browse/new-releases")))
+
+(def get-a-list-of-categories 
   " Takes two arguments, a map m with query parameters and an optional oauth-token t.
   There are no compulsary keys in m, optional keys are :country, :limit and :offset.
   :country is an ISO 3166-1 alpha-2 country code.
   :limit is the maxium number of tracks to return, default is 20.
   :offset is the index of the first track to return, default is 0.
 
-  Example: (get-a-list-of-categories {:country \"SE\" :limit 50 :offset 50} \"BQBw-JtC..._7GvA\")")
-
-(def-spotify-api-call get-a-category client/get (str spotify-api-url "browse/categories/category_id")
+  Example: (get-a-list-of-categories {:country \"SE\" :limit 50 :offset 50} \"BQBw-JtC..._7GvA\")" (spotify-api-call client/get (str spotify-api-url "browse/categories")))
+
+(def get-a-category 
   " Takes two arguments, a map m with query parameters and an optional oauth-token t.
   Compulsory key in m is :category_id, optional keys are :country and :locale.
   :category_id has to be a spotify category id.
   :country is an ISO 3166-1 alpha-2 country code.
   :locale is an ISO 639 language code and a ISO 3166-1 alpha-2 country code joined with an underscore.
 
-  Example: (get-a-category {:category_id \"dinner\" :country \"SE\" :locale \"sv_SE\"} \"BQBw-JtC..._7GvA\")")
-
-(def-spotify-api-call get-a-categorys-playlists client/get (str spotify-api-url "browse/categories/category_id/playlists") 
+  Example: (get-a-category {:category_id \"dinner\" :country \"SE\" :locale \"sv_SE\"} \"BQBw-JtC..._7GvA\")" (spotify-api-call client/get (str spotify-api-url "browse/categories/category_id")))
+
+(def get-a-categorys-playlists  
   " Takes two arguments, a map m with query parameters and an optional oauth-token t.
   Compulsory key in m is :category_id, optional keys are :country, :limit and :offset.
   :category_id has to be a spotify category id.

(defn set-params-type
  "Return either :query-params or :form-params key depending on value of verb"
  [verb]
 (let [verb-type (type verb)] 
  (if
    (or (= verb-type clj_http.client$put) (= verb-type clj_http.client$post))
    :form-params
    :query-params)))

;TODO - better doc string
(defmacro def-spotify-api-call
  "Creates a function f with doc-string d that calls the http-verb verb for url url."
  [f verb url doc-string]
  `(defn ~f 
     ~doc-string
     ([m#] (~f m# nil))
     ([m# t#]
      (let [query-params# {(set-params-type ~verb) (modify-form-params m#) :oauth-token t# :content-type :json}]
        (->
          (try
            (~verb (replace-url-values m# ~url) query-params#)
            (catch Exception e# (ex-data e#))
            )
          (response-to-map))))))

;Albums
(def-spotify-api-call get-an-album client/get (str spotify-api-url "albums/id")
  " Takes two arguments, a map m with query parameters and an optional oauth-token t.
  Compulsory key in m is :id, optional key is :market.
  :id has to have the value of an existing album's id.
  :market is an ISO 3166-1 alpha-2 country code.

  Example: (get-an-album {:id \"0MnG7y5F1n4Wns63RjEItx\" :market \"SE\"} \"BQBw-JtC..._7GvA\")")

(def-spotify-api-call get-several-albums client/get (str spotify-api-url "albums")
  " Takes two arguments, a map m with query parameters and an optional oauth-token t.
  Compulsory key in m is :ids, optional key is :market.
  :ids has to be a comma separated string of spotify album ids.
  :market is an ISO 3166-1 alpha-2 country code.

  Example: (get-several-albums {:ids \"4hTil0JVdMyxK2vH11ZbiX,4RjjFbiqFaO8mKTDM2Kzna\" :market \"SE\"} \"BQBw-JtC..._7GvA\") ")

(def-spotify-api-call get-an-albums-tracks client/get (str spotify-api-url "albums/id/tracks")
  " Takes two arguments, a map m with query parameters and an optional oauth-token t.
  Compulsory key in m is :id, optional keys are :limit, :offset and :market.
  :id has to have the value of an existing album's id.

  :limit is the maxium number of tracks to return, default is 20.
  :offset is the index of the first track to return, default is 0.

  Example: (get-an-artists-albums {:id \"7lOJ7WXyopaxri0dbOiZkd\" :album_type \"album, single\" :market \"SE\" :limit 50 :offset 50}} \"BQBw-JtC..._7GvA\")" (spotify-api-call client/get (str spotify-api-url "artists/id/albums")))

(def get-an-artists-top-tracks 
  " Takes two arguments, a map m with query parameters and an optional oauth-token t.
  Compulsory keys in m are :id and :country.
  :id has to be a spotify artist id.
  :country is an ISO 3166-1 alpha-2 country code.

  Example: (get-an-artists-top-tracks {:id \"7hCsRnXtcbez8msLPfjbkz\" :country \"SE\"} \"BQBw-JtC..._7GvA\")" (spotify-api-call client/get (str spotify-api-url "artists/id/top-tracks")))

(def get-an-artists-related-artists
  " Takes two arguments, a map m with query parameters and an optional oauth-token t.
  Compulsory key in m is :id.
  :id has to be a spotify artist id.

  Example: (get-an-artists-related-artists {:id \"4EF5vIcCYKMM61oYOG2Tqa\"} \"BQBw-JtC..._7GvA\")" (spotify-api-call client/get (str spotify-api-url "artists/id/related-artists")))

;Browse
(def get-a-list-of-featured-playlists
  " Takes two arguments, a map m with query parameters and an optional oauth-token t.
  There are no compulsary keys in m, optional keys are :locale, :country, :timestamp, :limit and :offset.
  :locale is an ISO 639 language code and a ISO 3166-1 alpha-2 country code joined with an underscore.
