Adds the ability for intuit snapshot balance
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
(ns auto-ap.import.intuit
|
||||
(:require
|
||||
[auto-ap.datomic :refer [conn pull-attr]]
|
||||
[auto-ap.import.common :refer [wrap-integration]]
|
||||
[auto-ap.import.transactions :as t]
|
||||
[auto-ap.intuit.core :as i]
|
||||
[auto-ap.logging :as alog]
|
||||
[auto-ap.time :as atime]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clj-time.core :as time]
|
||||
[clojure.string :as str]
|
||||
[com.unbounce.dogstatsd.core :as statsd]
|
||||
[datomic.api :as dc]))
|
||||
(:require [auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.import.common :refer [wrap-integration]]
|
||||
[auto-ap.import.transactions :as t]
|
||||
[auto-ap.intuit.core :as i]
|
||||
[auto-ap.logging :as alog]
|
||||
[auto-ap.time :as atime]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clj-time.core :as time]
|
||||
[clojure.string :as str]
|
||||
[com.unbounce.dogstatsd.core :as statsd]
|
||||
[datomic.api :as dc]
|
||||
[iol-ion.utils :refer [remove-nils]]))
|
||||
|
||||
(defn get-intuit-bank-accounts
|
||||
( [db]
|
||||
@@ -90,6 +90,10 @@
|
||||
bank-accounts (i/get-bank-accounts token)]
|
||||
@(dc/transact conn (mapv
|
||||
(fn [ba]
|
||||
{:intuit-bank-account/external-id (:name ba)
|
||||
:intuit-bank-account/name (:name ba)})
|
||||
(remove-nils
|
||||
{:intuit-bank-account/external-id (:name ba)
|
||||
:intuit-bank-account/name (:name ba)
|
||||
:intuit-bank-account/last-synced (coerce/to-date (:last-updated ba))
|
||||
:intuit-bank-account/current-balance (:current-balance ba)}))
|
||||
bank-accounts))))
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
(ns auto-ap.intuit.core
|
||||
(:require
|
||||
[amazonica.aws.s3 :as s3]
|
||||
[clj-http.client :as client]
|
||||
[clojure.core.memoize :as m]
|
||||
[clojure.java.io :as io]
|
||||
[clojure.string :as str]
|
||||
[config.core :as cfg :refer [env]])
|
||||
(:import
|
||||
(org.apache.commons.codec.binary Base64)))
|
||||
(:require [amazonica.aws.s3 :as s3]
|
||||
[clj-http.client :as client]
|
||||
[clj-time.coerce :as c]
|
||||
[clojure.core.memoize :as m]
|
||||
[clojure.java.io :as io]
|
||||
[clojure.string :as str]
|
||||
[config.core :as cfg :refer [env]])
|
||||
(:import (org.apache.commons.codec.binary Base64)))
|
||||
|
||||
;; (def authorization-code "AB11638463964I0tYPR3A1inog2HL407u2bZBXHg6LEqCbILRO")
|
||||
;; (def realm-id "4620816365202617680")
|
||||
@@ -98,6 +97,13 @@
|
||||
{:headers base-headers
|
||||
:as :json})
|
||||
|
||||
(defn get-bank-accounts-raw [token]
|
||||
(->> (:body (client/get (str prod-base-url "/company/" prod-company-id "/query" )
|
||||
{:headers
|
||||
(with-auth prod-base-headers token)
|
||||
:as :json
|
||||
:query-params {"query" "SELECT * From Account maxresults 1000"}}))
|
||||
:QueryResponse))
|
||||
|
||||
|
||||
(defn get-bank-accounts [token]
|
||||
@@ -110,10 +116,13 @@
|
||||
:Account
|
||||
#_(filter
|
||||
#(#{"Bank" "Credit Card"} (:AccountType %)))
|
||||
(map (juxt :Id :Name))
|
||||
(map (fn [[id name]]
|
||||
(map (juxt :Id :Name :CurrentBalance :MetaData))
|
||||
(map (fn [[id name current-balance metadata]]
|
||||
{:id id
|
||||
:name name}))))
|
||||
:name name
|
||||
:last-updated (c/to-date-time (-> metadata :LastUpdatedTime))
|
||||
:current-balance current-balance}))))
|
||||
|
||||
|
||||
(defn get-all-transactions [start end]
|
||||
(let [token (get-fresh-access-token)]
|
||||
|
||||
@@ -132,6 +132,7 @@
|
||||
request
|
||||
(com/page {:nav com/company-aside-nav
|
||||
:client-selection (:client-selection request)
|
||||
:request request
|
||||
:client (:client request)
|
||||
:clients (:clients request)
|
||||
:identity (:identity request)
|
||||
|
||||
Reference in New Issue
Block a user