canvas

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 19, 2020 License: Apache-2.0 Imports: 14 Imported by: 4

README

go-canvas

A (very incomplete) api client for Instructure's Canvas API.

Build Status GoDoc Go Report Card codecov TODOs

Download/Install

go get github.com/harrybrwn/go-canvas

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultHost is the default url host for the canvas api.
	DefaultHost = "canvas.instructure.com"

	// ConcurrentErrorHandler is the error handling callback for
	// handling errors in tricky goroutines.
	ConcurrentErrorHandler func(error, chan int) = defaultErrorHandler

	// DefaultUserAgent is the default user agent used to make requests.
	DefaultUserAgent = "go-canvas"
)
View Source
var ErrRateLimitExceeded = errors.New("403 Forbidden (Rate Limit Exceeded)")

ErrRateLimitExceeded is returned when the api rate limit has been reached.

Functions

func CreateBookmark

func CreateBookmark(b *Bookmark) error

CreateBookmark will take a bookmark and send it to canvas.

func DeleteBookmark

func DeleteBookmark(b *Bookmark) error

DeleteBookmark will delete a bookmark

func IsRateLimit

func IsRateLimit(e error) bool

IsRateLimit returns true if the error given is a rate limit error.

func SetHost

func SetHost(host string) error

SetHost will set the package level host.

func SetToken

func SetToken(token string)

SetToken will set the package level canvas object token.

func Todos

func Todos() error

Todos will get the current user's todo's.

Types

type Account

type Account struct {
	ID              int    `json:"id"`
	Name            string `json:"name"`
	UUID            string `json:"uuid"`
	ParentAccountID int    `json:"parent_account_id"`
	RootAccountID   int    `json:"root_account_id"`
	WorkflowState   string `json:"workflow_state"`
	DefaultTimeZone string `json:"default_time_zone"`
	IntegrationID   string `json:"integration_id"`
	SisAccountID    string `json:"sis_account_id"`
	SisImportID     int    `json:"sis_import_id"`
	LtiGUID         string `json:"lti_guid"`

	// Storage Quotas
	DefaultStorageQuotaMB      int `json:"default_storage_quota_mb"`
	DefaultUserStorageQuotaMB  int `json:"default_user_storage_quota_mb"`
	DefaultGroupStorageQuotaMB int `json:"default_group_storage_quota_mb"`

	Domain   string      `json:"domain"`
	Distance interface{} `json:"distance"`
	// Authentication Provider
	AuthProvider string `json:"authentication_provider"`
	// contains filtered or unexported fields
}

Account is an account

func Accounts

func Accounts(opts ...Option) ([]Account, error)

Accounts will list the accounts

func CourseAccounts

func CourseAccounts(opts ...Option) ([]Account, error)

CourseAccounts will make a call to the course accounts endpoint

func CurrentAccount

func CurrentAccount() (a *Account, err error)

CurrentAccount will get the current account.

func SearchAccounts

func SearchAccounts(opts ...Option) ([]Account, error)

SearchAccounts will search for canvas accounts. Options: name, domain, latitude, longitude

c.SearchAccouts(Opt("name", "My School Name"))

func (*Account) Courses

func (a *Account) Courses(opts ...Option) (courses []*Course, err error)

Courses returns the account's list of courses

type AuthError

type AuthError struct {
	Status string     `json:"status"`
	Errors []errorMsg `json:"errors"`
}

AuthError is an authentication error response from canvas.

func (*AuthError) Error

func (ae *AuthError) Error() string

type Avatar

type Avatar struct {
	ID          int    `json:"id"`
	Type        string `json:"type"`
	DisplayName string `json:"display_name"`
	Filename    string `json:"filename"`
	URL         string `json:"url"`
	Token       string `json:"token"`
	ContentType string `json:"content-type"`
	Size        int    `json:"size"`
}

Avatar is the avatar data for a user.

type Bookmark

type Bookmark struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	URL      string `json:"url"`
	Position int    `json:"position"`
	Data     struct {
		ActiveTab int `json:"active_tab"`
	} `json:"data"`
}

Bookmark is a bookmark object.

func Bookmarks

func Bookmarks(opts ...Option) ([]Bookmark, error)

Bookmarks will get the current user's bookmarks.

type CalendarEvent

