This commit is contained in:
Bryce Covert
2018-04-05 18:17:45 -07:00
parent 7fc02c1d04
commit 33cfc395de
10 changed files with 230 additions and 4 deletions

View File

@@ -24,6 +24,7 @@
[buddy.auth.backends.token :refer [jws-backend]]
[buddy.auth.middleware :refer [wrap-authorization wrap-authentication]]
[auto-ap.db.companies :as companies]
[auto-ap.db.vendors :as vendors]
[amazonica.core :refer [defcredential]]
[amazonica.aws.simpleemail :as ses]))
(defn best-match [companies company-identifier]
@@ -88,6 +89,11 @@
{:status 200
:body (pr-str (companies/get-all))
:headers {"Content-Type" "application/edn"}})
(GET "/api/vendors" []
{:status 200
:body (pr-str (vendors/get-all))
:headers {"Content-Type" "application/edn"}})
(GET "/api/invoices" []
{:status 200
@@ -105,7 +111,7 @@
:headers {"Content-Type" "application/edn"}})
(POST "/api/reminders/send" {:keys [query-params]}
(doseq [{:keys [name email invoice-reminder-schedule]} (companies/get-all)]
(doseq [{:keys [name email invoice-reminder-schedule]} (vendors/get-all)]
(when (= "Weekly" invoice-reminder-schedule)
(println "Sending email to" email)
(ses/send-email :destination {:to-addresses [email]}
@@ -122,6 +128,11 @@
:body (pr-str (companies/upsert id edn-params))
:headers {"Content-Type" "application/edn"}})
(PUT "/api/vendors/:id" {:keys [edn-params] {:keys [id]} :route-params :as r}
{:status 200
:body (pr-str (vendors/upsert id edn-params))
:headers {"Content-Type" "application/edn"}})
(POST "/api/invoices" {:keys [edn-params]}
(invoices/insert-multi! (:rows edn-params))
{:status 200