Add support to download all the users courses
This commit is contained in:
@@ -51,6 +51,20 @@ func (c *Client) GetCourseInfo() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) GetEnrolledCourses() ([]models.Course, error) {
|
||||
req, _ := http.NewRequest("GET", fmt.Sprintf("%s/api/v1/courses?enrollment_state=active&per_page=100", config.BaseURL), nil)
|
||||
req.Header.Set("Authorization", "Bearer "+c.AccessToken)
|
||||
resp, err := c.HTTPClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
var courses []models.Course
|
||||
json.NewDecoder(resp.Body).Decode(&courses)
|
||||
return courses, nil
|
||||
}
|
||||
|
||||
func (c *Client) DownloadCourseFiles(root string) {
|
||||
fmt.Println("\n[*] Fetching regular course files...")
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ type TokenResponse struct {
|
||||
}
|
||||
|
||||
type Course struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user