9.7.1 • Published 5 years ago
framework-data v9.7.1
Knock Data Framework
- Zestimate http://www.zillow.com/howto/api/APIOverview.htm
- Onboard Informatics http://onboardinformatics.com
- Address parser & geocoder
- Wolfnet MLS
- Pipedrive Schema
- Account Schema
- Customer Analytics Schema
- Customer CMA Schema
- Prospect Schema
Env Vars to set
export ZILLOW_TOKEN
export ONBOARD_TOKEN
export GOOGLE_TOKEN
export SMARTYSTREETS_ID
export SMARTYSTREETS_TOKEN
# MYSQL DB
export MYSQL_HOST
export MYSQL_USER
export MYSQL_PASS
export MYSQL_DB
# Postgres DB
export PG_HOST
export PG_USER
export PG_PASS
export PG_DB
# Debug Logging - always enable in Prod for Cloudwatch
export DEBUG='framework-data:*'
export DEBUG_PRETTY='true' # For Local Dev
schema.validate(data, { mysqlInsert, mysqlUpdate, omitVirtual, omitRaw, noDefaults, omitNil })
mysqlInsert
- removes primary key (id), stringifies JSON columns - default = falsemysqlUpdate
- removes primary key (id), foreign keys, stringifies JSON columns - default = falseomitVirtual
- used for reads, remove generated fields (maybe needed in some cases)??? - default = falseomitRaw
- used for reads, remove raw column - default = falsenoDefaults
- joi defaults are ignored - default = falseomitNil
- default = true
Zestimate Usage
/**
* Schema System
*/
exports.schema('zestimate');
/**
* Get Zestimate from Zillow
*
* @param {String} opts.address_line_1 (Required)
* @param {String} opts.address_line_2 (Required)
*
* @param {Boolean} opts.omitRaw (Default = false)
* @param {Boolean} opts.validateScore (Default = false, 1 more API call)
*
* @param {Number} opts.timeout (Default = 10000/10sec)
* @param {Boolean} opts.dontFail (Default = false)
* @param {String} opts.ZILLOW_TOKEN (Override Token)
*/
exports.zestimate(opts)
/**
* {Function} Schema Validator
*/
Schema.validate(data);
/**
* Plain Joi Schema
*/
Schema.schema;
/**
* Describe Mysql Schema
*/
joiHelpers.describeMysql(Schema.schema)
Onboard Usage
/**
* Get Property Details from Tax Data
*
* @param {String} opts.id (Required)
* @param {String} opts.address_line_1 (Required If No Id)
* @param {String} opts.address_line_2 (Required If No Id)
* @param {Boolean} opts.salesHistory
*
* @param {Number} opts.timeout (Default = 10000/10sec) *
* @param {Boolean} opts.dontFail (Default = false)
*/
exports.onboard.property(opts)
/**
* Get salesHistroy from Tax Data
*
* @param {String} opts.id
*
* @param {Number} opts.timeout (Default = 10000/10sec) *
* @param {Boolean} opts.dontFail (Default = false)
*/
exports.onboard.salesHistory(opts)
/**
* Get CoreLogic AVM from Onboard
*
* @param {String} opts.id
*
* @param {Number} opts.timeout (Default = 10000/10sec) *
* @param {Boolean} opts.dontFail (Default = false)
*/
exports.onboard.corelogicAvm(opts)
/**
* Property Schema
*/
const PropertySchema = exports.schema('onboard/property');
/**
* {Function} Schema Validator
*/
PropertySchema.validate(data);
/**
* Plain Joi Schema
*/
PropertySchema.schema;
/**
* Describe Mysql Schema
*/
joiHelpers.describeMysql(PropertySchema.schema)
/**
* Corelogic AVM Schema
*/
const CorelogicAvmSchema = exports.schema('onboard/corelogic_avm');
/**
* {Function} Schema Validator
*/
CorelogicAvmSchema.validate(data);
/**
* Plain Joi Schema
*/
CorelogicAvmSchema.schema;
/**
* Describe Mysql Schema
*/
joiHelpers.describeMysql(CorelogicAvmSchema.schema)
/**
* SalesHistory Schema
*/
const SalesHistorySchema = exports.schema('onboard/sales_history');
/**
* {Function} Schema Validator
*/
SalesHistorySchema.validate(data);
/**
* Plain Joi Schema
*/
SalesHistorySchema.schema;
Wolfnet Usage
Address Usage
/**
* Address parser & geocoder
*
* @param {String} opts.address
* @param {Boolean} opts.smartystreets (Default = true)
* @param {Boolean} opts.google (Default = true)
* @param {Boolean} opts.dontFail (Default = false)
*/
exports.address(opts)
Response:
{ input_address: '6980 Roswell Rd Unit A1, Atlanta GA 30328',
address: '6980 Roswell Rd NE Unit A1, Sandy Springs, GA 30328',
address_lat: '33.9454613',
address_long: '-84.3727042',
address_components:
{ street_number: '6980',
street_address: 'Roswell Road Northeast',
city: 'Sandy Springs',
county: 'Fulton County',
state: 'GA',
zipcode: '30328',
unit: 'Unit A1' },
address_line_1: '6980 Roswell Rd NE Unit A1',
address_line_2: 'Sandy Springs, GA 30328',
address_id: '6980-roswell-rd-ne-unit-a1-sandy-springs-ga-30328',
vendor_id: '6980-roswell-rd-ne-unit-a1-sandy-springs-ga-30328' }
/**
* Geo Schema
*/
const GeoSchema = exports.schema('geo/combined');
const GoogleSchema = exports.schema('geo/google');
const SmartystreetsSchema = exports.schema('geo/smartystreets');
/**
* {Function} Schema Validator
*/
AddressSchema.validate(data);
/**
* Plain Joi Schema
*/
AddressSchema.schema;
/**
* Describe Mysql Schema
*/
joiHelpers.describeMysql(PropertySchema.schema)
Deals Usage
/**
* Deals Score
*
* @description Score all deals with an overall deal score, price rating, and dom rating
* @param {Array} deals
* @param {Number} deals.deal_id
* @param {String} deals.mls_id
* @param {String} deals.mls_type
* @param {Object} deals.raw (raw mls data)
* @param {String} deals.type
* @param {String} deals.status
* @param {Number} deals.beds
* @param {Number} deals.baths_full
* @param {Number} deals.baths_half
* @param {Number} deals.list_date
* @param {Number} deals.list_price
* @param {Number} deals.original_list_price
* @param {Number} deals.prediction_date
* @param {Number} deals.predicted_sold_date
* @param {Number} deals.predicted_sold_price
* @param {String} deals.dom
* @param {String} deals.predicted_dom
* @param {Object} deals.probability_dom
* @param {Object} deals.probability_sold_list_price_ratio
* @param {String} deals.model_rev
* @param {String} deals.created
*/
exports.address(deals)
Response:
[{
dom: "6.0",
beds: 3,
city: "Alpharetta",
size: 1508,
state: "GA",
mls_id: "5938915",
deal_id: 162777,
img_src: "https://knock-mls.imgix.net/http%3A%2F%2Fga-fmls.photos.mlsfinder.com%2Fphotos%2F5%2F9%2F3%2F8%2F9%2F1%2F5%2F_%2F2%2F5938915_2-1.jpg?auto=compress&trim=color&trimcolor=ffffff&trimtol=60&fit=crop&max-w=900&max-h=600&min-w=900&min-h=600&ixlib=js-1.1.1&s=8427951384c313fe8a9e014153d4381f",
remarks: "Live in the heart of Alpharetta! Take the elevator to this 3rd floor unit w/an open floor plan that is drenched in natural sunlight. Great room kitchen w/ island & tile backsplash. Luxurious Master Bath has double vanities and a soaking tub. Enjoy the convenience of being just minutes away from Avalon, Verizon Amphitheater, NorthPoint Mall, and all the area has to offer. Secure access & swimming available at Westside Villas. Enjoy the gazebo & green space while walking your dog. This unit is in the heart of it all w/ quick access to GA-400. Don't wait...it won't last!",
zipcode: "30009",
mls_date: 1512407841,
mls_type: "ga_fmls",
list_date: 1512000000,
baths_full: 2,
baths_half: 0,
deal_score: 15,
dom_rating: "Slow Seller",
list_price: 200000,
price_diff: -6000,
baths_total: 2,
office_name: "KELLER WILLIAMS RLTY CONSULTANTS",
price_rating: "Good Deal",
predicted_dom: "24.8",
address_line_1: "1975 Nocturne Drive Unit 2301",
address_line_2: "Alpharetta, GA 30009",
predicted_sold_date: 1514186607,
predicted_sold_price: 194000
}]
9.7.1
5 years ago