api

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2022 License: MIT Imports: 13 Imported by: 0

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

View Source
const (
	GET_FOLDERS   = 0
	GET_ALL_FILES = 1
	DOWNLOAD_FILE = 2
	GET_FILES     = 3
)
View Source
const DOWNLOAD_URL_ENDPOINT = "https://luminus.nus.edu.sg/v2/api/files/file/%s/downloadurl"
View Source
const FILE_URL_ENDPOINT = "https://luminus.nus.edu.sg/v2/api/files/%s/file?populate=Creator,lastUpdatedUser,comment"
View Source
const FOLDER_URL_ENDPOINT = "https://luminus.nus.edu.sg/v2/api/files/?populate=totalFileCount,subFolderCount,TotalSize&ParentID=%s"
View Source
const GRADE_URL_ENDPOINT = "https://luminus.nus.edu.sg/v2/api/gradebook/?populate=scores&ParentID=%s"
View Source
const MODULE_URL_ENDPOINT = "https://luminus.nus.edu.sg/v2/api/module/?populate=Creator,termDetail,isMandatory"
View Source
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

type DocumentRequest struct {
	File    File
	Folder  Folder
	Module  Module
	Request Request
	Mode    int
}

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

type File struct {
	Id          string
	Name        string
	Ancestors   []string
	LastUpdated time.Time
}

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

type Folder struct {
	Id           string
	Name         string
	Downloadable bool
	HasSubFolder bool
	Ancestors    []string
}

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 {
	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

type GradeRequest struct {
	Module  Module
	Request Request
}

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

type Request struct {
	Url       string
	JwtToken  string
	UserAgent string
}

Request struct is the datapack for containing details about a HTTP request.

func (Request) GetRawResponse

func (req Request) GetRawResponse(res interface{}) error

GetRawResponse sends the HTTP request and marshals it into the pointer provided. Argument provided must be a pointer.

Jump to

Keyboard shortcuts

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