refactor curl calls into stub class

this makes it possible to test the api client without performing curl
calls at all.