defmodule Webuntis do @moduledoc """ Documentation for Webuntis. This library is no longer being developed. Please use . """ import Webuntis.JsonRpc @method_timetable "getTimetable2017" @method_homework "getHomeWork2017" @method_messages "getMessagesOfDay2017" @method_absences "getStudentAbsences2017" @method_userdata "getUserData2017" @doc """ Display the timetable for the given time. Example usage for today: ```elixir timetable_student(889, Date.utc_today(), Date.utc_today()) ``` """ @doc since: "2.0.0" def timetable_student(id, start_date, end_date) do request(@method_timetable, %{ "id" => id, "type" => "STUDENT", "startDate" => start_date, "endDate" => end_date }) |> Webuntis.Parser.parse_timetable() end @doc """ This is the same as `timetable_student` but for classes. """ @doc since: "2.0.0" def timetable_class(id, start_date, end_date) do request(@method_timetable, %{ "id" => id, "type" => "CLASS", "startDate" => start_date, "endDate" => end_date }) |> Webuntis.Parser.parse_timetable() end @doc """ List all homework for the given range. Example: ```elixir homework_student( 889, Date.utc_today(), Date.utc_today() |> Date.add(7) ) ``` """ @doc since: "2.0.0" def homework_student(id, start_date, end_date) do request(@method_homework, %{ "id" => id, "type" => "STUDENT", "startDate" => start_date, "endDate" => end_date }) |> Webuntis.Parser.parse_response() |> Map.fetch!("homeWorks") end @doc """ List the messages of the day. """ @doc since: "2.0.0" def messages(date) do request(@method_messages, %{"date" => date}) |> Webuntis.Parser.parse_response() |> Map.fetch!("messages") end @doc """ List all absences for the given range. Returns Webuntis.Struct.Absence structs """ @doc since: "2.0.0" def absences(start_date, end_date, include_excused, include_unexcused) do request(@method_absences, %{ "startDate" => start_date, "endDate" => end_date, "includeExcused" => include_excused, "includeUnExcused" => include_unexcused }) |> Webuntis.Parser.parse_absence() end @doc """ This returns a lot of data: * master data (used internal to resolve elements) * settings * messenger settings * "real" user data (e.g. student id, display name etc.) """ @doc since: "2.0.0" def userdata do request(@method_userdata, %{}) |> Webuntis.Parser.parse_response() end @doc false def master_data do request(@method_userdata, %{}) |> Webuntis.Parser.parse_response() |> Map.fetch!("masterData") end end