opened yodlee up.

This commit is contained in:
2022-07-24 08:41:32 -07:00
parent 95c723e983
commit bc07ad8f01
13 changed files with 80 additions and 80 deletions

View File

@@ -0,0 +1,2 @@
{:lint-as {malli.experimental/defn schema.core/defn}
:linters {:unresolved-symbol {:exclude [(malli.core/=>)]}}}

View File

@@ -1,4 +1,4 @@
@charset "utf-8";
@/charset "utf-8";
/* latin */
@font-face {
font-family: 'Calibri';

View File

@@ -1,17 +1,9 @@
(ns auto-ap.graphql.yodlee2
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql assert-can-see-client assert-admin enum->keyword]]
[auto-ap.datomic.yodlee2 :as d-yodlee2]
[auto-ap.time :refer [parse iso-date]]
[auto-ap.utils :refer [dollars=]]
[datomic.api :as d]
[auto-ap.datomic :refer [uri remove-nils audit-transact conn]]
[clj-time.coerce :as coerce]
[clj-time.core :as time]
[clojure.set :as set]
[clojure.tools.logging :as log]))
(:require
[auto-ap.datomic.yodlee2 :as d-yodlee2]
[auto-ap.graphql.utils :refer [->graphql <-graphql assert-admin]]))
(defn get-yodlee-provider-account-page [context args value]
(assert-admin (:id context))
(let [args (assoc args :id (:id context))
[yodlee-provider-accounts cnt] (d-yodlee2/get-graphql (<-graphql (assoc args :id (:id context))))]
{:yodlee_provider_accounts (map ->graphql yodlee-provider-accounts)
@@ -21,9 +13,9 @@
:end (+ (:start args 0) (count yodlee-provider-accounts))}))
(defn get-all-yodlee-provider-accounts [context args value]
(assert-admin (:id context))
(map
->graphql
(first (d-yodlee2/get-graphql (assoc (<-graphql args)
:count Integer/MAX_VALUE)))))
(let [args (assoc args :id (:id context))]
(map
->graphql
(first (d-yodlee2/get-graphql (assoc (<-graphql args)
:count Integer/MAX_VALUE))))))

View File

@@ -14,6 +14,7 @@
:headers {"Content-Type" "application/json"}
:body "{}"})
(POST "/event" request
;; {"id" "bf3dcf5c-a68f-42d9-9084-049133e03d3d", "parent_type" "Caterer", "parent_id" "91541331-d7ae-4634-9e8b-ccbbcfb2ce70", "entity_type" "Order", "entity_id" "9ab05fee-a9c5-483b-a7f2-14debde4b7a8", "key" "accepted", "occurred_at" "2022-07-21T19:21:07.549Z"}
(log/info (str "POST EVENT " (body-string request) request))
{:status 200
:headers {"Content-Type" "application/json"}

View File

@@ -1,18 +1,20 @@
(ns auto-ap.routes.yodlee2
(:require
[auto-ap.yodlee.core2 :as yodlee]
[auto-ap.graphql.utils :refer [assert-admin]]
[auto-ap.datomic :refer [conn]]
[auto-ap.datomic.clients :as d-clients]
[auto-ap.graphql.utils :refer [assert-admin assert-can-see-client]]
[auto-ap.routes.utils :refer [wrap-secure]]
[compojure.core :refer [GET POST context defroutes wrap-routes]]
[config.core :refer [env]]
[auto-ap.yodlee.core2 :as yodlee]
[clojure.tools.logging :as log]
[auto-ap.datomic.clients :as d-clients]))
[compojure.core :refer [context defroutes GET POST wrap-routes]]
[config.core :refer [env]]
[datomic.api :as d]))
(defroutes routes
(wrap-routes
(context "/yodlee2" []
(GET "/fastlink" {:keys [query-params identity] :as request}
(assert-admin identity)
(assert-can-see-client identity (d/pull (d/db conn) [:db/id] [:client/code (get query-params "client")]))
(let [token (if-let [client-id (get query-params "client-id")]
(-> client-id

View File

@@ -16,7 +16,7 @@
"import-batches" :admin-import-batches
"vendors" :admin-vendors
"excel-import" :admin-excel-import
"yodlee2" :admin-yodlee2}
}
"invoices/" {"" :invoices
"import" :import-invoices
"unpaid" :unpaid-invoices
@@ -32,6 +32,7 @@
"excluded" :excluded-transactions}
"reports/" {"" :reports}
"plaid" :plaid
"yodlee2" :yodlee2
"ledger/" {"" :ledger
"profit-and-loss" :profit-and-loss
"balance-sheet" :balance-sheet

View File

@@ -47,10 +47,7 @@
[:span {:class "name"} "Rules"]]]
[:li.menu-item
[:a {:href (bidi/path-for routes/routes :admin-yodlee2), :class (str "item" (active-when ap = :admin-yodlee2))}
[:span {:class "icon icon-saving-bank-1" :style {:font-size "25px"}}]
[:span {:class "name"} "Yodlee 2 Link"]]]

View File

@@ -27,7 +27,7 @@
[auto-ap.views.pages.admin.excel-import :refer [admin-excel-import-page]]
[auto-ap.views.pages.admin.users :refer [admin-users-page]]
[auto-ap.views.pages.admin.import-batches :refer [import-batches-page]]
[auto-ap.views.pages.admin.yodlee2 :as yodlee2]
[auto-ap.views.pages.company.yodlee2 :as yodlee2]
[auto-ap.views.pages.company.plaid :as plaid]))
(defmulti page (fn [active-page] active-page))
@@ -109,8 +109,8 @@
(defmethod page :admin-import-batches [_]
[import-batches-page])
(defmethod page :admin-yodlee2 [_]
(yodlee2/admin-yodle-provider-accounts-page))
(defmethod page :yodlee2 [_]
(yodlee2/admin-yodlee-provider-accounts-page))
(defmethod page :plaid [_]
(plaid/plaid-page))

View File

@@ -18,4 +18,8 @@
[:li.menu-item
[:a {:href (bidi/path-for routes/routes :plaid), :class (str "item" (active-when ap = :plaid))}
[:span {:class "icon icon-saving-bank-1" :style {:font-size "25px"}}]
[:span {:class "name"} "Plaid Link"]]]]))
[:span {:class "name"} "Plaid Link"]]]
[:li.menu-item
[:a {:href (bidi/path-for routes/routes :yodlee2), :class (str "item" (active-when ap = :yodlee2))}
[:span {:class "icon icon-saving-bank-1" :style {:font-size "25px"}}]
[:span {:class "name"} "Yodlee Link"]]]]))

