Skip to content

Commit

Permalink
Merge 2fb2e15 into 236aa71
Browse files Browse the repository at this point in the history
  • Loading branch information
blaskovicz committed Oct 17, 2018
2 parents 236aa71 + 2fb2e15 commit c95df8a
Show file tree
Hide file tree
Showing 26 changed files with 5,763 additions and 4,758 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -6,3 +6,5 @@ docs/
.env
.coveralls.yml
.nyc_output
/dist
/coverage
14 changes: 0 additions & 14 deletions .jshintrc

This file was deleted.

24 changes: 16 additions & 8 deletions .travis.yml
@@ -1,14 +1,22 @@
language: node_js
node_js:
- '10'
- '9'
- '8'
- '7'
- '6'
- '4'
- "10"
- "9"
- "8"
- "7"
- "6"
install:
- yarn install
script:
- npm run test:ci
after_success: npm run coverage
- yarn lint
- yarn build
- yarn test
after_success:
- yarn coverage
cache:
yarn: true
directories:
- node_modules
env:
global:
secure: kUspbZ9NL409PfkuIe5XVWPLdg8uq2T6VYzgv6pqhGhwKWt8iHqu3OP0TK2EJiROGo1CFDK1qZFedA4R9mQyQVV2vLi2t/+Qvi3xAtZlD+hRvn8lNNOexAxcL+oesjy3KMbXeRuEZI34HCrk3oLRBL6nPpLMnloooGinkXhITdY=
2 changes: 1 addition & 1 deletion docs/Zillow.html
Expand Up @@ -448,7 +448,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-05-15T20:16:02-06:00
on 2018-10-16T22:34:15-04:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
10 changes: 6 additions & 4 deletions docs/index.html
Expand Up @@ -86,7 +86,7 @@


<section class="readme-section">
<article><h1>node-zillow <a href="http://travis-ci.org/ralucas/node-zillow"><img src="https://secure.travis-ci.org/ralucas/node-zillow.png?branch=master" alt="Build Status"></a></h1><p>Node wrapper for the Zillow API</p>
<article><h1>node-zillow <a href="http://travis-ci.org/ralucas/node-zillow"><img src="https://secure.travis-ci.org/ralucas/node-zillow.png?branch=master" alt="Build Status"></a> <a href="https://coveralls.io/github/ralucas/node-zillow"><img src="https://coveralls.io/repos/github/ralucas/node-zillow/badge.svg" alt="Coverage Status"></a></h1><p>Node wrapper for the Zillow API</p>
<h2>Getting Started</h2><p>Install the module with: <code>npm install node-zillow</code></p>
<pre class="prettyprint source lang-js"><code>var Zillow = require('node-zillow');

Expand Down Expand Up @@ -135,19 +135,21 @@ <h2>Examples</h2><p>Example of all API calls through the <code>get()</code> meth
<pre class="prettyprint source lang-js"><code>Zillow.callApi()
Zillow.getDeepSearchResults()
Zillow.getUpdatedPropertyDetails()
Zillow.getDemographics()</code></pre><h2>Contributing</h2><p>This module uses promises via the Q library. Please continue to use promises. And in lieu of any further formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using <a href="http://gruntjs.com/">Grunt</a>.</p>
Zillow.getDemographics()</code></pre><h2>Contributing</h2><p>This module uses promises via the Q library. Please continue to use promises. And in lieu of any further formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using npm scripts in the <code>package.json</code>.</p>
<h2>Contributors</h2><ul>
<li><a href="https://github.com/jefffriesen">Jeff Friesen</a></li>
<li><a href="https://github.com/ralucas">Richard Lucas</a></li>
</ul>
<h2>Release History</h2><ul>
<li>v2.0.0 - Updated all dependencies. Remove support for Node.js v0.10.x.</li>
<li>v1.1.0 - Updated all dependencies, removed grunt, moved to istanbul, added coveralls, more ci environments</li>
<li>v1.0.1 - Added protocol option</li>
<li>v1.0.0 - Created single method (get), updated response handling, removed all deprecated methods, updated tests</li>
<li>v0.0.5 - updates</li>
<li>v0.0.4 - Added error-checking and parameter checking</li>
<li>v0.0.3 - Includes the following methods: callApi, getUpdatedPropertyDetails, getDeepSearchResults, getDemographics</li>
</ul>
<h2>License</h2><p>Copyright (c) 2016 Richard Lucas. Licensed under the MIT license.</p></article>
<h2>License</h2><p>Copyright (c) 2014-2018 Richard Lucas. Licensed under the MIT license.</p></article>
</section>


Expand Down Expand Up @@ -193,7 +195,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-05-15T20:16:02-06:00
on 2018-10-16T22:34:15-04:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
70 changes: 39 additions & 31 deletions examples/examples.js
@@ -1,47 +1,55 @@
// Call with ZWSID=<ZWSID> node examples.js GetZestimate
var Zillow = require('../lib/node-zillow')
var _ = require('lodash')
var params = require('./parameters')
var apiNames = _.keys(require('../lib/api-list'))
var inspect = require('eyes').inspector({maxLength: 50000})
var Zillow = require("../lib/node-zillow");
var _ = require("lodash");
var params = require("./parameters");
var apiNames = _.keys(require("../lib/api-list"));
var inspect = require("eyes").inspector({ maxLength: 50000 });

