Files
payouts/internal/models/payout.go

53 lines
947 B
Go

package models
import (
"fmt"
"strings"
)
type PayoutType int64
const (
TypeSBP PayoutType = iota
TypeYooMoney
)
func (r PayoutType) String() string {
switch r {
case TypeSBP:
return "spb"
case TypeYooMoney:
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 = TypeSBP
case "yoo_money":
*r = TypeYooMoney
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"`
}
type PayoutResp struct {
Result string `json:"result"`
PayoutID string `json:"payout_id,omitempty"`
ErrorReason string `json:"error_reason,omitempty"`
}