interactor

package module
v0.0.0-...-3d331b0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Id       string `json:"id"`
	Username string `json:"username"`
	Type     string `json:"type,omitempty"`
	Ip       string `json:"ip,omitempty"`
	TeamId   string `json:"team_id,omitempty"`
	PersonId string `json:"person_id,omitempty"`
}

func (Account) FromJSON

func (a Account) FromJSON(data []byte) (ApiType, error)

func (Account) Generate

func (a Account) Generate() ApiType

func (Account) InContest

func (a Account) InContest() bool

func (Account) Path

func (a Account) Path() string

func (Account) String

func (a Account) String() string

type ApiRelTime

type ApiRelTime time.Duration

ApiRelTime is a time.Duration which marshals to and from the format used in the CCS Api

func (ApiRelTime) Duration

func (a ApiRelTime) Duration() time.Duration

func (ApiRelTime) String

func (a ApiRelTime) String() string

func (*ApiRelTime) UnmarshalJSON

func (a *ApiRelTime) UnmarshalJSON(b []byte) (err error)

type ApiTime

type ApiTime time.Time

ApiTime is a time.Time which marshals to and from the format used in the CCS Api

func (ApiTime) AddDuration

func (a ApiTime) AddDuration(d ApiRelTime) ApiTime

func (ApiTime) After

func (a ApiTime) After(b ApiTime) bool

func (ApiTime) Before

func (a ApiTime) Before(b ApiTime) bool

func (ApiTime) Equal

func (a ApiTime) Equal(b ApiTime) bool

func (ApiTime) MarshalJSON

func (a ApiTime) MarshalJSON() ([]byte, error)

func (ApiTime) String

func (a ApiTime) String() string

func (ApiTime) Time

func (a ApiTime) Time() time.Time

func (*ApiTime) UnmarshalJSON

func (a *ApiTime) UnmarshalJSON(b []byte) (err error)

type ApiType

type ApiType interface {
	FromJSON([]byte) (ApiType, error)
	fmt.Stringer

	Path() string
	Generate() ApiType
	InContest() bool
}

ApiType is an interface used for objects that interact with the API.

type Clarification

type Clarification struct {
	Id          string     `json:"id,omitempty"`
	FromTeamId  string     `json:"from_team_id,omitempty"`
	ToTeamId    string     `json:"to_team_id,omitempty"`
	ReplyToId   string     `json:"reply_to_id,omitempty"`
	ProblemId   string     `json:"problem_id,omitempty"`
	Text        string     `json:"text"`
	Time        *ApiTime   `json:"time,omitempty"`
	ContestTime ApiRelTime `json:"contest_time,omitempty"`
}

func (Clarification) FromJSON

func (c Clarification) FromJSON(data []byte) (ApiType, error)

func (Clarification) Generate

func (c Clarification) Generate() ApiType

func (Clarification) InContest

func (c Clarification) InContest() bool

func (Clarification) Path

func (c Clarification) Path() string

func (Clarification) String

func (c Clarification) String() string

type Contest

type Contest struct {
	Id                       string     `json:"id"`
	Name                     string     `json:"name"`
	FormalName               string     `json:"formal_name,omitempty"`
	StartTime                ApiTime    `json:"start_time"`
	Duration                 ApiRelTime `json:"duration"`
	ScoreboardFreezeDuration ApiRelTime `json:"scoreboard_freeze_duration,omitempty"`
	CountdownTime            ApiRelTime `json:"countdown_pause_time,omitempty"`
}

func (Contest) FromJSON

func (c Contest) FromJSON(data []byte) (ApiType, error)

func (Contest) Generate

func (c Contest) Generate() ApiType

func (Contest) InContest

func (c Contest) InContest() bool

func (Contest) Path

func (c Contest) Path() string

func (Contest) String

func (c Contest) String() string

type ContestApi

type ContestApi interface {
	ContestsApi

	Contest() (Contest, error)

	State() (State, error)

	JudgementTypes() ([]JudgementType, error)
	JudgementTypeById(judgementTypeId string) (JudgementType, error)

	Languages() ([]Language, error)
	LanguageById(languageId string) (Language, error)

	Problems() ([]Problem, error)
	ProblemById(problemId string) (Problem, error)

	Groups() ([]Group, error)
	GroupById(groupId string) (Group, error)

	Organizations() ([]Organization, error)
	OrganizationById(organizationId string) (Organization, error)

	Teams() ([]Team, error)
	TeamById(teamId string) (Team, error)

	Persons() ([]Person, error)
	PersonById(personId string) (Person, error)

	Accounts() ([]Account, error)
	AccountById(accountId string) (Account, error)
	Account() (Account, error)

	Submissions() ([]Submission, error)
	SubmissionById(submissionId string) (Submission, error)

	Judgements() ([]Judgement, error)
	JudgementById(judgementId string) (Judgement, error)

	Clarifications() ([]Clarification, error)
	ClarificationById(clarificationId string) (Clarification, error)

	Scoreboard() (Scoreboard, error)

	Submit(submittable Submittable) (ApiType, error)
	PostClarification(problemId, text string) (Clarification, error)
	PostSubmission(problemId, languageId, entrypoint string, files LocalFileReference) (Submission, error)

	GetObject(interactor ApiType, id string) (ApiType, error)
	GetObjects(interactor ApiType) ([]ApiType, error)
}

