public static function response($data, $type = self::FORMAT_XML)
    {
        if (is_string($data) && strlen($data) === 0) {
            return true; // Many operations return an empty string for success
        }
        switch ($type) {
            case static::FORMAT_XML:
                return AbstractResponse::fromXml($data);
            case static::FORMAT_JSON:
                return AbstractResponse::fromJson($data);
        }
        throw new InvalidArgumentException("Type must be 'xml' or 'json'");
    }