View File

@@ -1,15 +1,16 @@
(ns auto-ap.views.pages.admin.yodlee2
(ns auto-ap.views.pages.company.yodlee2
(:require
[auto-ap.effects.forward :as forward]
[auto-ap.status :as status]
[auto-ap.subs :as subs]
[auto-ap.views.components.admin.side-bar :refer [admin-side-bar]]
[auto-ap.views.components.grid :as grid]
[auto-ap.views.components.layouts :refer [side-bar-layout]]
[auto-ap.views.pages.admin.yodlee2.table :as table]
[auto-ap.views.utils :refer [dispatch-event]]
[auto-ap.views.pages.company.side-bar :refer [company-side-bar]]
[auto-ap.views.pages.company.yodlee2.table :as table]
[auto-ap.views.utils :refer [dispatch-event with-user]]
[re-frame.core :as re-frame]
[reagent.core :as reagent]))
[reagent.core :as reagent]
[vimsical.re-frame.cofx.inject :as inject]))
(re-frame/reg-sub
::authentication
@@ -27,11 +28,6 @@
(fn [db]
(::yodlee-provider-accounts db)))
(re-frame/reg-event-fx
::params-change
(fn [_ [_ params]]
{:set-uri-params params}))
(re-frame/reg-sub
::page
:<- [::params]
@@ -42,10 +38,11 @@
(re-frame/reg-event-fx
::data-requested
(fn [{:keys [db]} _]
{:graphql {:token (:user db)
[with-user (re-frame/inject-cofx ::inject/sub [::subs/client])]
(fn [{:keys [user] ::subs/keys [client]} _]
{:graphql {:token user
:owns-state {:single ::page}
:query-obj {:venia/queries [[:yodlee-provider-account-page {:client-id (:id @(re-frame/subscribe [::subs/client]))}
:query-obj {:venia/queries [[:yodlee-provider-account-page {:client-id (:id client)}
[[:yodlee-provider-accounts [:id :last-updated :status :detailed-status
[:client [:id]]
[:accounts [:id :name :number :available-balance]]]]
@@ -58,20 +55,21 @@
{:dispatch [::data-requested]
::forward/register {:id ::yodlee-account-refreshed
:events #{::table/refreshed ::table/provider-account-deleted}
:event-fn (fn [[_ query-result]]
:event-fn (fn [[_ _]]
[::data-requested])}
:db (dissoc db ::authentication)}))
(re-frame/reg-event-fx
::unmounted
(fn [{:keys [db]} _]
(fn [_ _]
{::forward/dispose {:id ::yodlee-account-refreshed}}))
(re-frame/reg-event-fx
::authenticate-with-yodlee
(fn [{:keys [db]} [_ client]]
{:http {:token (:user db)
[with-user]
(fn [{:keys [user]} [_ client]]
{:http {:token user
:method :get
:headers {"Content-Type" "application/edn"}
:uri (str "/api/yodlee2/fastlink?client=" client)
@@ -110,7 +108,6 @@
#js {"fastLinkURL" (:url authentication)
"accessToken" (:token authentication)
"params" #js { "configName" "Aggregation"}}
"fa-spot")
)}
[:span [:span.icon [:i.fa.fa-external-link]] " Go to yodlee"]]]
@@ -131,11 +128,14 @@
[yodlee-link-button]])
(defn admin-yodle-provider-accounts-page []
(reagent/create-class
{:component-will-unmount #(re-frame/dispatch [::unmounted])
:component-did-mount #(re-frame/dispatch [::mounted])
:reagent-render (fn []
[side-bar-layout {:side-bar [admin-side-bar {}]
:main [admin-yodlee-provider-accounts-content]}])}))
(defn admin-yodlee-provider-accounts-page []
(let [user (re-frame/subscribe [::subs/user])]
(reagent/create-class
{:component-will-unmount #(re-frame/dispatch [::unmounted])
:component-did-mount #(re-frame/dispatch [::mounted])
:reagent-render (fn []
(if (not= "manager" (:user/role @user))
[side-bar-layout {:side-bar [company-side-bar {}]
:main [admin-yodlee-provider-accounts-content]}]
[:div "Not authorized"]))})))

View File

@@ -1,4 +1,4 @@
(ns auto-ap.views.pages.admin.yodlee2.form
(ns auto-ap.views.pages.company.yodlee2.form
(:require
[auto-ap.views.components.modal :as modal]
[re-frame.core :as re-frame]

View File

@@ -1,25 +1,24 @@
(ns auto-ap.views.pages.admin.yodlee2.table
(ns auto-ap.views.pages.company.yodlee2.table
(:require [auto-ap.status :as status]
[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.yodlee2.form :as form]
[auto-ap.views.pages.company.yodlee2.form :as form]
[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.core :as re-frame]))
(re-frame/reg-event-fx
::refreshed
[with-user ]
(fn [{:keys [user db]} [_ provider-account ]]
(fn [_ _]
;; this is tracked in yodlee main, for refreshing
{}))
(re-frame/reg-event-fx
::request-refresh
[with-user ]
(fn [{:keys [user db]} [_ provider-account client-id ]]
(fn [{:keys [user]} [_ provider-account client-id ]]
{:http {:token user
:method :post
:headers {"Content-Type" "application/edn"}
@@ -32,7 +31,7 @@
(re-frame/reg-event-fx
::provider-account-deleted
(fn [{:keys [db]} [_ i result]]
(fn [_ _]
{:dispatch [::modal/modal-closed ]}))
@@ -52,8 +51,7 @@
(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] ])
(fn [{:keys [user]} [_ provider-account-id ]]
{:http {:token user
:method :post
:owns-state {:single ::delete-provider-account}
@@ -67,7 +65,7 @@
(re-frame/reg-event-fx
::delete-requested
[with-user]
(fn [{:keys [user db]} [_ account-id]]
(fn [_ [_ account-id]]
{:dispatch
[::modal/modal-requested {:title "Delete Provider account "
:body [:div "Are you sure you want to delete provider account " account-id "?"]
@@ -91,7 +89,8 @@
(defn table [{:keys [status page]}]
(let [params @(re-frame/subscribe [::params])
statuses @(re-frame/subscribe [::status/multi ::refresh])
login-statuses @(re-frame/subscribe [::status/multi ::request-login-form])]
login-statuses @(re-frame/subscribe [::status/multi ::request-login-form])
is-admin? @(re-frame/subscribe [::subs/is-admin?])]
[grid/grid {:status status
:on-params-change (fn [p]
(re-frame/dispatch [::params-changed p]))
@@ -121,13 +120,14 @@
^{:key (:id a)}
[:li (:name a) " - " (:number a) [:div.tag (->$ (:available-balance a))]])]]
[grid/cell {}
[:div.buttons
[buttons/fa-icon {:event
[::request-login-form (:id c) (:id (:client c))]
:class (status/class-for (get login-statuses (:id c)))
:icon "fa-pencil"}]
[buttons/fa-icon {:event [::request-refresh (:id c) (:id (:client c))]
:class (status/class-for (get statuses (:id c)))
:icon "fa-refresh"}]
[buttons/fa-icon {:event [::delete-requested (:id c)]
:icon "fa-times"}]]]])]]]))
(when is-admin?
[:div.buttons
[buttons/fa-icon {:event
[::request-login-form (:id c) (:id (:client c))]
:class (status/class-for (get login-statuses (:id c)))
:icon "fa-pencil"}]
[buttons/fa-icon {:event [::request-refresh (:id c) (:id (:client c))]
:class (status/class-for (get statuses (:id c)))
:icon "fa-refresh"}]
[buttons/fa-icon {:event [::delete-requested (:id c)]
:icon "fa-times"}]])]])]]]))

View File

@@ -71,6 +71,7 @@
:component-will-unmount #(re-frame/dispatch [::unmounted])
:reagent-render
(fn []
(println "ROLE" (:user/role @user))
(if (not= "manager" (:user/role @user))
[side-bar-layout
{:side-bar [company-side-bar {:data-page ::page}]