Lately, I was missioned to integrate a vendor PHP SDK that is transport-agnostic as it implements HTTPlug. Pretty cool.

Everything went well until I found out that the SDK used a response reader method helper which is:

/**
 * @param ResponseInterface $response
 *
 * @return stdClass
 */
private function handleResponse(ResponseInterface $response)
{
    $this->setRateLimitDetails($response);

    $stream = $response->getBody()->getContents();

    return json_decode($stream);
}

First issue: I can't pick the response format, I'm forced to deal with the object deserialization version of the JSON payload. This is okay but not completely since the structure of the JSON may vary if my peers

> Continue Reading