Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit

Permalink
Fix 'renew'
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlynux committed Feb 21, 2023
1 parent 164e845 commit ac00c6f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
[org.clojure/core.async "0.4.500"]
[datascript "1.3.9"]
[org.clojure/tools.logging "1.2.4"]
[org.clojure/test.check "0.9.0"]]
[org.clojure/test.check "0.9.0"]
[djblue/portal "0.35.1"]]
:plugins [[lein-cljfmt "0.5.7"]]
:main ^:skip-aot library-monkey.core
:target-path "target/%s"
Expand Down
13 changes: 11 additions & 2 deletions src/library_monkey/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[library-monkey.console :as console]
[clojure.spec.alpha :as s]
[cognitect.anomalies :as anom]
[clojure.core.async :as a :refer [<!! <! go chan]]
[clojure.core.async :as a :refer [<!! chan]]
[datascript.core :as d]))

(defprotocol Library
Expand All @@ -19,7 +19,10 @@
(let [cookie (authenticate library username password)]
(if (::anom/category cookie)
(assoc creds :credentials-error (::anom/category cookie))
(assoc creds :borrowings (get-borrowings library cookie)))))
(let [borrowings (get-borrowings library cookie)]
(doseq [b borrowings]
(renew-borrowing! library cookie b))
(assoc creds :borrowings (get-borrowings library cookie))))))

(defn generate-reports [library credentials ch]
(a/pipeline-blocking
Expand All @@ -45,6 +48,11 @@
:borrowings {:db/type :db.type/ref
:db/cardinality :db.cardinality/many}})
(comment
(require '[portal.api :as p])

(def p (p/open))
(add-tap #'p/submit)


(require '[clojure.spec.gen.alpha :as gen])
(def conn (d/create-conn schema))
Expand Down Expand Up @@ -119,4 +127,5 @@
(comment
(-main "config.edn")

(tap> (hickory.core/as-hiccup (hickory.core/parse @p)))
)
3 changes: 3 additions & 0 deletions src/library_monkey/network.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
:form-params {:name username
:pwd password}
:follow-redirects false})]
(tap> {:username username :response response})
(log/debug (str "auth-cookie [" username "] : [" (:status response) "]" ))
(case (:status response)
302 ((comp find-auth-cookie :set-cookie :headers) response)
Expand Down Expand Up @@ -62,7 +63,9 @@
(defn renew [cookie barcode]
(let [response @(http/get "http://bibliotheques.amiens.fr/clientBookline/recherche/dossier_lecteur.asp"
{:query-params {"STRCODEDOCBASE" "CAAM"
"ACT" "RENEW"
"VALUE" barcode}
:headers {"Cookie" cookie}
:follow-redirects false})]
(tap> {:barcode barcode :response response})
response))

0 comments on commit ac00c6f

Please sign in to comment.