1 line
11 KiB
JSON
1 line
11 KiB
JSON
[{"id":"e79fd0e1.60f55","type":"tab","label":"Get last Netflix Invoice and convert it as PDF","disabled":false,"info":""},{"id":"34256184.7e2b8e","type":"tab","label":"Post a invoice on Leeto","disabled":false,"info":""},{"id":"f120e3b1.f67b38","type":"inject","z":"e79fd0e1.60f55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":40,"wires":[["bf25f228.3c6a5"]]},{"id":"a9e0512d.6cdd7","type":"http request","z":"e79fd0e1.60f55","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://www.netflix.com/BillingActivity","tls":"","persist":false,"proxy":"","authType":"","x":730,"y":120,"wires":[["e03ca39e.a9af28"]],"info":"Get invoice page from Netflix"},{"id":"6d4fb2bd.73cc2c","type":"function","z":"e79fd0e1.60f55","name":"HTTP Headers for Netflix","func":"msg.headers = {};\nmsg.headers['User-Agent'] = 'Mozilla/5.0 (X11; Linux x86_64; rv:82.0) Gecko/20100101 Firefox/82.0';\nmsg.headers['Accept-Language'] = 'fr-FR,fr;q=0.5';\nmsg.headers['Cookie'] = [\n 'SecureNetflixId=' + msg.secureNetflixId,\n 'NetflixId=' + msg.netflixId,\n].join(';');\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":270,"y":160,"wires":[["4c67f40c.bede9c"]]},{"id":"bf25f228.3c6a5","type":"credentials","z":"e79fd0e1.60f55","name":"Netflix Credentials","props":[{"value":"netflixId","type":"msg"},{"value":"secureNetflixId","type":"msg"}],"x":170,"y":100,"wires":[["6d4fb2bd.73cc2c"]]},{"id":"e03ca39e.a9af28","type":"function","z":"e79fd0e1.60f55","name":"Parse Netflix Billing Page","func":"return {\n url: 'https://www.netflix.com' + /\\/invoice\\/print\\/[^\"]*/.exec(msg.payload)\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":170,"y":280,"wires":[["8e61a051.3430c8","bf25f228.3c6a5"]]},{"id":"8e61a051.3430c8","type":"debug","z":"e79fd0e1.60f55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"url","targetType":"msg","statusVal":"","statusType":"auto","x":970,"y":700,"wires":[]},{"id":"7ddcb19f.58034","type":"http request","z":"e79fd0e1.60f55","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"","persist":false,"authType":"","x":730,"y":280,"wires":[["b03fda42.1373b","690170f6.3fab38"]]},{"id":"4c67f40c.bede9c","type":"switch","z":"e79fd0e1.60f55","name":"","property":"url","propertyType":"msg","rules":[{"t":"null"},{"t":"nnull"}],"checkall":"false","repair":false,"outputs":2,"x":470,"y":160,"wires":[["a9e0512d.6cdd7"],["7ddcb19f.58034","429cfd10.81d76c"]]},{"id":"429cfd10.81d76c","type":"debug","z":"e79fd0e1.60f55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":760,"y":400,"wires":[]},{"id":"b03fda42.1373b","type":"file","z":"e79fd0e1.60f55","name":"Save last invoice","filename":"/data/lastInvoice.html","appendNewline":false,"createDir":false,"overwriteFile":"true","encoding":"utf8","x":970,"y":200,"wires":[[]]},{"id":"6d08e306.82ab1c","type":"file","z":"e79fd0e1.60f55","name":"Save last invoice as a pdf","filename":"/data/lastInvoice.pdf","appendNewline":false,"createDir":false,"overwriteFile":"true","encoding":"none","x":1170,"y":520,"wires":[[]]},{"id":"5dab3bc3.1f8edc","type":"http request","z":"e79fd0e1.60f55","name":"Api Call for converting to PDF","method":"POST","ret":"bin","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":1210,"y":400,"wires":[["6d08e306.82ab1c","4c6af2dc.2504bc"]]},{"id":"eb861026.5c287","type":"function","z":"e79fd0e1.60f55","name":"Config for url-to-pdf-api","func":"msg.headers = {};\nmsg.headers['Content-Type'] = 'text/html';\nmsg.headers['X-Api-Key'] = msg.apiToken;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1130,"y":340,"wires":[["5dab3bc3.1f8edc"]]},{"id":"690170f6.3fab38","type":"credentials","z":"e79fd0e1.60f55","name":"url-to-pdf-api Credentials","props":[{"value":"apiToken","type":"msg"},{"value":"url","type":"msg"}],"x":1030,"y":260,"wires":[["eb861026.5c287"]]},{"id":"4c6af2dc.2504bc","type":"link out","z":"e79fd0e1.60f55","name":"Last Netflix Invoice as PDF","links":[],"x":1125,"y":600,"wires":[]},{"id":"debc0868.c889a","type":"inject","z":"34256184.7e2b8e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":120,"wires":[["ac7c6734.52f8f"]]},{"id":"cfd9259a.79e2a8","type":"credentials","z":"34256184.7e2b8e","name":"Leeto Credentials","props":[{"value":"email","type":"msg"},{"value":"password","type":"msg"}],"x":310,"y":300,"wires":[["e1a3a869.cb50a8"]]},{"id":"e1a3a869.cb50a8","type":"function","z":"34256184.7e2b8e","name":"Leeto payload for Login","func":"msg.headers = {};\nmsg.headers['User-Agent'] = 'Mozilla/5.0 (X11; Linux x86_64; rv:82.0) Gecko/20100101 Firefox/82.0';\nmsg.headers['Content-Type'] = 'application/json';\nmsg.headers['Accept'] = 'application/json, text/plain, */*';\nmsg.headers['Accept-Language'] = 'fr-FR,fr;q=0.5';\nmsg.payload = {\n user: {\n email: msg.email,\n password: msg.password\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":530,"y":300,"wires":[["38582789.81bb28"]]},{"id":"38582789.81bb28","type":"http request","z":"34256184.7e2b8e","name":"Connect to Leeto","method":"POST","ret":"obj","paytoqs":"ignore","url":"https://api.leeto.co/api/v2/users/sign_in?locale=fr","tls":"","persist":false,"proxy":"","authType":"","x":750,"y":300,"wires":[["10c5487b.65eea8"]]},{"id":"ac7c6734.52f8f","type":"file in","z":"34256184.7e2b8e","name":"Test invoice","filename":"/data/test.pdf","format":"","chunk":false,"sendError":false,"encoding":"none","x":270,"y":120,"wires":[["ee1a1e10.8655a8"]]},{"id":"d7867c95.86491","type":"join","z":"34256184.7e2b8e","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":490,"y":580,"wires":[["17d03aa5.9a232d"]]},{"id":"10c5487b.65eea8","type":"change","z":"34256184.7e2b8e","name":"Mark as leetoUser","rules":[{"t":"set","p":"topic","pt":"msg","to":"leetoUser","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":340,"wires":[["d7867c95.86491","8e087080.9c07c8"]]},{"id":"65bdcfce.0c10e8","type":"change","z":"34256184.7e2b8e","name":"Mark as invoice","rules":[{"t":"set","p":"topic","pt":"msg","to":"invoice","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":420,"wires":[["d7867c95.86491"]]},{"id":"f5429dca.a2783","type":"http request","z":"34256184.7e2b8e","name":"Leeto Reimbursement Request","method":"POST","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":710,"y":660,"wires":[["337393c6.282844"]]},{"id":"5571d225.8e12dc","type":"function","z":"34256184.7e2b8e","name":"Leeto payload for reimbursement","func":"msg.headers = {};\nmsg.headers['User-Agent'] = 'Mozilla/5.0 (X11; Linux x86_64; rv:82.0) Gecko/20100101 Firefox/82.0';\nmsg.headers['Content-Type'] = 'multipart/form-data';\nmsg.headers['Accept'] = 'application/json, text/plain, */*';\nmsg.headers['Accept-Language'] = 'fr-FR,fr;q=0.5';\nmsg.headers['Authorization'] = 'Bearer ' + msg.payload.leetoUser.token;\nmsg.payload = {\n 'reimbursement_request[user_id]': msg.payload.leetoUser.id,\n 'reimbursement_request[grantable_id]': msg.payload.leetoUser.id,\n 'reimbursement_request[grantable_type]': 'User',\n 'reimbursement_request[amount]': 0,\n 'reimbursement_request[quotum_id]': msg.payload.benefit.data.period.quota[0].id,\n 'reimbursement_request[receipts_attributes][][image]': {\n value: msg.payload.invoice.file,\n options: {\n filename: msg.payload.invoice.filename,\n contentType: msg.payload.invoice.contentType,\n }\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":420,"y":660,"wires":[["f5429dca.a2783"]]},{"id":"337393c6.282844","type":"debug","z":"34256184.7e2b8e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":930,"y":660,"wires":[]},{"id":"38445ef0.73a4ca","type":"http request","z":"34256184.7e2b8e","name":"Leeto get benefit","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":1010,"y":440,"wires":[["6cb603b8.f9a93c"]]},{"id":"6cb603b8.f9a93c","type":"change","z":"34256184.7e2b8e","name":"Mark as benefit","rules":[{"t":"set","p":"topic","pt":"msg","to":"benefit","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1020,"y":520,"wires":[["d7867c95.86491"]]},{"id":"c63deac6.d6ff18","type":"function","z":"34256184.7e2b8e","name":"Leeto payload for get Benefit","func":"msg.headers = {};\nmsg.headers['User-Agent'] = 'Mozilla/5.0 (X11; Linux x86_64; rv:82.0) Gecko/20100101 Firefox/82.0';\nmsg.headers['Content-Type'] = 'multipart/form-data';\nmsg.headers['Accept'] = 'application/json, text/plain, */*';\nmsg.headers['Accept-Language'] = 'fr-FR,fr;q=0.5';\nmsg.headers['Authorization'] = 'Bearer ' + msg.payload.token;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":780,"y":440,"wires":[["38445ef0.73a4ca"]]},{"id":"8e087080.9c07c8","type":"template","z":"34256184.7e2b8e","name":"Build URL","field":"url","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"https://api.leeto.co/api/v2/organisations/{{payload.organisationId}}/users/{{payload.id}}/benefits/{{payload.authorizedBenefitIds.0}}?locale=fr","output":"str","x":580,"y":440,"wires":[["c63deac6.d6ff18"]]},{"id":"17d03aa5.9a232d","type":"template","z":"34256184.7e2b8e","name":"Build URL","field":"url","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"https://api.leeto.co/api/v2/organisations/{{payload.leetoUser.organisationId}}/reimbursement_requests?locale=fr","output":"str","x":200,"y":660,"wires":[["5571d225.8e12dc"]]},{"id":"848ba398.23bef8","type":"link in","z":"34256184.7e2b8e","name":"Trigged from Netflix Last Invoice","links":[],"x":175,"y":200,"wires":[["65bdcfce.0c10e8","cfd9259a.79e2a8"]]},{"id":"ee1a1e10.8655a8","type":"change","z":"34256184.7e2b8e","name":"Test payload","rules":[{"t":"move","p":"payload","pt":"msg","to":"file","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.file","pt":"msg","to":"file","tot":"msg"},{"t":"set","p":"payload.filename","pt":"msg","to":"test.pdf","tot":"str"},{"t":"set","p":"payload.amount","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":120,"wires":[["cfd9259a.79e2a8","65bdcfce.0c10e8"]]}] |