Reorganaze modules, add auth processing.
This commit is contained in:
46
internal/models/payout.go
Normal file
46
internal/models/payout.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type PayoutType int64
|
||||
|
||||
const (
|
||||
SBP PayoutType = iota
|
||||
YooMoney
|
||||
)
|
||||
|
||||
func (r PayoutType) String() string {
|
||||
switch r {
|
||||
case SBP:
|
||||
return "spb"
|
||||
case YooMoney:
|
||||
return "yoo_money"
|
||||
}
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
func (r PayoutType) MarshalText() (text []byte, err error) {
|
||||
return []byte(r.String()), nil
|
||||
}
|
||||
|
||||
func (r *PayoutType) UnmarshalText(text []byte) (err error) {
|
||||
s := strings.ToLower(string(text))
|
||||
switch s {
|
||||
case "spb":
|
||||
*r = SBP
|
||||
case "yoo_money":
|
||||
*r = YooMoney
|
||||
default:
|
||||
err = fmt.Errorf("invalid payment type: %s", s)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
type PayoutReq struct {
|
||||
PayoutType PayoutType `json:"payout_type"`
|
||||
AccountNumber string `json:"account_number"`
|
||||
Amount float32 `json:"amount"`
|
||||
}
|
||||
Reference in New Issue
Block a user