Client refactoring

Hi Garreth

Consider this a work in progress, for your review. Don't merge yet, as I'm far from done.
I'll continue to commit things to this branch so this PR stays up to date.
I think this is quite similar to some business logic the existing codebase has here https://github.com/gaye/davinci.js/blob/master/lib/request/request.js. Do you think that code is flexible enough to work here? If not, are there modifications there that can be made to support this?