protected function buildRequest($method, $path, $body = null, array $customHeaders = [])
    {
        $headers = [];

        // If a body was included, add it to the request.
        if (isset($body)) {
            $headers['Content-Type'] = 'application/json';
            $body = json_encode($body);
            // Check for JSON encoding errors.
            if (json_last_error() !== JSON_ERROR_NONE) {
                throw new JsonEncodingException(
                    'JSON error while encoding Heroku API request: ' . json_last_error_msg()
                );
            }
        }

        // Add required headers.
        $headers['Accept'] = 'application/vnd.heroku+json; version=3'; // Heroku specifies this.
        $headers['Authorization'] = 'Bearer ' . $this->apiKey;

        // Incorporate any custom headers, preferring them over our defaults.
        $headers = $customHeaders + $headers;

        return new Request($method, $this->baseUrl . $path, $headers, $body);
    }