Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 26fa546

Browse files
committed
Add new API endpoints for /checkoutbreakdown
1 parent c2c6765 commit 26fa546

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

api/endpoints.go

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ func post(i *jsonAPIHandler, path string, w http.ResponseWriter, r *http.Request
9191
i.POSTShutdown(w, r)
9292
case strings.HasPrefix(path, "/ob/estimatetotal"):
9393
i.POSTEstimateTotal(w, r)
94+
case strings.HasPrefix(path, "/ob/checkoutbreakdown"):
95+
i.POSTCheckoutBreakdown(w, r)
9496
case strings.HasPrefix(path, "/ob/fetchratings"):
9597
i.POSTFetchRatings(w, r)
9698
case strings.HasPrefix(path, "/ob/sales"):

api/jsonapi.go

+23
Original file line numberDiff line numberDiff line change
@@ -3578,6 +3578,29 @@ func (i *jsonAPIHandler) GETFees(w http.ResponseWriter, r *http.Request) {
35783578
SanitizedResponse(w, string(out))
35793579
}
35803580

3581+
func (i *jsonAPIHandler) POSTCheckoutBreakdown(w http.ResponseWriter, r *http.Request) {
3582+
decoder := json.NewDecoder(r.Body)
3583+
var data repo.PurchaseData
3584+
err := decoder.Decode(&data)
3585+
if err != nil {
3586+
ErrorResponse(w, http.StatusBadRequest, err.Error())
3587+
return
3588+
}
3589+
cb, err := i.node.CheckoutBreakdown(&data)
3590+
if err != nil {
3591+
ErrorResponse(w, http.StatusInternalServerError, err.Error())
3592+
return
3593+
}
3594+
3595+
out, err := json.MarshalIndent(cb, "", " ")
3596+
if err != nil {
3597+
ErrorResponse(w, http.StatusInternalServerError, err.Error())
3598+
return
3599+
}
3600+
3601+
SanitizedResponse(w, string(out))
3602+
}
3603+
35813604
func (i *jsonAPIHandler) POSTEstimateTotal(w http.ResponseWriter, r *http.Request) {
35823605
decoder := json.NewDecoder(r.Body)
35833606
var data repo.PurchaseData

0 commit comments

Comments
 (0)