/* GoSkola24API Copyright (C) 2024, Zervó Zadachin DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License version 3 for more details. This program incorporates external libraries for certain functionalities. These libraries are covered by their respective licenses, and their usage agreements are as outlined in their respective documentation or source code. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ package requests import ( "errors" "fmt" "git.zervo.org/zervo/goskola24api/internal/types" "git.zervo.org/zervo/goskola24api/internal/utility" pubtypes "git.zervo.org/zervo/goskola24api/types" ) func GetSchedule(year int, week int, day int, school pubtypes.School, term pubtypes.SchoolTerm, class pubtypes.Class) (_result any, _error error) { // Verify week number if week > 52 || week < 1 { return nil, errors.New("week number out of range (1-53): " + fmt.Sprint(week)) } // Verify year if year > 9999 || year < 2000 { return nil, errors.New("year number out of range (2000-9999): " + fmt.Sprint(year)) } // Verify day if day > 7 || day < 0 { return nil, errors.New("day number out of range (0-7): " + fmt.Sprint(day)) } // Get render key renderKey, err := utility.GetRendererKey() if err != nil { return nil, errors.New("failed to get render key: " + err.Error()) } // Construct request request := types.RequestSchedule{ RenderKey: renderKey, Host: school.HostName, UnitGuid: school.SchoolId, StartDate: nil, EndDate: nil, ScheduleDay: day, BlackAndWhite: false, Width: 1000, Height: 1000, SelectionType: 0, Selection: class.ClassId, ShowHeader: false, PeriodText: "", Week: week, Year: year, SchoolYear: term.TermId, PersonalTimetable: false, PrivateFreeTextMode: nil, PrivateSelectionMode: false, CustomerKey: "", } response, err := utility.Request(request, "render/timetable") if err != nil { return nil, errors.New("could not get schedule data: " + err.Error()) } return response, nil }