enhancements for the JSONAPI gateway

This is intended to make the JSONAPI gateway a fully specified interface, and to replace the old API gateway in Flapjack v1.0. It has been the subject of much out-of-band discussion I won't replicate here.

NB: the 'edit_contacts' backbone interface hasn't yet been updated to work properly with this.

Implements #396.