The webservice response containing the status code and a list of lookup results.
        /// <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;
            }
        }
Exemple #2
0
        /// <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;
            }
        }