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.
Index ¶
Constants ¶
const ( GET_FOLDERS = 0 GET_ALL_FILES = 1 DOWNLOAD_FILE = 2 GET_FILES = 3 )
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 MODULE_URL_ENDPOINT = "https://luminus.nus.edu.sg/v2/api/module/?populate=Creator,termDetail,isMandatory"
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 ¶
This section is empty.
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 DocumentRequest mode is DOWNLOAD_FILE (2). Find out more about DocumentRequests under request.go.
func (DocumentRequest) GetAllFiles ¶
func (req DocumentRequest) GetAllFiles() ([]File, error)
Deprecated - build DocumentRequest with a Folder instead of a module instead, and call getRootFiles() directly. GetAllFiles returns a slice of File objects that are in a Folder using a DocumentRequest. Ensure 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. Ensure DocumentRequest mode is GET_FOLDERS (0). 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 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 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 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.