|
|
@@ -442,6 +442,22 @@ func createFeesTemp(w http.ResponseWriter, db *sql.DB, r *http.Request) { |
|
|
|
json.NewEncoder(w).Encode(fee) |
|
|
|
} |
|
|
|
|
|
|
|
// Fetch fees from the database |
|
|
|
func deleteFeeTemp(w http.ResponseWriter, db *sql.DB, r *http.Request) { |
|
|
|
var fee FeeTemplate |
|
|
|
var query string |
|
|
|
var err error |
|
|
|
|
|
|
|
// claims, err := getClaims(r) |
|
|
|
// var id int // Inserted estimate's id |
|
|
|
err = json.NewDecoder(r.Body).Decode(&fee) |
|
|
|
if err != nil { w.WriteHeader(422); return } |
|
|
|
|
|
|
|
query = `DELETE FROM fee_template WHERE id = ?` |
|
|
|
_, err = db.Exec(query, fee.Id) |
|
|
|
if err != nil { w.WriteHeader(500); return } |
|
|
|
} |
|
|
|
|
|
|
|
func getMi(db *sql.DB, loan int) (MI, error) { |
|
|
|
var mi MI |
|
|
|
|
|
|
@@ -1551,6 +1567,10 @@ func api(w http.ResponseWriter, r *http.Request) { |
|
|
|
r.Method == http.MethodPost && |
|
|
|
guard(r, 1): |
|
|
|
createFeesTemp(w, db, r) |
|
|
|
case match(p, "/api/fee", &args) && |
|
|
|
r.Method == http.MethodDelete && |
|
|
|
guard(r, 1): |
|
|
|
deleteFeeTemp(w, db, r) |
|
|
|
case match(p, "/api/estimates", &args) && |
|
|
|
r.Method == http.MethodGet && |
|
|
|
guard(r, 1): |
|
|
|