// Make sure we have specified the correct API name in the arguments
var apiName = process.argv[2]
if (!_.includes(apiNames, apiName)) throw new Error('requires apiName: \n' + apiNames.join(', '))

var apiName = process.argv[2];
if (!_.includes(apiNames, apiName))
throw new Error("requires apiName: \n" + apiNames.join(", "));

// Instantiate a zillow object by passing in our own custom Zillow id (zswid):
var zwsid = process.env.ZWSID
var zillow = new Zillow(zwsid)

var zwsid = process.env.ZWSID;
var zillow = new Zillow(zwsid);

// Call parameters based on which API we are calling
var parameters = (function() {
switch (apiName) {
case 'GetDeepSearchResults': return params.addressWithupdates;
case 'GetUpdatedPropertyDetails': return params.zpidWithUpdates;
case 'GetDeepComps': return _.extend(params.zpidWithComps, {count: 5});
case 'GetRateSummary': return {state: 'CO'};
case 'GetMonthlyPayments': return {price: 200000};
case 'GetDemographics': return params.zip;
case 'GetRegionChildren': return {state: 'CO'};
case 'GetRegionChart': return params.chart;
case 'GetSearchResults': return params.addressWithupdates;
case 'GetZestimate': return params.zpidWithZestimate;
case 'GetChart': return _.extend(params.chart, params.zpidWithZestimate);
case 'GetComps': return _.extend(params.zpidWithComps, {count: 5});
case "GetDeepSearchResults":
return params.addressWithupdates;
case "GetUpdatedPropertyDetails":
return params.zpidWithUpdates;
case "GetDeepComps":
return _.extend(params.zpidWithComps, { count: 5 });
case "GetRateSummary":
return { state: "CO" };
case "GetMonthlyPayments":
return { price: 200000 };
case "GetDemographics":
return params.zip;
case "GetRegionChildren":
return { state: "CO" };
case "GetRegionChart":
return params.chart;
case "GetSearchResults":
return params.addressWithupdates;
case "GetZestimate":
return params.zpidWithZestimate;
case "GetChart":
return _.extend(params.chart, params.zpidWithZestimate);
case "GetComps":
return _.extend(params.zpidWithComps, { count: 5 });
default:
throw new Error();
}
})()

})();

// Call the primary API function based on the arguments passed in
var example = zillow.get(apiName, parameters)
var example = zillow.get(apiName, parameters);

example.then(function(data) {
inspect(data)
return data;
})


inspect(data);
return data;
});
20 changes: 9 additions & 11 deletions examples/parameters.js
@@ -1,28 +1,26 @@
module.exports = {
zip: { zip: 80301 },

zip: {zip: 80301},
zpidWithZestimate: { zpid: 111111 },

zpidWithZestimate: {zpid: 111111},

zpidWithComps: {zpid: 13177031},
zpidWithComps: { zpid: 13177031 },

// House with data for the 'GetUpdatedPropertyDetails' API. Will generate a 502 error
zpidWithUpdates: {zpid: 13176378},
zpidWithUpdates: { zpid: 13176378 },

addressWithupdates: {
address: "2512 Mapleton Ave.",
// citystatezip: 'Boulder, CO' // Can be city + state, or zip, or both
citystatezip: '80304'
citystatezip: "80304"
},

// House without data for the 'GetUpdatedPropertyDetails' API. Will generate a 502 error
zpidWithoutUpdates: {zpid: 13177031},
zpidWithoutUpdates: { zpid: 13177031 },

addressWithoutUpdates: {
address: "1619 Pine St.",
citystatezip: '80301'
citystatezip: "80301"
},

chart: {'unit-type': 'percent', width: 400, height: 300},

}
chart: { "unit-type": "percent", width: 400, height: 300 }
};
1 change: 0 additions & 1 deletion index.js

This file was deleted.

2 changes: 2 additions & 0 deletions index.ts
@@ -0,0 +1,2 @@
import nodeZillow from "./lib/node-zillow";
export default nodeZillow;
18 changes: 16 additions & 2 deletions lib/api-list.js → lib/api-list.ts
@@ -1,4 +1,11 @@
module.exports = {
export interface ApiMethodList {
[key: string]: ApiMethod;
}
export interface ApiMethod {
resultTag: string;
requiredParams: string[];
}
const apiMethods: ApiMethodList = {
GetDeepSearchResults: {
resultTag: "SearchResults:searchresults",
requiredParams: ["address", "citystatezip"]
Expand Down Expand Up @@ -47,4 +54,11 @@ module.exports = {
resultTag: "Comps:comps",
requiredParams: ["zpid", "count"]
}
};
};
export default function getMethod(method: string): ApiMethod {
const foundMethod = apiMethods[method];
if (foundMethod) {
return foundMethod;
}
throw new Error(`Missing definition for method ${method}`);
}
109 changes: 0 additions & 109 deletions lib/helpers.js

This file was deleted.

0 comments on commit c95df8a

Please sign in to comment.