unibo

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Client = http.Client{
	Transport: &transport{
		http.DefaultTransport,
	},
}

Client is the http client used to make requests. It is used to set a custom User-Agent.

Functions

func GetCurriculaUrl

func GetCurriculaUrl(course CourseId, year int) string

func GetPackageUrl

func GetPackageUrl(id string) string

func GetTimetableUrl

func GetTimetableUrl(course CourseId, curriculum Curriculum, year int, period *TimetablePeriod) string

GetTimetableUrl returns the URL to fetch the timetable for the given course.

If `curriculum` is not empty, it will be used to filter the timetable. If `period` is not nil, it will be used to filter the timetable.

Types

type Aula

type Aula struct {
	DesRisorsa string `json:"des_risorsa"`
}

type CalendarTime

type CalendarTime struct {
	time.Time
}

func (*CalendarTime) MarshalJSON

func (c *CalendarTime) MarshalJSON() ([]byte, error)

func (*CalendarTime) UnmarshalJSON

func (c *CalendarTime) UnmarshalJSON(b []byte) error

type Course

type Course struct {
	AnnoAccademico       string
	Immatricolabile      string
	Codice               int
	Descrizione          string
	Url                  string
	Campus               string
	Ambiti               string
	Tipologia            string
	DurataAnni           int
	Internazionale       bool
	InternazionaleTitolo string
	InternazionaleLingua string
	Lingue               string
	Accesso              string
	SedeDidattica        string
}

func (Course) GetAllCurricula

func (c Course) GetAllCurricula() (map[int]Curricula, error)

func (Course) GetCourseWebsiteId

func (c Course) GetCourseWebsiteId() (CourseId, error)

GetCourseWebsiteId returns the [CourseWebsiteId] of the course.

If the course website id is already set, it returns it, otherwise it scrapes it from the course website.

func (Course) GetCurricula

func (c Course) GetCurricula(year int) (Curricula, error)

func (Course) GetTimetable

func (c Course) GetTimetable(year int, curriculum Curriculum, period *TimetablePeriod) (Timetable, error)

type CourseId added in v0.1.2

type CourseId struct {
	Tipologia string
	Id        string
}

type Courses

type Courses []Course

func (Courses) Len

func (c Courses) Len() int

func (Courses) Less

func (c Courses) Less(i, j int) bool

func (Courses) Swap

func (c Courses) Swap(i, j int)

type CoursesMap

type CoursesMap map[int]Course

func (CoursesMap) FindById

func (c CoursesMap) FindById(id int) (*Course, bool)

func (CoursesMap) ToList

func (c CoursesMap) ToList() Courses

type Curricula

type Curricula []Curriculum

func FetchCurricula

func FetchCurricula(course CourseId, year int) (curricula Curricula, err error)

type Curriculum

type Curriculum struct {
	Selected bool   `json:"selected"`
	Value    string `json:"value"`
	Label    string `json:"label"`
}

type Package

type Package struct {
	Success bool `json:"success"`
	Result  struct {
		Resources Resources
	}
}

func GetPackage

func GetPackage(id string) (*Package, error)

type Resource

type Resource struct {
	Frequency string `json:"frequency"`
	Url       string `json:"url"`
	Id        string `json:"id"`
	PackageId string `json:"package_id"`
	LastMod   string `json:"last_modified"`
	Alias     string `json:"alias"`
}

func (Resource) Download

func (r Resource) Download() ([]Course, error)

type Resources

type Resources []Resource

func (Resources) GetByAlias

func (r Resources) GetByAlias(alias string) *Resource

type Timetable

type Timetable []TimetableEvent

func FetchTimetable

func FetchTimetable(
	course CourseId,
	curriculum Curriculum,
	year int,
	period *TimetablePeriod,
) (timetable Timetable, err error)

type TimetableEvent

type TimetableEvent struct {
	CodModulo         string       `json:"cod_modulo"`
	PeriodoCalendario string       `json:"periodo_calendario"`
	CodSdoppiamento   string       `json:"cod_sdoppiamento"`
	Title             string       `json:"title"`
	ExtCode           string       `json:"extCode"`
	Periodo           string       `json:"periodo"`
	Docente           string       `json:"docente"`
	Cfu               int          `json:"cfu"`
	Teledidattica     bool         `json:"teledidattica"`
	Teams             string       `json:"teams,omitempty"`
	Start             CalendarTime `json:"start"`
	End               CalendarTime `json:"end"`
	Aule              []Aula       `json:"aule"`
}

type TimetablePeriod added in v0.1.2

type TimetablePeriod struct {
	Start time.Time
	End   time.Time
}

Jump to

Keyboard shortcuts

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