/// <inheritdoc /> public LookupResponse ParseLookupResponse(string text) { try { var root = XDocument.Parse(text).Element("response"); var status = root.Element("status"); if (status.Value == "ok") { var response = new LookupResponse(); var list = root.Element("results").Descendants("result"); foreach (var item in list) { response.Results.Add(ParseLookupResult(item)); } return response; } if (status.Value == "error") { var error = root.Element("error"); return new LookupResponse(HttpStatusCode.BadRequest, error.Element("message").Value); } return null; } catch (Exception e) { throw e; } }
/// <inheritdoc /> public LookupResponse ParseLookupResponse(string text) { try { var root = XDocument.Parse(text).Element("response"); var status = root.Element("status"); if (status.Value == "ok") { var response = new LookupResponse(); var list = root.Element("results").Descendants("result"); foreach (var item in list) { response.Results.Add(ParseLookupResult(item)); } return(response); } if (status.Value == "error") { var error = root.Element("error"); return(new LookupResponse(HttpStatusCode.BadRequest, error.Element("message").Value)); } return(null); } catch (Exception e) { throw e; } }