As part of my day job I've had to create a couple of HTTP API clients and after some experimentation I've ended up with a code structure that I like and that I feel makes testing code that uses a JSON API client easier.
Making actual HTTP requests to 3rd-party services while running the tests can be difficult because of credential availability on the machine that runs the tests,