I’m new to JSON API and I got a user invite problem at hand I don’t know how to model correctly.
The scenario is the following: My application has teams and registered users can be invited to join a team, registered users get a link to the invite, and they can either accept or reject the invite. If an invite is accepted, a new membership for the team will be created.
At the moment I have four resources:
I currently support CREATE and DELETE for invites. How would you model the accept and reject actions? I used to break the CRUD principle there and just add two member functions
reject to the invite’s resource controller.
What I find particularly tricky is that when an invite is accepted, a membership resource will be returned.
My questions are:
- How would you structure the resources to accept the invite?
- How to let the client know “how” it can accept the invite, i.e if the client calls
READ /invites/:invite_idthe response should point the client to where he can exchange the invite for a membership.
Thanks a lot in advance,