app

package
v0.0.0-...-799dd52 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	All = iota
	Sale
)
View Source
const TimeFormat = "15:04"

Variables

View Source
var SearchByID = searchByID
View Source
var SearchByName = searchByName

to be mocked in tests

View Source
var Version = "0.0.1"

Functions

func BuildURLForID

func BuildURLForID(id string) (string, error)

func BuildURLForName

func BuildURLForName(name string) (string, error)

func DescribeGames

func DescribeGames(games []Game) ([]string, []string)

func Exit

func Exit(err error)

func GenerateMessage

func GenerateMessage(games []Game, filterForSales bool) string

func SetupRestAPI

func SetupRestAPI(host string, port int, debug bool) *http.Server

Types

type Client

type Client interface {
	Type() ClientType
	Subscriptions() []string
	ID() string
	Storable() StorableClient
	AddSubscription(subscription string)
}

func NewTelegramClient

func NewTelegramClient(id string) Client

type ClientType

type ClientType int
const (
	Telegram ClientType = iota
)

func GetClientType

func GetClientType(str string) (ClientType, error)

GetClientType takes source string and returns parsed type and error. if failed, then returns error and -1 as ClientType

type Database

type Database struct {
	// contains filtered or unexported fields
}

func NewDatabase

func NewDatabase() *Database

func (*Database) AddGame

func (database *Database) AddGame(game Game) error

func (*Database) AddGameToUser

func (database *Database) AddGameToUser(gameID string, clientID string, clientType ClientType) error

func (*Database) AddGames

func (database *Database) AddGames(games []Game) error

func (*Database) AddUser

func (database *Database) AddUser(client Client) error

func (*Database) Close

func (database *Database) Close()

func (*Database) DeleteGame

func (database *Database) DeleteGame(id string) error

func (*Database) DeleteGameFromUser

func (database *Database) DeleteGameFromUser(gameID string, clientID string, clientType ClientType) error

func (*Database) GetGame

func (database *Database) GetGame(id string) (game Game, err error)

func (*Database) GetGames

func (database *Database) GetGames() (games []Game, err error)

func (*Database) GetGamesForUser

func (database *Database) GetGamesForUser(clientID string, clientType ClientType, requestType RequestType) (games []Game, e error)

func (*Database) GetIDByGameName

func (database *Database) GetIDByGameName(name string) (id string, err error)

func (*Database) GetUsers

func (database *Database) GetUsers(clientType ClientType) ([]string, error)

type Game

type Game struct {
	Id        string    `json:"id"`
	Name      string    `json:"name"`
	Price     int       `json:"price"`
	IsPlus    bool      `json:"is_plus"`
	SalePrice int       `json:"sale_price"`
	SaleEnd   time.Time `json:"sale_end"`
}

type Notifier

type Notifier struct {
	// Events are pushed to this channel by the main events-gathering routine
	Notifier chan NotifierMessage
	// contains filtered or unexported fields
}

func NewNotifier

func NewNotifier() *Notifier

func (*Notifier) NotifyUser

func (notifier *Notifier) NotifyUser(clientType ClientType, notif structs.UserNotification) error

func (*Notifier) ServeHTTP

func (notifier *Notifier) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type NotifierClient

type NotifierClient struct {
	Destination ClientType
	Channel     chan []byte
}

type NotifierMessage

type NotifierMessage struct {
	Destination ClientType
	Message     []byte
}

type RequestType

type RequestType int

func GetRequestType

func GetRequestType(str string) (RequestType, error)

type StorableClient

type StorableClient struct {
	Subscriptions []string `json:"subs"`
}

type Updater

type Updater struct {
	// contains filtered or unexported fields
}

func NewUpdater

func NewUpdater(betweenUpdates, updateTime string) (*Updater, error)

func (*Updater) Start

func (updater *Updater) Start()

func (*Updater) Stop

func (updater *Updater) Stop()

Jump to

Keyboard shortcuts

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