api

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2022 License: MIT Imports: 15 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.

Package api provides functions that link up and communicate with Luminus servers.

Index

Constants

View Source
const (
	GET_ALL_FOLDERS = 0
	GET_ALL_FILES   = 1
	DOWNLOAD_FILE   = 2
)
View Source
const CONTENT_TYPE_FORM = "application/x-www-form-urlencoded"
View Source
const CONTENT_TYPE_JSON = "application/json; charset=UTF-8"
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 LTI_DATA_URL_ENDPOINT = "" /* 131-byte string literal not displayed */
View Source
const MODULE_URL_ENDPOINT = "https://luminus.nus.edu.sg/v2/api/module/?populate=Creator,termDetail,isMandatory"
View Source
const MULTIMEMDIA_CHANNEL_URL_ENDPOINT = "https://luminus.nus.edu.sg/v2/api/multimedia/?populate=contentSummary&ParentID=%s"
View Source
const PANAPTO_ASPAUTH_KEY = ".ASPXAUTH"
View Source
const PANAPTO_AUTH_URL_ENDPOINT = "https://mediaweb.ap.panopto.com/Panopto/LTI/LTI.aspx"
View Source
const PANAPTO_CSRF_KEY = "csrfToken"
View Source
const PANAPTO_VIDEOS_URL_ENDPOINT = "https://mediaweb.ap.panopto.com/Panopto/Services/Data.svc/GetSessions"
View Source
const PANAPTO_VIDEO_DELIVERY_URL_ENDPOINT = "https://mediaweb.ap.panopto.com/Panopto/Pages/Viewer/DeliveryInfo.aspx"
View Source
const POST = "POST"
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

func IsResponseValid added in v1.2.0

func IsResponseValid(fieldsRequired []string, response map[string]interface{}) bool

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

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

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

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

type MultimediaChannel struct {
	Id          string
	Name        string
	MediaCount  int
	LastUpdated int64
}

MultimediaChannel struct is the datapack for containing details about every multimedia channel in a module.

type MultimediaChannelRequest added in v1.2.0

type MultimediaChannelRequest struct {
	Module  Module
	Request Request
}

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 PanaptoVideoResponse struct {
	Results []map[string]interface{} `json:"Results"`
	Total   int                      `json:"TotalNumber"`
}

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