private static function _batchResponseFromFields(&$json, &$fields)
    {
        if ($fields->type == 'mt_text') {
            $result = new Api\MtBatchTextSmsResult();
            $result->setBody($fields->body);

            if (isset($fields->parameters)) {
                $result->setParameters(
                    Deserialize::_convertParameters($fields->parameters)
                );
            }
        } else if ($fields->type == 'mt_binary') {
            $result = new Api\MtBatchBinarySmsResult();
            $result->setUdh(hex2bin($fields->udh));
            $result->setBody(base64_decode($fields->body));
        } else {
            throw new UnexpectedResponseException(
                "Received unexpected batch type " . $fields->type,
                $json
            );
        }

        // Read the common fields.
        Deserialize::_batchResponseHelper($json, $fields, $result);

        return $result;
    }