added ability to see existing accounts.
This commit is contained in:
@@ -30,5 +30,11 @@
|
|||||||
|
|
||||||
:url (:yodlee-fastlink env)
|
:url (:yodlee-fastlink env)
|
||||||
|
|
||||||
}) })))
|
}) }))
|
||||||
|
(GET "/accounts" {:keys [query-params identity] :as request}
|
||||||
|
(assert-admin identity)
|
||||||
|
(let [[session token] (yodlee/get-access-token)]
|
||||||
|
{:status 200
|
||||||
|
:headers {"Content-Type" "application/edn"}
|
||||||
|
:body (pr-str (yodlee/get-accounts)) })))
|
||||||
wrap-secure))
|
wrap-secure))
|
||||||
|
|||||||
@@ -43,7 +43,9 @@
|
|||||||
user-session (login-user cob-session)]
|
user-session (login-user cob-session)]
|
||||||
(-> (str (:yodlee-base-url env) "/accounts")
|
(-> (str (:yodlee-base-url env) "/accounts")
|
||||||
(client/get {:headers (merge base-headers {"Authorization" (auth-header cob-session user-session)})
|
(client/get {:headers (merge base-headers {"Authorization" (auth-header cob-session user-session)})
|
||||||
:as :json}))))
|
:as :json})
|
||||||
|
:body
|
||||||
|
:account)))
|
||||||
|
|
||||||
(defn get-provider-accounts []
|
(defn get-provider-accounts []
|
||||||
(let [cob-session (login-cobrand)
|
(let [cob-session (login-cobrand)
|
||||||
|
|||||||
@@ -12,16 +12,7 @@
|
|||||||
[auto-ap.routes :as routes]
|
[auto-ap.routes :as routes]
|
||||||
[bidi.bidi :as bidi]))
|
[bidi.bidi :as bidi]))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
|
||||||
::authenticate-with-yodlee
|
|
||||||
(fn [{:keys [db]} _]
|
|
||||||
{:db (assoc-in db [::yodlee :loading?] true)
|
|
||||||
:http {:token (:user db)
|
|
||||||
:method :get
|
|
||||||
:headers {"Content-Type" "application/edn"}
|
|
||||||
:uri (str "/api/yodlee/fastlink")
|
|
||||||
:on-success [::authenticated]
|
|
||||||
:on-error [::save-error]}}))
|
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::authentication
|
::authentication
|
||||||
@@ -33,6 +24,44 @@
|
|||||||
(fn [db]
|
(fn [db]
|
||||||
(-> db ::yodlee :loading?)))
|
(-> db ::yodlee :loading?)))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
::accounts
|
||||||
|
(fn [db]
|
||||||
|
(-> db ::yodlee :accounts)))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
::accounts-loading?
|
||||||
|
(fn [db]
|
||||||
|
(-> db ::yodlee :accounts-loading?)))
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::authenticate-with-yodlee
|
||||||
|
(fn [{:keys [db]} _]
|
||||||
|
{:db (assoc-in db [::yodlee :loading?] true)
|
||||||
|
:http {:token (:user db)
|
||||||
|
:method :get
|
||||||
|
:headers {"Content-Type" "application/edn"}
|
||||||
|
:uri (str "/api/yodlee/fastlink")
|
||||||
|
:on-success [::authenticated]
|
||||||
|
:on-error [::save-error]}}))
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::mounted
|
||||||
|
(fn [{:keys [db]} _]
|
||||||
|
{:db (assoc-in db [::yodlee] {:accounts-loading? true})
|
||||||
|
:http {:token (:user db)
|
||||||
|
:method :get
|
||||||
|
:headers {"Content-Type" "application/edn"}
|
||||||
|
:uri (str "/api/yodlee/accounts")
|
||||||
|
:on-success [::got-accounts]
|
||||||
|
:on-error [::save-error]}}))
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::got-accounts
|
||||||
|
(fn [{:keys [db]} [_ accounts]]
|
||||||
|
{:db (-> db
|
||||||
|
(assoc-in [::yodlee :accounts] accounts)
|
||||||
|
(assoc-in [::yodlee :accounts-loading?] false))}))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::authenticated
|
::authenticated
|
||||||
@@ -43,32 +72,58 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn admin-yodlee-page []
|
(defn yodlee-link-button []
|
||||||
[:div
|
[:div
|
||||||
(let [authentication @(re-frame/subscribe [::authentication])
|
(let [authentication @(re-frame/subscribe [::authentication])
|
||||||
loading? @(re-frame/subscribe [::loading?])]
|
loading? @(re-frame/subscribe [::loading?])]
|
||||||
|
|
||||||
[:div
|
(if authentication
|
||||||
[:h1.title "Yodlee"]
|
[:div
|
||||||
(if authentication
|
"Authentication successful!"
|
||||||
[:div
|
[:form {:action (:url authentication) :method "POST"}
|
||||||
"Authentication successful!"
|
[:input {:type "hidden"
|
||||||
[:form {:action (:url authentication) :method "POST"}
|
:name "rsession"
|
||||||
[:input {:type "hidden"
|
:value (:session authentication)}]
|
||||||
:name "rsession"
|
[:input {:type "hidden"
|
||||||
:value (:session authentication)}]
|
:name "token"
|
||||||
[:input {:type "hidden"
|
:value (:token authentication)}]
|
||||||
:name "token"
|
[:input {:type "hidden"
|
||||||
:value (:token authentication)}]
|
:name "app"
|
||||||
[:input {:type "hidden"
|
:value (:app authentication)}]
|
||||||
:name "app"
|
|
||||||
:value (:app authentication)}]
|
|
||||||
|
|
||||||
[:input {:type "hidden"
|
[:input {:type "hidden"
|
||||||
:name "redirectReq"
|
:name "redirectReq"
|
||||||
:value "true"}]
|
:value "true"}]
|
||||||
[:button.button.is-primary [:span [:span.icon [:i.fa.fa-external-link]] " Go to yodlee"]]]]
|
[:button.button.is-primary [:span [:span.icon [:i.fa.fa-external-link]] " Go to yodlee"]]]]
|
||||||
|
|
||||||
|
[:button.button.is-primary {:class (if loading? "is-loading" "") :on-click (dispatch-event [::authenticate-with-yodlee])} "Authenticate with Yodlee"]))])
|
||||||
|
|
||||||
|
(defn yodlee-accounts-table []
|
||||||
|
|
||||||
|
[:div
|
||||||
|
[:table.table
|
||||||
|
[:thead
|
||||||
|
[:tr
|
||||||
|
[:th "Account Name"]
|
||||||
|
[:th "Account Number"]
|
||||||
|
[:th "Yodlee Account Number"]]]
|
||||||
|
(if @(re-frame/subscribe [::accounts-loading?])
|
||||||
|
[:tr [:td {:col-span "3"} "Loading..."]
|
||||||
|
]
|
||||||
|
(for [account @(re-frame/subscribe [::accounts])]
|
||||||
|
[:tr
|
||||||
|
[:td (:accountName account)]
|
||||||
|
[:td (:accountNumber account)]
|
||||||
|
[:td (:id account)]]))]])
|
||||||
|
|
||||||
|
|
||||||
|
(defn admin-yodlee-page []
|
||||||
|
[(with-meta
|
||||||
|
(fn []
|
||||||
|
[:div
|
||||||
|
[:h1.title "Yodlee"]
|
||||||
|
|
||||||
[:button.button.is-primary {:class (if loading? "is-loading" "") :on-click (dispatch-event [::authenticate-with-yodlee])} "Authenticate with Yodlee"])
|
[yodlee-accounts-table]
|
||||||
|
[yodlee-link-button]])
|
||||||
])])
|
{:component-did-mount (fn []
|
||||||
|
(re-frame/dispatch [::mounted]))})])
|
||||||
|
|||||||
Reference in New Issue
Block a user