func ContestInteractor

func ContestInteractor(baseUrl, username, password, contestId string, insecure bool) (ContestApi, error)

type ContestsApi

type ContestsApi interface {
	Contests() ([]Contest, error)
	ContestById(contestId string) (Contest, error)
	ToContest(cid string) (ContestApi, error)
}

func ContestsInteractor

func ContestsInteractor(baseUrl, username, password string, insecure bool) (ContestsApi, error)

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type FileReference

type FileReference struct {
	Href   string             `json:"href,omitempty"`
	Mime   string             `json:"mime,omitempty"`
	Width  int                `json:"width,omitempty"`
	Height int                `json:"height,omitempty"`
	Data   LocalFileReference `json:"data,omitempty"`
}

type Group

type Group struct {
	Id     string `json:"id"`
	ICPCId string `json:"icpc_id"`
	Name   string `json:"name"`
	Type   string `json:"type"`
	Hidden bool   `json:"hidden"`
}

func (Group) FromJSON

func (g Group) FromJSON(data []byte) (ApiType, error)

func (Group) Generate

func (g Group) Generate() ApiType

func (Group) InContest

func (g Group) InContest() bool

func (Group) Path

func (g Group) Path() string

func (Group) String

func (g Group) String() string

type Identifier

type Identifier string

func (*Identifier) UnmarshalJSON

func (i *Identifier) UnmarshalJSON(bts []byte) error

type Judgement

type Judgement struct {
	Id               string     `json:"id"`
	SubmissionId     string     `json:"submission_id"`
	JudgementTypeId  string     `json:"judgement_type_id,omitempty"`
	StartTime        *ApiTime   `json:"start_time"`
	StartContestTime ApiRelTime `json:"start_contest_time"`
	EndTime          *ApiTime   `json:"end_time,omitempty"`
	EndContestTime   ApiRelTime `json:"end_contest_time,omitempty"`
	MaxRunTime       float32    `json:"max_run_time,omitempty"`
}

func (Judgement) FromJSON

func (j Judgement) FromJSON(data []byte) (ApiType, error)

func (Judgement) Generate

func (j Judgement) Generate() ApiType

func (Judgement) InContest

func (j Judgement) InContest() bool

func (Judgement) Path

func (j Judgement) Path() string

func (Judgement) String

func (j Judgement) String() string

type JudgementType

type JudgementType struct {
	Id      string `json:"id"`
	Name    string `json:"name"`
	Penalty bool   `json:"penalty,omitempty"`
	Solved  bool   `json:"solved"`
}

func (JudgementType) FromJSON

func (jt JudgementType) FromJSON(data []byte) (ApiType, error)

func (JudgementType) Generate

func (jt JudgementType) Generate() ApiType

func (JudgementType) InContest

func (jt JudgementType) InContest() bool

func (JudgementType) Path

func (jt JudgementType) Path() string

func (JudgementType) String

func (jt JudgementType) String() string

type Language

type Language struct {
	Id                 string   `json:"id"`
	Name               string   `json:"name"`
	EntryPointRequired bool     `json:"entry_point_required"`
	EntryPointName     string   `json:"entry_point_name,omitempty"`
	Extensions         []string `json:"extensions"`
}

func (Language) FromJSON

func (l Language) FromJSON(data []byte) (ApiType, error)

func (Language) Generate

func (l Language) Generate() ApiType

func (Language) InContest

func (l Language) InContest() bool

func (Language) Path

func (l Language) Path() string

func (Language) String

func (l Language) String() string

type LocalFileReference

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

func (*LocalFileReference) FromFile

func (r *LocalFileReference) FromFile(file *os.File) error

func (*LocalFileReference) FromString

func (r *LocalFileReference) FromString(filename, body string) error

func (LocalFileReference) MarshalJSON

func (r LocalFileReference) MarshalJSON() ([]byte, error)

type Organization

type Organization struct {
	Id             string `json:"id"`
	ICPCId         string `json:"icpc_id"`
	Name           string `json:"name"`
	FormalName     string `json:"formal_name"`
	Country        string `json:"country"`
	URL            string `json:"url"`
	TwitterHashtag string `json:"twitter_hashtag"`
}

func (Organization) FromJSON

func (o Organization) FromJSON(data []byte) (ApiType, error)

func (Organization) Generate

func (o Organization) Generate() ApiType

func (Organization) InContest

func (o Organization) InContest() bool

func (Organization) Path

func (o Organization) Path() string

func (Organization) String

func (o Organization) String() string

type Person

