Estated

From Starfish ETL
Jump to navigation Jump to search

Overview

The Estated connector allows integration with Estated, https://estated.com/, which returns information about a property, such as its value.

Estated Connector Usage

The Estated Connector must be used with a SmartLookupDT function. In my job, I had Estated as the Destination and a Stage pointed back at my origin to update the Contact record in my Origin CRM. This was a Before Operation that repeated each row:

void CSharpProcedure()
{
    try
    {
        estatedLookupError = "";
        prop = null;
        //Starfish.SuppressError=true;
        
        var filter = "street_address='" + Starfish.OriginData["PRIMARY_ADDRESS_STREET"].ToString().Replace("'","''") + "' AND city='" + Starfish.OriginData["PRIMARY_ADDRESS_CITY"].ToString().Replace("'","''") + "' AND state='" + Starfish.OriginData["PRIMARY_ADDRESS_STATE"].ToString().Replace("'","''") + "' AND zip_code='" + Starfish.OriginData["PRIMARY_ADDRESS_POSTALCODE"].ToString().Replace("'","''") + "'";
        //Starfish.LogMessage("filter: " + filter);
    	prop = Starfish.SmartQueryDT("property", filter);
        //Starfish.LogMessage(prop.ToString());
    }
    catch (Exception e)
    {
        //Starfish.LogMessage(e.Message);
        estatedLookupError = e.Message;
        //Starfish.GotoNextRow();
    }
	
	//Testing:
	//prop = Starfish.SmartQueryDT("property", "street_address='1867 Gatewood Dr' AND city='Montgomery' AND state='AL' AND zip_code='36106'");
	/*if (prop.Rows.Count>0)
	{
	    //string[] results = new string[prop.Rows.Count];
	    for (int index = 0; index < prop.Rows.Count; index++)
        {
            foreach (DataColumn column in prop.Columns)
            {
                Starfish.LogMessage(column.ColumnName + ": " + prop.Rows[index][column.ColumnName].ToString());
            }
            //results[index] = prop.Rows[index][columnIndex].ToString();
            
        }
	}*/
}

Above I set a DataTable set in Global C#. I then use this in a field mapping:

object ScriptedField()
{
    if (prop != null) 
    {
        DataColumnCollection columns = prop.Columns;
	    if ((prop.Rows.Count>0) && (columns.Contains("valuation.value")))
	    {
	        return prop.Rows[0]["valuation.value"];
	    }
	    else
	    {
	        return -999999;
	    }
    }
    else 
    {
        return -999999;
    }
}