client

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: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFetchingFranchises is a generic error
	ErrFetchingFranchises = errors.New("error while fetching franchises")
	// ErrCreatingFranchise is a generic error
	ErrCreatingFranchise = errors.New("error while creating franchise")
)
View Source
var (
	// ErrFetchingGames is a generic error
	ErrFetchingGames = errors.New("error while fetching games")
	// ErrCreatingGame is a generic error
	ErrCreatingGame = errors.New("error while creating game")
	// ErrNoAuthorization is returned when no authorization is sent for a authorized routes
	ErrNoAuthorization = errors.New("no authorization is present")
	// ErrLinkingGame is returned when an error occurred while linking game to user
	ErrLinkingGame = errors.New("error while linking game to user")
	// ErrChangingGame is returned when an error ocurred while changing status of game
	ErrChangingGame = errors.New("error while changing game")
	// ErrDeletingGame is returned when an error ocurred while deleting a game
	ErrDeletingGame = errors.New("error while deleting game")
)
View Source
var (
	// ErrFetchingStatuses is a generic error
	ErrFetchingStatuses = errors.New("error while fetching statuses")
)
View Source
var XAuthToken = "x-auth-token"

XAuthToken is the name of the header used for authentication

Functions

This section is empty.

Types

type Client

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

Client is the struct that is used to communicate with the games service.

func New

func New(addr string) (*Client, error)

New returns a new client with the given address.

func (*Client) CreateFranchise

func (c *Client) CreateFranchise(ctx context.Context, req *CreateFranchiseRequest) (*CreateFranchiseResponse, error)

CreateFranchise creates a franchise

func (*Client) CreateGame

func (c *Client) CreateGame(ctx context.Context, request *CreateGameRequest) (*CreateGameResponse, error)

CreateGame creates a new game from the passed model.

func (*Client) CreateUser

func (c *Client) CreateUser(ctx context.Context, request *CreateUserRequest) (*CreateUserResponse, error)

func (*Client) DeleteUserGame

func (c *Client) DeleteUserGame(ctx context.Context, request *DeleteUserGameRequest) error

func (*Client) GetFranchises

func (c *Client) GetFranchises(ctx context.Context, request *GetFranchisesRequest) (*GetFranchisesResponse, error)

GetFranchises returns all the franchises

func (*Client) GetGames

func (c *Client) GetGames(ctx context.Context, request *GetGamesRequest) (*GetGamesResponse, error)

GetGames returns all the games or all the games that are not assigned to the user to whom the token belongs.

func (*Client) GetStatuses

func (c *Client) GetStatuses(ctx context.Context, request *GetStatusesRequest) (*GetStatusesResponse, error)

GetStatuses fetches the statuses from the server

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context, request *GetUserRequest) (*GetUserResponse, error)

func (*Client) LoginUser

func (c *Client) LoginUser(ctx context.Context, request *LoginUserRequest) (*UserLoginResponse, error)

func (*Client) LogoutUser

func (c *Client) LogoutUser(ctx context.Context, request *LogoutUserRequest) error

func (*Client) UpdateGameProgress

func (c *Client) UpdateGameProgress(ctx context.Context, request *UpdateGameProgressRequest) error

type CreateFranchiseRequest

type CreateFranchiseRequest struct {
	Name  string
	Token string
}

CreateFranchiseRequest is used when the consumer wants to create a franchise

type CreateFranchiseResponse

type CreateFranchiseResponse struct {
	Franchise *Franchise
}

CreateFranchiseResponse is the response that is returned from CreateFranchise

type CreateGameRequest

type CreateGameRequest struct {
	Token string
	Game  *Game
}

CreateGameRequest is used when the consumer wants to create a games

type CreateGameResponse

type CreateGameResponse struct {
	Game *Game
}

CreateGameResponse is the response that is returned from CreateGame

type CreateUserRequest

type CreateUserRequest struct {
	Username string `json:"username,omitempty"`
	Email    string `json:"email,omitempty"`
	Password string `json:"password,omitempty"`
}

type CreateUserResponse

type CreateUserResponse struct {
	ID       string `json:"id,omitempty"`
	Username string `json:"username,omitempty"`
	Email    string `json:"email,omitempty"`
}

type DeleteUserGameRequest

type DeleteUserGameRequest struct {
	GameID string
	Token  string
}

type ErrorResponse

type ErrorResponse struct {
	Err string `json:"error"`
}

ErrorResponse - this is duplicated with api/server/users_handlers.go

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

type Franchise

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

Franchise is the struct that represents a franchise

type Game

type Game struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	FranchiseID string `json:"franchiseId"`

	Status   Status        `json:"status,omitempty"`
	Progress *GameProgress `json:"progress,omitempty"`
}

Game is the struct that represents a game

type GameProgress

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

type GetFranchisesRequest

type GetFranchisesRequest struct {
	Token string
}

GetFranchisesRequest is used when the consumer wants to get all franchises

type GetFranchisesResponse

type GetFranchisesResponse struct {
	Franchises []*Franchise `json:"franchises,omitempty"`
}

GetFranchisesResponse is the response that is returned from GetFranchises

type GetGamesRequest

type GetGamesRequest struct {
	Token           string
	ExcludeAssigned bool
}

GetGamesRequest is used when the consumer wants to get all games

type GetGamesResponse

type GetGamesResponse struct {
	Games []*Game
}

GetGamesResponse is the response that is returned from GetGames

type GetStatusesRequest

type GetStatusesRequest struct {
	Token string
}

GetStatusesRequest is used when getting the statuses from the server

type GetStatusesResponse

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

GetStatusesResponse is returned from the GetStatuses method

type GetUserRequest

type GetUserRequest struct {
	Token string
}

type GetUserResponse

type GetUserResponse struct {
	ID       string `json:"id,omitempty"`
	Username string `json:"username,omitempty"`
	Email    string `json:"email,omitempty"`
}

type LinkGameToUserRequest

type LinkGameToUserRequest struct {
	Token  string
	GameID string
}

type LoginUserRequest

type LoginUserRequest struct {
	Username string `json:"username,omitempty"`
	Email    string `json:"email,omitempty"`
	Password string `json:"password,omitempty"`
}

type LogoutUserRequest

type LogoutUserRequest struct {
	Token string
}

type Status

type Status string

Status is the status of the game

type UpdateGameProgressChange

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

type UpdateGameProgressRequest

type UpdateGameProgressRequest struct {
	GameID string
	Token  string
	Update UpdateGameProgressChange
}

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

type UserLoginResponse

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

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

Jump to

Keyboard shortcuts

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