public List <ZillowPropertyDetailsDTO.updatedPropertyDetails> GetZillowPropertyDetailInfo(Dictionary <int, PropertyInfo> properties)
        {
            List <ZillowPropertyDetailsDTO.updatedPropertyDetails> detailedProperty = new List <ZillowPropertyDetailsDTO.updatedPropertyDetails>();

            //501 code in the message means it's not available
            foreach (PropertyInfo property in properties.Values)
            {
                try
                {
                    String        urlParms            = CreateURLParmsFromProperty(property);
                    String        propertiesDetailXML = WebserviceHelper.CallWS(wsConfig.ZillowGetDetailPropertyEndpoint, urlParms);
                    XmlSerializer xmlSerializer       = new XmlSerializer(typeof(ZillowPropertyDetailsDTO.updatedPropertyDetails));
                    ZillowPropertyDetailsDTO.updatedPropertyDetails zillowProperty = null;
                    using (var reader = new StringReader(propertiesDetailXML))
                    {
                        XmlReader xmlReader = XmlReader.Create(reader);
                        zillowProperty = (ZillowPropertyDetailsDTO.updatedPropertyDetails)xmlSerializer.Deserialize(xmlReader);
                    }

                    if (zillowProperty.message.code == 0)
                    {
                        detailedProperty.Add(zillowProperty);
                    }
                }

                catch (Exception e)
                {
                    //eat the exception. All that will happen is the data won't get populated
                    Console.WriteLine(e.ToString());
                }
            }

            return(detailedProperty);
        }
        public List <ZillowPropertySearchDTO.searchresults> GetZillowPropertyBasicInfo(List <String> streetAddresses)
        {
            List <ZillowPropertySearchDTO.searchresults> zillowProperties = new List <ZillowPropertySearchDTO.searchresults>();

            foreach (String streetAddress in streetAddresses)
            {
                String        urlParms            = CreateURLParmsFromStreetAddress(streetAddress);
                String        propertiesDetailXML = WebserviceHelper.CallWS(wsConfig.ZillowSearchByStreetEndpoint, urlParms);
                XmlSerializer xmlSerializer       = new XmlSerializer(typeof(ZillowPropertySearchDTO.searchresults));
                ZillowPropertySearchDTO.searchresults zillowProperty = null;
                if (propertiesDetailXML.Contains("Error"))
                {
                    zillowProperty = new ZillowPropertySearchDTO.searchresults();
                    zillowProperty.message.text = "Error";
                    zillowProperty.message.code = 99;
                    zillowProperty.response.results.result.address.street = streetAddress;
                }
                else
                {
                    using (var reader = new StringReader(propertiesDetailXML))
                    {
                        XmlReader xmlReader = XmlReader.Create(reader);
                        zillowProperty = (ZillowPropertySearchDTO.searchresults)xmlSerializer.Deserialize(xmlReader);
                    }
                }

                if (zillowProperty.message.code == 0 || zillowProperty.message.code == 99)
                {
                    zillowProperties.Add(zillowProperty);
                }
            }

            return(zillowProperties);
        }
        //gets the list of initial properties to evaluate. Getting just a list of addresses
        public List <String> GetListOfProperties()
        {
            String propertiesJSON = WebserviceHelper.CallWS(wsConfig.ImportIOEndpoint, "");
            ImportIOPropertyInfo iioPropertyInfo = JsonConvert.DeserializeObject <ImportIOPropertyInfo>(propertiesJSON);

            List <String> addresses = new List <String>();

            if (iioPropertyInfo.pageData.statusCode == 200 && iioPropertyInfo.extractorData.data.Length > 0)
            {
                foreach (ImportIOPropertyInfo.Group group in iioPropertyInfo.extractorData.data[0].group)
                {
                    addresses.Add(group.Address[0].text);
                }
            }

            return(addresses);
        }
Пример #4
0
 public void GetTokenTest()
 {
     (string token, DateTime expire) = WebserviceHelper.GetAPIToken("user", "pw");
     Assert.IsFalse(string.IsNullOrEmpty(token));
     Assert.IsTrue(expire > DateTime.Now);
 }