I have been working on a simple api to add a player to a team. The approach I took was to put some working code out (without getting any detailed requirements from you), which can be used as a starting point for discussing any changes that you all would like to make. If there is anything you want done differently, let's discuss it and I can make the changes before you accept the pull request.
Here is what a curl request to add an existing player (Harry Potter) to an existing team (Gryffindor) looks like with this new code:
I chose a PUT function to the maps api - since the thing we are really doing is updating the mapping between players and teams (not really a team object or a player object). It also seems that this approach could work quite well with the UI: updating a player/team mapping (maybe by dragging and dropping a player to a new team) will return the complete new mapping which we can then use to re-render the changes in the UI. I am open to moving it to a different endpoint though if you collectively think it belongs somewhere else.
I am using the player email and team name as parameters, since they are unique and human-readable (unlike the ids which are not very readable), and using them will make scripting team creation much easier.
I'll see what I can do tomorrow to put together a curl script that we can use to build a few teams up.
I have been working on a simple api to add a player to a team. The approach I took was to put some working code out (without getting any detailed requirements from you), which can be used as a starting point for discussing any changes that you all would like to make. If there is anything you want done differently, let's discuss it and I can make the changes before you accept the pull request.
Here is what a curl request to add an existing player (Harry Potter) to an existing team (Gryffindor) looks like with this new code:
curl -X PUT http://localhost:9000/api/maps/harry.potter@hogwarts.com/Gryffindor
I chose a PUT function to the maps api - since the thing we are really doing is updating the mapping between players and teams (not really a team object or a player object). It also seems that this approach could work quite well with the UI: updating a player/team mapping (maybe by dragging and dropping a player to a new team) will return the complete new mapping which we can then use to re-render the changes in the UI. I am open to moving it to a different endpoint though if you collectively think it belongs somewhere else.
I am using the player email and team name as parameters, since they are unique and human-readable (unlike the ids which are not very readable), and using them will make scripting team creation much easier.
I'll see what I can do tomorrow to put together a curl script that we can use to build a few teams up.