topcoder

package
v0.0.0-...-03e1cd2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UserProfile *UserProfileApi
	Members     *MembersApi
	Data        *DataApi
)

Kind of a singleton allowing users to make requests for public data without explicitly keeping a reference to a go-topcoder client

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors. A response is considered an error if its status code is outside the 200 range. API error responses might have a JSON response body that maps to ErrorResponse.

Types

type Client

type Client struct {

	// Base URL for API requests.
	BaseURL *url.URL

	// User agent used when communicating with the Topcoder API.
	UserAgent string

	// Services used for talking to different parts of the Topcoder API.
	UserProfile *UserProfileApi
	Members     *MembersApi
	Data        *DataApi
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new Topcoder API client. A http.DefaultClient is used when a nil httpClient is provided.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.

func (*Client) NewRequest

func (c *Client) NewRequest(method, relPath string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A specific endpoint can be provided, and is resolved relative to the BaseURL of the Client. Endpoints should be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type DataApi

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

func (*DataApi) GetSrmSchedule

func (api *DataApi) GetSrmSchedule(opt *SRMScheduleOptions) (*SrmSchedule, *Response, error)

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response
	Err      struct {
		Message string `json:"description"`
		Details string `json:"details"`
	} `json:"error"`
}

Reports the errors caused by the Topcoder API request.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type ListOptions

type ListOptions struct {
	PageIndex  int           `url:"pageIndex,omitempty"`
	PageSize   int           `url:"pageSize,omitempty"`
	SortColumn string        `url:"sortColumn,omitempty"`
	SortOrder  SortOrderType `url:"sortOrder,omitempty"`
}

type MembersApi

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

func (*MembersApi) TopTrack

func (api *MembersApi) TopTrack(tt TrackType, opt *TopTrackListOptions) (*TopTrackMembers, *Response, error)

type PublicProfile

type PublicProfile struct {
	Handle         *string  `json:"handle,omitempty"`
	Country        *string  `json:"country,omitempty"`
	MemberSince    *string  `json:"memberSince,omitempty"`
	Quote          *string  `json:"quote,omitempty"`
	PhotoLink      *string  `json:"photoLink,omitempty"`
	Copilot        *bool    `json:"copilot,omitempty"`
	OverallEarning *float64 `json:"overallEarning,omitempty"`
	RatingSummary  []struct {
		Name       *string `json:"name,omitempty"`
		Rating     *int    `json:"rating,omitempty"`
		ColorStyle *string `json:"colorStyle,omitempty"`
	} `json:"ratingSummary,omitempty"`
	Achievements []struct {
		Date        *string `json:"date,omitempty"`
		Description *string `json:"description,omitempty"`
	} `json:"Achievements,omitempty"`
}

type RankItem

type RankItem struct {
	Rank              uint   `json:"rank,omitempty"`
	Handle            string `json:"handle,omitempty"`
	UserId            uint64 `json:"userId,omitempty"`
	Color             string `json:"color,omitempty"`
	Rating            int    `json:"rating,omitempty"`
	HighestRatingType string `json:"highestRatingType,omitempty"`
}

type Response

type Response struct {
	*http.Response
}

A Topcoder API response. It wraps the standard http.Response and might be useful later for Topcoder' specific response handling

type SRMScheduleOptions

type SRMScheduleOptions struct {
	Statuses []SrmStatus `url:"statuses,omitempty"`
	Types    []SrmType   `url:"types,omitempty"`
	// TODO - add filters on time fields
	ListOptions
}

type ScheduledSrm

type ScheduledSrm struct {
	RoundId     uint      `json:"roundId,omitempty"`
	Name        string    `json:"name,omitempty"`
	ShorName    string    `json:"shortName,omitempty"`
	ContestName string    `json:"contestName,omitempty"`
	RoundType   SrmType   `json:"roundType,omitempty"`
	Status      SrmStatus `json:"status,omitempty"`
}

type SortOrderType

type SortOrderType string
const (
	Ascending  SortOrderType = "asc"
	Descending SortOrderType = "desc"
)

type SrmSchedule

type SrmSchedule struct {
	Data []*ScheduledSrm `json:"data,omitempty"`
}

type SrmStatus

type SrmStatus string

TODO - figure out Status meaning

const (
	SrmStatusA SrmStatus = "a"
	SrmStatusF SrmStatus = "f"
	SrmStatusP SrmStatus = "p"
)

type SrmType

type SrmType string
const (
	Short      SrmType = "Single Round Match"
	Long       SrmType = "Long Round"
	Tournament SrmType = "Tournament"
)

type TopTrackListOptions

type TopTrackListOptions struct {
	ListOptions
}

type TopTrackMembers

type TopTrackMembers struct {
	Data []*RankItem `json:"data,omitempty"`
}

type TrackType

type TrackType string
const (
	Design      TrackType = "design"
	Development TrackType = "develop"
	DataScience TrackType = "data"
)

type UserProfileApi

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

func (*UserProfileApi) PublicProfile

func (api *UserProfileApi) PublicProfile(handle string) (*PublicProfile, *Response, error)

Jump to

Keyboard shortcuts

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