scottwainstock/pbm — pull request #247 by fmscode (2014-04-29 11:32:51+00:00)
Title: API Improvements

Some more API improvements. We seemed to both write a locations API, so I merged your recent changes and added mine on top.

### New API Routes
- /api/v1/regions => Returns all regions.
- /api/v1/:region/locations => Location data for region

### API Standardization
I think we should try to standardize the API responses. I've been using the json/xml builders to format the responses to a single format when possible. The main thing I've been doing is removing the root model name. For example without using builders you would receive a response such as this.
```json
[ "location": {
"id": 1,
"name": "Beths",
"neighborhood": "",
"zoneNo": null,
"numMachines": 1,
"lat": "47.6821087",
"lon": "-122.3447548",
....
},
```
By using builders we can remove that top node that is not that important, and receive just an array of locations.
```json
[ {
"id": 1,
"name": "Beths",
"neighborhood": "",
"zoneNo": null,
"numMachines": 1,
"lat": "47.6821087",
"lon": "-122.3447548",
....
},
```
By using builders it will also make it so we have to manually add the new fields when they become available, which is important for API's since we don't want it to automatically change until we can alter our existing code to support it.