Skip to content

Commit acd3f56

Browse files
author
Steven Berlanga
committed
adding submission api
1 parent 34da700 commit acd3f56

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎api/api.go‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,22 @@ func (c *Client) Submissions() (map[string][]SubmissionInfo, error) {
111111
return payload, nil
112112
}
113113

114+
// Submission get the latest submitted exercise for the given language and exercise
115+
func (c *Client) Submission(language, excercise string) (*Submission, error) {
116+
url := fmt.Sprintf("%s/api/v1/submissions/%s/%s?key=%s", c.APIHost, language, excercise, c.APIKey)
117+
req, err := c.NewRequest("GET", url, nil)
118+
if err != nil {
119+
return nil, err
120+
}
121+
122+
var payload Submission
123+
if _, err := c.Do(req, &payload); err != nil {
124+
return nil, err
125+
}
126+
127+
return &payload, nil
128+
}
129+
114130
// Download fetches a solution by submission key and writes it to disk.
115131
func (c *Client) Download(submissionID string) (*Submission, error) {
116132
url := fmt.Sprintf("%s/api/v1/submissions/%s", c.APIHost, submissionID)

0 commit comments

Comments
 (0)