maxapi: add wallet type validation

This commit is contained in:
c9s 2022-05-24 18:00:52 +08:00
parent 79893f4b88
commit 9d459612a4
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
5 changed files with 36 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package max
//go:generate -command GetRequest requestgen -method GET
//go:generate -command PostRequest requestgen -method POST
//go:generate -command DeleteRequest requestgen -method DELETE
import (
"github.com/c9s/requestgen"

View File

@ -13,8 +13,8 @@ import (
type WalletType string
const (
WalletTypeSpot = WalletType("spot")
WalletTypeMargin = WalletType("m")
WalletTypeSpot WalletType = "spot"
WalletTypeMargin WalletType = "m"
)
type Order = maxapi.Order

View File

@ -190,6 +190,17 @@ func (w *WalletCreateOrderRequest) GetSlugParameters() (map[string]interface{},
}
// END TEMPLATE check-required
// TEMPLATE check-valid-values
switch walletType {
case WalletTypeSpot, WalletTypeMargin:
params["walletType"] = walletType
default:
return nil, fmt.Errorf("walletType value %v is invalid", walletType)
}
// END TEMPLATE check-valid-values
// assign parameter of walletType
params["walletType"] = walletType

View File

@ -190,6 +190,17 @@ func (w *WalletGetOrderRequest) GetSlugParameters() (map[string]interface{}, err
}
// END TEMPLATE check-required
// TEMPLATE check-valid-values
switch walletType {
case WalletTypeSpot, WalletTypeMargin:
params["walletType"] = walletType
default:
return nil, fmt.Errorf("walletType value %v is invalid", walletType)
}
// END TEMPLATE check-valid-values
// assign parameter of walletType
params["walletType"] = walletType

View File

@ -119,6 +119,17 @@ func (w *WalletOrderCancelAllRequest) GetSlugParameters() (map[string]interface{
}
// END TEMPLATE check-required
// TEMPLATE check-valid-values
switch walletType {
case WalletTypeSpot, WalletTypeMargin:
params["walletType"] = walletType
default:
return nil, fmt.Errorf("walletType value %v is invalid", walletType)
}
// END TEMPLATE check-valid-values
// assign parameter of walletType
params["walletType"] = walletType