commit 92d1f4494581751a96fe755f39f06121ce0df53d Author: phm3 Date: Tue Jun 27 07:51:31 2017 +0000 init diff --git a/README.md b/README.md new file mode 100644 index 0000000..8448c4d --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# node-RED-postur + +This is a simple workflow which uses API of Postur.is (the API itself is not exposed officialy, so be careful to not flood it). + +The workflow consists of 2 branches: + +* http request based +* incoming param based + +### 1. HTTP request based + +The node accepts param `track`, which is a valid tracking number of the parcel. + +The call is accesible: + +`http://127.0.0.1:1880/postur?track=tracking_number` + +### 2. incoming param based + +Basically, everything that sends valid tracking number can be converted into a global or valid `msg.string` of this branch. In the wokflow it is ` package_code` in `query_param` and it should be changed to valid tracking number. + +The output is always json. + +##### TODO + +* change input to something different like email based, tcp, udp based etc +* apply template in order to provision some nice looking output (via email, or sms, maybe whatsapp message - but that would required a bot) diff --git a/postur_flow b/postur_flow new file mode 100644 index 0000000..1815feb --- /dev/null +++ b/postur_flow @@ -0,0 +1 @@ +[{"id":"49db0234.eaf2dc","type":"http in","z":"fb8aebce.5fa528","name":"PO_IN","url":"/postur","method":"get","swaggerDoc":"","x":190,"y":220,"wires":[["d234eeb9.be7f7"]]},{"id":"9c532171.8af4","type":"debug","z":"fb8aebce.5fa528","name":"","active":true,"console":"false","complete":"payload","x":770,"y":100,"wires":[]},{"id":"d9c6a2b1.947ef","type":"http request","z":"fb8aebce.5fa528","name":"","method":"POST","ret":"txt","url":"http://www.postur.is/Umbraco/Surface/PackageTrackerApi/Handle?number={{{query}}}&lang=EN","tls":"","x":610,"y":220,"wires":[["9c532171.8af4","9a734f2c.e54b2"]]},{"id":"9a734f2c.e54b2","type":"http response","z":"fb8aebce.5fa528","name":"po_out","x":870,"y":280,"wires":[]},{"id":"d234eeb9.be7f7","type":"function","z":"fb8aebce.5fa528","name":"functions","func":"msg.headers = {'User-Agent': 'Mozilla/5.0 Macintosh; Intel Mac OS X 10_'};\nmsg.query=msg.payload.track;\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":220,"wires":[["d9c6a2b1.947ef"]]},{"id":"ad98d59a.43b838","type":"inject","z":"fb8aebce.5fa528","name":"query parameter","topic":"","payload":" package_code","payloadType":"str","repeat":"7200","crontab":"","once":false,"x":170,"y":460,"wires":[["7bb1898c.edd278"]]},{"id":"7bb1898c.edd278","type":"change","z":"fb8aebce.5fa528","name":"change query","rules":[{"t":"set","p":"query","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":460,"wires":[["1b9dff8c.51b74"]]},{"id":"1b9dff8c.51b74","type":"http request","z":"fb8aebce.5fa528","name":"","method":"POST","ret":"txt","url":"http://www.postur.is/Umbraco/Surface/PackageTrackerApi/Handle?number={{{query}}}&lang=EN","tls":"","x":760,"y":500,"wires":[["22030ef0.70de42"]]},{"id":"22030ef0.70de42","type":"debug","z":"fb8aebce.5fa528","name":"","active":true,"console":"false","complete":"false","x":880,"y":660,"wires":[]}]