type Person struct {
	Id     string `json:"id"`
	ICPCId string `json:"icpc_id,omitempty"`
	Name   string `json:"name"`
	Title  string `json:"title,omitempty"`
	Email  string `json:"email,omitempty"`
	Sex    string `json:"sex,omitempty"`
	Role   string `json:"role,omitempty"`
	TeamId string `json:"team_id,omitempty"`
}

func (Person) FromJSON

func (p Person) FromJSON(data []byte) (ApiType, error)

func (Person) Generate

func (p Person) Generate() ApiType

func (Person) InContest

func (p Person) InContest() bool

func (Person) Path

func (p Person) Path() string

func (Person) String

func (p Person) String() string

type Problem

type Problem struct {
	Id      string `json:"id"`
	Label   string `json:"label"`
	Name    string `json:"name"`
	Ordinal int    `json:"ordinal"`
}

func (Problem) FromJSON

func (p Problem) FromJSON(data []byte) (ApiType, error)

func (Problem) Generate

func (p Problem) Generate() ApiType

func (Problem) InContest

func (p Problem) InContest() bool

func (Problem) Path

func (p Problem) Path() string

func (Problem) String

func (p Problem) String() string

type Row

type Row struct {
	Rank     int            `json:"rank"`
	TeamId   Identifier     `json:"team_id"`
	Score    Score          `json:"score,omitempty"`
	Problems []ScoreProblem `json:"problems"`
}

func (Row) String

func (r Row) String() string

type Score

type Score struct {
	NumSolved int     `json:"num_solved,omitempty"`
	TotalTime int     `json:"total_time,omitempty"`
	Score     float64 `json:"score,omitempty"`
}

func (Score) String

func (s Score) String() string

type ScoreProblem

type ScoreProblem struct {
	ProblemId  Identifier `json:"problem_id"`
	NumJudged  int        `json:"num_judged"`
	NumPending int        `json:"num_pending"`
	Solved     bool       `json:"solved"`
	Score      float64    `json:"score,omitempty"`
	Time       int        `json:"time"`
}

func (ScoreProblem) String

func (s ScoreProblem) String() string

type Scoreboard

type Scoreboard struct {
	EventId     Identifier `json:"event_id"`
	Time        ApiTime    `json:"time"`
	ContestTime ApiRelTime `json:"contest_time"`
	State       State      `json:"state"`
	Rows        []Row      `json:"rows"`
}

func (Scoreboard) FromJSON

func (s Scoreboard) FromJSON(data []byte) (ApiType, error)

func (Scoreboard) Generate

func (s Scoreboard) Generate() ApiType

func (Scoreboard) InContest

func (s Scoreboard) InContest() bool

func (Scoreboard) Path

func (s Scoreboard) Path() string

func (Scoreboard) String

func (s Scoreboard) String() string

type State

type State struct {
	Started      *ApiTime `json:"started"`
	Ended        *ApiTime `json:"ended"`
	Frozen       *ApiTime `json:"frozen"`
	Thawed       *ApiTime `json:"thawed,omitempty"`
	Finalized    *ApiTime `json:"finalized"`
	EndOfUpdates *ApiTime `json:"end_of_updates"`
}

func (State) FromJSON

func (s State) FromJSON(data []byte) (ApiType, error)

func (State) Generate

func (s State) Generate() ApiType

func (State) InContest

func (s State) InContest() bool

func (State) Path

func (s State) Path() string

func (State) String

func (s State) String() string

type Submission

type Submission struct {
	Id          string          `json:"id,omitempty"`
	LanguageId  string          `json:"language_id"`
	Time        *ApiTime        `json:"time,omitempty"`
	ContestTime ApiRelTime      `json:"contest_time,omitempty"`
	TeamId      string          `json:"team_id,omitempty"`
	ProblemId   string          `json:"problem_id,omitempty"`
	EntryPoint  string          `json:"entry_point,omitempty"`
	Files       []FileReference `json:"files,omitempty"`
}

func (Submission) FromJSON

func (s Submission) FromJSON(data []byte) (ApiType, error)

func (Submission) Generate

func (s Submission) Generate() ApiType

func (Submission) InContest

func (s Submission) InContest() bool

func (Submission) Path

func (s Submission) Path() string

func (Submission) String

func (s Submission) String() string

type Submittable

type Submittable interface {
	ApiType
}

Submittable is an ApiType that can be submitted to the API. TODO decide on whether to merge the interfaces

type Team

type Team struct {
	Id             string   `json:"id"`
	ICPCId         string   `json:"icpc_id"`
	Name           string   `json:"name"`
	DisplayName    string   `json:"display_name"`
	GroupIds       []string `json:"group_ids"`
	OrganizationId string   `json:"organization_id"`
}

func (Team) FromJSON

func (t Team) FromJSON(data []byte) (ApiType, error)

func (Team) Generate

func (t Team) Generate() ApiType

func (Team) InContest

func (t Team) InContest() bool

func (Team) Path

func (t Team) Path() string

func (Team) String

func (t Team) String() string

Jump to

Keyboard shortcuts

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