domain

package
v0.0.0-...-4976f39 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Error that could occur during database querying
	ErrInternalDatabase = fmt.Errorf("internal database error")
	// Error that could occure during Wargaming API call
	ErrInternalWargaming = fmt.Errorf("internal Wargaming API error")
	// Error that could occur during XVM stats call
	ErrInternalXVM = fmt.Errorf("internal XVM stats error")
	// Error that could occur during KTTC stats call
	ErrInternalKTTC = fmt.Errorf("internal KTTC stats error")
	// Error that occurs if user passed wrong data on input
	ErrBotBadRequest = fmt.Errorf("bot bad request")
	// Error that occurs if player not found
	ErrPlayerNotFound = fmt.Errorf("player not found")
	// Error that occurs if user not found
	ErrUserNotFound = fmt.Errorf("user not found")
	// Error that occurs if user didn't save nickname
	ErrNicknameNotSaved = fmt.Errorf("nickname not saved")
	// Error that occurs if trend image not found
	ErrTrendImageNotFound = fmt.Errorf("trend image not found")
)

Functions

This section is empty.

Types

type Database

type Database interface {
	GetUserByTelegramID(telegramID int) (*User, error)
	UpsertUser(user *User) (*User, error)
	GetStatsByUserID(userID int) ([]*XVMStat, error)
	UpdateStatsByUserID(userID int, stats []*XVMStat) ([]*XVMStat, error)
}

type KTTC

type KTTC interface {
	GetStats(accountID int) ([]*KTTCStat, error)
}

type KTTCStat

type KTTCStat struct {
	Name  string
	Value float64
	Color string
	Delta *float64
}

type Service

type Service interface {
	GetCreateUserMessage(telegramID int) (string, error)
	GetSaveNicknameMessage(telegramID int, nickname string) (string, error)
	GetRefreshMessage(telegramID int) (string, error)
	GetMeMessage(telegramID int, chatType string) (string, error)
	GetTrendImage(telegramID int, htmlID string) ([]byte, error)
	GetStatsMessage(nickname string) (string, error)
	GetKTTCStatsMessage(nickname string) (string, error)
}

func NewService

func NewService(logger *zap.Logger, database Database, wargaming Wargaming, xvm XVM, kttc KTTC) Service

type User

type User struct {
	ID          int        `db:"id"`
	TelegramID  int        `db:"telegram_id"`
	Nickname    *string    `db:"nickname"`
	WargamingID *int       `db:"wargaming_id"`
	CreatedAt   time.Time  `db:"created_at"`
	UpdatedAt   *time.Time `db:"updated_at"`
}

type Wargaming

type Wargaming interface {
	FindPlayer(nickname string) (string, int, error)
}

type XVM

type XVM interface {
	GetStats(accountID int, withTrend bool) ([]*XVMStat, error)
}

type XVMStat

type XVMStat struct {
	ID        int         `db:"id"`
	UserID    int         `db:"user_id"`
	Type      XVMStatType `db:"type"`
	Name      string      `db:"name"`
	Value     *string     `db:"value"`
	HtmlID    string      `db:"html_id"`
	Image     []byte      `db:"img"`
	CreatedAt time.Time   `db:"created_at"`
	UpdatedAt *time.Time  `db:"updated_at"`
}

type XVMStatType

type XVMStatType string
const (
	XVMTrendStat   XVMStatType = "trend"
	XVMVehicleStat XVMStatType = "vehicle"
)

Jump to

Keyboard shortcuts

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