type CalendarEvent struct {
	// ID                         int         `json:"id"`
	ID                         string      `json:"id"`
	Title                      string      `json:"title"`
	StartAt                    string      `json:"start_at"`
	EndAt                      string      `json:"end_at"`
	Description                string      `json:"description"`
	LocationName               string      `json:"location_name"`
	LocationAddress            string      `json:"location_address"`
	ContextCode                string      `json:"context_code"`
	EffectiveContextCode       interface{} `json:"effective_context_code"`
	AllContextCodes            string      `json:"all_context_codes"`
	WorkflowState              string      `json:"workflow_state"`
	Hidden                     bool        `json:"hidden"`
	ParentEventID              interface{} `json:"parent_event_id"`
	ChildEventsCount           int         `json:"child_events_count"`
	ChildEvents                interface{} `json:"child_events"`
	URL                        string      `json:"url"`
	HTMLURL                    string      `json:"html_url"`
	AllDayDate                 string      `json:"all_day_date"`
	AllDay                     bool        `json:"all_day"`
	CreatedAt                  string      `json:"created_at"`
	UpdatedAt                  string      `json:"updated_at"`
	AppointmentGroupID         interface{} `json:"appointment_group_id"`
	AppointmentGroupURL        interface{} `json:"appointment_group_url"`
	OwnReservation             bool        `json:"own_reservation"`
	ReserveURL                 string      `json:"reserve_url"`
	Reserved                   bool        `json:"reserved"`
	ParticipantType            string      `json:"participant_type"`
	ParticipantsPerAppointment interface{} `json:"participants_per_appointment"`
	AvailableSlots             interface{} `json:"available_slots"`
	User                       *User       `json:"user"`
	Group                      interface{} `json:"group"`
}

CalendarEvent is a calendar event

func CalendarEvents

func CalendarEvents(opts ...Option) ([]CalendarEvent, error)

CalendarEvents makes a call to get calendar events.

type Canvas

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

Canvas is the main api controller.

func New

func New(token string) *Canvas

New will create a Canvas struct from an api token. New uses the default host.

func WithHost

func WithHost(token, host string) *Canvas

WithHost will create a canvas object that uses a different hostname.

func (*Canvas) Accounts

func (c *Canvas) Accounts(opts ...Option) ([]Account, error)

Accounts will list the accounts

func (*Canvas) ActiveCourses

func (c *Canvas) ActiveCourses(opts ...Option) ([]*Course, error)

ActiveCourses returns a list of only the courses that are currently active

func (*Canvas) Announcements

func (c *Canvas) Announcements(contextCodes []string, opts ...Option) (arr []DiscussionTopic, err error)

Announcements will get the announcements

func (*Canvas) Bookmarks

func (c *Canvas) Bookmarks(opts ...Option) (b []Bookmark, err error)

Bookmarks will get the current user's bookmarks.

func (*Canvas) CalendarEvents

func (c *Canvas) CalendarEvents(opts ...Option) (cal []CalendarEvent, err error)

CalendarEvents makes a call to get calendar events.

func (*Canvas) CompletedCourses

func (c *Canvas) CompletedCourses(opts ...Option) ([]*Course, error)

CompletedCourses returns a list of only the courses that are not currently active and have been completed

func (*Canvas) Conversations

func (c *Canvas) Conversations(opts ...Option) (conversations []Conversation, err error)

Conversations returns a list of conversations

func (*Canvas) CourseAccounts

func (c *Canvas) CourseAccounts(opts ...Option) ([]Account, error)

CourseAccounts will make a call to the course accounts endpoint

func (*Canvas) Courses

func (c *Canvas) Courses(opts ...Option) ([]*Course, error)

Courses lists all of the courses associated with that canvas object.

func (*Canvas) CreateBookmark

func (c *Canvas) CreateBookmark(b *Bookmark) error

CreateBookmark will take a bookmark and send it to canvas.

func (*Canvas) CurrentAccount

func (c *Canvas) CurrentAccount() (a *Account, err error)

CurrentAccount will get the current account.

func (*Canvas) CurrentUser

func (c *Canvas) CurrentUser(opts ...Option) (*User, error)

CurrentUser get the currently logged in user.

func (*Canvas) DeleteBookmark

func (c *Canvas) DeleteBookmark(b *Bookmark) error

DeleteBookmark will delete a bookmark

func (*Canvas) GetCourse

func (c *Canvas) GetCourse(id int, opts ...Option) (*Course, error)

GetCourse will get a course given a course id.

func (*Canvas) GetUser

func (c *Canvas) GetUser(id int, opts ...Option) (*User, error)

GetUser will return a user object given that user's ID.

func (*Canvas) SearchAccounts

func (c *Canvas) SearchAccounts(opts ...Option) ([]Account, error)

SearchAccounts will search for canvas accounts. Options: name, domain, latitude, longitude

c.SearchAccouts(Opt("name", "My School Name"))

func (*Canvas) SetHost

func (c *Canvas) SetHost(host string) error

SetHost will set the host for the canvas requestor.

func (*Canvas) Todos

func (c *Canvas) Todos() error

Todos will get the current user's todo's.

type Conversation

type Conversation struct {
	ID               int         `json:"id"`
	Subject          string      `json:"subject"`
	WorkflowState    string      `json:"workflow_state"`
	LastMessage      string      `json:"last_message"`
	StartAt          time.Time   `json:"start_at"`
	MessageCount     int         `json:"message_count"`
	Subscribed       bool        `json:"subscribed"`
	Private          bool        `json:"private"`
	Starred          bool        `json:"starred"`
	Properties       interface{} `json:"properties"`
	Audience         interface{} `json:"audience"`
	AudienceContexts interface{} `json:"audience_contexts"`
	AvatarURL        string      `json:"avatar_url"`
	Participants     interface{} `json:"participants"`
	Visible          bool        `json:"visible"`
	ContextName      string      `json:"context_name"`
}

Conversation is a conversation.

func Conversations

func Conversations(opts ...Option) ([]Conversation, error)

Conversations returns a list of conversations

type Course

type Course struct {
	ID                   int         `json:"id"`
	Name                 string      `json:"name"`
	SisCourseID          int         `json:"sis_course_id"`
	UUID                 string      `json:"uuid"`
	IntegrationID        interface{} `json:"integration_id"`
	SisImportID          int         `json:"sis_import_id"`
	CourseCode           string      `json:"course_code"`
	WorkflowState        string      `json:"workflow_state"`
	AccountID            int         `json:"account_id"`
	RootAccountID        int         `json:"root_account_id"`
	EnrollmentTermID     int         `json:"enrollment_term_id"`
	GradingStandardID    int         `json:"grading_standard_id"`
	GradePassbackSetting string      `json:"grade_passback_setting"`
	CreatedAt            time.Time   `json:"created_at"`
	StartAt              time.Time   `json:"start_at"`
	EndAt                time.Time   `json:"end_at"`
	Locale               string      `json:"locale"`
	Enrollments          []struct {
		EnrollmentState                string `json:"enrollment_state"`
		Role                           string `json:"role"`
		RoleID                         int64  `json:"role_id"`
		Type                           string `json:"type"`
		UserID                         int64  `json:"user_id"`
		LimitPrivilegesToCourseSection bool   `json:"limit_privileges_to_course_section"`
	} `json:"enrollments"`
	TotalStudents     int         `json:"total_students"`
	Calendar          interface{} `json:"calendar"`
	DefaultView       string      `json:"default_view"`
	SyllabusBody      string      `json:"syllabus_body"`
	NeedsGradingCount int         `json:"needs_grading_count"`

	Term           Term           `json:"term"`
	CourseProgress CourseProgress `json:"course_progress"`

	ApplyAssignmentGroupWeights bool `json:"apply_assignment_group_weights"`
	Permissions                 struct {
		CreateDiscussionTopic bool `json:"create_discussion_topic"`
		CreateAnnouncement    bool `json:"create_announcement"`
	} `json:"permissions"`
	IsPublic                         bool   `json:"is_public"`
	IsPublicToAuthUsers              bool   `json:"is_public_to_auth_users"`
	PublicSyllabus                   bool   `json:"public_syllabus"`
	PublicSyllabusToAuth             bool   `json:"public_syllabus_to_auth"`
	PublicDescription                string `json:"public_description"`
	StorageQuotaMb                   int    `json:"storage_quota_mb"`
	StorageQuotaUsedMb               int    `json:"storage_quota_used_mb"`
	HideFinalGrades                  bool   `json:"hide_final_grades"`
	License                          string `json:"license"`
	AllowStudentAssignmentEdits      bool   `json:"allow_student_assignment_edits"`
	AllowWikiComments                bool   `json:"allow_wiki_comments"`
	AllowStudentForumAttachments     bool   `json:"allow_student_forum_attachments"`
	OpenEnrollment                   bool   `json:"open_enrollment"`
	SelfEnrollment                   bool   `json:"self_enrollment"`
	RestrictEnrollmentsToCourseDates bool   `json:"restrict_enrollments_to_course_dates"`
	CourseFormat                     string `json:"course_format"`
	AccessRestrictedByDate           bool   `json:"access_restricted_by_date"`
	TimeZone                         string `json:"time_zone"`
	Blueprint                        bool   `json:"blueprint"`
	BlueprintRestrictions            struct {
		Content           bool `json:"content"`
		Points            bool `json:"points"`
		DueDates          bool `json:"due_dates"`
		AvailabilityDates bool `json:"availability_dates"`
	} `json:"blueprint_restrictions"`
	BlueprintRestrictionsByObjectType struct {
		Assignment struct {
			Content bool `json:"content"`
			Points  bool `json:"points"`
		} `json:"assignment"`
		WikiPage struct {
			Content bool `json:"content"`
		} `json:"wiki_page"`
	} `json:"blueprint_restrictions_by_object_type"`
	// contains filtered or unexported fields
}

Course represents a canvas course.

func ActiveCourses

func ActiveCourses(opts ...Option) ([]*Course, error)

ActiveCourses returns a list of only the courses that are currently active

func CompletedCourses

func CompletedCourses(opts ...Option) ([]*Course, error)

CompletedCourses returns a list of only the courses that are not currently active and have been completed

func Courses

func Courses(opts ...Option) ([]*Course, error)

Courses lists all of the courses associated with that canvas object.

func GetCourse

func GetCourse(id int, opts ...Option) (*Course, error)

GetCourse will get a course given a course id.

func (*Course) Activity

func (c *Course) Activity() (interface{}, error)

Activity returns a course's activity data

func (*Course) File

func (c *Course) File(id int, opts ...Option) (*File, error)

File will get a specific file id.

func (*Course) Files

func (c *Course) Files(opts ...Option) <-chan *File

Files returns a channel of all the course's files

func (*Course) FilesErrChan

func (c *Course) FilesErrChan() (<-chan *File, <-chan error)

FilesErrChan will return a channel that sends File structs and a channel that sends errors.

func (*Course) Folder

func (c *Course) Folder(id int, opts ...Option) (*Folder, error)

Folder will the a folder from the course given a folder id.

func (*Course) Folders

func (c *Course) Folders(opts ...Option) <-chan *Folder

Folders will retrieve the course's folders.

func (*Course) FoldersErrChan

func (c *Course) FoldersErrChan() (<-chan *Folder, <-chan error)

FoldersErrChan will return a channel for receiving folders and one for errors.

func (*Course) ListFiles

func (c *Course) ListFiles(opts ...Option) ([]*File, error)

ListFiles returns a slice of files for the course.

func (*Course) ListFolders

func (c *Course) ListFolders(opts ...Option) ([]*Folder, error)

ListFolders returns a slice of folders for the course.

func (*Course) Quiz

func (c *Course) Quiz(id int, opts ...Option) (*Quiz, error)

Quiz will return a quiz given a quiz id.

func (*Course) Quizzes

func (c *Course) Quizzes(opts ...Option) ([]*Quiz, error)

Quizzes will get all the course quizzes

func (*Course) SearchUsers

func (c *Course) SearchUsers(term string, opts ...Option) (users []User, err error)

SearchUsers will search for a user in the course

func (*Course) SetErrorHandler

func (c *Course) SetErrorHandler(f func(error, chan int))

SetErrorHandler will set a error handling callback that is used to handle errors in goroutines. The default error handler will simply panic.

The callback should accept an error and a quit channel. If a value is sent on the quit channel, whatever secsion of code is receiving the channel will end gracefully.

func (*Course) Settings

func (c *Course) Settings(opts ...Option) (cs *CourseSettings, err error)

Settings gets the course settings

func (*Course) UpdateSettings

func (c *Course) UpdateSettings(settings *CourseSettings) (*CourseSettings, error)

UpdateSettings will update a user's settings based on a given settings struct and will return the updated settings struct.

func (*Course) User

func (c *Course) User(id int, opts ...Option) (*User, error)

User gets a specific user.

func (*Course) Users

func (c *Course) Users(opts ...Option) (users []User, err error)

Users will get a list of users in the course

type CourseProgress

type CourseProgress struct {
	RequirementCount          int    `json:"requirement_count"`
	RequirementCompletedCount int    `json:"requirement_completed_count"`
	NextRequirementURL        string `json:"next_requirement_url"`
	CompletedAt               string `json:"completed_at"`
}

CourseProgress is the progress through a course.

type CourseSettings

type CourseSettings struct {
	AllowStudentDiscussionTopics  bool `json:"allow_student_discussion_topics"`
	AllowStudentForumAttachments  bool `json:"allow_student_forum_attachments"`
	AllowStudentDiscussionEditing bool `json:"allow_student_discussion_editing"`
	GradingStandardEnabled        bool `json:"grading_standard_enabled"`
	GradingStandardID             int  `json:"grading_standard_id"`
	AllowStudentOrganizedGroups   bool `json:"allow_student_organized_groups"`
	HideFinalGrades               bool `json:"hide_final_grades"`
	HideDistributionGraphs        bool `json:"hide_distribution_graphs"`
	LockAllAnnouncements          bool `json:"lock_all_announcements"`
	UsageRightsRequired           bool `json:"usage_rights_required"`
}

CourseSettings is a json struct for a course's settings.

type DiscussionTopic

type DiscussionTopic struct {
	ID                      int         `json:"id"`
	Title                   string      `json:"title"`
	Message                 string      `json:"message"`
	HTMLURL                 string      `json:"html_url"`
	PostedAt                time.Time   `json:"posted_at"`
	LastReplyAt             time.Time   `json:"last_reply_at"`
	RequireInitialPost      bool        `json:"require_initial_post"`
	UserCanSeePosts         bool        `json:"user_can_see_posts"`
	DiscussionSubentryCount int         `json:"discussion_subentry_count"`
	ReadState               string      `json:"read_state"`
	UnreadCount             int         `json:"unread_count"`
	Subscribed              bool        `json:"subscribed"`
	SubscriptionHold        string      `json:"subscription_hold"`
	AssignmentID            interface{} `json:"assignment_id"`
	DelayedPostAt           interface{} `json:"delayed_post_at"`
	Published               bool        `json:"published"`
	LockAt                  interface{} `json:"lock_at"`
	Locked                  bool        `json:"locked"`
	Pinned                  bool        `json:"pinned"`
	LockedForUser           bool        `json:"locked_for_user"`
	LockInfo                interface{} `json:"lock_info"`
	LockExplanation         string      `json:"lock_explanation"`
	UserName                string      `json:"user_name"`
	TopicChildren           []int       `json:"topic_children"`
	GroupTopicChildren      []struct {
		ID      int `json:"id"`
		GroupID int `json:"group_id"`
	} `json:"group_topic_children"`
	RootTopicID     interface{} `json:"root_topic_id"`
	PodcastURL      string      `json:"podcast_url"`
	DiscussionType  string      `json:"discussion_type"`
	GroupCategoryID interface{} `json:"group_category_id"`
	Attachments     interface{} `json:"attachments"`
	Permissions     struct {
		Attach bool `json:"attach"`
	} `json:"permissions"`
	AllowRating        bool `json:"allow_rating"`
	OnlyGradersCanRate bool `json:"only_graders_can_rate"`
	SortByRating       bool `json:"sort_by_rating"`
}

DiscussionTopic is a discussion topic

func Announcements

func Announcements(contextCodes []string, opts ...Option) ([]DiscussionTopic, error)

Announcements will get the announcements

type Enrollment

type Enrollment struct {
	ID                             int         `json:"id"`
	CourseID                       int         `json:"course_id"`
	SisCourseID                    string      `json:"sis_course_id"`
	CourseIntegrationID            string      `json:"course_integration_id"`
	CourseSectionID                int         `json:"course_section_id"`
	SectionIntegrationID           string      `json:"section_integration_id"`
	SisAccountID                   string      `json:"sis_account_id"`
	SisSectionID                   string      `json:"sis_section_id"`
	SisUserID                      string      `json:"sis_user_id"`
	EnrollmentState                string      `json:"enrollment_state"`
	LimitPrivilegesToCourseSection bool        `json:"limit_privileges_to_course_section"`
	SisImportID                    int         `json:"sis_import_id"`
	RootAccountID                  int         `json:"root_account_id"`
	Type                           string      `json:"type"`
	UserID                         int         `json:"user_id"`
	AssociatedUserID               interface{} `json:"associated_user_id"`
	Role                           string      `json:"role"`
	RoleID                         int         `json:"role_id"`
	CreatedAt                      time.Time   `json:"created_at"`
	UpdatedAt                      time.Time   `json:"updated_at"`
	StartAt                        time.Time   `json:"start_at"`
	EndAt                          time.Time   `json:"end_at"`
	LastActivityAt                 time.Time   `json:"last_activity_at"`
	LastAttendedAt                 time.Time   `json:"last_attended_at"`
	TotalActivityTime              int         `json:"total_activity_time"`
	HTMLURL                        string      `json:"html_url"`
	Grades                         struct {
		HTMLURL              string  `json:"html_url"`
		CurrentScore         string  `json:"current_score"`
		CurrentGrade         string  `json:"current_grade"`
		FinalScore           float64 `json:"final_score"`
		FinalGrade           string  `json:"final_grade"`
		UnpostedCurrentGrade string  `json:"unposted_current_grade"`
		UnpostedFinalGrade   string  `json:"unposted_final_grade"`
		UnpostedCurrentScore string  `json:"unposted_current_score"`
		UnpostedFinalScore   string  `json:"unposted_final_score"`
	} `json:"grades"`
	User struct {
		ID           int    `json:"id"`
		Name         string `json:"name"`
		SortableName string `json:"sortable_name"`
		ShortName    string `json:"short_name"`
	} `json:"user"`
	OverrideGrade                     string  `json:"override_grade"`
	OverrideScore                     float64 `json:"override_score"`
	UnpostedCurrentGrade              string  `json:"unposted_current_grade"`
	UnpostedFinalGrade                string  `json:"unposted_final_grade"`
	UnpostedCurrentScore              string  `json:"unposted_current_score"`
	UnpostedFinalScore                string  `json:"unposted_final_score"`
	HasGradingPeriods                 bool    `json:"has_grading_periods"`
	TotalsForAllGradingPeriodsOption  bool    `json:"totals_for_all_grading_periods_option"`
	CurrentGradingPeriodTitle         string  `json:"current_grading_period_title"`
	CurrentGradingPeriodID            int     `json:"current_grading_period_id"`
	CurrentPeriodOverrideGrade        string  `json:"current_period_override_grade"`
	CurrentPeriodOverrideScore        float64 `json:"current_period_override_score"`
	CurrentPeriodUnpostedCurrentScore float64 `json:"current_period_unposted_current_score"`
	CurrentPeriodUnpostedFinalScore   float64 `json:"current_period_unposted_final_score"`
	CurrentPeriodUnpostedCurrentGrade string  `json:"current_period_unposted_current_grade"`
	CurrentPeriodUnpostedFinalGrade   string  `json:"current_period_unposted_final_grade"`
}

Enrollment is an enrollment object

type Error

type Error struct {
	Errors struct {
		EndDate string `json:"end_date"`
	} `json:"errors"`
	Message string `json:"message"`
}

Error is an error response.

func (*Error) Error

func (e *Error) Error() string

type File

type File struct {
	ID       int    `json:"id"`
	FolderID int    `json:"folder_id"`
	URL      string `json:"url"`
	UUID     string `json:"uuid"`

	Filename    string `json:"filename"`
	DisplayName string `json:"display_name"`

	ContentType string    `json:"content-type"`
	Size        int       `json:"size"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	ModifiedAt  time.Time `json:"modified_at"`

	Locked   bool      `json:"locked"`
	UnlockAt time.Time `json:"unlock_at"`
	Hidden   bool      `json:"hidden"`
	LockAt   time.Time `json:"lock_at"`

	HiddenForUser   bool        `json:"hidden_for_user"`
	ThumbnailURL    string      `json:"thumbnail_url"`
	MimeClass       string      `json:"mime_class"`
	MediaEntryID    string      `json:"media_entry_id"`
	LockedForUser   bool        `json:"locked_for_user"`
	LockInfo        interface{} `json:"lock_info"`
	LockExplanation string      `json:"lock_explanation"`
	PreviewURL      string      `json:"preview_url"`
	// contains filtered or unexported fields
}

File is a file

func (*File) ParentFolder

func (f *File) ParentFolder() (*Folder, error)

ParentFolder will get the folder that the file is a part of.

type Folder

type Folder struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	FullName string `json:"full_name"`

	FilesURL   string `json:"files_url"`
	FoldersURL string `json:"folders_url"`

	ContextType string `json:"context_type"`
	ContextID   int    `json:"context_id"`

	Position     int `json:"position"`
	FilesCount   int `json:"files_count"`
	FoldersCount int `json:"folders_count"`

	UpdatedAt      time.Time   `json:"updated_at"`
	LockAt         time.Time   `json:"lock_at"`
	Locked         bool        `json:"locked"`
	ParentFolderID int         `json:"parent_folder_id"`
	CreatedAt      time.Time   `json:"created_at"`
	UnlockAt       interface{} `json:"unlock_at"`
	Hidden         bool        `json:"hidden"`
	HiddenForUser  bool        `json:"hidden_for_user"`
	LockedForUser  bool        `json:"locked_for_user"`
	ForSubmissions bool        `json:"for_submissions"`
	// contains filtered or unexported fields
}

Folder is a folder

func (*Folder) File

func (f *Folder) File(id int, opts ...Option) (*File, error)

File gets a file by id.

func (*Folder) Files

func (f *Folder) Files() <-chan *File

Files will return a channel that sends all of the files in the folder.

func (*Folder) Folders

func (f *Folder) Folders() <-chan *Folder

Folders will return a channel that sends all of the sub-folders.

func (*Folder) ParentFolder

func (f *Folder) ParentFolder() (*Folder, error)

ParentFolder will get the folder's parent folder.

type Option

type Option interface {
	Name() string
	Value() []string
}

Option is a key value pair used for api parameters. see Opt

func ArrayOpt

func ArrayOpt(key string, vals ...string) Option

ArrayOpt creates an option that will be sent as an array of options (ex. include[], content_type[], etc.)

func ContentType

func ContentType(contentTypes ...string) Option

ContentType retruns a option param for getting a content type.

func DateOpt

func DateOpt(key string, date time.Time) Option

DateOpt will return an Option with a correctly formatted date.

func IncludeOpt

func IncludeOpt(vals ...string) Option

IncludeOpt is the option for any "include[]" api parameters.

func Opt

func Opt(key string, val interface{}) Option

Opt creates a new option. Used for creating a new Param interface.

func SortOpt

func SortOpt(schemes ...string) Option

SortOpt returns a sorting option

func UserOpt

func UserOpt(key, val string) Option

UserOpt creates an Option that should be sent when asking for a user, updating a user, or creating a user.

type Quiz

type Quiz struct {
	ID       int       `json:"id"`
	Title    string    `json:"title"`
	DueAt    string    `json:"due_at"`
	LockAt   time.Time `json:"lock_at"`
	UnlockAt string    `json:"unlock_at"`

	HTMLURL                       string          `json:"html_url"`
	MobileURL                     string          `json:"mobile_url"`
	PreviewURL                    string          `json:"preview_url"`
	Description                   string          `json:"description"`
	QuizType                      string          `json:"quiz_type"`
	AssignmentGroupID             int             `json:"assignment_group_id"`
	TimeLimit                     int             `json:"time_limit"`
	ShuffleAnswers                bool            `json:"shuffle_answers"`
	HideResults                   string          `json:"hide_results"`
	ShowCorrectAnswers            bool            `json:"show_correct_answers"`
	ShowCorrectAnswersLastAttempt bool            `json:"show_correct_answers_last_attempt"`
	ShowCorrectAnswersAt          time.Time       `json:"show_correct_answers_at"`
	HideCorrectAnswersAt          time.Time       `json:"hide_correct_answers_at"`
	OneTimeResults                bool            `json:"one_time_results"`
	ScoringPolicy                 string          `json:"scoring_policy"`
	AllowedAttempts               int             `json:"allowed_attempts"`
	OneQuestionAtATime            bool            `json:"one_question_at_a_time"`
	QuestionCount                 int             `json:"question_count"`
	PointsPossible                int             `json:"points_possible"`
	CantGoBack                    bool            `json:"cant_go_back"`
	AccessCode                    string          `json:"access_code"`
	IPFilter                      string          `json:"ip_filter"`
	Published                     bool            `json:"published"`
	Unpublishable                 bool            `json:"unpublishable"`
	LockedForUser                 bool            `json:"locked_for_user"`
	LockInfo                      interface{}     `json:"lock_info"`
	LockExplanation               string          `json:"lock_explanation"`
	SpeedgraderURL                string          `json:"speedgrader_url"`
	QuizExtensionsURL             string          `json:"quiz_extensions_url"`
	Permissions                   QuizPermissions `json:"permissions"`
	AllDates                      []string        `json:"all_dates"`
	VersionNumber                 int             `json:"version_number"`
	QuestionTypes                 []string        `json:"question_types"`
	AnonymousSubmissions          bool            `json:"anonymous_submissions"`
}

Quiz is a quiz json response.

type QuizPermissions

type QuizPermissions struct {
	Read           bool `json:"read"`
	Submit         bool `json:"submit"`
	Create         bool `json:"create"`
	Manage         bool `json:"manage"`
	ReadStatistics bool `json:"read_statistics"`
	ReviewGrades   bool `json:"review_grades"`
	Update         bool `json:"update"`
}

QuizPermissions is the permissions for a quiz.

type Submission

type Submission struct {
	AssignmentID                  int         `json:"assignment_id"`
	Assignment                    interface{} `json:"assignment"`
	Course                        interface{} `json:"course"`
	Attempt                       int         `json:"attempt"`
	Body                          string      `json:"body"`
	Grade                         string      `json:"grade"`
	GradeMatchesCurrentSubmission bool        `json:"grade_matches_current_submission"`
	HTMLURL                       string      `json:"html_url"`
	PreviewURL                    string      `json:"preview_url"`
	Score                         float64     `json:"score"`
	SubmissionComments            interface{} `json:"submission_comments"`
	SubmissionType                string      `json:"submission_type"`
	SubmittedAt                   time.Time   `json:"submitted_at"`
	URL                           interface{} `json:"url"`
	UserID                        int         `json:"user_id"`
	GraderID                      int         `json:"grader_id"`
	GradedAt                      time.Time   `json:"graded_at"`
	User                          interface{} `json:"user"`
	Late                          bool        `json:"late"`
	AssignmentVisible             bool        `json:"assignment_visible"`
	Excused                       bool        `json:"excused"`
	Missing                       bool        `json:"missing"`
	LatePolicyStatus              string      `json:"late_policy_status"`
	PointsDeducted                float64     `json:"points_deducted"`
	SecondsLate                   int         `json:"seconds_late"`
	WorkflowState                 string      `json:"workflow_state"`
	ExtraAttempts                 int         `json:"extra_attempts"`
	AnonymousID                   string      `json:"anonymous_id"`
	PostedAt                      time.Time   `json:"posted_at"`
}

Submission is a submission type.

type Term

type Term struct {
	ID      int
	Name    string
	StartAt time.Time `json:"start_at"`
	EndAt   time.Time `json:"end_at"`
}

Term is a school term. One school year.

type User

type User struct {
	ID              int        `json:"id"`
	Name            string     `json:"name"`
	Email           string     `json:"email"`
	Bio             string     `json:"bio"`
	SortableName    string     `json:"sortable_name"`
	ShortName       string     `json:"short_name"`
	SisUserID       string     `json:"sis_user_id"`
	SisImportID     int        `json:"sis_import_id"`
	IntegrationID   string     `json:"integration_id"`
	CreatedAt       time.Time  `json:"created_at"`
	LoginID         string     `json:"login_id"`
	AvatarURL       string     `json:"avatar_url"`
	Enrollments     Enrollment `json:"enrollments"`
	Locale          string     `json:"locale"`
	EffectiveLocale string     `json:"effective_locale"`
	LastLogin       time.Time  `json:"last_login"`
	TimeZone        string     `json:"time_zone"`

	CanUpdateAvatar bool `json:"can_update_avatar"`
	Permissions     struct {
		CanUpdateName           bool `json:"can_update_name"`
		CanUpdateAvatar         bool `json:"can_update_avatar"`
		LimitParentAppWebAccess bool `json:"limit_parent_app_web_access"`
	} `json:"permissions"`
	// contains filtered or unexported fields
}

User is a canvas user

func CurrentUser

func CurrentUser(opts ...Option) (*User, error)

CurrentUser get the currently logged in user.

func GetUser

func GetUser(id int, opts ...Option) (*User, error)

GetUser will return a user object given that user's ID.

func (*User) Avatars

func (u *User) Avatars() (av []Avatar, err error)

Avatars will get a list of the user's avatars.

func (*User) Bookmarks

func (u *User) Bookmarks(opts ...Option) (bks []Bookmark, err error)

Bookmarks will get the user's bookmarks

func (*User) CalendarEvents

func (u *User) CalendarEvents(opts ...Option) (cal []CalendarEvent, err error)

CalendarEvents gets the user's calendar events.

func (*User) Color

func (u *User) Color(asset string) (color *UserColor, err error)

Color will get a specific color from the user's profile.

func (*User) Colors

func (u *User) Colors() (map[string]string, error)

Colors will return a map of the user's custom profile colors.

func (*User) Courses

func (u *User) Courses(opts ...Option) ([]*Course, error)

Courses will return the user's courses.

func (*User) CreateBookmark

func (u *User) CreateBookmark(b *Bookmark) error

CreateBookmark will create a bookmark

func (*User) DeleteBookmark

func (u *User) DeleteBookmark(b *Bookmark) error

DeleteBookmark will delete a user's bookmark.

func (*User) GradedSubmissions

func (u *User) GradedSubmissions() (subs []*Submission, err error)

GradedSubmissions gets the user's graded submissions.

func (*User) Profile

func (u *User) Profile() (p *UserProfile, err error)

Profile will make a call to get the user's profile data.

func (*User) SetColor

func (u *User) SetColor(asset, hexcode string) error

SetColor will update the color of the given asset to as specific hex color.

func (*User) Settings

func (u *User) Settings() (settings map[string]interface{}, err error)

Settings will get the user's settings.

type UserColor

type UserColor struct {
	HexCode string `json:"hexcode"`
}

UserColor is just a hex color.

type UserProfile

type UserProfile struct {
	ID             int               `json:"id"`
	LoginID        string            `json:"login_id"`
	Name           string            `json:"name"`
	PrimaryEmail   string            `json:"primary_email"`
	ShortName      string            `json:"short_name"`
	SortableName   string            `json:"sortable_name"`
	TimeZone       string            `json:"time_zone"`
	Bio            string            `json:"bio"`
	Title          string            `json:"title"`
	Calendar       map[string]string `json:"calendar"`
	LTIUserID      string            `json:"lti_user_id"`
	AvatarURL      string            `json:"avatar_url"`
	EffectiveLocal string            `json:"effective_local"`
	IntegrationID  string            `json:"integration_id"`
	Local          string            `json:"local"`
}

UserProfile is a user's profile data.

Jump to

Keyboard shortcuts

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