api

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Clubs = map[string]uint64{}
	Users = map[string]*User{}
	Cfg   = cfg.Cfg // shortcut
)
View Source
var (
	ErrAlienServer = errors.New("server is not slotopol server")
)

Functions

func DoReq

func DoReq[Tr any](req *http.Request) (ret Tr, status int, err error)

func HttpGet

func HttpGet[Tr any](path string, token string, arg url.Values) (ret Tr, status int, err error)

func HttpPost

func HttpPost[Ta, Tr any](path string, token string, arg *Ta) (ret Tr, status int, err error)

func ReqAccessSet

func ReqAccessSet(cid, uid uint64, al AL) (err error)

func ReqPing

func ReqPing() (err error)

func ReqRtpGet

func ReqRtpGet(cid, uid uint64, all bool) (mrtp float64, err error)

func ReqRtpSet

func ReqRtpSet(cid, uid uint64, mrtp float64) (err error)

func ReqWalletAdd

func ReqWalletAdd(cid, uid uint64, sum float64) (wallet float64, err error)

func ReqWalletGet

func ReqWalletGet(cid, uid uint64) (wallet float64, err error)

Types

type AL

type AL uint

Access level.

const (
	ALmem   AL = 1 << iota // user have access to club
	ALgame                 // can change club game settings
	ALuser                 // can change user balance and move user money to/from club deposit
	ALclub                 // can change club bank, fund, deposit
	ALadmin                // can change same access levels to other users
	ALall   = ALgame | ALuser | ALclub | ALadmin
)

func ReqAccessGet

func ReqAccessGet(cid, uid uint64, all bool) (al AL, err error)

type AjaxErr

type AjaxErr struct {
	What string `json:"what" yaml:"what" xml:"what"`
	Code int    `json:"code,omitempty" yaml:"code,omitempty" xml:"code,omitempty"`
	UID  uint64 `json:"uid,omitempty" yaml:"uid,omitempty" xml:"uid,omitempty,attr"`
}

func (AjaxErr) Error

func (err AjaxErr) Error() string

type ArgAccessGet

type ArgAccessGet struct {
	XMLName xml.Name `json:"-" yaml:"-" xml:"arg"`
	CID     uint64   `json:"cid" yaml:"cid" xml:"cid,attr"`
	UID     uint64   `json:"uid" yaml:"uid" xml:"uid,attr"`
	All     bool     `json:"all" yaml:"all" xml:"all,attr"`
}

type ArgAccessSet

type ArgAccessSet struct {
	XMLName xml.Name `json:"-" yaml:"-" xml:"arg"`
	CID     uint64   `json:"cid" yaml:"cid" xml:"cid,attr"`
	UID     uint64   `json:"uid" yaml:"uid" xml:"uid,attr"`
	Access  AL       `json:"access" yaml:"access" xml:"access"`
}

type ArgClubCashin

type ArgClubCashin struct {
	XMLName xml.Name `json:"-" yaml:"-" xml:"arg"`
	CID     uint64   `json:"cid" yaml:"cid" xml:"cid,attr"`
	BankSum float64  `json:"banksum" yaml:"banksum" xml:"banksum"`
	FundSum float64  `json:"fundsum" yaml:"fundsum" xml:"fundsum"`
	LockSum float64  `json:"locksum" yaml:"locksum" xml:"locksum"`
}

type ArgClubInfo

type ArgClubInfo struct {
	XMLName xml.Name `json:"-" yaml:"-" xml:"arg"`
	CID     uint64   `json:"cid" yaml:"cid" xml:"cid,attr"`
}

type ArgPropGet

type ArgPropGet struct {
	XMLName xml.Name `json:"-" yaml:"-" xml:"arg"`
	CID     uint64   `json:"cid" yaml:"cid" xml:"cid,attr"`
	UID     uint64   `json:"uid" yaml:"uid" xml:"uid,attr"`
}

type ArgRtpGet

