Documentation
¶
Index ¶
- Variables
- func CheckResponse(r *http.Response) error
- type Client
- type DataApi
- type ErrorResponse
- type ListOptions
- type MembersApi
- type PublicProfile
- type RankItem
- type Response
- type SRMScheduleOptions
- type ScheduledSrm
- type SortOrderType
- type SrmSchedule
- type SrmStatus
- type SrmType
- type TopTrackListOptions
- type TopTrackMembers
- type TrackType
- type UserProfileApi
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
NewClient returns a new Topcoder API client. A http.DefaultClient is used when a nil httpClient is provided.
func (*Client) Do ¶
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 ¶
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 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 SortOrderType ¶
type SortOrderType string
const ( Ascending SortOrderType = "asc" Descending SortOrderType = "desc" )
type SrmSchedule ¶
type SrmSchedule struct {
Data []*ScheduledSrm `json:"data,omitempty"`
}
type TopTrackListOptions ¶
type TopTrackListOptions struct {
ListOptions
}
type TopTrackMembers ¶
type TopTrackMembers struct {
Data []*RankItem `json:"data,omitempty"`
}
type UserProfileApi ¶
type UserProfileApi struct {
// contains filtered or unexported fields
}
func (*UserProfileApi) PublicProfile ¶
func (api *UserProfileApi) PublicProfile(handle string) (*PublicProfile, *Response, error)