Closed carinhbrander closed 1 year ago
Realised we don't really have to use the API. We can just make a form submission same as the webapp does:
So essentially we can make a POST call to https://hjarntorget.goteborg.se/attendanceParentSubmitAbsence.do
With the body:
attendeeId=<child_id>&statusId=27433608&_submit=Register+the+whole+day&startTimeString=2021-11-25+00%3A00&endTimeString=2021-11-25+23%3A59
This is what gets posted when submitting the form in the webapp. The _submit
parameter is not be required (tried calling the endpoint without it and that worked).
I checked the PING PONG API and it seems like reason is connected to AbsentStatus which you can get from attendance/absent-statuses. So we could probably use the id of the selected status for reason
as stated in the register-absence description:
Reason refers to the id of the selected status.
Calling https://hjarntorget.goteborg.se/api/attendance/absent-statuses?language=sv&role=PARENT for me gives:
[{"id":27433608,"name":"Anmäld frånvaro"}]
@marioleed Thanks, I had completely missed that endpoint! The id matches up with the statusId
used in the POST on Hjärntorget too.
There is an api available for registering abscences. However we need to find the value for the
reason
parameter that is required. It's documented as an int I'd for matching the reported status. However which int that should be used is not specified in the docs, nor the response you get when fetching the abscences for a child. I have not been able to find it on the abscence registration page in Hjärntorget either :/The endpoint is documented here (no login required): https://hjarntorget.goteborg.se/api#attendancexregister-absence_header
I think this will also rerquire some changes in the actual app code as the stockholm app basically just creates/prepares an SMS to send.
We could also decide to skip this and just not show the report abscence if we can not find the info needed. Also one consideration is if we add this to
Api
we will need to toggle that feature for the Stockholm version as that doesn't have that capability.