ogsclient

package
v0.0.0-...-a1f1577 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2019 License: MPL-2.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Me *MeService
	// contains filtered or unexported fields
}

Client is an OGS client for making OGS API requests.

func NewClient

func NewClient(httpClient *http.Client, ogsAPIBaseEndpoint string) *Client

NewClient returns a new OGS client.

type Game

type Game struct {
	ID        int     `json:"id"`
	Name      string  `json:"name"`
	Players   Players `json:"players"`
	Outcome   string  `json:"outcome"`
	BlackLost bool    `json:"black_lost"`
	WhiteLost bool    `json:"white_lost"`
	StartedAt string  `json:"started"`
	EndedAt   string  `json:"ended"`
}

Game represents basic game information.

func (*Game) HasBlackWon

func (game *Game) HasBlackWon() bool

HasBlackWon returns true if black has won the game.

func (*Game) HasEnded

func (game *Game) HasEnded() bool

HasEnded returns true if the game has finished.

func (*Game) HasWhiteWon

func (game *Game) HasWhiteWon() bool

HasWhiteWon returns true if white has won the game.

type MeService

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

MeService provides method for accessing resources under /me endpoint of the OGS API

func (*MeService) Games

func (s *MeService) Games() (*[]Game, error)

Games fetches all the authenticated user's games.

func (*MeService) User

func (s *MeService) User() (*User, error)

User fetches the /me resource endpoint, which represents the authenticated user.

type Players

type Players struct {
	Black User `json:"black"`
	White User `json:"white"`
}

Players holds both black and white users.

type User

type User struct {
	ID       int     `json:"id"`
	Username string  `json:"username"`
	Rating   float32 `json:"rating"`
	Ranking  int     `json:"ranking"`
}

User represents an authenticated user resource

func (User) DisplayRanking

func (user User) DisplayRanking() string

DisplayRanking converts Ranking into the usual Kyu/Dan ranking.

Jump to

Keyboard shortcuts

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