Documentation ¶
Index ¶
- Constants
- func FillEmptyDates(days *[]TimeTableDate, dateStart string, dateEnd string) error
- func GetDateFromDayOfYear(year int, dayOfYear int) time.Time
- func GetDateRange(date time.Time, range_ int) (time.Time, time.Time)
- func ParseISODate(date string) (time.Time, error)
- type Api
- type CallSchedule
- type CallScheduleEntry
- type Course
- type DefaultApi
- func (a DefaultApi) GetCallSchedule() (CallSchedule, error)
- func (a DefaultApi) GetCourses(facultyId int) ([]Course, error)
- func (a DefaultApi) GetFaculties(structureId int) ([]Faculty, error)
- func (a DefaultApi) GetGroupSchedule(groupId int, dateStart string, dateEnd string) (Schedule, error)
- func (a DefaultApi) GetGroupScheduleDay(groupId int, date string) (*TimeTableDate, error)
- func (a DefaultApi) GetGroupStudents(groupId int) ([]Student, error)
- func (a DefaultApi) GetGroups(facultyId int, course int) ([]Group, error)
- func (a DefaultApi) GetScheduleExtraInfo(classCode int, date string) (ScheduleExtraInfo, error)
- func (a DefaultApi) GetStructures() ([]Structure, error)
- type Faculty
- type ForbiddenError
- type Group
- type HTTPApiError
- type InternalServerError
- type Schedule
- type ScheduleExtraInfo
- type Structure
- type Student
- type TimeTableDate
- type TimeTableLesson
- type TimeTablePeriod
- type UnauthorizedError
- type ValidationError
- type ValidationErrorField
Constants ¶
const Location = "Europe/Kyiv"
Variables ¶
This section is empty.
Functions ¶
func FillEmptyDates ¶
func FillEmptyDates(days *[]TimeTableDate, dateStart string, dateEnd string) error
FillEmptyDates fills empty dates in given days slice
For example, we have schedule for 2023-08-21 and 2023-08-23. If there is no lessons for 2023-08-22, API will return schedule only for 2023-08-21 and 2023-08-23. This function will fill empty dates with empty lessons list.
func GetDateFromDayOfYear ¶
GetDateFromDayOfYear returns date from given year and day of year
func GetDateRange ¶
GetDateRange returns date range from given date and range
For example, we have date 2023-08-21 and range of 10 days. Let's convert it to day of year: 233. Then we will have 230 and 239 (240 not included) days of year of range. So, we will have date range from 2023-08-18 to 2023-08-27.
Types ¶
type Api ¶
type Api interface { // GetStructures returns a list of structures GetStructures() ([]Structure, error) // GetFaculties returns a list of faculties in a structure GetFaculties(structureId int) ([]Faculty, error) // GetCourses returns a list of courses in a faculty GetCourses(facultyId int) ([]Course, error) // GetGroups returns a list of groups in a faculty GetGroups(facultyId int, course int) ([]Group, error) // GetGroupStudents returns a list of students in a group GetGroupStudents(groupId int) ([]Student, error) // GetCallSchedule returns a call schedule GetCallSchedule() (CallSchedule, error) // GetGroupSchedule returns a schedule for a group // from dateStart to dateEnd (inclusive) GetGroupSchedule(groupId int, dateStart string, dateEnd string) (Schedule, error) // GetScheduleExtraInfo returns a extra info for a schedule, // that can be added by a teacher or university administration. // // classCode is a TimeTablePeriod.R1 field GetScheduleExtraInfo(classCode int, date string) (ScheduleExtraInfo, error) // GetGroupScheduleDay returns a schedule for a group for a day // // Alias for GetGroupSchedule(groupId, date, date).GetDay(date) GetGroupScheduleDay(groupId int, date string) (*TimeTableDate, error) }
Api is a wrapper for mkr.org.ua API requests. Documentation can be found here: https://mkr.org.ua
type CallSchedule ¶
type CallSchedule []CallScheduleEntry
func (*CallSchedule) GetCall ¶
func (s *CallSchedule) GetCall(number int) *CallScheduleEntry
type CallScheduleEntry ¶
type DefaultApi ¶
func (DefaultApi) GetCallSchedule ¶
func (a DefaultApi) GetCallSchedule() (CallSchedule, error)
func (DefaultApi) GetCourses ¶
func (a DefaultApi) GetCourses(facultyId int) ([]Course, error)
func (DefaultApi) GetFaculties ¶
func (a DefaultApi) GetFaculties(structureId int) ([]Faculty, error)
func (DefaultApi) GetGroupSchedule ¶
func (DefaultApi) GetGroupScheduleDay ¶
func (a DefaultApi) GetGroupScheduleDay(groupId int, date string) (*TimeTableDate, error)
func (DefaultApi) GetGroupStudents ¶
func (a DefaultApi) GetGroupStudents(groupId int) ([]Student, error)
func (DefaultApi) GetGroups ¶
func (a DefaultApi) GetGroups(facultyId int, course int) ([]Group, error)
func (DefaultApi) GetScheduleExtraInfo ¶
func (a DefaultApi) GetScheduleExtraInfo(classCode int, date string) (ScheduleExtraInfo, error)
func (DefaultApi) GetStructures ¶
func (a DefaultApi) GetStructures() ([]Structure, error)
type ForbiddenError ¶
type ForbiddenError struct { Name string `json:"name"` Message string `json:"message"` Code int `json:"code"` Status int `json:"status"` }
ForbiddenError is an error returned by the API when status code is 403
func (*ForbiddenError) Error ¶
func (e *ForbiddenError) Error() string
type HTTPApiError ¶
HTTPApiError is an error returned by the API when status code is not 200
func (*HTTPApiError) Error ¶
func (e *HTTPApiError) Error() string
type InternalServerError ¶
type InternalServerError struct { Name string `json:"name"` Message string `json:"message"` Code int `json:"code"` Status int `json:"status"` }
InternalServerError is an error returned by the API when status code is 500
func (*InternalServerError) Error ¶
func (e *InternalServerError) Error() string
type Schedule ¶
type Schedule []TimeTableDate
func (*Schedule) GetDay ¶
func (s *Schedule) GetDay(date string) *TimeTableDate
type ScheduleExtraInfo ¶
type ScheduleExtraInfo struct {
Html string `json:"html"`
}
type Student ¶
type Student struct { Id int `json:"id"` FirstName string `json:"firstName"` SecondName string `json:"secondName"` LastName string `json:"lastName"` }
func (*Student) GetFullName ¶
type TimeTableDate ¶
type TimeTableDate struct { Date string `json:"date"` Lessons []TimeTableLesson `json:"lessons"` }
func (*TimeTableDate) GetLesson ¶
func (day *TimeTableDate) GetLesson(number int) *TimeTableLesson
GetLesson returns a lesson with a specific number from a day.
type TimeTableLesson ¶
type TimeTableLesson struct { Number int `json:"number"` Periods []TimeTablePeriod `json:"periods"` }
type TimeTablePeriod ¶
type TimeTablePeriod struct { R1 int `json:"r1"` Rz14 int `json:"rz14"` Rz15 int `json:"rz15"` R5 int `json:"r5"` DisciplineId int `json:"disciplineId"` // Disabled because it can sometimes be bool instead of int, // which causes errors. University's fault. //EducationDisciplineId int `json:"educationDisciplineId"` DisciplineFullName string `json:"disciplineFullName"` DisciplineShortName string `json:"disciplineShortName"` Classroom string `json:"classroom"` TimeStart string `json:"timeStart"` TimeEnd string `json:"timeEnd"` TeachersName string `json:"teachersName"` TeachersNameFull string `json:"teachersNameFull"` Type int `json:"type"` TypeStr string `json:"typeStr"` DateUpdated string `json:"dateUpdated"` NonstandardTime bool `json:"nonstandardTime"` Groups string `json:"groups"` ChairName string `json:"chairName"` ExtraText bool `json:"extraText"` LessonYear int `json:"lessonYear"` Semester int `json:"semester"` }
type UnauthorizedError ¶
type UnauthorizedError struct {}
UnauthorizedError is an error returned by the API when status code is 401
func (*UnauthorizedError) Error ¶
func (e *UnauthorizedError) Error() string
type ValidationError ¶
type ValidationError struct {
Fields []ValidationErrorField `json:"fields"`
}
ValidationError is an error returned by the API when status code is 422. It means that the request body is invalid
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
type ValidationErrorField ¶
ValidationErrorField is a field of ValidationError