From 8f9d1de32e82d07b317c2d2412a4b1fb18acaf18 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Tue, 6 Jul 2021 09:15:24 -0700 Subject: [PATCH] Fixes gift cards --- src/clj/auto_ap/square/core.clj | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/clj/auto_ap/square/core.clj b/src/clj/auto_ap/square/core.clj index bd2ac0d5..5a372c25 100644 --- a/src/clj/auto_ap/square/core.clj +++ b/src/clj/auto_ap/square/core.clj @@ -117,6 +117,19 @@ result))) +(defn order + + ([o] + (log/info "Searching for" o) + (let [result (->> (client/get (str "https://connect.squareup.com/v2/orders/" o) + {:headers {"Square-Version" "2020-08-12" + "Authorization" "Bearer EAAAEO2xSqesDutZz71hz3eulKmrlKTiEqG3uZ4j25x5GYlOluQ2cj2JxNUXqXD7" + "Content-Type" "application/json"} + :as :json}) + :body)] + + (log/info "found " (count result)) + result))) (defn amount->money [amt] (* 0.01 (or (:amount amt) 0.0))) @@ -206,7 +219,9 @@ (remove-nils #:order-line-item {:item-name (:name li) - :category (item-id->category-name (:catalog_object_id li)) + :category (if (= "GIFT_CARD" (:item_type li)) + "Gift Card" + (item-id->category-name (:catalog_object_id li))) :total (amount->money (:total_money li)) :tax (amount->money (:total_tax_money li)) :discount (amount->money (:total_discount_money li))}))))}))))))