protected function sendRequest(RequestInterface $request, $responseClass)
    {
        if (!in_array(ApiResponseInterface::class, class_implements($responseClass))) {
            throw new \InvalidArgumentException('The response class must implement "'.ApiResponseInterface::class.'".');
        }

        $body = $this->serializer->serialize($request, 'json');
        $response = $this->transport->sendRequest($body);

        /** @var ApiResponseInterface $apiResponse */
        $apiResponse = $this->serializer->deserialize($response, $responseClass, 'json');
        if ($apiResponse->getResponse() !== null && $apiResponse->getResponse()->hasErrors()) {
            throw new ApiResponseException(
                sprintf('Error calling "%s"', $request->getService()),
                $apiResponse->getResponse()->getErrors()
            );
        }

        return $apiResponse;
    }