cachedapi

package
v1.6.1-0...-e0dc824 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiConfig

type ApiConfig struct {
	// LevelDBPath is a path to leveldb cache directory. Default is "api-cache/leveldb"
	LevelDBPath string
	// SQLiteDbPath is a path to sqlite3 cache file. Default is "api-cache/api.sqlite"
	SQLiteDbPath string
	// Expires is a cache expiration time. Default is 1 hour
	Expires time.Duration
	// Timeout is a request timeout. Default is 10 seconds
	Timeout time.Duration
}

type CachedApi

type CachedApi struct {
	Url     string
	Expires time.Duration
	Timeout time.Duration
	// contains filtered or unexported fields
}

func New

func New(url string, config *ApiConfig) (*CachedApi, error)

New creates a new CachedApi instance

func (*CachedApi) Close

func (api *CachedApi) Close() error

func (*CachedApi) GetCallSchedule

func (api *CachedApi) GetCallSchedule() (api2.CallSchedule, error)

GetCallSchedule returns a call schedule

func (*CachedApi) GetCourses

func (api *CachedApi) GetCourses(facultyId int) ([]api2.Course, error)

GetCourses returns a list of courses in a faculty

func (*CachedApi) GetFaculties

func (api *CachedApi) GetFaculties(structureId int) ([]api2.Faculty, error)

GetFaculties returns a list of faculties in a structure

func (*CachedApi) GetGroupSchedule

func (api *CachedApi) GetGroupSchedule(groupId int, dateStart string, dateEnd string) (api2.Schedule, error)

GetGroupSchedule returns a schedule for a group from dateStart to dateEnd (inclusive)

func (*CachedApi) GetGroupScheduleDay

func (api *CachedApi) GetGroupScheduleDay(groupId int, date string) (*api2.TimeTableDate, error)

GetGroupScheduleDay returns a schedule for a group for a day

Alias for GetGroupSchedule(groupId, date, date).GetDay(date)

func (*CachedApi) GetGroupStudents

func (api *CachedApi) GetGroupStudents(groupId int) ([]api2.Student, error)

GetGroupStudents returns a list of students in a group

func (*CachedApi) GetGroups

func (api *CachedApi) GetGroups(facultyId int, course int) ([]api2.Group, error)

GetGroups returns a list of groups in a faculty

func (*CachedApi) GetScheduleExtraInfo

func (api *CachedApi) GetScheduleExtraInfo(classCode int, date string) (api2.ScheduleExtraInfo, error)

GetScheduleExtraInfo returns a extra info for a schedule, that can be added by a teacher or university administration.

classCode is a "R1" field from TimeTablePeriod

func (*CachedApi) GetStructures

func (api *CachedApi) GetStructures() ([]api2.Structure, error)

GetStructures returns a list of structures

type CachedDate

type CachedDate struct {
	GroupId int    `db:"group_id"`
	Date    string `db:"date"`
	Lessons string `db:"lessons"`
	Updated int64  `db:"updated"`
}

CachedDate is a cached schedule date

Jump to

Keyboard shortcuts

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