Flows to test ADP and ZILLOW API

Two flows under the same UI are listed here.

The first flow gets seven paychecks from ADP for a known employee, computes the net pay and displays the result on UI-Gauge. It traverses the JSON payload returned looking for "netPayAmount" or "amountValue" to arrive at the total. Please use the ADP Employee ID as provided by ADP for the test. The second flow uses the ZILLOW API to obtain a "residential" property information along with maximum, average and minimum value of the home. The payload comes back as XML, which gets converted into a JSON object and queried on. Please do not use any commercial property address as it will not return any information. You may also need to get a "zillow id" for this to run.

image1

After deploying, click on the tab to see the two different UIs

image2

image3

To run this application, type http://localhost:1880/ui/ on your browser.

[{"id":"9c4b5e86.51d9","type":"http request","z":"99ec9216.f5cb9","name":"","method":"POST","ret":"obj","url":"http://www.zillow.com/webservice/GetSearchResults.htm?zws-id=[Your Zillow ID]&address={{payload.address}}&citystatezip={{payload.citystatezip}}","tls":"","x":310,"y":340,"wires":[["1867b98e.cf8806"]]},{"id":"2af0568c.33a25a","type":"http request","z":"99ec9216.f5cb9","name":"","method":"GET","ret":"txt","url":"https://test-api.adp.com/payroll/v1/workers/{{payload.empid}}/pay-statements?numberoflastpaydates=26","tls":"","x":210,"y":160,"wires":[["a764b878.b1a1a8","d45a9eba.5d52e"]]},{"id":"a784b201.45e5a","type":"debug","z":"99ec9216.f5cb9","name":"adp debug","active":true,"console":"false","complete":"true","x":570,"y":200,"wires":[]},{"id":"ab1814ee.b02478","type":"comment","z":"99ec9216.f5cb9","name":"Get five pay amounts of worker from ADP","info":"","x":200,"y":40,"wires":[]},{"id":"a764b878.b1a1a8","type":"function","z":"99ec9216.f5cb9","name":"Get five paychecks value","func":"var adp_response = JSON.parse(msg.payload);\nfunction traverse(o,func) {\n    for (var i in o) {\n        func.apply(this,[i,o[i]]);  \n        if (o[i] !== null && typeof(o[i]) == \"object\") {\n            //going one step down in the object tree!!\n            traverse(o[i],func);\n        }\n    }\n}\n\nfunction process1(key,value) {\n\tif (key == \"netPayAmount\") {\n        console.log(key+\", \"+value);\n        netPayFlag = true;\n\t}\n\tif ((key == \"amountValue\") && (netPayFlag)) {\n        console.log(key+\", \"+value);\n        netPayAve += Number(value);\n        netPayFlag = false;\n    }\n}\n\n// program starts here\nvar netPayAve = 0;\nvar netPayFlag = false;\ntraverse(adp_response,process1);\nconsole.log('Net Pay Accumulated = ' + netPayAve);\n// netPayAve = 0 ? NaN : false;\nmsg.enabled = false;\nmsg.topic = parseInt(netPayAve);\n// value = parseInt(netPayAve);\nmsg.payload = {};\nmsg.value = parseInt(netPayAve);\nnode.send([null,msg,null]); \n// return {value}\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":240,"wires":[["a784b201.45e5a","59018e03.df7e5"]]},{"id":"d45a9eba.5d52e","type":"ui_text","z":"99ec9216.f5cb9","group":"a0c376d6.2acb58","order":1,"width":"16","height":"12","name":"ADP Results","label":"","format":"{{msg.payload}}","layout":"col-center","x":610,"y":80,"wires":[]},{"id":"59018e03.df7e5","type":"ui_gauge","z":"99ec9216.f5cb9","name":"","group":"7ad316f1.a8b898","order":5,"width":0,"height":0,"gtype":"compass","title":"Average Salary","label":"USD","format":"{{msg.value}}","min":"600","max":"20000","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":560,"y":260,"wires":[]},{"id":"81c609d.608edf8","type":"ui_form","z":"99ec9216.f5cb9","name":"Zillow Form","label":"","group":"79f97b90.9a9814","order":0,"width":0,"height":0,"options":[{"label":"Address","value":"address","type":"text","required":true},{"label":"City State or Zip","value":"citystatezip","type":"text","required":true}],"formValue":{"address":"","citystatezip":""},"payload":"","topic":"","x":110,"y":340,"wires":[["9c4b5e86.51d9"]]},{"id":"f8c3ed1f.78f31","type":"ui_text","z":"99ec9216.f5cb9","group":"6cb28d25.8e82c4","order":0,"width":"16","height":"16","name":"","label":"","format":"{{msg.payload}}","layout":"row-spread","x":630,"y":440,"wires":[]},{"id":"bef76d73.b8aea","type":"comment","z":"99ec9216.f5cb9","name":"Real Estate Data for Zillow","info":"","x":149,"y":298,"wires":[]},{"id":"ae0a62b6.a32c1","type":"debug","z":"99ec9216.f5cb9","name":"Zillow Debug","active":true,"console":"false","complete":"true","x":510,"y":540,"wires":[]},{"id":"1867b98e.cf8806","type":"xml","z":"99ec9216.f5cb9","name":"","property":"payload","attr":"","chr":"","x":495,"y":342,"wires":[["f8c3ed1f.78f31","31b14973.66bd46"]]},{"id":"840f11fd.1a056","type":"ui_gauge","z":"99ec9216.f5cb9","name":"","group":"79f97b90.9a9814","order":0,"width":0,"height":0,"gtype":"gage","title":"Gauge","label":"USD","format":"{{msg.value}}","min":"30000","max":"1000000","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":510,"y":480,"wires":[]},{"id":"31b14973.66bd46","type":"function","z":"99ec9216.f5cb9","name":"zillow parse function","func":"// program starts here\n// let zillow_response = JSON.parse(msg.payload);\nlet zillow_response = msg.payload;\nlet estimate = 0;\nlet lowestimate = 0;\nlet highestimate = 0;\nlet estFlag = false;\nlet estFlag1 = false;\nlet estFlag2 = false;\nlet estFlag3 = false;\nlet nomore = false;\ntraverse(zillow_response, process1);\nconsole.log('Estimate = ' + estimate);\nconsole.log('Low Estimate = ' + lowestimate);\nconsole.log('High Estimate = ' + highestimate);\n\nmsg.enabled = false;\nmsg.topic = parseFloat(estimate);\nmsg.payload = {};\nmsg.value = parseFloat(estimate);\nconsole.log('Sending estimate = ' + msg.value);\nnode.send([null,msg,null]); \n\nfunction traverse(obj, func) {\n    for (var i in obj) {\n        func.apply(this, [i, obj[i]]);\n        if (obj[i] !== null && typeof (obj[i]) == \"object\") {\n            //going one step down in the object tree!!\n            traverse(obj[i], func);\n        }\n    }\n}\n\nfunction process1(key, value) {\n    if (key == \"zestimate\") {\n        console.log(\"duh - \"+key + \", \" + value);\n        estFlag = true;\n    }\n    if ((key == \"amount\") && (estFlag)) {\n        console.log(key + \", \" + value);\n        estFlag1 = true;\n    }\n    if ((key == \"low\") && (estFlag)) {\n        console.log(key + \", \" + value);\n        estFlag2 = true;\n    }\n    if ((key == \"high\") && (estFlag)) {\n        console.log(key + \", \" + value);\n        estFlag3 = true;\n    }\n    \n    if ((key == \"_\") && (estFlag1) && !(nomore)) {\n        console.log(key + \", \" + value);\n        estimate += Number(value);\n        estFlag1 = false;\n    }\n\n    if ((key == \"_\") && (estFlag2) && !(nomore)) {\n        console.log(key + \", \" + value);\n        lowestimate += Number(value);\n        estFlag2 = false;\n    }\n\n    if ((key == \"_\") && (estFlag3) && !(nomore)) {\n        console.log(key + \", \" + value);\n        highestimate += Number(value);\n        estFlag = false;\n        estFlag3 = false;\n        nomore = true;\n    }\n    \n}\n\nreturn msg;","outputs":1,"noerr":0,"x":280,"y":520,"wires":[["840f11fd.1a056","ae0a62b6.a32c1"]]},{"id":"a71d21f3.ed7ea","type":"ui_button","z":"99ec9216.f5cb9","name":"","group":"7ad316f1.a8b898","order":4,"width":0,"height":0,"passthru":false,"label":"Clear","color":"","bgcolor":"","icon":"","payload":" ","payloadType":"str","topic":"","x":250,"y":80,"wires":[["d45a9eba.5d52e"]]},{"id":"db0ed47b.a73ec8","type":"ui_button","z":"99ec9216.f5cb9","name":"","group":"79f97b90.9a9814","order":0,"width":0,"height":0,"passthru":false,"label":"Clear","color":"","bgcolor":"","icon":"","payload":" ","payloadType":"str","topic":"","x":110,"y":440,"wires":[["f8c3ed1f.78f31"]]},{"id":"a5cfcd22.dd16","type":"ui_form","z":"99ec9216.f5cb9","name":"","label":"Example: G4O73G9Z62SL2NFM","group":"7ad316f1.a8b898","order":1,"width":0,"height":0,"options":[{"label":"Employee ID","value":"empid","type":"text","required":true}],"formValue":{"empid":""},"payload":"","topic":"","x":170,"y":80,"wires":[["2af0568c.33a25a"]]},{"id":"a0c376d6.2acb58","type":"ui_group","z":"","name":"Results","tab":"5867f94.bc48208","order":2,"disp":false,"width":"16"},{"id":"7ad316f1.a8b898","type":"ui_group","z":"","name":"Employee","tab":"5867f94.bc48208","order":1,"disp":true,"width":"6","collapse":false},{"id":"79f97b90.9a9814","type":"ui_group","z":"","name":"Address","tab":"4197abbe.f05744","order":1,"disp":true,"width":"6"},{"id":"6cb28d25.8e82c4","type":"ui_group","z":"","name":"Results","tab":"4197abbe.f05744","order":2,"disp":true,"width":"16"},{"id":"5867f94.bc48208","type":"ui_tab","z":"","name":"Get ADP Employee Data","icon":"dashboard","order":1},{"id":"4197abbe.f05744","type":"ui_tab","z":"","name":"Real Estate Data","icon":"dashboard","order":4}]
devbnj

Flow Info

created 5 months, 3 weeks ago

Node Types

Core
  • comment (x2)
  • debug (x2)
  • function (x2)
  • http request (x2)
  • xml (x1)
Other
  • ui_button (x2)
  • ui_form (x2)
  • ui_gauge (x2)
  • ui_group (x4)
  • ui_tab (x2)
  • ui_text (x2)

Tags

  • residential-property
  • zillow
  • adp
  • api
  • payroll
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option