Documentation
¶
Index ¶
- Constants
- Variables
- func ExtractSubjectsFromTimetable(timetable *TimetableResponse) (map[string]*Subject, error)
- type AbsencesResponse
- type AllDayEvent
- type Classroom
- type CommunicationMetadata
- type Department
- type EAsistentJWTClaims
- type EAsistentNotification
- type Event
- type GradeMetadata
- type GradesResponse
- type Grading
- type GradingResponse
- type Group
- type Location
- type LoginRequest
- type LoginResponse
- type Meal
- type MealsResponse
- type Menu
- type MenuMeal
- type MenusResponse
- type MobileClassHour
- type MobileEvent
- type MobileNotificationsResponse
- type MobileTimetableResponse
- type Notification
- type NotificationsResponse
- type OrderCreateRequest
- type RefreshSessionRequest
- type RefreshSessionResponse
- type Session
- type Subject
- type SubjectGradesResponse
- type SubstitutionMetadata
- type Teacher
- type TimetableHour
- type TimetableResponse
- type TimetableSubject
- type UserInfo
- type WebLoginResponse
Constants ¶
View Source
const ( GradeNotification = iota SubstitutionNotification = iota CommunicationNotification = iota )
View Source
const ( PisnaOcena = iota UstnaOcena = iota DrugaOcena = iota )
View Source
const EASISTENT_URL = "https://www.easistent.com"
Variables ¶
View Source
var CaptchaRequired = errors.New("captcha required")
View Source
var ERROR_NO_CONTENT = errors.New("eAsistent responded with no content. This is likely due to no grades on this subject")
View Source
var MOBILE_HEADER = map[string]string{
"Content-Type": "application/json",
"X-App-Name": "child",
"X-Client-Version": "11102",
"X-Client-Platform": "android",
}
View Source
var WEB_HEADER = map[string]string{
"Content-Type": "application/json",
"X-Client-Version": "13",
"X-Client-Platform": "web",
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0",
}
Functions ¶
func ExtractSubjectsFromTimetable ¶
func ExtractSubjectsFromTimetable(timetable *TimetableResponse) (map[string]*Subject, error)
Types ¶
type AbsencesResponse ¶
type AbsencesResponse struct {
Summary struct {
PendingHours int `json:"pending_hours"`
ExcusedHours int `json:"excused_hours"`
UnexcusedHours int `json:"unexcused_hours"`
UnmanagedAbsences int `json:"unmanaged_absences"`
} `json:"summary"`
Items []struct {
Id int `json:"id"`
Date string `json:"date"`
MissingCount int `json:"missing_count"`
ExcusedCount int `json:"excused_count"`
NotExcusedCount int `json:"not_excused_count"`
State string `json:"state"`
Seen bool `json:"seen"`
ExcuseSent bool `json:"excuse_sent"`
ExcuseDescription *string `json:"excuse_description"`
ExcuseWrittenDate any `json:"excuse_written_date"`
Hours []struct {
ClassName string `json:"class_name"`
ClassShortName string `json:"class_short_name"`
Value string `json:"value"`
From string `json:"from"`
To string `json:"to"`
State string `json:"state"`
} `json:"hours"`
Attachments []any `json:"attachments"`
} `json:"items"`
}
type AllDayEvent ¶
type AllDayEvent struct {
ID int `json:"id"`
Date string `json:"date"`
Location Location `json:"location"`
// Teachers: TBD
Teachers []Teacher `json:"teachers"`
Name string `json:"name"`
// EventType je:
// 4 – prazniki/počitnice;
// 6 – celodnevne aktivnosti, ki jih določi šola;
// ostalo – ????
EventType int `json:"event_type"`
}
type CommunicationMetadata ¶
type Department ¶
type EAsistentJWTClaims ¶
type EAsistentJWTClaims struct {
jwt.MapClaims
ConsumerKey string `json:"consumerKey"`
UserId string `json:"userId"`
UserType string `json:"userType"`
SchoolId any `json:"schoolId"`
SessionId string `json:"sessionId"`
PasswordHash any `json:"password_hash"`
IssuedAt string `json:"issuedAt"`
AppName string `json:"appName"`
ExpiresAt string `json:"exp"`
}
type EAsistentNotification ¶
type GradeMetadata ¶
type GradesResponse ¶
type GradesResponse struct {
Items []struct {
Name string `json:"name"`
ShortName string `json:"short_name"`
ID int `json:"id"`
GradeType string `json:"grade_type"`
IsExcused bool `json:"is_excused"`
FinalGrade *struct {
Value string `json:"value"`
} `json:"final_grade"`
AverageGrade string `json:"average_grade"`
GradeRank string `json:"grade_rank"`
Semesters []struct {
ID int `json:"id"`
FinalGrade any `json:"final_grade"`
Grades []struct {
TypeName string `json:"type_name"`
Comment *string `json:"comment"`
ID int `json:"id"`
Type string `json:"type"`
OverridesIds any `json:"overrides_ids"`
Value string `json:"value"`
Color string `json:"color"`
Date string `json:"date"`
} `json:"grades"`
} `json:"semesters"`
} `json:"items"`
}
type GradingResponse ¶
type GradingResponse struct {
Items []struct {
ID int `json:"id"`
Course string `json:"course"`
Subject string `json:"subject"`
Type string `json:"type"`
Date string `json:"date"`
Period string `json:"period"`
Test bool `json:"test"` // Kaj zaboga naj bi ta vrednost pomenila/povedala? Še en duplicate za pisno oceno???
Grade string `json:"grade"`
TypeName string `json:"type_name"`
} `json:"items"`
}
type LoginRequest ¶
type LoginResponse ¶
type LoginResponse struct {
AccessToken struct {
Token string `json:"token"`
ExpirationDate string `json:"expiration_date"`
} `json:"access_token"`
RefreshToken string `json:"refresh_token"`
User struct {
ID int `json:"id"`
Language string `json:"language"`
Username string `json:"username"`
Name string `json:"name"`
Type string `json:"type"`
FreshPassword any `json:"freshPassword"`
} `json:"user"`
Redirect any `json:"redirect"`
}
type MealsResponse ¶
type MealsResponse struct {
Items []Meal `json:"items"`
}
type MenusResponse ¶
type MenusResponse struct {
Items []Menu `json:"items"`
}
type MobileClassHour ¶
type MobileEvent ¶
type MobileEvent struct {
Slug string `json:"slug"` // useless
// Type je lahko:
// - school_hour
// - event
Type string `json:"type"`
Date string `json:"date"`
From string `json:"from"` // ura (npr. 12.45)
To string `json:"to"` // ura (npr. 13.30)
Color string `json:"color"`
Title string `json:"title"`
TitleShort string `json:"title_short"`
Teachers []string `json:"teachers"`
// Subject je na voljo samo na Type == "school_hour"
Subject struct {
SubjectID int `json:"subject_id"`
TitleShort string `json:"title_short"`
Title string `json:"title"`
Color string `json:"color"`
} `json:"subject,omitempty"`
// Classroom je na voljo samo na Type == "school_hour"
Classroom string `json:"classroom,omitempty"`
// Lesson je na voljo samo na Type == "school_hour".
// Lesson je opis realizacije učne ure (kar se vpiše kot snov v dnevnik)
Lesson string `json:"lesson,omitempty"`
// ScheduleIndex pove, katere učne ure pokriva ta predmet
ScheduleIndex []int `json:"schedule_index"`
// Description je na voljo samo na Type == "event"
Description string `json:"description,omitempty"`
// TypeLabel je na voljo samo na Type == "event"
TypeLabel string `json:"type_label,omitempty"`
// TypeLabelShort je na voljo samo na Type == "event"
TypeLabelShort string `json:"type_label_short,omitempty"`
// IsImportant je na voljo samo na Type == "event" (še vedno ne vem, kakšni dogodki so nepomembni)
IsImportant bool `json:"is_important,omitempty"`
// TextColor je na voljo samo na Type == "event"
TextColor string `json:"text_color,omitempty"`
// BackgroundImage je na voljo samo na Type == "event"
BackgroundImage struct {
Daily string `json:"daily"`
Weekly string `json:"weekly"`
} `json:"background_image,omitempty"`
}
type MobileNotificationsResponse ¶
type MobileNotificationsResponse struct {
Items []EAsistentNotification `json:"items"`
}
type MobileTimetableResponse ¶
type MobileTimetableResponse struct {
Schedule []MobileClassHour `json:"schedule"`
Events []MobileEvent `json:"events"`
}
type Notification ¶
type Notification struct {
CreatedAt time.Time
Type int
GradeData struct {
GradeID int
SubjectID int
SubjectName string
Grade int
GradeType int
}
SubstitutionData SubstitutionMetadata
CommunicationData CommunicationMetadata
}
Notification je javen izhod iz funkcije GetNotifications
type NotificationsResponse ¶
type NotificationsResponse struct {
Status any `json:"status"`
Message any `json:"message"`
Errfields []any `json:"errfields"`
Data []EAsistentNotification `json:"data"`
}
type OrderCreateRequest ¶
type RefreshSessionRequest ¶
type RefreshSessionRequest struct {
RefreshToken string `json:"refresh_token"`
}
type RefreshSessionResponse ¶
type Session ¶
type Session interface {
RefreshSession() error
RefreshWebSession(string) error
GetGradings(past bool) ([]Grading, error)
GetTimetable(startDate time.Time, endDate time.Time) (TimetableResponse, error)
GetMobileTimetable(startDate time.Time, endDate time.Time) (MobileTimetableResponse, error)
GetNotifications() ([]Notification, error)
GetMobileNotifications() ([]Notification, error)
GetGrades() (GradesResponse, error)
GetGradesForSubject(subjectId int) (SubjectGradesResponse, error)
GetSessionData() *sessionImpl
GetMeals(from time.Time, to time.Time) (MealsResponse, error)
GetMenus(from time.Time, to time.Time) (MenusResponse, error)
CreateOrder(t string, date string, menu int) error
DeleteOrder(mealId int) error
GetAbsences() (AbsencesResponse, error)
GetUserInfo() (UserInfo, error)
SetRefreshToken(refreshToken string)
SetSessionToken(sessionToken string)
}
func SessionFromAuthToken ¶
type SubjectGradesResponse ¶
type SubjectGradesResponse struct {
Name string `json:"name"`
ShortName string `json:"short_name"`
ID int `json:"id"`
GradeType string `json:"grade_type"`
IsExcused bool `json:"is_excused"`
FinalGrade *struct {
ID int `json:"id"`
Value string `json:"value"`
Date string `json:"date"`
InsertedBy *struct {
ID int `json:"id"`
Name string `json:"name"`
} `json:"inserted_by"`
} `json:"final_grade"`
AverageGrade string `json:"average_grade"`
GradeRank string `json:"grade_rank"`
Semesters []struct {
ID int `json:"id"`
FinalGrade any `json:"final_grade"`
Grades []struct {
TypeName string `json:"type_name"`
Comment any `json:"comment"`
ID int `json:"id"`
OverridesIds any `json:"overrides_ids"`
Value string `json:"value"`
Subject any `json:"subject"`
Date string `json:"date"`
NotifiedAt any `json:"notified_at"`
InsertedAt string `json:"inserted_at"`
InsertedBy *struct {
ID int `json:"id"`
Name string `json:"name"`
} `json:"inserted_by"`
GradeRank string `json:"grade_rank"`
} `json:"grades"`
} `json:"semesters"`
}
type SubstitutionMetadata ¶
type TimetableHour ¶
type TimetableHour struct {
Time struct {
FromID int `json:"from_id"`
ToID int `json:"to_id"`
Date string `json:"date"`
} `json:"time"`
// Videokonferenca je useless
Videokonferenca struct {
ID any `json:"id"`
Link any `json:"link"`
Zacetek any `json:"zacetek"`
Opomba any `json:"opomba"`
} `json:"videokonferenca"`
EventID int `json:"event_id"`
Color string `json:"color"`
Subject TimetableSubject `json:"subject"`
Completed bool `json:"completed"`
// HourSpecialType je lahko
// - exam
// - substitution
// - pre-exam (preverjanje)
// - cancelled (odpadla)
// - prazen string (eAsistent pošlje null)
//
// Zanimivo, da eAsistent ne podpira exama in substitutiona hkrati ... slab design choice ig
HourSpecialType string `json:"hour_special_type"`
Departments []Department `json:"departments"`
Classroom Classroom `json:"classroom"`
Teachers []Teacher `json:"teachers"`
Groups []Group `json:"groups"`
Info []any `json:"info"`
}
type TimetableResponse ¶
type TimetableResponse struct {
// TimeTable nam pove vse ure zahtevanega tedna (in še preveč???). To je torej najbolj levi stolpec v eAsistent sistemu.
TimeTable []struct {
ID int `json:"id"`
Name string `json:"name"`
NameShort string `json:"name_short"`
Time struct {
From string `json:"from"`
To string `json:"to"`
} `json:"time"`
Type string `json:"type"`
} `json:"time_table"`
// DayTable nam pove vse datume zahtevanega tedna. Torej gornja vrstica v eAsistent sistemu.
DayTable []struct {
Name string `json:"name"`
ShortName string `json:"short_name"`
Date string `json:"date"`
} `json:"day_table"`
// SchoolHourEvents nam pove dejanske ure (predmete) na urniku. Končno nekaj uporabnega.
SchoolHourEvents []TimetableHour `json:"school_hour_events"`
// Events: TBD
Events []Event `json:"events"`
AllDayEvents []AllDayEvent `json:"all_day_events"`
}
type TimetableSubject ¶
type WebLoginResponse ¶
Click to show internal directories.
Click to hide internal directories.