Before diving into the examples, let's plan the new API at high level. The following table outlines the URLs, the HTTP methods, and the response formats for each:
URL |
Method |
Description |
Response formats |
---|---|---|---|
/someco/whitepapers | GET | Returns a list of Whitepapers. | HTML, JSON |
/someco/rating?id={id} | GET | Gets the average rating for a given Whitepaper by passing in the Whitepaper's noderef. | HTML, JSON |
/someco/rating?id={id}&rating={rating}&user={user} | POST | Creates a new rating for the specified Whitepaper by passing in a rating value and the user who posted the rating. | HTML, JSON |
/someco/rating?id={id} | DELETE | Deletes all ratings for a specified Whitepaper. | HTML |
When this API is in place, frontend developers can incorporate Whitepapers and user-contributed ratings into the SomeCo web site. The following screenshots show pages that use the API you're going to build to query for Whitepaper and ratings data. It looks like the folks at SomeCo have shamelessly ripped...