Exemplo n.º 1
0
        public Endpoint GetEndpointData(string host, string s, FromCache fromCache)
        {
            var endpointModel = new Endpoint();

            // Checking host is valid before continuing
            if (!_urlValidation.IsValid(host))
            {
                endpointModel.HasErrorOccurred = true;
                endpointModel.Errors.Add(new Error {
                    message = "Host does not pass preflight validation. No Api call has been made."
                });
                return(endpointModel);
            }

            // Building request model
            var requestModel = _requestModelFactory.NewEndpointDataRequestModel(ApiUrl, "getEndpointData", host, s,
                                                                                fromCache.ToString());

            try
            {
                var webResponse = _apiProvider.MakeGetRequest(requestModel);
                endpointModel = _responsePopulation.EndpointModel(webResponse, endpointModel);
            }
            catch (Exception ex)
            {
                endpointModel.HasErrorOccurred = true;
                endpointModel.Errors.Add(new Error {
                    message = ex.ToString()
                });
            }

            // Checking if errors have occoured either from ethier api or wrapper
            if (endpointModel.Errors.Count != 0 && !endpointModel.HasErrorOccurred)
            {
                endpointModel.HasErrorOccurred = true;
            }

            return(endpointModel);
        }
Exemplo n.º 2
0
        public Analyze Analyze(string host, Publish publish, StartNew startNew, FromCache fromCache, int?maxHours, All all, IgnoreMismatch ignoreMismatch)
        {
            var analyzeModel = new Analyze();

            // Checking host is valid before continuing
            if (!_urlValidation.IsValid(host))
            {
                analyzeModel.HasErrorOccurred = true;
                analyzeModel.Errors.Add(new Error {
                    message = "Host does not pass preflight validation. No Api call has been made."
                });
                return(analyzeModel);
            }

            // Building request model
            var requestModel = _requestModelFactory.NewAnalyzeRequestModel(ApiUrl, "analyze", host, publish.ToString().ToLower(), startNew.ToString().ToLower(),
                                                                           fromCache.ToString().ToLower(), maxHours, all.ToString().ToLower(), ignoreMismatch.ToString().ToLower());

            try
            {
                var webResponse = _apiProvider.MakeGetRequest(requestModel);
                analyzeModel = _responsePopulation.AnalyzeModel(webResponse, analyzeModel);
            }
            catch (Exception ex)
            {
                analyzeModel.HasErrorOccurred = true;
                analyzeModel.Errors.Add(new Error {
                    message = ex.ToString()
                });
            }

            // Checking if errors have occoured either from ethier api or wrapper
            if (analyzeModel.Errors.Count != 0 && !analyzeModel.HasErrorOccurred)
            {
                analyzeModel.HasErrorOccurred = true;
            }

            return(analyzeModel);
        }
        public Analyze Analyze(string host, Publish publish, StartNew startNew, FromCache fromCache, int? maxHours, All all, IgnoreMismatch ignoreMismatch)
        {
            var analyzeModel = new Analyze();

            // Checking host is valid before continuing
            if (!_urlValidation.IsValid(host))
            {
                analyzeModel.HasErrorOccurred = true;
                analyzeModel.Errors.Add(new Error { message = "Host does not pass preflight validation. No Api call has been made." });
                return analyzeModel;
            }

            // Building request model
            var requestModel = _requestModelFactory.NewAnalyzeRequestModel(ApiUrl, "analyze", host, publish.ToString().ToLower(), startNew.ToString().ToLower(),
                fromCache.ToString().ToLower(), maxHours, all.ToString().ToLower(), ignoreMismatch.ToString().ToLower());

            try
            {
                var webResponse = _apiProvider.MakeGetRequest(requestModel);
                analyzeModel = _responsePopulation.AnalyzeModel(webResponse, analyzeModel);
            }
            catch (Exception ex)
            {
                analyzeModel.HasErrorOccurred = true;
                analyzeModel.Errors.Add(new Error { message = ex.ToString() });
            }

            // Checking if errors have occoured either from ethier api or wrapper
            if (analyzeModel.Errors.Count != 0 && !analyzeModel.HasErrorOccurred) { analyzeModel.HasErrorOccurred = true; }

            return analyzeModel;
        }
        public Endpoint GetEndpointData(string host, string s, FromCache fromCache)
        {
            var endpointModel = new Endpoint();

            // Checking host is valid before continuing
            if (!_urlValidation.IsValid(host))
            {
                endpointModel.HasErrorOccurred = true;
                endpointModel.Errors.Add(new Error { message = "Host does not pass preflight validation. No Api call has been made." });
                return endpointModel;
            }

            // Building request model
            var requestModel = _requestModelFactory.NewEndpointDataRequestModel(ApiUrl, "getEndpointData", host, s,
                fromCache.ToString());

            try
            {
                var webResponse = _apiProvider.MakeGetRequest(requestModel);
                endpointModel = _responsePopulation.EndpointModel(webResponse, endpointModel);
            }
            catch (Exception ex)
            {
                endpointModel.HasErrorOccurred = true;
                endpointModel.Errors.Add(new Error { message = ex.ToString() });
            }

            // Checking if errors have occoured either from ethier api or wrapper
            if (endpointModel.Errors.Count != 0 && !endpointModel.HasErrorOccurred) { endpointModel.HasErrorOccurred = true; }

            return endpointModel;
        }