fixed errors.

This commit is contained in:
2022-04-06 09:16:02 -07:00
parent 54de896c6c
commit 2dbafd157a
5 changed files with 48 additions and 68 deletions

View File

@@ -1,16 +1,16 @@
(ns auto-ap.yodlee.core2
(:require [clj-http.client :as client]
[auto-ap.utils :refer [by]]
[cemerick.url :as u]
[unilog.context :as lc]
[clojure.tools.logging :as log]
[clojure.data.json :as json]
[clojure.core.async :as async]
[config.core :refer [env]]
#_{:clj-kondo/ignore [:unused-namespace]}
[mount.core :as mount]
#_{:clj-kondo/ignore [:unused-namespace]}
[yang.scheduler :as scheduler]
[clj-time.coerce :as coerce]
[auto-ap.time :as time2]
[datomic.api :as d]
[auto-ap.datomic :refer [conn]]
[auto-ap.datomic.clients :as d-clients]))
@@ -220,23 +220,19 @@
:body)))
(defn assert-user [client-code]
(let [cob-session (login-cobrand client-code)]
cob-session))
(defn get-provider-accounts-with-details [client-code ]
(let [provider-accounts (get-provider-accounts client-code)]
(let [concurrent 20
output-chan (async/chan)]
(async/pipeline-blocking concurrent
output-chan
(map (fn [provider-account]
(lc/with-context {:provider-account-id (:id provider-account)}
(get-provider-account-detail client-code (:id provider-account)))))
(async/to-chan provider-accounts))
(async/<!! (async/into [] output-chan)))))
(let [provider-accounts (get-provider-accounts client-code)
concurrent 20
output-chan (async/chan)]
(async/pipeline-blocking concurrent
output-chan
(map (fn [provider-account]
(lc/with-context {:provider-account-id (:id provider-account)}
(get-provider-account-detail client-code (:id provider-account)))))
(async/to-chan! provider-accounts))
(async/<!! (async/into [] output-chan))))
(defn get-accounts-for-providers [client-code provider-account-ids]
(log/info "looking up " (count provider-account-ids) " provider accounts's accounts for client " client-code ".")
@@ -248,7 +244,6 @@
provider-account-ids)))
(defn get-provider-accounts-with-accounts [client-code]
(let [provider-accounts (by :id (get-provider-accounts-with-details client-code))
accounts (get-accounts-for-providers client-code (keys provider-accounts))]
@@ -319,28 +314,23 @@
(catch Exception e
(log/error "Could not update client " (:client/code client)
e))))))
(async/to-chan (d-clients/get-all)))
(async/to-chan! (d-clients/get-all)))
(let [result (async/<!! (async/into [] output-chan))]
(log/info "Current yodlee state is " result)
@(d/transact conn result))))
(defn update-yodlee [id]
(update-provider-account id)
(refresh-provider-account id))
(defn reauthenticate [client-code pa data]
(println client-code)
(try
(doto (-> (str (:yodlee2-base-url env) "/providerAccounts?providerAccountIds=" pa)
(-> (str (:yodlee2-base-url env) "/providerAccounts?providerAccountIds=" pa)
(client/put (doto (merge {:headers (merge base-headers {"Authorization" (auth-header (login-user (client-code->login client-code)))})
:body (json/write-str data)
:as :json}
other-config)
clojure.pprint/pprint)))
log/info)
(client/put (merge {:headers (merge base-headers {"Authorization" (auth-header (login-user (client-code->login client-code)))})
:body (json/write-str data)
:as :json}
other-config)))
(catch Exception e
(log/error e))) )