 ;; a specific order.
 (deftype OrderedMultipartParams [xs]
   InfersRequestOptions
-  (-params-key [_] :multipart-params)
-  (-params [_] xs))
+  (-params [_] {:multipart-params xs}))
 
 (defn ordered-multipart-params [xs]
   {:pre [(seqable? xs)]}

  (let [params (:params opts)
        base-opts (-opts params)
        opts* (merge base-opts opts)
        k (-params-key params)
        v (or (get opts* k) (-params params))]
    (-> opts*
        (dissoc :params)
        (assoc
          k v
          :url url)
        (dissoc nil))))

(defn put-error! [opts error]

  (extend-protocol InfersRequestOptions
    MyTransitType
    (-opts [_] {:accept \"application/transit+json\"})
    (-params [this] {:transit-params this}))"

  (-opts [_] "Returns arbitrary request options for params type")
  (-params [_] "Returns a map of cljs-http params for request options"))

(extend-protocol InfersRequestOptions
  js/FormData
  (-params [form-data] {:body form-data})

  nil
  (-params [_] nil)

  default
  (-opts [x] (request-defaults x))
  (-params [x]
    ;; The conversion to JSON or similar serializations depends on `clj->js`,
    ;; which for our purposes is restricted to types satisfying ICollection.
    (let [k (if (coll? x)
                (collection-format->params-key (:collection-format @config) :params)
                :params)]
      {k x})))

(defrecord MultipartParams []
  InfersRequestOptions
  (-params [this] {:multipart-params (seq this)}))

(def multipart-params map->MultipartParams)

