Add default customer id
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package m
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
@@ -13,8 +13,8 @@ type NKodeHandler struct {
|
||||
|
||||
func (h *NKodeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case api.CreateNewCustomer:
|
||||
h.CreateNewCustomerHandler(w, r)
|
||||
//case api.CreateNewCustomer:
|
||||
// h.CreateNewCustomerHandler(w, r)
|
||||
case api.GenerateSignupInterface:
|
||||
h.GenerateSignupInterfaceHandler(w, r)
|
||||
case api.SetNKode:
|
||||
@@ -46,7 +46,7 @@ func (h *NKodeHandler) CreateNewCustomerHandler(w http.ResponseWriter, r *http.R
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
customerId, err := h.Api.CreateNewCustomer(customerPost.NKodePolicy)
|
||||
customerId, err := h.Api.CreateNewCustomer(customerPost.NKodePolicy, nil)
|
||||
if err != nil {
|
||||
internalServerErrorHandler(w)
|
||||
log.Fatal(err)
|
||||
@@ -84,7 +84,17 @@ func (h *NKodeHandler) GenerateSignupInterfaceHandler(w http.ResponseWriter, r *
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
resp, err := h.Api.GenerateSignupInterface(signupPost.CustomerId, KeypadDefault)
|
||||
kp := KeypadDimension{
|
||||
AttrsPerKey: signupPost.AttrsPerKey,
|
||||
NumbOfKeys: signupPost.NumbOfKeys,
|
||||
}
|
||||
err = kp.IsValidKeypadDimension()
|
||||
if err != nil {
|
||||
keypadSizeOutOfRange(w)
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
resp, err := h.Api.GenerateSignupInterface(signupPost.CustomerId, kp)
|
||||
if err != nil {
|
||||
internalServerErrorHandler(w)
|
||||
log.Fatal(err)
|
||||
@@ -270,3 +280,8 @@ func methodNotAllowed(w http.ResponseWriter) {
|
||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||
w.Write([]byte("405 method not allowed"))
|
||||
}
|
||||
|
||||
func keypadSizeOutOfRange(w http.ResponseWriter) {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
w.Write([]byte("invalid keypad dimensions"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user