Merge branch 'master' into datomic
This commit is contained in:
@@ -35,5 +35,11 @@
|
|||||||
(let [[session token] (yodlee/get-access-token)]
|
(let [[session token] (yodlee/get-access-token)]
|
||||||
{:status 200
|
{:status 200
|
||||||
:headers {"Content-Type" "application/edn"}
|
:headers {"Content-Type" "application/edn"}
|
||||||
:body (pr-str (yodlee/get-accounts)) })))
|
:body (pr-str (yodlee/get-accounts)) }))
|
||||||
|
(POST "/accounts/:id" {:keys [query-params identity] {:keys [id]} :route-params :as request}
|
||||||
|
(assert-admin identity)
|
||||||
|
(let [[session token] (yodlee/get-access-token)]
|
||||||
|
{:status 200
|
||||||
|
:headers {"Content-Type" "application/edn"}
|
||||||
|
:body (pr-str (yodlee/update-yodlee (Long/parseLong id))) })))
|
||||||
wrap-secure))
|
wrap-secure))
|
||||||
|
|||||||
@@ -92,18 +92,33 @@
|
|||||||
(defn get-provider-accounts []
|
(defn get-provider-accounts []
|
||||||
(let [cob-session (login-cobrand)
|
(let [cob-session (login-cobrand)
|
||||||
user-session (login-user cob-session)
|
user-session (login-user cob-session)
|
||||||
batch-size 100
|
batch-size 100]
|
||||||
get-transaction-batch (fn []
|
|
||||||
(-> (str (:yodlee-base-url env) "/providerAccounts")
|
|
||||||
|
|
||||||
(client/get {:headers (doto
|
(-> (str (:yodlee-base-url env) "/providerAccounts")
|
||||||
(merge base-headers {"Authorization" (auth-header cob-session user-session)})
|
|
||||||
println)
|
|
||||||
:as :json})
|
|
||||||
:body
|
|
||||||
))]
|
|
||||||
|
|
||||||
(get-transaction-batch)))
|
(client/get {:headers (doto
|
||||||
|
(merge base-headers {"Authorization" (auth-header cob-session user-session)})
|
||||||
|
println)
|
||||||
|
:as :json})
|
||||||
|
:body
|
||||||
|
:providerAccount
|
||||||
|
)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(defn get-provider-account [id]
|
||||||
|
(let [cob-session (login-cobrand)
|
||||||
|
user-session (login-user cob-session)
|
||||||
|
batch-size 100]
|
||||||
|
|
||||||
|
(-> (str (:yodlee-base-url env) "/providerAccounts/" id)
|
||||||
|
|
||||||
|
(client/get {:headers (doto
|
||||||
|
(merge base-headers {"Authorization" (auth-header cob-session user-session)})
|
||||||
|
println)
|
||||||
|
:as :json})
|
||||||
|
:body
|
||||||
|
:providerAccount)))
|
||||||
|
|
||||||
(defn update-provider-account [pa]
|
(defn update-provider-account [pa]
|
||||||
(let [cob-session (login-cobrand)
|
(let [cob-session (login-cobrand)
|
||||||
@@ -118,12 +133,16 @@
|
|||||||
:body "{\"dataSetName\": [\"BASIC_AGG_DATA\"]}"
|
:body "{\"dataSetName\": [\"BASIC_AGG_DATA\"]}"
|
||||||
:as :json}))))
|
:as :json}))))
|
||||||
|
|
||||||
(defn get-specific-transactions []
|
(defn update-yodlee [id]
|
||||||
|
(update-provider-account (:providerAccountId (first (filter #(= (:id %) id) (get-accounts)))))
|
||||||
|
(get-provider-account (:providerAccountId (first (filter #(= (:id %) id) (get-accounts))))))
|
||||||
|
|
||||||
|
(defn get-specific-transactions [account]
|
||||||
(let [cob-session (login-cobrand)
|
(let [cob-session (login-cobrand)
|
||||||
user-session (login-user cob-session)
|
user-session (login-user cob-session)
|
||||||
batch-size 100
|
batch-size 100
|
||||||
get-transaction-batch (fn [skip]
|
get-transaction-batch (fn [skip]
|
||||||
(-> (str (:yodlee-base-url env) "/transactions?top=" batch-size "&skip=" skip "&accountId=16422358")
|
(-> (str (:yodlee-base-url env) "/transactions?top=" batch-size "&skip=" skip "&accountId=" account)
|
||||||
(doto println)
|
(doto println)
|
||||||
|
|
||||||
(client/get {:headers (doto
|
(client/get {:headers (doto
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
[clojure.string :as str]))
|
[clojure.string :as str]))
|
||||||
|
|
||||||
(def date-regex #"[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}")
|
(def date-regex #"[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}")
|
||||||
(def money-regex #"[0-9]+(\.[0-9]{1,2})?$")
|
(def money-regex #"\-?[0-9]+(\.[0-9]{1,2})?$")
|
||||||
|
|
||||||
(s/def ::identifier (s/nilable string?))
|
(s/def ::identifier (s/nilable string?))
|
||||||
(s/def ::date (s/and string? #(re-matches date-regex %)))
|
(s/def ::date (s/and string? #(re-matches date-regex %)))
|
||||||
|
|||||||
@@ -5,8 +5,7 @@
|
|||||||
|
|
||||||
(def email-regex #"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$")
|
(def email-regex #"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$")
|
||||||
(s/def ::id int)
|
(s/def ::id int)
|
||||||
(s/def ::identifier (s/nilable string?))
|
(s/def ::identifier (s/nilable string?)) (s/def ::required-identifier (s/and string?
|
||||||
(s/def ::required-identifier (s/and string?
|
|
||||||
#(not (str/blank? %))))
|
#(not (str/blank? %))))
|
||||||
|
|
||||||
(s/def ::name ::required-identifier)
|
(s/def ::name ::required-identifier)
|
||||||
@@ -17,14 +16,14 @@
|
|||||||
(s/def ::phone (s/nilable string?))
|
(s/def ::phone (s/nilable string?))
|
||||||
|
|
||||||
(s/def ::invoice-reminder-schedule (s/nilable #{"Weekly" "Never" nil}))
|
(s/def ::invoice-reminder-schedule (s/nilable #{"Weekly" "Never" nil}))
|
||||||
(s/def ::primary-contact ::identifier)
|
(s/def ::primary-contact (s/nilable ::identifier))
|
||||||
(s/def ::primary-email ::email)
|
(s/def ::primary-email (s/nilable ::email))
|
||||||
(s/def ::primary-phone ::phone)
|
(s/def ::primary-phone (s/nilable ::phone))
|
||||||
|
|
||||||
(s/def ::secondary-contact ::identifier)
|
(s/def ::secondary-contact (s/nilable ::identifier))
|
||||||
(s/def ::secondary-email ::email)
|
(s/def ::secondary-email (s/nilable ::email))
|
||||||
(s/def ::secondary-phone ::phone)
|
(s/def ::secondary-phone (s/nilable ::phone))
|
||||||
(s/def ::address ::address/address)
|
(s/def ::address (s/nilable ::address/address))
|
||||||
(s/def ::default-expense-account int?)
|
(s/def ::default-expense-account int?)
|
||||||
|
|
||||||
(s/def ::code (s/nilable string?))
|
(s/def ::code (s/nilable string?))
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
[auto-ap.subs :as subs]))
|
[auto-ap.subs :as subs]))
|
||||||
|
|
||||||
(defn vendor-dialog [{:keys [vendor save-event change-event id] {:keys [name]} :vendor}]
|
(defn vendor-dialog [{:keys [vendor save-event change-event id] {:keys [name]} :vendor}]
|
||||||
|
|
||||||
(let [companies-by-id @(re-frame/subscribe [::subs/companies-by-id])]
|
(let [companies-by-id @(re-frame/subscribe [::subs/companies-by-id])]
|
||||||
[action-modal {:id id
|
[action-modal {:id id
|
||||||
:title [:span (if (:id vendor)
|
:title [:span (if (:id vendor)
|
||||||
@@ -23,7 +24,7 @@
|
|||||||
:save-event save-event
|
:save-event save-event
|
||||||
:can-submit? (s/valid? ::entity/vendor vendor)}
|
:can-submit? (s/valid? ::entity/vendor vendor)}
|
||||||
|
|
||||||
(doto (s/explain ::entity/vendor vendor) println)
|
|
||||||
|
|
||||||
[horizontal-field
|
[horizontal-field
|
||||||
[:label.label "Name"]
|
[:label.label "Name"]
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
(:require-macros [cljs.core.async.macros :refer [go]])
|
(:require-macros [cljs.core.async.macros :refer [go]])
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
[reagent.core :as reagent]
|
[reagent.core :as reagent]
|
||||||
|
[clojure.string :as str]
|
||||||
[auto-ap.subs :as subs]
|
[auto-ap.subs :as subs]
|
||||||
[auto-ap.events.admin.companies :as events]
|
[auto-ap.events.admin.companies :as events]
|
||||||
[auto-ap.entities.companies :as entity]
|
[auto-ap.entities.companies :as entity]
|
||||||
@@ -56,6 +57,28 @@
|
|||||||
:on-success [::got-accounts]
|
:on-success [::got-accounts]
|
||||||
:on-error [::save-error]}}))
|
:on-error [::save-error]}}))
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::kicked
|
||||||
|
(fn [{:keys [db]} [_ id state]]
|
||||||
|
{:db (update-in db [::yodlee :accounts]
|
||||||
|
(fn [as]
|
||||||
|
(map (fn [a]
|
||||||
|
(if (= (:id a) id)
|
||||||
|
(assoc a :status state)
|
||||||
|
a))
|
||||||
|
as)))}))
|
||||||
|
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::kick
|
||||||
|
(fn [{:keys [db]} [_ id]]
|
||||||
|
{:http {:token (:user db)
|
||||||
|
:method :post
|
||||||
|
:headers {"Content-Type" "application/edn"}
|
||||||
|
:uri (str "/api/yodlee/accounts/" id)
|
||||||
|
:on-success [::kicked id :kicking]
|
||||||
|
:on-error [::kicked id :errored]}}))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::got-accounts
|
::got-accounts
|
||||||
(fn [{:keys [db]} [_ accounts]]
|
(fn [{:keys [db]} [_ accounts]]
|
||||||
@@ -106,15 +129,30 @@
|
|||||||
[:tr
|
[:tr
|
||||||
[:th "Account Name"]
|
[:th "Account Name"]
|
||||||
[:th "Account Number"]
|
[:th "Account Number"]
|
||||||
[:th "Yodlee Account Number"]]]
|
[:th "Yodlee Account Number"]
|
||||||
|
[:th "Yodlee Last updated"]
|
||||||
|
[:th "Yodlee Status"]
|
||||||
|
[:th]]]
|
||||||
|
|
||||||
(if @(re-frame/subscribe [::accounts-loading?])
|
(if @(re-frame/subscribe [::accounts-loading?])
|
||||||
[:tr [:td {:col-span "3"} "Loading..."]
|
[:tr [:td {:col-span "6"} "Loading..."]
|
||||||
]
|
]
|
||||||
(for [account @(re-frame/subscribe [::accounts])]
|
(for [account @(re-frame/subscribe [::accounts])]
|
||||||
[:tr
|
[:tr
|
||||||
[:td (:accountName account)]
|
[:td (:accountName account)]
|
||||||
[:td (:accountNumber account)]
|
[:td (:accountNumber account)]
|
||||||
[:td (:id account)]]))]])
|
[:td (:id account)]
|
||||||
|
[:td (str/join ", " (map :lastUpdated (:dataset account)))]
|
||||||
|
[:td (str/join ", " (map :additionalStatus (:dataset account)))]
|
||||||
|
[:td
|
||||||
|
(cond (= (:status account) :kicking)
|
||||||
|
[:button.button.is-success.is-loading {:disabled "disabled"} "Kick."]
|
||||||
|
|
||||||
|
(= (:status account) :error)
|
||||||
|
[:button.button.is-error.is-loading {:disabled "disabled"} "Error."]
|
||||||
|
|
||||||
|
:else
|
||||||
|
[:button.button.is-success {:on-click (dispatch-event [::kick (:id account)] )} "Kick." ])]]))]])
|
||||||
|
|
||||||
|
|
||||||
(defn admin-yodlee-page []
|
(defn admin-yodlee-page []
|
||||||
|
|||||||
Reference in New Issue
Block a user