@@ -139,14 +139,48 @@ public AnalyzeModel Analyze(string host, Publish publish, ClearCache clearCache,
139
139
return analyzeModel ;
140
140
}
141
141
142
- public string GetEndpointData ( string host , string s )
142
+ public EndpointDataModel GetEndpointData ( string host , string s )
143
143
{
144
- return GetEndpointData ( host , s , "no" ) ;
144
+ return GetEndpointData ( host , s , FromCache . Off ) ;
145
145
}
146
146
147
- public string GetEndpointData ( string host , string s , string fromCache )
147
+ public EndpointDataModel GetEndpointData ( string host , string s , FromCache fromCache )
148
148
{
149
- throw new NotImplementedException ( ) ;
149
+ var endpointDataModel = new EndpointDataModel ( ) ;
150
+
151
+ // Checking host is valid before continuing
152
+ if ( ! _urlHelper . IsValid ( host ) )
153
+ {
154
+ endpointDataModel . HasErrorOccurred = true ;
155
+ endpointDataModel . Errors . Add ( new Error { message = "Host does not pass preflight validation. No Api call has been made." } ) ;
156
+ return endpointDataModel ;
157
+ }
158
+
159
+ // Building request model
160
+ var requestModel = _requestModelHelper . GetEndpointDataProperties ( ApiUrl , "getEndpointData" , host , s ,
161
+ fromCache . ToString ( ) ) ;
162
+
163
+ try
164
+ {
165
+ // Making Api request and gathering response
166
+ var webResponse = _api . MakeGetRequest ( requestModel ) ;
167
+ var webResult = _webResponseHelper . GetResponsePayload ( webResponse ) ;
168
+
169
+ // Trying to bind result to model
170
+ endpointDataModel = JsonConvert . DeserializeObject < EndpointDataModel > ( webResult , JsonSerializerSettings ) ;
171
+ endpointDataModel . Headers . statusCode = _webResponseHelper . GetStatusCode ( webResponse ) ;
172
+ endpointDataModel . Headers . statusDescription = _webResponseHelper . GetStatusDescription ( webResponse ) ;
173
+ }
174
+ catch ( Exception ex )
175
+ {
176
+ endpointDataModel . HasErrorOccurred = true ;
177
+ endpointDataModel . Errors . Add ( new Error { message = ex . ToString ( ) } ) ;
178
+ }
179
+
180
+ // Checking if errors have occoured either from ethier api or wrapper
181
+ if ( endpointDataModel . Errors . Count != 0 && ! endpointDataModel . HasErrorOccurred ) { endpointDataModel . HasErrorOccurred = true ; }
182
+
183
+ return endpointDataModel ;
150
184
}
151
185
152
186
public string GetStatusCodes ( )
0 commit comments