The following endpoint is added, which allows searching events from Hitobito. Only events that the user manages are returned (that the user is Lagerleiter:in of).
Workflow
- Initialize OAuth (TBD)
- Retrieve events from the Hitobito API retrieving event participations of the current user, starting with the first page:
GET <base-url>/api/event_participations
?include=roles,event
&filter[participant_id][eq]=<hitobito_user_id>
&fields[event_participations]=active
&fields[events]=name
&fields[event_roles]=type
&page[number]=<page>
&page[size]=20
The fields[event_participations], fields[events]=name, fields[event_roles]=type params limit the fields that are returned, only including the specified fields. By default all fields of participations, events and event_roles would be returned, which results in a larger response body.
Example Response:
- For every retrieved page, perform the following steps:
- Go through each participation
- Check whether one of the corresponding event roles has
attributes.type = "Event::Camp::Role::Leader"
- If not, discard the participation
- Check whether the participation has
attributes.active = true
- If not, discard the participation
- Add the event
id and attributes.name to result array
- If the response contains
links.next, increment the page and continue
- Otherwise, exit and return all gathered events
Implementation Note: Make sure that the role that identifies a user as a leader of an event (for MiData Event::Camp::Role::Leader) is configurable per different Hitobito provider, so that new supported instance (i.e. CeviDB) can be easily added in the future.
Optimally we would directly query the event name / filter the role when calling the api, but this is seemingly unsupported by Hitobito.
The following endpoint is added, which allows searching events from Hitobito. Only events that the user manages are returned (that the user is
Lagerleiter:inof).Workflow
Example Response:
{ "data": [ { "id": "16904", "type": "event_participations", "attributes": { "active": true }, "relationships": { "event": { "data": { "type": "events", "id": "2611" } }, // ... "roles": { "data": [ { "type": "event_roles", "id": "17996" } ] } } } ], "included": [ { "id": "2611", "type": "events", "attributes": { "name": "Lumos + Iltis" }, "relationships": { // ... } }, { "id": "17996", "type": "event_roles", "attributes": { "type": "Event::Camp::Role::Leader" }, "relationships": { "participation": { "meta": { "included": false } } } } ], "links": { // ... "next": "/api/event_participations?fields%5Bevent_participations%5D=active&fields%5Bevent_roles%5D=type&fields%5Bevents%5D=name&filter%5Bparticipant_id%5D%5Beq%5D=2&include=roles%2Cevent&page%5Bnumber%5D=2&page%5Bsize%5D=20" // not set if there are no more pages }, "meta": {} }attributes.type = "Event::Camp::Role::Leader"attributes.active = trueidandattributes.nameto result arraylinks.next, increment thepageand continue