ecamp / ecamp/ecamp3

Implement Hitobito deep-link endpoint

Open
#10,425 1 comment 0 reactions 1 assignee Claimed by @eliaSchenker View on GitHub
Ready for implementation type: API
Dominant language
PHP
Stars
156
Forks
72
Avg merge
12h 43m
Merged PRs (30d)
203

Description

The *"deep-link"* endpoint allows retrieving an eCamp camp by a Hitobito event id, taking into consideration
- whether a camp already exists for this event
- whether the user has the permissions to view / create it

```jsonc
// GET /api/hitobito//events//camp

// Response (camp exists, user has access)
{
"_links": {
"self": {
"href": "/api/hitobito/pbsmidata/events/123/camp"
},
"camp": {
"href": "/api/camps/5d28f99890bc"
}
},
"id": 123 // hitobito event id
}

// Response (camp exists, user does not have access)
{
"title": "Forbidden",
"detail": "A camp exists for this event, but you don't have access to it. Please contact your camp administrator.",
"status": 403,
"type": "/errors/hitobito-camp-forbidden"
}

// Response (camp does not exist, Hitobito event exists, user does not have access to the Hitobito event)
{
"title": "Forbidden",
"detail": "A Hitobito event was found, but you don't have permission to import it.",
"status": 403,
"type": "/errors/hitobito-event-forbidden"
}

// Response (camp does not exist, Hitobito event exists)
{
"title": "Not Found",
"detail": "No camp has been created for this event yet.",
"status": 404,
"type": "/errors/hitobito-camp-not-found"
}

// Response (camp does not exist, Hitobito event does not exist)
{
"title": "Not Found",
"detail": "No Hitobito event or camp could be found for this ID.",
"status": 404,
"type": "/errors/hitobito-event-not-found"
}
```

## Implementation

1. Retrieve a camp from the `camp` table with `hitobitoprovider = ` and `hitobitoid = `
1. If no camp is found, continue with the following flow:
2. Retrieve / verify access token
- See https://github.com/ecamp/ecamp3/issues/10400
3. Retrieve the event by `eventId` as described here: https://github.com/ecamp/ecamp3/issues/10419
1. If the event does not exist, respond with `/errors/hitobito-event-not-found` as described above
2. If the user doesn't have access to the event, respond with `/errors/hitobito-event-forbidden` as described above
4. Respond with `/errors/hitobito-camp-not-found`
2. Check whether the user has access to the camp (`camp_collaborations`)
1. If not, respond with `/errors/hitobito-camp-forbidden` as described above
3. Respond with the camp model

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.