type ArgRtpGet struct {
	XMLName xml.Name `json:"-" yaml:"-" xml:"arg"`
	CID     uint64   `json:"cid" yaml:"cid" xml:"cid,attr"`
	UID     uint64   `json:"uid" yaml:"uid" xml:"uid,attr"`
	All     bool     `json:"all" yaml:"all" xml:"all,attr"`
}

type ArgRtpSet

type ArgRtpSet struct {
	XMLName xml.Name `json:"-" yaml:"-" xml:"arg"`
	CID     uint64   `json:"cid" yaml:"cid" xml:"cid,attr"`
	UID     uint64   `json:"uid" yaml:"uid" xml:"uid,attr"`
	MRTP    float64  `json:"mrtp" yaml:"mrtp" xml:"mrtp"`
}

type ArgSignIn

type ArgSignIn struct {
	XMLName xml.Name `json:"-" yaml:"-" xml:"arg"`
	UID     uint64   `json:"uid" yaml:"uid" xml:"uid"`
	Email   string   `json:"email" yaml:"email" xml:"email"`
	Secret  string   `json:"secret" yaml:"secret,omitempty" xml:"secret,omitempty"`
	HS256   string   `json:"hs256,omitempty" yaml:"hs256,omitempty" xml:"hs256,omitempty"`
	SigTime string   `json:"sigtime,omitempty" yaml:"sigtime,omitempty" xml:"sigtime,omitempty"`
	Code    uint32   `json:"code,omitempty" yaml:"code,omitempty" xml:"code,omitempty"`
}

type ArgSignIs

type ArgSignIs struct {
	XMLName xml.Name `json:"-" yaml:"-" xml:"arg"`
	UID     uint64   `json:"uid" yaml:"uid" xml:"uid"`
	Email   string   `json:"email" yaml:"email" xml:"email"`
}

type ArgUserIs

type ArgUserIs struct {
	XMLName xml.Name   `json:"-" yaml:"-" xml:"arg"`
	List    []useritem `json:"list" yaml:"list" xml:"list>user"`
}

type ArgWalletAdd

type ArgWalletAdd struct {
	XMLName xml.Name `json:"-" yaml:"-" xml:"arg"`
	CID     uint64   `json:"cid" yaml:"cid" xml:"cid,attr"`
	UID     uint64   `json:"uid" yaml:"uid" xml:"uid,attr"`
	Sum     float64  `json:"sum" yaml:"sum" xml:"sum"`
}

type AuthResp

type AuthResp struct {
	XMLName xml.Name `json:"-" yaml:"-" xml:"ret"`
	UID     uint64   `json:"uid" yaml:"uid" xml:"uid"`
	Email   string   `json:"email" yaml:"email" xml:"email"`
	Access  string   `json:"access" yaml:"access" xml:"access"`
	Refrsh  string   `json:"refrsh" yaml:"refrsh" xml:"refrsh"`
	Expire  string   `json:"expire" yaml:"expire" xml:"expire"`
	Living  string   `json:"living" yaml:"living" xml:"living"`
}
var Admin AuthResp

func ReqRefresh

func ReqRefresh() (ret AuthResp, err error)

func ReqSignIn

func ReqSignIn(email, secret string) (ret AuthResp, err error)

type Props

type Props struct {
	Wallet float64 `json:"wallet" yaml:"wallet" xml:"wallet"` // in coins
	Access AL      `json:"access" yaml:"access" xml:"access"` // access level
	MRTP   float64 `json:"mrtp" yaml:"mrtp" xml:"mrtp"`       // personal master RTP
	// contains filtered or unexported fields
}

func ReqPropGet

func ReqPropGet(cid, uid uint64) (p Props, err error)

func (Props) Expired

func (p Props) Expired() bool

type RetAccessGet

type RetAccessGet struct {
	XMLName xml.Name `json:"-" yaml:"-" xml:"ret"`
	Access  AL       `json:"access" yaml:"access" xml:"access"`
}

type RetClubCashin

