Documentation ¶
Overview ¶
Package quizduell provides an interface to the REST API used by the Quizduell mobile apps. It supports all functionality that is also possible in the mobile apps. Note: Most calls to the API do _not_ populate all
fields of the returned type. As an example, Client.GetUserGames() does not include the full-text of the questions.
Index ¶
- type CategoryStatistic
- type Client
- func (c *Client) AcceptGame(gameID int) (bool, error)
- func (c *Client) AddBlocked(userID int) ([]User, error)
- func (c *Client) AddFriend(userID int) (*Popup, error)
- func (c *Client) CategoryList() (map[int]string, error)
- func (c *Client) CategoryStatistics() (*UserCategoryStatistics, error)
- func (c *Client) CreateTVUser() (*User, error)
- func (c *Client) CreateUser(username, email, password string) (*Status, error)
- func (c *Client) DeclineGame(gameID int) (bool, error)
- func (c *Client) FindUser(username string) (*User, error)
- func (c *Client) GameStatistics() ([]GameStatistic, error)
- func (c *Client) GetGame(gameID int) (*Game, error)
- func (c *Client) GetGames(gameIDs []int) ([]Game, error)
- func (c *Client) GetUserGames() (*Status, error)
- func (c *Client) GiveUp(gameID int) (*Game, *Popup, error)
- func (c *Client) Login(username, password string) (*Status, error)
- func (c *Client) RemoveBlocked(userID int) ([]User, error)
- func (c *Client) RemoveFriend(userID int) (*Popup, error)
- func (c *Client) SendForgotPasswordEmail(email string) (*Popup, error)
- func (c *Client) SendMessage(gameID int, message string) (*InGameMessage, error)
- func (c *Client) StartGame(opponentID int) (*Game, error)
- func (c *Client) StartRandomGame() (*Game, error)
- func (c *Client) TopPlayers() ([]User, error)
- func (c *Client) TopWriters() ([]User, error)
- func (c *Client) UpdateAvatar(avatarCode string) (bool, error)
- func (c *Client) UpdateUser(username, email, password string) (*Status, error)
- func (c *Client) UploadRoundAnswers(gameID int, answers []int, categoryID int) (*Game, error)
- type Game
- type GameState
- type GameStatistic
- type InGameMessage
- type Popup
- type Question
- type Status
- type TVClient
- func (t *TVClient) AgreeAGBs() (map[string]interface{}, error)
- func (t *TVClient) DeleteUser() (map[string]interface{}, error)
- func (t *TVClient) GetMyProfile() (map[string]interface{}, error)
- func (t *TVClient) GetProfile(userID int) (map[string]interface{}, error)
- func (t *TVClient) GetRankings() (map[string]interface{}, error)
- func (t *TVClient) GetState() (map[string]interface{}, error)
- func (t *TVClient) PostProfile(profile map[string]string) (map[string]interface{}, error)
- func (t *TVClient) SelectCategory(categoryID int) (map[string]interface{}, error)
- func (t *TVClient) SendAnswer(questionID, answerID int) (map[string]interface{}, error)
- func (t *TVClient) SetAvatarAndNickname(nick, avatarCode string) (map[string]interface{}, error)
- func (t *TVClient) UploadProfileImage(r io.Reader) (map[string]interface{}, error)
- type User
- type UserCategoryStatistics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CategoryStatistic ¶
type Client ¶
type Client struct { // We're separating out this cookie jar from // the HTTP client, because Go is trying to be // peticularly RFC compliant and doesn't allow // certain characters in cookies. That's why we // have to handle them seperately. Jar http.CookieJar // contains filtered or unexported fields }
Client represents a single user's (non-persistent) connection to Quizduell. In fact it just wraps the HTTP client and cookiejar.
func NewClient ¶
NewClient produces a new Quizduell client. It optionally takes a cookiejar, but if there isn't one provided it automatically creates one for you.
func (*Client) AcceptGame ¶
AcceptGame accepts a pending game request that has the given gameID. Requires you to be logged in.
func (*Client) AddBlocked ¶
AddBlocked puts the user with the provided userID onto your blocked list. Requires you to be logged in.
func (*Client) AddFriend ¶
AddFriend puts the user with the provided userID onto your friends list. Requires you to be logged in.
func (*Client) CategoryList ¶
CategoryList fetches all possible categories. Requires you to be logged in.
func (*Client) CategoryStatistics ¶
func (c *Client) CategoryStatistics() (*UserCategoryStatistics, error)
CategoryStatistics gives you the performance of the logged in user for all categories. Requires you to be logged in.
func (*Client) CreateTVUser ¶
CreateTVUser creates a new TV user profile for the current logged in Quizduell users. Requires you to be logged in.
func (*Client) CreateUser ¶
CreateUser registers a new user with Quizduell, this user is automatically logged in. The email is optional and will be omitted for the call if it is the empty string.
func (*Client) DeclineGame ¶
DeclineGame declines a pending game request that has the given gameID. Requires you to be logged in.
func (*Client) FindUser ¶
FindUser returns the user object of the user with the provided username. Requires you to be logged in.
func (*Client) GameStatistics ¶
func (c *Client) GameStatistics() ([]GameStatistic, error)
GameStatistics returns general game statistic information on a per opponent basis. Requires you to be logged in.
func (*Client) GetGame ¶
GetGame returns more information about the game with the given gameID. The returned game object also contains the all possible questions of every round. Requires you to be logged in.
func (*Client) GetGames ¶
GetGames returns details of the specified games, not including question and answer strings though. Requires you to be logged in.
func (*Client) GetUserGames ¶
GetUserGames returns a status update, that also contains game data from the user's games. Requires you to be logged in.
func (*Client) GiveUp ¶
GiveUp ends the game with the provided gameID, you may loose points when giving up. Requires you to be logged in.
func (*Client) Login ¶
Login logs in a user to Quizduell and puts the returned cookie (on success) into the cookiejar. You've no need to call login, if you create a new user or provide a new cookiejar with the appropriate cookie in it.
func (*Client) RemoveBlocked ¶
RemoveBlocked removes the user with the provided userID from your blocked list. Requires you to be logged in.
func (*Client) RemoveFriend ¶
RemoveFriend removes the user with the provided userID from your friends list. Requires you to be logged in.
func (*Client) SendForgotPasswordEmail ¶
SendForgotPasswordEmail sends a forgot password email to the current user. I guess this function requires the current user to have an email set in his profile. Requires you to be logged in.
func (*Client) SendMessage ¶
func (c *Client) SendMessage(gameID int, message string) (*InGameMessage, error)
SendMessage sends a message to the user that is the opponent in the game with the given gameID. All messages to a user are visible in all games against this opponent. Requires you to be logged in.
func (*Client) StartGame ¶
StartGame starts a new game against the player with the provided opponentID. Requires you to be logged in.
func (*Client) StartRandomGame ¶
StartRandomGame starts a new game against a player that is choosen randomly by the Quizduell server. After some time testing the automatic player, it seems that you can at most play in about 122 games. Requires you to be logged in.
func (*Client) TopPlayers ¶
TopPlayers gets the list of users that have the highest ranking based on the points won in games. Requires you to be logged in.
func (*Client) TopWriters ¶
TopWriters gets the list of users that have submitted the most questions, that have also been accepted. Requires you to be logged in.
func (*Client) UpdateAvatar ¶
UpdateAvatar sets the current user's avatar to the provided avatar code. An avatar consists of individual mouth, hair, eyes, hats, etc. encoded in a numerical string, e.g. "0010999912" (A skin-colored avatar with a crown). Requires you to be logged in.
func (*Client) UpdateUser ¶
UpdateUser sets the user's attributes, if one of them is the empty string that attribute will be omitted from the request. Requires you to be logged in.
func (*Client) UploadRoundAnswers ¶
UploadRoundAnswers sends your provided answers to the Quizduell server. Note: In the answers you must include all answers you gave in the previous rounds of the same game. Requires you to be logged in.
type Game ¶
type Game struct { ID int `json:"game_id"` CategoryChoices []int `json:"cat_choices"` ElapsedMinutes int `json:"elapsed_min"` Messages []InGameMessage `json:"messages"` Opponent User `json:"opponent"` OpponentAnswers []int `json:"opponent_answers"` YourAnswers []int `json:"your_answers"` YourTurn bool `json:"your_turn"` Questions []Question `json:"questions"` RatingBonus int `json:"rating_bonus"` GameState `json:"state"` }
type GameStatistic ¶
type InGameMessage ¶
type Question ¶
type Question struct { QuestionText string `json:"question"` Correct string `json:"correct"` Wrong1 string `json:"wrong1"` Wrong2 string `json:"wrong2"` Wrong3 string `json:"wrong3"` Timestamp string `json:"timestamp"` CategoryName string `json:"cat_name"` CategoryID int `json:"cat_id"` QuestionID int `json:"q_id"` }
type Status ¶
type Status struct { LoggedIn bool `json:"logged_in"` *User `json:"user"` Settings *struct { MaxFreeGames int `json:"max_free_games"` GiveUpPointLoss int `json:"give_up_point_loss"` AdProvider string `json:"ad_provider"` AdmobMedID string `json:"ad_mob_med_id"` AdmobMedSplashID string `json:"admob_med_splash_id"` Fulmium bool `json:"fulmium"` Feo bool `json:"feo"` Feos float64 `json:"feos"` PPF float64 `json:"ppf"` CheckLimboGames bool `json:"check_limbo_games"` RefreshTableFreq int `json:"refresh_table_freq"` RefreshFreq int `json:"refresh_freq"` SplashFreq float64 `json:"splash_freq"` // contains filtered or unexported fields } `json:"settings"` }
type TVClient ¶
type TVClient struct { UserID int // The API seems to be using this auth token (tt) // as a validation mechanism, instead of cookies // or the like. AuthToken string }
func FromClient ¶
FromClient returns a new TV client based on an already existant (and logged in) Quizduell client. If the user hasn't created a TV profile yet, this will also be done in the process.
func NewTVClient ¶
NewTVClient creates a new TV client that can be used to interact with the TV version of Quizduell. The authToken is User.TT
func (*TVClient) AgreeAGBs ¶
AgreeAGBs makes the current user agree to the AGB put up by the TV quiz broadcaster.
func (*TVClient) DeleteUser ¶
func (*TVClient) GetMyProfile ¶
func (*TVClient) GetProfile ¶
func (*TVClient) GetRankings ¶
func (*TVClient) PostProfile ¶
func (*TVClient) SelectCategory ¶
func (*TVClient) SendAnswer ¶
func (*TVClient) SetAvatarAndNickname ¶
type User ¶
type User struct { AvatarCode string `json:"avatar_code"` Name string `json:"name"` ID int `json:"user_id,string"` TT string `json:"tt"` QC bool `json:"qc"` QuestionReviewer int `json:"q_reviewer"` NumApprovedQuestions int `json:"n_approved_questions"` Key int `json:"key"` Rating int `json:"rating"` Friends []User `json:"friends"` FacebookID int `json:"facebook_id,string"` Games []Game `json:"games"` Email string `json:"email"` }
type UserCategoryStatistics ¶
type UserCategoryStatistics struct { CategoryStatistics []CategoryStatistic `json:"cat_stats"` GamesLost int `json:"n_games_lost"` GamesPlayed int `json:"n_games_played"` GamesTied int `json:"n_games_tied"` GamesWon int `json:"n_games_won"` PerfectGames int `json:"n_perfect_games"` QuestionsAnswered int `json:"n_questions_answered"` QuestionsCorrect int `json:"n_questions_correct"` NumUsers int `json:"n_users"` Rank int `json:"rank"` Rating int `json:"rating"` }