types

package
v0.0.0-...-85b58fb Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2021 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func IsValidStatus

func IsValidStatus(stat StatusType) bool

IsValidStatus returns whether stat is a declared status.

Types

type Candidate

type Candidate struct {
	// The unique id of candidate, used for identifying.
	ID int `json:"id" example:"1"`
	// The name of the candidates.
	Name []string `json:"name" db:"-"`

	NameInternal string `json:"-" db:"name" swaggerignore:"true"`

	// The description provided by the candidate, intended as a short introduction.
	Description null.String `json:"description" swaggertype:"string" example:"Hello. Vote for me."`
	// The picture of the candidate.
	Picture null.String `json:"picture" swaggertype:"string" format:"base64"`

} // @name Candidate

Stores all candidate data

func (*Candidate) In

func (c *Candidate) In()

In transforms Candidate data from REST format to db format

func (*Candidate) Out

func (c *Candidate) Out()

Out transforms Candidate data from db format to REST format

type CandidateEssay

type CandidateEssay struct {
	Essay string `json:"essay" format:"base64"`
}

type CandidateID

type CandidateID struct {
	Candidate int `json:"candidate" binding:"required"`
}

type CandidateResult

type CandidateResult struct {
	// The unique id of candidate, used for identifying.
	ID     int `json:"id" example:"1" db:"id"`
	Result int `json:"result" example:"69"`
}

type Empty

type Empty struct{} // @name Empty

Pseudotype for empty json object

type Error

type Error struct {
	Error ErrorType `` /* 222-byte string literal not displayed */

} // @name Error

Error structure to be returned in case of a non 2xx status code.

type ErrorType

type ErrorType string

Type for const errors.

const (
	ErrNotFound          ErrorType = "NOT_FOUND"
	ErrMethodNotAllowed  ErrorType = "METHOD_NOT_ALLOWED"
	ErrServerError       ErrorType = "SERVER_ERROR"
	ErrInvalidAuthHeader ErrorType = "INVALID_AUTH_HEADER"
	ErrExpiredToken      ErrorType = "EXPIRED_TOKEN"
	ErrInvalidBody       ErrorType = "INVALID_BODY"
	ErrBadPasscode       ErrorType = "BAD_PASSCODE"
	ErrAlreadyVoted      ErrorType = "ALREADY_VOTED"
	ErrNoSuchVoter       ErrorType = "NO_SUCH_VOTER"
	ErrTooManyTries      ErrorType = "TOO_MANY_TRIES"
	ErrNoSuchCandidate   ErrorType = "NO_SUCH_CANDIDATE"
	ErrWrongStatus       ErrorType = "WRONG_STATUS"
)

Error types which are present in the swagger enums.

type Passcode

type Passcode struct {
	Passcode string `json:"passcode" binding:"required"`

} // @name Passcode

JSON object for receiving passcode

func (*Passcode) Validate

func (p *Passcode) Validate() bool

Validates, if the passcode is valid

type StatusCurrent

type StatusCurrent struct {
	Status StatusType `json:"current" enums:"CLOSED,OPEN,VOTE,VOTE_EXPIRED,RESULT" example:"CLOSED" binding:"required"`

} // @name CurrentStatus

Type to be returned to /status/current

type StatusTiming

type StatusTiming struct {
	Status StatusType `json:"status" db:"name" enums:"CLOSED,OPEN,VOTE,VOTE_EXPIRED,RESULT" example:"CLOSED" binding:"required"`
	Start  time.Time  `json:"start" db:"ts_start" binding:"required"`
	Until  time.Time  `json:"until" db:"ts_until" binding:"required"`
}

func NewDummyTiming

func NewDummyTiming(i int) *StatusTiming

type StatusType

type StatusType string

Type for status types

const (
	StatusClosed      StatusType = "CLOSED"
	StatusOpen        StatusType = "OPEN"
	StatusVote        StatusType = "VOTE"
	StatusVoteExpired StatusType = "VOTE_EXPIRED"
	StatusResult      StatusType = "RESULT"
	StatusAuto        StatusType = "AUTO"
)

Status types in swagger enum

type Token

type Token struct {
	Token string `json:"token"`

} // @name Token

JSON object for returning an auth token

type Vote

type Vote struct {
	Voter
	CandidateID

} // @name Vote

Data type containing voter id + chosen candidate

type VoteStat

type VoteStat struct {
	Candidate int       `json:"candidate"`
	Ts        time.Time `json:"ts"`
}

type Voter

type Voter struct {
	Om string `form:"om" json:"om" binding:"required"`
}

Data type containing voter id

type VoterStatus

type VoterStatus int

Enum for voter status

const (
	CanVote VoterStatus = iota
	AlreadyVoted
	WrongData
)

VoterStatus states

Jump to

Keyboard shortcuts

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