type RetClubCashin struct {
	XMLName xml.Name `json:"-" yaml:"-" xml:"ret"`
	BID     uint64   `json:"bid" yaml:"bid" xml:"bid,attr"`
	Bank    float64  `json:"bank" yaml:"bank" xml:"bank"`
	Fund    float64  `json:"fund" yaml:"fund" xml:"fund"`
	Lock    float64  `json:"lock" yaml:"lock" xml:"lock"`
}

func ClubCashin

func ClubCashin(cid uint64, bsum, fsum, lsum float64) (ret RetClubCashin, err error)

type RetClubInfo

type RetClubInfo struct {
	XMLName xml.Name `json:"-" yaml:"-" xml:"ret"`
	Name    string   `json:"name,omitempty" yaml:"name,omitempty" xml:"name,omitempty"`
	Bank    float64  `json:"bank" yaml:"bank" xml:"bank"` // users win/lost balance, in coins
	Fund    float64  `json:"fund" yaml:"fund" xml:"fund"` // jackpot fund, in coins
	Lock    float64  `json:"lock" yaml:"lock" xml:"lock"` // not changed deposit within games
	Rate    float64  `json:"rate" yaml:"rate" xml:"rate"` // jackpot rate for games with progressive jackpot
	MRTP    float64  `json:"mrtp" yaml:"mrtp" xml:"mrtp"` // master RTP
}

func ReqClubInfo

func ReqClubInfo(cid uint64) (ret RetClubInfo, err error)

type RetClubList

type RetClubList struct {
	XMLName xml.Name   `json:"-" yaml:"-" xml:"ret"`
	List    []clubitem `json:"list" yaml:"list" xml:"list>club" form:"list"`
}

func ReqClubList

func ReqClubList() (ret RetClubList, err error)

type RetPropGet

type RetPropGet struct {
	XMLName xml.Name `json:"-" yaml:"-" xml:"ret"`
	Wallet  float64  `json:"wallet" yaml:"wallet" xml:"wallet"`
	Access  AL       `json:"access" yaml:"access" xml:"access"`
	MRTP    float64  `json:"mrtp" yaml:"mrtp" xml:"mrtp"`
}

type RetRtpGet

type RetRtpGet struct {
	XMLName xml.Name `json:"-" yaml:"-" xml:"ret"`
	MRTP    float64  `json:"mrtp" yaml:"mrtp" xml:"mrtp"`
}

type RetSignIs

type RetSignIs struct {
	XMLName xml.Name `json:"-" yaml:"-" xml:"ret"`
	UID     uint64   `json:"uid" yaml:"uid" xml:"uid"`
	Email   string   `json:"email" yaml:"email" xml:"email"`
	Name    string   `json:"name,omitempty" yaml:"name,omitempty" xml:"name,omitempty"`
}

type RetUserIs

type RetUserIs struct {
	XMLName xml.Name   `json:"-" yaml:"-" xml:"ret"`
	List    []useritem `json:"list" yaml:"list" xml:"list>user"`
}

type RetWalletGet

type RetWalletGet struct {
	XMLName xml.Name `json:"-" yaml:"-" xml:"ret"`
	Wallet  float64  `json:"wallet" yaml:"wallet" xml:"wallet"`
}

type User

type User struct {
	UID   uint64 `json:"uid" yaml:"uid" xml:"uid,attr"`                             // user ID
	Email string `json:"email" yaml:"email" xml:"email"`                            // unique user email
	Name  string `json:"name,omitempty" yaml:"name,omitempty" xml:"name,omitempty"` // user name
	// contains filtered or unexported fields
}

func ReqSignIs

func ReqSignIs(email string) (user User, status int, err error)

func ReqUserIs

func ReqUserIs(emails []string) (users []User, err error)

func (*User) GetProps

func (u *User) GetProps(cid uint64) (p Props, ok bool)

func (*User) SetProps

func (u *User) SetProps(cid uint64, p Props)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL