<commit_before>;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) 2016 <NAME> <<EMAIL>>

(ns uxbox.main.repo.images
  "A main interface for access to remote resources."
  (:require [beicon.core :as rx]
            [uxbox.config :refer (url)]
            [uxbox.main.repo.impl :refer (request send!)]
            [uxbox.util.transit :as t]))

(defmethod request :fetch/image-collections
  [_]
  (let [params {:url (str url "/library/image-collections")
                :method :get}]
    (send! params)))

(defmethod request :delete/image-collection
  [_ id]
  (let [url (str url "/library/image-collections/" id)]
    (send! {:url url :method :delete})))

(defmethod request :create/image-collection
  [_ {:keys [data] :as body}]
  (let [body (assoc body :data (t/encode data))
        params {:url (str url "/library/image-collections")
                :method :post
                :body body}]
    (send! params)))

(defmethod request :update/image-collection
  [_ {:keys [id data] :as body}]
  (let [body (assoc body :data (t/encode data))
        params {:url (str url "/library/image-collections/" id)
                :method :put
                :body body}]
    (send! params)))

(defmethod request :fetch/images
  [_ {:keys [coll]}]
  (let [params {:url (str url "/library/image-collections/" coll "/images")
                :method :get}]
    (send! params)))

(defmethod request :create/image
  [_ {:keys [coll id file] :as body}]
  (let [body (doto (js/FormData.)
               (.append "file" file)
               (.append "id" id))
        params {:url (str url "/library/image-collections/" coll "/images")
                :method :post
                :body body}]
    (send! params)))

(defmethod request :delete/image
  [_ id]
  (let [url (str url "/library/images/" id)]
    (send! {:url url :method :delete})))<commit_msg>Send width and height fields on image uploading repo method.<commit_after>;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) 2016 <NAME> <<EMAIL>>

(ns uxbox.main.repo.images
  "A main interface for access to remote resources."
  (:require [beicon.core :as rx]
            [uxbox.config :refer (url)]
            [uxbox.main.repo.impl :refer (request send!)]
            [uxbox.util.transit :as t]))

(defmethod request :fetch/image-collections
  [_]
  (let [params {:url (str url "/library/image-collections")
                :method :get}]
    (send! params)))

(defmethod request :delete/image-collection
  [_ id]
  (let [url (str url "/library/image-collections/" id)]
    (send! {:url url :method :delete})))

(defmethod request :create/image-collection
  [_ {:keys [data] :as body}]
  (let [body (assoc body :data (t/encode data))
        params {:url (str url "/library/image-collections")
                :method :post
                :body body}]
    (send! params)))

(defmethod request :update/image-collection
  [_ {:keys [id data] :as body}]
  (let [body (assoc body :data (t/encode data))
        params {:url (str url "/library/image-collections/" id)
                :method :put
                :body body}]
    (send! params)))

(defmethod request :fetch/images
  [_ {:keys [coll]}]
  (let [params {:url (str url "/library/image-collections/" coll "/images")
                :method :get}]
    (send! params)))

(defmethod request :create/image
  [_ {:keys [coll id file width height] :as body}]
  (let [body (doto (js/FormData.)
               (.append "file" file)
               (.append "width" width)
               (.append "height" height)
               (.append "id" id))
        params {:url (str url "/library/image-collections/" coll "/images")
                :method :post
                :body body}]
    (send! params)))

(defmethod request :delete/image
  [_ id]
  (let [url (str url "/library/images/" id)]
    (send! {:url url :method :delete})))
{'fraction_non_alphanumeric': 0.15283109404990403, 'fraction_numerical': 0.003838771593090211, 'mean_word_length': 2.500419815281276, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7126960', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1267, 'n_words': 432}