models

package
v0.0.0-...-015e340 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// XAuthToken is the name of the header used to pass the authorization token
	XAuthToken = "x-auth-token"
)

Functions

This section is empty.

Types

type ChangeGameStatusRequest

type ChangeGameStatusRequest struct {
	Status   Status        `json:"status,omitempty"`
	Progress *GameProgress `json:"progress,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error,omitempty"`
}

ErrorResponse is the generic error response returned from the API, when an error of any kind occurred.

type Franchise

type Franchise struct {
	ID   string `json:"id"`
	Name string `json:"name"`

	UserID string `json:"-"`
}

type FranchisesResponse

type FranchisesResponse struct {
	Franchises []*Franchise `json:"franchises"`
}

type Game

type Game struct {
	ID          string        `json:"id"`
	Name        string        `json:"name,omitempty"`
	Franchise   string        `json:"franchise,omitempty"`
	FranchiseID string        `json:"franchiseId,omitempty"`
	Status      Status        `json:"status,omitempty"`
	Progress    *GameProgress `json:"progress,omitempty"`

	UserID string `json:"-"`
}

Game is the representation of a game in the database.

type GameProgress

type GameProgress struct {
	Current int `json:"current"`
	Final   int `json:"final,omitempty"`
}

type GamesResponse

type GamesResponse struct {
	Games []*Game `json:"games"`
}

type Status

type Status string

Status is the type that represents the status of a game

var (
	// StatusTODO is the To Do status of a game
	StatusTODO Status = "To Do"
	// StatusInProgress is the In progress status of a game
	StatusInProgress Status = "In Progress"
	// StatusDone is the Done status of the game
	StatusDone Status = "Done"

	// AllStatuses is collection of all statuses
	AllStatuses = []Status{
		StatusTODO,
		StatusInProgress,
		StatusDone,
	}
)

func (Status) Validate

func (s Status) Validate() error

Validate shows whether the status is a valid status and returns an error if not.

type StatusesResponse

type StatusesResponse struct {
	Statuses []Status `json:"statuses,omitempty"`
}

StatusesResponse is the response that is returned from the Statuses API

type User

type User struct {
	ID             string `json:"id,omitempty"`
	Username       string `json:"username,omitempty"`
	Email          string `json:"email,omitempty"`
	Password       string `json:"password,omitempty"`
	HashedPassword []byte `json:"-"`
}

User is the representation of a user in the database.

type UserGameRequest

type UserGameRequest struct {
	Game     *Game         `json:"game"`
	Progress *GameProgress `json:"progress,omitempty"`
}

type UserGameResponse

type UserGameResponse struct {
	ID     string `json:"id"`
	Game   *Game  `json:"game"`
	Status Status `json:"status"`
}

type UserGamesResponse

type UserGamesResponse struct {
	Games []*Game `json:"games"`
}

type UserLoginResponse

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

UserLoginResponse is the response that is returned when a user is logged in.

type UserResponse

type UserResponse struct {
	User *User `json:"user"`
}

UserResponse is the response that is returned from the GET /users API

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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