1
1
using System ;
2
- using Newtonsoft . Json ;
3
2
using SSLLWrapper . Helpers ;
4
3
using SSLLWrapper . Interfaces ;
5
4
using SSLLWrapper . Models . Response ;
6
- using SSLLWrapper . Models . Response . BaseResponseSubModels ;
5
+ using SSLLWrapper . Models . Response . BaseSubModels ;
7
6
8
7
namespace SSLLWrapper
9
8
{
@@ -55,9 +54,9 @@ public ApiService(string apiUrl)
55
54
56
55
#endregion
57
56
58
- public InfoModel Info ( )
57
+ public Info Info ( )
59
58
{
60
- var infoModel = new InfoModel ( ) ;
59
+ var infoModel = new Info ( ) ;
61
60
62
61
// Building new request model
63
62
var requestModel = _requestModelHelper . InfoProperties ( ApiUrl , "info" ) ;
@@ -87,15 +86,15 @@ public InfoModel Info()
87
86
return infoModel ;
88
87
}
89
88
90
- public AnalyzeModel Analyze ( string host )
89
+ public Analyze Analyze ( string host )
91
90
{
92
91
// overloaded method to provide a default set of options
93
92
return Analyze ( host , Publish . Off , ClearCache . On , FromCache . Off , All . On ) ;
94
93
}
95
94
96
- public AnalyzeModel Analyze ( string host , Publish publish , ClearCache clearCache , FromCache fromCache , All all )
95
+ public Analyze Analyze ( string host , Publish publish , ClearCache clearCache , FromCache fromCache , All all )
97
96
{
98
- var analyzeModel = new AnalyzeModel ( ) ;
97
+ var analyzeModel = new Analyze ( ) ;
99
98
100
99
// Checking host is valid before continuing
101
100
if ( ! _urlHelper . IsValid ( host ) )
@@ -129,21 +128,21 @@ public AnalyzeModel Analyze(string host, Publish publish, ClearCache clearCache,
129
128
return analyzeModel ;
130
129
}
131
130
132
- public EndpointDataModel GetEndpointData ( string host , string s )
131
+ public Endpoint GetEndpointData ( string host , string s )
133
132
{
134
133
return GetEndpointData ( host , s , FromCache . Off ) ;
135
134
}
136
135
137
- public EndpointDataModel GetEndpointData ( string host , string s , FromCache fromCache )
136
+ public Endpoint GetEndpointData ( string host , string s , FromCache fromCache )
138
137
{
139
- var endpointDataModel = new EndpointDataModel ( ) ;
138
+ var endpointModel = new Endpoint ( ) ;
140
139
141
140
// Checking host is valid before continuing
142
141
if ( ! _urlHelper . IsValid ( host ) )
143
142
{
144
- endpointDataModel . HasErrorOccurred = true ;
145
- endpointDataModel . Errors . Add ( new Error { message = "Host does not pass preflight validation. No Api call has been made." } ) ;
146
- return endpointDataModel ;
143
+ endpointModel . HasErrorOccurred = true ;
144
+ endpointModel . Errors . Add ( new Error { message = "Host does not pass preflight validation. No Api call has been made." } ) ;
145
+ return endpointModel ;
147
146
}
148
147
149
148
// Building request model
@@ -156,23 +155,42 @@ public EndpointDataModel GetEndpointData(string host, string s, FromCache fromCa
156
155
var webResponse = _api . MakeGetRequest ( requestModel ) ;
157
156
158
157
// Binding result to model
159
- _responsePopulationHelper . EndpointDataModel ( webResponse , endpointDataModel ) ;
158
+ _responsePopulationHelper . EndpointModel ( webResponse , endpointModel ) ;
160
159
}
161
160
catch ( Exception ex )
162
161
{
163
- endpointDataModel . HasErrorOccurred = true ;
164
- endpointDataModel . Errors . Add ( new Error { message = ex . ToString ( ) } ) ;
162
+ endpointModel . HasErrorOccurred = true ;
163
+ endpointModel . Errors . Add ( new Error { message = ex . ToString ( ) } ) ;
165
164
}
166
165
167
166
// Checking if errors have occoured either from ethier api or wrapper
168
- if ( endpointDataModel . Errors . Count != 0 && ! endpointDataModel . HasErrorOccurred ) { endpointDataModel . HasErrorOccurred = true ; }
167
+ if ( endpointModel . Errors . Count != 0 && ! endpointModel . HasErrorOccurred ) { endpointModel . HasErrorOccurred = true ; }
169
168
170
- return endpointDataModel ;
169
+ return endpointModel ;
171
170
}
172
171
173
- public string GetStatusCodes ( )
172
+ public StatusDetails GetStatusCodes ( )
174
173
{
175
- throw new NotImplementedException ( ) ;
174
+ var statusDetailsModel = new StatusDetails ( ) ;
175
+
176
+ // Building request model
177
+ var requestModel = _requestModelHelper . GetStatusCodeProperties ( ApiUrl , "getStatusCodes" ) ;
178
+
179
+ try
180
+ {
181
+ // Making Api request and gathering response
182
+ var webResponse = _api . MakeGetRequest ( requestModel ) ;
183
+
184
+ // Binding result to model
185
+ _responsePopulationHelper . StatusDetailsModel ( webResponse , statusDetailsModel ) ;
186
+ }
187
+ catch ( Exception ex )
188
+ {
189
+ statusDetailsModel . HasErrorOccurred = true ;
190
+ statusDetailsModel . Errors . Add ( new Error { message = ex . ToString ( ) } ) ;
191
+ }
192
+
193
+ return statusDetailsModel ;
176
194
}
177
195
}
178
196
}
0 commit comments