Update the 'updateboltcard' api call. Allow updating 'day_limit_sats'
This commit is contained in:
parent
90f7f7a64b
commit
1acbe9895a
2 changed files with 17 additions and 7 deletions
|
|
@ -1,11 +1,12 @@
|
|||
package internalapi
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/boltcard/boltcard/db"
|
||||
"github.com/boltcard/boltcard/resp_err"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func Updateboltcard(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
@ -25,6 +26,15 @@ func Updateboltcard(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
day_max_str := r.URL.Query().Get("day_max")
|
||||
day_max, err := strconv.Atoi(day_max_str)
|
||||
if err != nil {
|
||||
msg := "updateboltcard: day_max is not a valid integer"
|
||||
log.Warn(msg)
|
||||
resp_err.Write_message(w, msg)
|
||||
return
|
||||
}
|
||||
|
||||
enable_flag_str := r.URL.Query().Get("enable")
|
||||
enable_flag, err := strconv.ParseBool(enable_flag_str)
|
||||
if err != nil {
|
||||
|
|
@ -54,12 +64,12 @@ func Updateboltcard(w http.ResponseWriter, r *http.Request) {
|
|||
// log the request
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"card_name": card_name, "tx_max": tx_max,
|
||||
"card_name": card_name, "tx_max": tx_max, "day_max": day_max,
|
||||
"enable": enable_flag}).Info("updateboltcard API request")
|
||||
|
||||
// update the card record
|
||||
|
||||
err = db.Update_card(card_name, tx_max, enable_flag)
|
||||
err = db.Update_card(card_name, tx_max, day_max, enable_flag)
|
||||
if err != nil {
|
||||
log.Warn(err.Error())
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue