Documentation
¶
Overview ¶
Package api provides functions that link up and communicate with Luminus servers.
Package api provides functions that link up and communicate with Luminus servers.
Package api provides functions that link up and communicate with Luminus servers.
Package api provides functions that link up and communicate with Luminus servers.
Package api provides functions that link up and communicate with Luminus servers.
Package api provides functions that link up and communicate with Luminus servers.
Index ¶
- Constants
- func IsResponseValid(fieldsRequired []string, response map[string]interface{}) bool
- type DocumentRequest
- type DownloadResponse
- type File
- type Folder
- type Grade
- type GradeRequest
- type LTIDataResponse
- type Module
- type ModuleRequest
- type MultimediaChannel
- type MultimediaChannelRequest
- type MultimediaVideo
- type MultimediaVideoRequest
- type PanaptoVideoRawResponse
- type PanaptoVideoResponse
- type RawResponse
- type Request
Constants ¶
const ( GET_ALL_FOLDERS = 0 GET_ALL_FILES = 1 DOWNLOAD_FILE = 2 )
const CONTENT_TYPE_FORM = "application/x-www-form-urlencoded"
const CONTENT_TYPE_JSON = "application/json; charset=UTF-8"
const DOWNLOAD_URL_ENDPOINT = "https://luminus.nus.edu.sg/v2/api/files/file/%s/downloadurl"
const FILE_URL_ENDPOINT = "https://luminus.nus.edu.sg/v2/api/files/%s/file?populate=Creator,lastUpdatedUser,comment"
const FOLDER_URL_ENDPOINT = "https://luminus.nus.edu.sg/v2/api/files/?populate=totalFileCount,subFolderCount,TotalSize&ParentID=%s"
const GRADE_URL_ENDPOINT = "https://luminus.nus.edu.sg/v2/api/gradebook/?populate=scores&ParentID=%s"
const LTI_DATA_URL_ENDPOINT = "" /* 131-byte string literal not displayed */
const MODULE_URL_ENDPOINT = "https://luminus.nus.edu.sg/v2/api/module/?populate=Creator,termDetail,isMandatory"
const MULTIMEMDIA_CHANNEL_URL_ENDPOINT = "https://luminus.nus.edu.sg/v2/api/multimedia/?populate=contentSummary&ParentID=%s"
const PANAPTO_ASPAUTH_KEY = ".ASPXAUTH"
const PANAPTO_AUTH_URL_ENDPOINT = "https://mediaweb.ap.panopto.com/Panopto/LTI/LTI.aspx"
const PANAPTO_CSRF_KEY = "csrfToken"
const PANAPTO_VIDEOS_URL_ENDPOINT = "https://mediaweb.ap.panopto.com/Panopto/Services/Data.svc/GetSessions"
const PANAPTO_VIDEO_DELIVERY_URL_ENDPOINT = "https://mediaweb.ap.panopto.com/Panopto/Pages/Viewer/DeliveryInfo.aspx"
const POST = "POST"
const USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0"
Variables ¶
This section is empty.
Functions ¶
func IsResponseValid ¶ added in v1.2.0
isResponseValid is a helper function that checks if a Folder/File response is valid. It checks if the response contains the required fields required.
Types ¶
type DocumentRequest ¶
DocumentRequest struct is the datapack for containing details about a specific HTTP request used for documents (Luminus Files).
func BuildDocumentRequest ¶
func BuildDocumentRequest(builder interface{}, mode int) (DocumentRequest, error)
BuildDocumentRequest builds and returns a DocumentRequest that can be used for File/Folder related operations such as retrieving files/folders of a module. DocumentRequests must be built using Module/Folder/File only. Building it with Folder enables you to specify the specific folder you are interested in. Building it with Module taks you to the root folder of the module files. Building it with File enables you to download the file.
Modes available: GET_FOLDERS - retrieves folders in a specific folder (root folder if Module was used to build the DocumentRequest). Nested folders are not returned. GET_ALL_FILES - retrieves all files in a specific folder (root folder if Module was used to build the DocumentRequest). Nested files are returned. DOWNLOAD_FILE - downloads a particular file. DocumentRequest must be built with File.
func (DocumentRequest) Download ¶
func (req DocumentRequest) Download(filePath string) error
Download downloads the specified File in a DocumentRequest into local storage. Ensure that DocumentRequest mode is DOWNLOAD_FILE (2). Find out more about DocumentRequests under request.go.
func (DocumentRequest) GetAllFiles ¶
func (req DocumentRequest) GetAllFiles() ([]File, error)
GetAllFiles returns a slice of File objects that are in a Folder from a DocumentRequest. It will only return files in the current folder. To return nested files, use GetRootFiles() instead. Ensure that DocumentRequest mode is GET_ALL_FILES (1). Find out more about DocumentRequests under request.go.
func (DocumentRequest) GetAllFolders ¶
func (req DocumentRequest) GetAllFolders() ([]Folder, error)
GetAllFolders returns a slice of Folder objects from a DocumentRequest. It will only return folders in the current folder. Nested folders will not be returned. Ensure that DocumentRequest mode is GET_ALL_FOLDERS (0). Find out more about DocumentRequests under request.go.
func (DocumentRequest) GetRootFiles ¶ added in v1.1.4
func (req DocumentRequest) GetRootFiles() ([]File, error)
GetRootFiles returns a slice of File objects and nested File objects that are in a Folder from a DocumentRequest. It will traverse all nested folders and return all nested files. Ensure that DocumentRequest mode is GET_ALL_FILES (1). Find out more about DocumentRequests under request.go.
type DownloadResponse ¶
type DownloadResponse struct { Code int `json:"code"` Status string `json:"status"` DownloadUrl string `json:"data"` }
DownloadResponse struct is the datapack for containing API download response raw data.
type File ¶
File struct is the datapack for containing details about a File Ancestors the relative folders that precedes the current folder, including itself. Eg. Ancestors for a file with the path: /folder1/folder2/file.pdf is ['folder1', 'folder2', 'file.pdf']
type Folder ¶
Folder struct is the datapack for containing details about a Folder Ancestors the relative folders that precedes the current folder, including itself. Eg. Ancestors for a folder with the path: /folder1/folder2/folder3 is ['folder1', 'folder2', 'folder3']
type Grade ¶
type Grade struct { Module Module Name string Marks float64 MaxMarks float64 Comments string LastUpdated int64 }
Grade struct is the datapack for containing details about every Grade in a module.
type GradeRequest ¶
GradeRequest struct is the datapack for containing details about a specific HTTP request used for grades (Luminus Gradebook).
func BuildGradeRequest ¶
func BuildGradeRequest(module Module) (GradeRequest, error)
BuildGradeRequest builds and returns a GradeRequest that can be used for Grade related operations such as retrieving grades of a module. A Module is required to build a GradeRequest as it is module specific.
func (GradeRequest) GetGrades ¶
func (req GradeRequest) GetGrades() ([]Grade, error)
GetGrades retrieves all grades for a particular module represented by moduleCode specified in GradeRequest. Find out more about GradeRequests under request.go.
type LTIDataResponse ¶ added in v1.2.0
type LTIDataResponse struct { DataItems []map[string]interface{} `json:"dataItems"` Html string `json:"html"` LaunchURL string `json:"launchURL"` }
LTIDataResponse struct is the datapack for containing API response Panapto LTI data.
type Module ¶
type Module struct { Id string Name string ModuleCode string CreatorName string CreatorEmail string Period string }
Module struct is the datapack for containing details about every module
type ModuleRequest ¶
type ModuleRequest struct {
Request Request
}
ModuleRequest struct is the datapack for containing details about a specific HTTP request used for modules being taken.
func BuildModuleRequest ¶
func BuildModuleRequest() (ModuleRequest, error)
BuildModuleRequest builds and returns a ModuleRequest that can be used for Module related operations such as retrieving all modules.
func (ModuleRequest) GetModules ¶
func (req ModuleRequest) GetModules() ([]Module, error)
GetModules retrieves all modules that are taken by the user using a ModuleRequest. Find out more about ModuleRequests under request.go.
type MultimediaChannel ¶ added in v1.2.0
MultimediaChannel struct is the datapack for containing details about every multimedia channel in a module.
type MultimediaChannelRequest ¶ added in v1.2.0
MultimediaChannelRequest struct is the datapack for containing details about a specific HTTP request used for multimedia channels (Luminus Multimedia).
func BuildMultimediaChannelRequest ¶ added in v1.2.0
func BuildMultimediaChannelRequest(module Module) (MultimediaChannelRequest, error)
BuildMultimediaChannelRequest builds and returns a MultimediaChannelRequuest that can be used for Multimedia channel related operations such as retrieving all channels of a module. A Module is required to build a BuildMultimediaChannelRequest as it is module specific.
func (MultimediaChannelRequest) GetMultimediaChannels ¶ added in v1.2.0
func (req MultimediaChannelRequest) GetMultimediaChannels() ([]MultimediaChannel, error)
type MultimediaVideo ¶ added in v1.2.0
type MultimediaVideo struct { Id string Name string FolderId string // Also known as Channel Id FolderName string // Also known as Channel Name M3u8Url string }
MultimediaVideo struct is the datapack for containing details about every multimedia video in a module.
type MultimediaVideoRequest ¶ added in v1.2.0
type MultimediaVideoRequest struct { MultimediaChannel MultimediaChannel Request Request }
MultimediaVideoRequest struct is the datapack for containing details about a specific HTTP request used for multimedia video (Luminus Multimedia).
func BuildMultimediaVideoRequest ¶ added in v1.2.0
func BuildMultimediaVideoRequest(multimediaChannel MultimediaChannel) (MultimediaVideoRequest, error)
BuildMultimediaChannelRequest builds and returns a MultimediaChannelRequuest that can be used for Multimedia channel related operations such as retrieving all channels of a module. A Module is required to build a BuildMultimediaChannelRequest as it is module specific.
func (MultimediaVideoRequest) GetMultimediaVideos ¶ added in v1.2.0
func (req MultimediaVideoRequest) GetMultimediaVideos() ([]MultimediaVideo, error)
type PanaptoVideoRawResponse ¶ added in v1.2.0
type PanaptoVideoRawResponse struct {
D PanaptoVideoResponse `json:"d"`
}
type PanaptoVideoResponse ¶ added in v1.2.0
type RawResponse ¶
type RawResponse struct { Status string `json:"status"` Code int `json:"code"` Total int `json:"total"` Offset int `json:"offset"` Data []map[string]interface{} `json:"data"` }
RawResponse struct is the datapack for containing API response raw data.
type Request ¶
Request struct is the datapack for containing details about a HTTP request.
func (Request) GetRawResponse ¶
GetRawResponse sends the HTTP request and marshals it into the pointer provided. Argument provided must be a pointer.