public function executeBatch(array $headers = null, array $clientOptions = [])
    {
        $requests = $this->getBatchHttpRequests($headers);
        $client = $this->getHttpClient();
        if ($client instanceof AdapterOptionInterface) {
            $httpResponses = $client->executeBatch($requests, $clientOptions);
        } else {
            $httpResponses = $client->executeBatch($requests);
        }

        $responses = [];
        foreach ($httpResponses as $key => $httpResponse) {
            $request = $this->batchRequests[$key];
            $httpRequest = $requests[$key];
            if ($httpResponse instanceof ApiException) {
                $exception = $httpResponse;
                if ($this->getConfig()->getThrowExceptions() ||
                    !$httpResponse->getResponse() instanceof ResponseInterface
                ) {
                    throw $exception;
                }
                $this->logException($httpResponse);
                $httpResponse = $exception->getResponse();
                $responses[$request->getIdentifier()] = new ErrorResponse(
                    $exception,
                    $request,
                    $httpResponse
                );
            } else {
                $responses[$request->getIdentifier()] = $request->buildResponse($httpResponse);
            }
            $this->logDeprecatedRequest($httpResponse, $httpRequest);
        }
        unset($this->batchRequests);
        $this->batchRequests = [];

        return $responses;
    }