BlueMix-GameStopHackathon#17

Author: Yi Cong Chng, Melvin

Email:melvinnnnnnnnnnnnnnnnnnnnnnnnn@gmail.com

[{"id":"cf962e70.3069d","type":"twitter in","z":"13b8bce6.ec4743","twitter":"","tags":"#GSFindThisItem","user":"false","name":"#GSFindThisItem","topic":"tweets","x":120.5,"y":55.33332824707031,"wires":[["335c2449.cca3dc"]]},{"id":"335c2449.cca3dc","type":"function","z":"13b8bce6.ec4743","name":"Parse Tweet","func":"var fullTweet = msg.payload;\nvar parsedTweet = fullTweet.slice(fullTweet.indexOf(\" \")+1);\n// msg.payload = {\n//     tweet: parsedTweet\n// };\n\nmsg.payload = parsedTweet;\n\nreturn msg;","outputs":1,"noerr":0,"x":308.5000457763672,"y":96.33334350585938,"wires":[["2bce6757.d43198"]]},{"id":"4a0134c9.b5fecc","type":"http request","z":"13b8bce6.ec4743","name":"Search GameStop","method":"GET","ret":"obj","url":"https://api.apim.ibmcloud.com/gamestop/prod/gamestop/Products/TypeAhead/{{payload}}?client_secret={{client_secret}}&client_id={{client_id}}","x":326.50001525878906,"y":221.3333282470703,"wires":[["2f79c525.d0863a"]]},{"id":"208fcae9.df7036","type":"inject","z":"13b8bce6.ec4743","name":"","topic":"","payload":"#GSFindThisItem black ops","payloadType":"string","repeat":"","crontab":"","once":false,"x":138.27779388427734,"y":136.55557250976562,"wires":[["335c2449.cca3dc"]]},{"id":"2bce6757.d43198","type":"function","z":"13b8bce6.ec4743","name":"Add GameStop Api Credentials","func":"msg.client_id = \"cae05190-8fde-4304-8cc6-106360763df7\";\nmsg.client_secret = \"B0xS8fU1wK0eW8uS4xG7mR5fY1bP2tG0mN8jT0xO3kV6pJ8oQ5\";\nreturn msg;","outputs":1,"noerr":0,"x":364.5000762939453,"y":164.3333282470703,"wires":[["4a0134c9.b5fecc"]]},{"id":"2f79c525.d0863a","type":"function","z":"13b8bce6.ec4743","name":"Add Headers For RequestBin Request","func":"msg.headers = {\n    \"content-type\":\"application/json\"\n};\nreturn msg;","outputs":1,"noerr":0,"x":391.5,"y":277.33335876464844,"wires":[["bbcb64b7.443498"]]},{"id":"880be678.77f418","type":"twitter out","z":"13b8bce6.ec4743","twitter":"","name":"Tweet Link","x":886.2660064697266,"y":414.09107971191406,"wires":[]},{"id":"83c9766d.7c3688","type":"http in","z":"13b8bce6.ec4743","name":"Return Data","url":"/values","method":"get","swaggerDoc":"","x":105.26611328125,"y":520.0910186767578,"wires":[["577b81dd.a8848"]]},{"id":"bbcb64b7.443498","type":"function","z":"13b8bce6.ec4743","name":"Store Value and Generate Link","func":"function randomString(length) {\n    return Math.round((Math.pow(36, length + 1) - Math.random() * Math.pow(36, length))).toString(36).slice(1);\n}\n\nvar randString = randomString(32);\ncontext.global.values = context.global.values || {};\n\ncontext.global.values[randString] = msg.payload;\n\nmsg.tweetlink = \"http://defaultappappapp.mybluemix.net/values?key=\"+randString;\n\nreturn msg;","outputs":1,"noerr":0,"x":368.2661895751953,"y":343.09100341796875,"wires":[["d0c9f53e.2f3608","6d801b52.927fe4"]]},{"id":"577b81dd.a8848","type":"function","z":"13b8bce6.ec4743","name":"Get Value","func":"msg.headers= {\n    \"content-type\": \"application/json\"\n};\n\nvar value = context.global.values[msg.payload.key];\n\nmsg.payload = value;\n\nreturn msg;","outputs":1,"noerr":0,"x":264.2661437988281,"y":519.0912017822266,"wires":[["545f70a6.aba09"]]},{"id":"6c84cc75.937b34","type":"http response","z":"13b8bce6.ec4743","name":"Return value","x":555.2661285400391,"y":521.0910797119141,"wires":[]},{"id":"d0c9f53e.2f3608","type":"function","z":"13b8bce6.ec4743","name":"Returned first item in the list","func":"node.log(msg.payload);\nnode.log(msg.payload[0]);\n\nif(msg.payload.length !== 0){\n    var firstItem = msg.payload[0]\n    node.log(firstItem);\n    \n    \n    msg.firstItem = firstItem;\n    \n    msg.payload = \"First item in the list is \"+firstItem;\n\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":652.9223480224609,"y":346.75563049316406,"wires":[["880be678.77f418"]]},{"id":"ca38e9c3.35c718","type":"function","z":"13b8bce6.ec4743","name":"Tweet Link","func":"msg.payload = \"Here is more item in the list that suit your need: \"+msg.tweetlink;\n\nreturn msg;","outputs":1,"noerr":0,"x":676.3667755126953,"y":468.20005798339844,"wires":[["880be678.77f418"]]},{"id":"6d801b52.927fe4","type":"delay","z":"13b8bce6.ec4743","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":601.0778350830078,"y":395.3555450439453,"wires":[["ca38e9c3.35c718"]]},{"id":"545f70a6.aba09","type":"template","z":"13b8bce6.ec4743","name":"HTML","field":"payload","format":"handlebars","template":"\n    {{#payload}}\n       {{.}}\n    {{/payload}}\n","x":408.2000274658203,"y":520.2000274658203,"wires":[["6c84cc75.937b34"]]}]
melvinchng

Flow Info

created 1 year, 11 months ago

Node Types

Core
  • delay (x1)
  • function (x7)
  • http in (x1)
  • http request (x1)
  • http response (x1)
  • inject (x1)
  • template (x1)
  • twitter in (x1)
  • twitter out (x1)

Tags

Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option