Skip to content

Commit 97f37d8

Browse files
committed
Major refractor
1 parent e8bfe63 commit 97f37d8

13 files changed

+64
-123
lines changed

SSLLWrapper.ConsoleAppTester/Program.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace SSLLWrapper.ConsoleAppTester
55
class Program
66
{
77
private const string ApiUrl = "https://api.dev.ssllabs.com/api/fa78d5a4";
8-
static readonly Service ApiService = new Service(ApiUrl);
8+
static readonly SSLLService SSLLService = new SSLLService(ApiUrl);
99

1010
static void Main(string[] args)
1111
{
@@ -16,7 +16,7 @@ static void Main(string[] args)
1616

1717
static void InfoTester()
1818
{
19-
var info = ApiService.Info();
19+
var info = SSLLService.Info();
2020

2121
Console.WriteLine("Has Error Occoured: {0}", info.HasErrorOccurred);
2222
Console.WriteLine("Status Code: {0}", info.Header.statusCode);
@@ -28,7 +28,7 @@ static void InfoTester()
2828

2929
static void AnalyzeTester()
3030
{
31-
var analyze = ApiService.Analyze("http://www.ashleypoole.co.uk");
31+
var analyze = SSLLService.Analyze("http://www.ashleypoole.co.uk");
3232

3333
Console.WriteLine("Has Error Occoured: {0}", analyze.HasErrorOccurred);
3434
Console.WriteLine("Status Code: {0}", analyze.Header.statusCode);
@@ -39,7 +39,7 @@ static void AnalyzeTester()
3939

4040
static void GetEndpointData()
4141
{
42-
var endpointDataModel = ApiService.GetEndpointData("http://www.ashleypoole.co.uk", "104.28.6.2");
42+
var endpointDataModel = SSLLService.GetEndpointData("http://www.ashleypoole.co.uk", "104.28.6.2");
4343

4444
Console.WriteLine("Has Error Occoured: {0}", endpointDataModel.HasErrorOccurred);
4545
Console.WriteLine("Status Code: {0}", endpointDataModel.Header.statusCode);

SSLLWrapper/Helpers/RequestModelHelper.cs renamed to SSLLWrapper/Domain/RequestModelFactory.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
using System;
2-
using SSLLWrapper.Interfaces;
3-
using SSLLWrapper.Models;
1+
using SSLLWrapper.Models;
42

5-
namespace SSLLWrapper.Helpers
3+
namespace SSLLWrapper.Domain
64
{
7-
class RequestModelHelper : IRequestModelHelper
5+
class RequestModelFactory
86
{
9-
public RequestModel InfoProperties(string apiBaseUrl, string action)
7+
public RequestModel NewInfoRequestModel(string apiBaseUrl, string action)
108
{
119
return new RequestModel() {ApiBaseUrl = apiBaseUrl, Action = action};
1210
}
1311

14-
public RequestModel AnalyzeProperties(string apiBaseUrl, string action, string host, string publish, string clearCache,
12+
public RequestModel NewAnalyzeRequestModel(string apiBaseUrl, string action, string host, string publish, string clearCache,
1513
string fromCache, string all)
1614
{
1715
var requestModel = new RequestModel() { ApiBaseUrl = apiBaseUrl, Action = action};
@@ -26,7 +24,7 @@ public RequestModel AnalyzeProperties(string apiBaseUrl, string action, string h
2624
return requestModel;
2725
}
2826

29-
public RequestModel GetEndpointDataProperties(string apiBaseUrl, string action, string host, string s, string fromCache)
27+
public RequestModel NewEndpointDataRequestModel(string apiBaseUrl, string action, string host, string s, string fromCache)
3028
{
3129
var requestModel = new RequestModel() {ApiBaseUrl = apiBaseUrl, Action = action};
3230

@@ -37,7 +35,7 @@ public RequestModel GetEndpointDataProperties(string apiBaseUrl, string action,
3735
return requestModel;
3836
}
3937

40-
public RequestModel GetStatusCodeProperties(string apiBaseUrl, string action)
38+
public RequestModel NewStatusCodesRequestModel(string apiBaseUrl, string action)
4139
{
4240
return new RequestModel() {ApiBaseUrl = apiBaseUrl, Action = action};
4341
}

SSLLWrapper/Helpers/ResponsePopulationHelper.cs renamed to SSLLWrapper/Domain/ResponsePopulation.cs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,62 @@
11
using System.Net;
22
using Newtonsoft.Json;
3-
using SSLLWrapper.Interfaces;
43
using SSLLWrapper.Models.Response;
54

6-
namespace SSLLWrapper.Helpers
5+
namespace SSLLWrapper.Domain
76
{
8-
class ResponsePopulationHelper : IResponsePopulationHelper
7+
class ResponsePopulation
98
{
109
public JsonSerializerSettings JsonSerializerSettings;
11-
private readonly IHttpWebResponseHelper _webResponseHelper;
10+
private readonly WebResponseReader _webResponseReader;
1211

13-
public ResponsePopulationHelper()
12+
public ResponsePopulation()
1413
{
1514
// Ignoring null values when serializing json objects
1615
JsonSerializerSettings = new JsonSerializerSettings {NullValueHandling = NullValueHandling.Ignore};
1716

18-
_webResponseHelper = new HttpWebResponseHelper();
17+
_webResponseReader = new WebResponseReader();
1918
}
2019

2120
public Info InfoModel(HttpWebResponse webResponse, Info infoModel)
2221
{
23-
var webResult = _webResponseHelper.GetResponsePayload(webResponse);
22+
var webResult = _webResponseReader.GetResponsePayload(webResponse);
2423

2524
infoModel = JsonConvert.DeserializeObject<Info>(webResult, JsonSerializerSettings);
26-
infoModel.Header.statusCode = _webResponseHelper.GetStatusCode(webResponse);
27-
infoModel.Header.statusDescription = _webResponseHelper.GetStatusDescription(webResponse);
25+
infoModel.Header.statusCode = _webResponseReader.GetStatusCode(webResponse);
26+
infoModel.Header.statusDescription = _webResponseReader.GetStatusDescription(webResponse);
2827

2928
return infoModel;
3029
}
3130

3231
public Analyze AnalyzeModel(HttpWebResponse webResponse, Analyze analyzeModel)
3332
{
34-
var webResult = _webResponseHelper.GetResponsePayload(webResponse);
33+
var webResult = _webResponseReader.GetResponsePayload(webResponse);
3534

3635
analyzeModel = JsonConvert.DeserializeObject<Analyze>(webResult, JsonSerializerSettings);
37-
analyzeModel.Header.statusCode = _webResponseHelper.GetStatusCode(webResponse);
38-
analyzeModel.Header.statusDescription = _webResponseHelper.GetStatusDescription(webResponse);
36+
analyzeModel.Header.statusCode = _webResponseReader.GetStatusCode(webResponse);
37+
analyzeModel.Header.statusDescription = _webResponseReader.GetStatusDescription(webResponse);
3938

4039
return analyzeModel;
4140
}
4241

4342
public Endpoint EndpointModel(HttpWebResponse webResponse, Endpoint endpointModel)
4443
{
45-
var webResult = _webResponseHelper.GetResponsePayload(webResponse);
44+
var webResult = _webResponseReader.GetResponsePayload(webResponse);
4645

4746
endpointModel = JsonConvert.DeserializeObject<Endpoint>(webResult, JsonSerializerSettings);
48-
endpointModel.Header.statusCode = _webResponseHelper.GetStatusCode(webResponse);
49-
endpointModel.Header.statusDescription = _webResponseHelper.GetStatusDescription(webResponse);
47+
endpointModel.Header.statusCode = _webResponseReader.GetStatusCode(webResponse);
48+
endpointModel.Header.statusDescription = _webResponseReader.GetStatusDescription(webResponse);
5049

5150
return endpointModel;
5251
}
5352

5453
public StatusDetails StatusDetailsModel(HttpWebResponse webResponse, StatusDetails statusDetails)
5554
{
56-
var webResult = _webResponseHelper.GetResponsePayload(webResponse);
55+
var webResult = _webResponseReader.GetResponsePayload(webResponse);
5756

5857
statusDetails = JsonConvert.DeserializeObject<StatusDetails>(webResult, JsonSerializerSettings);
59-
statusDetails.Header.statusCode = _webResponseHelper.GetStatusCode(webResponse);
60-
statusDetails.Header.statusDescription = _webResponseHelper.GetStatusDescription(webResponse);
58+
statusDetails.Header.statusCode = _webResponseReader.GetStatusCode(webResponse);
59+
statusDetails.Header.statusDescription = _webResponseReader.GetStatusDescription(webResponse);
6160

6261
return statusDetails;
6362
}

SSLLWrapper/Helpers/UrlHelper.cs renamed to SSLLWrapper/Domain/UrlValidation.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
using System;
2-
using SSLLWrapper.Interfaces;
32

4-
namespace SSLLWrapper.Helpers
3+
namespace SSLLWrapper.Domain
54
{
6-
class UrlHelper : IUrlHelper
5+
class UrlValidation
76
{
87
public bool IsValid(string url)
98
{

SSLLWrapper/Helpers/HttpWebResponseHelper.cs renamed to SSLLWrapper/Domain/WebResponseReader.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
using System.IO;
22
using System.Net;
3-
using SSLLWrapper.Interfaces;
43

5-
namespace SSLLWrapper.Helpers
4+
namespace SSLLWrapper.Domain
65
{
7-
class HttpWebResponseHelper : IHttpWebResponseHelper
6+
class WebResponseReader
87
{
98
public string GetResponsePayload(HttpWebResponse webResponse)
109
{

SSLLWrapper/Api.cs renamed to SSLLWrapper/External/SSLLabsApi.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
using SSLLWrapper.Interfaces;
33
using SSLLWrapper.Models;
44

5-
namespace SSLLWrapper
5+
namespace SSLLWrapper.External
66
{
7-
class Api : IApi
7+
class SSLLabsApi : IApiProvider
88
{
99
public HttpWebResponse MakeGetRequest(RequestModel requestModel)
1010
{

SSLLWrapper/Interfaces/IApi.cs renamed to SSLLWrapper/Interfaces/IApiProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace SSLLWrapper.Interfaces
55
{
6-
public interface IApi
6+
public interface IApiProvider
77
{
88
HttpWebResponse MakeGetRequest(RequestModel requestModel);
99
}

SSLLWrapper/Interfaces/IHttpWebResponseHelper.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

SSLLWrapper/Interfaces/IRequestModelHelper.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

SSLLWrapper/Interfaces/IResponsePopulationHelper.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)