Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) CreateFranchise(ctx context.Context, req *CreateFranchiseRequest) (*CreateFranchiseResponse, error)
- func (c *Client) CreateGame(ctx context.Context, request *CreateGameRequest) (*CreateGameResponse, error)
- func (c *Client) CreateUser(ctx context.Context, request *CreateUserRequest) (*CreateUserResponse, error)
- func (c *Client) DeleteUserGame(ctx context.Context, request *DeleteUserGameRequest) error
- func (c *Client) GetFranchises(ctx context.Context, request *GetFranchisesRequest) (*GetFranchisesResponse, error)
- func (c *Client) GetGames(ctx context.Context, request *GetGamesRequest) (*GetGamesResponse, error)
- func (c *Client) GetStatuses(ctx context.Context, request *GetStatusesRequest) (*GetStatusesResponse, error)
- func (c *Client) GetUser(ctx context.Context, request *GetUserRequest) (*GetUserResponse, error)
- func (c *Client) LoginUser(ctx context.Context, request *LoginUserRequest) (*UserLoginResponse, error)
- func (c *Client) LogoutUser(ctx context.Context, request *LogoutUserRequest) error
- func (c *Client) UpdateGameProgress(ctx context.Context, request *UpdateGameProgressRequest) error
- type CreateFranchiseRequest
- type CreateFranchiseResponse
- type CreateGameRequest
- type CreateGameResponse
- type CreateUserRequest
- type CreateUserResponse
- type DeleteUserGameRequest
- type ErrorResponse
- type Franchise
- type Game
- type GameProgress
- type GetFranchisesRequest
- type GetFranchisesResponse
- type GetGamesRequest
- type GetGamesResponse
- type GetStatusesRequest
- type GetStatusesResponse
- type GetUserRequest
- type GetUserResponse
- type LinkGameToUserRequest
- type LoginUserRequest
- type LogoutUserRequest
- type Status
- type UpdateGameProgressChange
- type UpdateGameProgressRequest
- type User
- type UserLoginResponse
Constants ¶
This section is empty.
Variables ¶
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") )
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") )
var ( // ErrFetchingStatuses is a generic error ErrFetchingStatuses = errors.New("error while fetching statuses") )
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 (*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 ¶
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 ¶
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 CreateUserResponse ¶
type DeleteUserGameRequest ¶
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 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 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 ¶
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 LinkGameToUserRequest ¶
type LoginUserRequest ¶
type LogoutUserRequest ¶
type LogoutUserRequest struct {
Token string
}
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.