Example: Party Invites in Rest

189 views
Skip to first unread message

Kevin Wiggen

unread,
Oct 27, 2012, 12:46:18 PM10/27/12
to api-...@googlegroups.com

Imagine I am creating a party planning service that allows people to accept/reject invitations to parties (think evite).  I have the following Rest API

POST /parties  -- create party
GET /parties/:id -- get info about a party
GET /parties/:id/attendees -- people who are coming
GET /parties/:id/invitees -- people who are invited but have not decided yet

I don't care about people who don't want to come

I then need a way for people to see all the parties they are invited to

GET /users/:id/invites 

There are two related problems:

1)  How do I have a user accept/deny a party?  
  - Do I leave /users/:id/invites as read only and have the API allow the user to 
       PUT  /parties/:id/attendees/:userId to accept 
       DELTE  /parties/:id/invitees/:userId to DENY? 
  -  I could add a "Status" to /users/:id/invites/:id with <undecided><accept><deny> and have the user
       POST  /users/:id/invites/:id and update the status field -- which technically will update the party and  remove the invite object as I don't want to keep the invite forever

2)  This gets a little more complicated when we want a BATCH which allows the user to accept/decline lots of invites at the same time
  - POST /users/:id/invites seems like a place to put the batch command

I don't really like anything I have come up with so far.  Any suggestions?

Thanks,
Kevin

Mike Kelly

unread,
Oct 27, 2012, 2:27:09 PM10/27/12
to api-...@googlegroups.com
How about for each individual invitation just expose it as a resource and have the client update it as accepted?

PUT /invitations/123
{ "accepted": true }

If you need a batch acceptance you can do something like:

POST /users/234/bulk-accept-invites
.. a list of invite URIs ..

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "API Craft" group.
To unsubscribe from this group, send email to api-craft+...@googlegroups.com.
Visit this group at http://groups.google.com/group/api-craft?hl=en.
 
 
Reply all
Reply to author
Forward
0 new messages