Adds ability for users to configure basic ezcater integration.

This commit is contained in:
2022-07-10 06:09:14 -07:00
parent a84993126b
commit 0606da9c49
12 changed files with 252 additions and 35 deletions

View File

@@ -259,7 +259,7 @@
:check (str (+ index (:bank-account/check-number bank-account)))
:memo memo
:date (date->str (local-now))
:client (dissoc client :client/bank-accounts :client/square-integration-status :client/locked-until :client/emails :client/square-auth-token :client/square-locations)
:client (dissoc client :client/bank-accounts :client/square-integration-status :client/ezcater-locations :client/locked-until :client/emails :client/square-auth-token :client/square-locations)
:bank-account (dissoc bank-account :bank-account/start-date :bank-account/integration-status)
#_#_:client {:name (:name client)
:address (:address client)

View File

@@ -112,6 +112,14 @@
{:db/id (:id sl)
:square-location/client-location (:client_location sl)}))
(:square_locations edit_client))
:client/ezcater-locations (map
(fn [el]
(remove-nils
{:db/id (:id el)
:ezcater-location/location (:location el)
:ezcater-location/caterer (:caterer el)}))
(:ezcater_locations edit_client))
:client/week-b-credits (:week_b_credits edit_client)
:client/location-matches (->> (:location_matches edit_client)
(filter (fn [lm] (and (:location lm) (:match lm))))
@@ -430,6 +438,11 @@
:square_id {:type 'String}
:id {:type :id}}}
:ezcater_location
{:fields {:location {:type 'String}
:caterer {:type :ezcater_caterer}
:id {:type :id}}}
:email_contact {:fields {:id {:type :id}
:email {:type 'String}
:description {:type 'String}}}
@@ -454,6 +467,7 @@
:matches {:type '(list String)}
:bank_accounts {:type '(list :bank_account)}
:square_locations {:type '(list :square_location)}
:ezcater_locations {:type '(list :ezcater_location)}
:forecasted_transactions {:type '(list :forecasted_transaction)}
:yodlee_provider_accounts {:type '(list :yodlee_provider_account)}
:plaid_items {:type '(list :plaid_item)}}}
@@ -510,6 +524,10 @@
:edit_square_location {:fields {:client_location {:type 'String}
:id {:type :id}}}
:edit_ezcater_location {:fields {:location {:type 'String}
:caterer {:type :id}
:id {:type :id}}}
:edit_forecasted_transaction {:fields {:identifier {:type 'String}
:id {:type :id}
:day_of_month {:type 'Int}
@@ -534,6 +552,7 @@
:matches {:type '(list String)}
:location_matches {:type '(list :edit_location_match)}
:square_locations {:type '(list :edit_square_location)}
:ezcater_locations {:type '(list :edit_ezcater_location)}
:bank_accounts {:type '(list :edit_bank_account)}
:forecasted_transactions {:type '(list :edit_forecasted_transaction)}}}

View File

@@ -0,0 +1,46 @@
(ns auto-ap.graphql.ezcater
(:require
[auto-ap.datomic :refer [conn]]
[auto-ap.graphql.utils :refer [assert-admin cleanse-query]]
[auto-ap.graphql.vendors :refer [partial-match-first]]
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
[datomic.api :as d]))
(defn search [context args _]
(assert-admin (:id context))
(let [search-query (cleanse-query (:query args))
data (d/q '[:find ?n ?i ?s
:in $ ?q
:where [(fulltext $ :ezcater-caterer/search-terms ?q) [[?i ?n _ ?s]]]]
(d/db conn)
search-query)]
(->> data
(sort-by (comp - last))
(partial-match-first (:query args))
(map (fn [[n i]]
{:name n
:id i})))))
(def objects
{:ezcater_caterer {:fields {:name {:type 'String}
:id {:type :id}}}})
(def queries
{:search_ezcater_caterer {:type '(list :search_result)
:args {:query {:type 'String}}
:resolve :search-ezcater-caterer}})
(def enums
{})
(def resolvers
{:search-ezcater-caterer search})
(defn attach [schema]
(->
(merge-with merge schema
{:objects objects
:queries queries
:enums enums})
(attach-resolvers resolvers)))