you can now delete yodlee accounts again.

This commit is contained in:
Bryce Covert
2020-12-22 14:21:13 -08:00
parent bbdb9602aa
commit c3b79a6f2f
4 changed files with 54 additions and 61 deletions

View File

@@ -72,15 +72,19 @@
:headers {"Content-Type" "application/edn"}
:body (pr-str {:message (.getMessage e)
:error (.toString e)})})))
(POST "/provider-accounts/delete/:id" {:keys [query-params identity] {:keys [id]} :route-params :as request}
(POST "/provider-accounts/delete/" {:keys [query-params edn-params identity] {:keys [id]} :route-params :as request}
(assert-admin identity)
(try
(let [[session token] (yodlee/get-access-token)]
(yodlee/delete-provider-account (Long/parseLong id))
{:status 200
:headers {"Content-Type" "application/edn"}
:body (pr-str @yodlee/in-memory-cache) })
(yodlee/delete-provider-account (-> (:client-id edn-params)
Long/parseLong
d-clients/get-by-id
:client/code)
(:provider-account-id edn-params))
{:status 200
:headers {"Content-Type" "application/edn"}
:body (pr-str {}) }
(catch Exception e
(log/error e)
{:status 400
:headers {"Content-Type" "application/edn"}
:body (pr-str {:message (.getMessage e)

View File

@@ -260,7 +260,7 @@
(defn delete-provider-account [client-code id]
(let [cob-session (login-user client-code)]
(let [cob-session (login-user (client-code->login client-code))]
(-> (str (:yodlee2-base-url env) "/providerAccounts/" id )
@@ -270,7 +270,7 @@
:body
:providerAccount
first))
@(d/transact conn [:db/retractEntity [:yodlee-provider-account/id id]]))
@(d/transact conn [[:db/retractEntity (:db/id (d/entity (d/db conn) [:yodlee-provider-account/id id]))]]))
(defn upsert-accounts-tx
([client-code]

View File

@@ -203,56 +203,7 @@
:on-success [::authenticated-mfa provider-account-id]
:on-error [::forms/save-error [::mfa-form provider-account-id] ]}}))
(re-frame/reg-event-fx
::provider-account-refreshed
(fn [{:keys [db]} [_ i result]]
{:db (assoc-in db [::provider-accounts] result)
:dispatch [::forms/form-closing [::refresh-provider-account i]]}))
(re-frame/reg-event-fx
::provider-account-deleted
(fn [{:keys [db]} [_ i result]]
{:db (assoc-in db [::provider-accounts] result)
:dispatch-n [[::forms/form-closing [::refresh-provider-account i]]
[::modal/modal-closed ]]}))
(re-frame/reg-event-fx
::delete-provider-account
[with-user ]
(fn [{:keys [user db]} [_ provider-account-id ]]
{:http {:token user
:method :post
:owns-state {:single ::delete-provider-account}
:headers {"Content-Type" "application/edn"}
:uri (str "/api/yodlee2/provider-accounts/delete/" provider-account-id )
:body {}
:on-success [::provider-account-deleted provider-account-id]
:on-error [::forms/save-error [::delete-provider-account provider-account-id] ]}}))
(re-frame/reg-event-fx
::delete-requested
[with-user]
(fn [{:keys [user db]} [_ account-id]]
{:dispatch
[::modal/modal-requested {:title "Delete Provider account "
:body [:div "Are you sure you want to delete provider account " account-id "?"]
:confirm {:value "Delete provider account"
:status-from [::status/single ::delete-provider-account]
:class "is-danger"
:on-click (dispatch-event [::delete-provider-account account-id])
:close-event [::status/completed ::delete-provider-account]}
:cancel? true}]}))
(defn delete-button [account-id]
[:button.button
{:on-click (dispatch-event [::delete-requested account-id])}
[:span.icon [:i.fa.fa-times]]])
(re-frame/reg-sub
::bank-accounts-by-yodlee-account-id
@@ -414,7 +365,7 @@
(fn [{:keys [db]} _]
{:dispatch [::data-requested]
::forward/register {:id ::yodlee-account-refreshed
:events #{::table/refreshed}
:events #{::table/refreshed ::table/provider-account-deleted}
:event-fn (fn [[_ query-result]]
[::data-requested])}
:db (dissoc db ::authentication)}))

View File

@@ -3,9 +3,11 @@
[auto-ap.subs :as subs]
[auto-ap.views.components.buttons :as buttons]
[auto-ap.views.components.grid :as grid]
[auto-ap.views.components.modal :as modal]
[auto-ap.views.pages.admin.users.form :as form]
[auto-ap.views.utils :refer [action-cell-width date->str with-user ->$]]
[re-frame.core :as re-frame]))
[auto-ap.views.utils :refer [->$ action-cell-width date->str with-user dispatch-event]]
[re-frame.core :as re-frame]
[auto-ap.forms :as forms]))
(re-frame/reg-event-fx
::refreshed
@@ -28,6 +30,40 @@
:provider-account-id provider-account}
:on-success [::refreshed provider-account]}}))
(re-frame/reg-event-fx
::provider-account-deleted
(fn [{:keys [db]} [_ i result]]
{:dispatch [::modal/modal-closed ]}))
(re-frame/reg-event-fx
::delete-provider-account
[with-user ]
(fn [{:keys [user db]} [_ provider-account-id ]]
(comment :on-error [::forms/save-error [::delete-provider-account provider-account-id] ])
{:http {:token user
:method :post
:owns-state {:single ::delete-provider-account}
:headers {"Content-Type" "application/edn"}
:uri (str "/api/yodlee2/provider-accounts/delete/" )
:body {:client-id (:id @(re-frame/subscribe [::subs/client]))
:provider-account-id provider-account-id}
:on-success [::provider-account-deleted provider-account-id]
}}))
(re-frame/reg-event-fx
::delete-requested
[with-user]
(fn [{:keys [user db]} [_ account-id]]
{:dispatch
[::modal/modal-requested {:title "Delete Provider account "
:body [:div "Are you sure you want to delete provider account " account-id "?"]
:confirm {:value "Delete provider account"
:status-from [::status/single ::delete-provider-account]
:class "is-danger"
:on-click (dispatch-event [::delete-provider-account account-id])
:close-event [::status/completed ::delete-provider-account]}
:cancel? true}]}))
(re-frame/reg-event-fx
::params-changed
(fn [{:keys [db]} [_ p]]
@@ -75,4 +111,6 @@
:icon "fa-pencil"}]
[buttons/fa-icon {:event [::request-refresh (:id c)]
:class (status/class-for (get statuses (:id c)))
:icon "fa-refresh"}]]]])]]]))
:icon "fa-refresh"}]
[buttons/fa-icon {:event [::delete-requested (:id c)]
:icon "fa-times"}]]]])]]]))