Slide Open Cloud API
This subflow produces a node that can be used the with Slide Open Cloud API
Usage:
Fill in your username/password Use an inject node with a timestamp, select "overview".
This will produce an output with all available slides in the household.
Determine the slide ID and fill in the form with the ID and deploy the changes
To control this slide ID, inject a number between 0 and 1 and the slide will open/close.
[{"id":"a9d27cb5.dcddc","type":"subflow","name":"Slide","info":"# Slide\n\nFill in your username/password\n\nTo start:\n\nUse an inject node with a timestamp, select \"overview\".\n\nThis will produce an output with all available slides in the household.\n\nDetermine the slide ID and fill in the form with the ID.\n\nTo control this slide ID, inject a number between 0 and 1 and the slide will open/close.\n\n","category":"","in":[{"x":140,"y":96,"wires":[{"id":"fb035ab9.466f9"}]}],"out":[{"x":404,"y":120,"wires":[{"id":"cd93a89c.9f4638","port":1}]}],"env":[{"name":"request","type":"str","value":"","ui":{"icon":"font-awesome/fa-window-maximize","label":{"en-US":"Request"},"type":"select","opts":{"opts":[{"l":{"en-US":"Overview"},"v":"overview"},{"l":{"en-US":"Slide state"},"v":"info"},{"l":{"en-US":"Set position"},"v":"position"}]}}},{"name":"email","type":"str","value":"","ui":{"type":"input","opts":{"types":["str"]},"label":{}}},{"name":"password","type":"str","value":"","ui":{"type":"input","opts":{"types":["str"]},"label":{}}},{"name":"slideid","type":"num","value":"","ui":{"label":{"en-US":"slideid"},"type":"input","opts":{"types":["num"]}}}],"color":"#FFCC66","icon":"font-awesome/fa-window-maximize"},{"id":"c03c4e79.2c558","type":"http request","z":"a9d27cb5.dcddc","name":"","method":"use","ret":"obj","paytoqs":false,"url":"","tls":"","persist":false,"proxy":"","authType":"","x":255,"y":96,"wires":[["cd93a89c.9f4638"]],"l":false},{"id":"fb035ab9.466f9","type":"function","z":"a9d27cb5.dcddc","name":"","func":"u = env.get(\"email\");\np = env.get(\"password\");\ntoken = flow.get(\"$parent.token.access_token\") || false\nexpired = true // force expiry date check\nmsg.headers = {}\nslideid = env.get(\"slideid\");\n\nif(token){\n expires = new Date(flow.get(\"$parent.token.expires_at\")).toISOString()\n cdate = new Date().toISOString()\n expired = cdate>expires\n}\n\nif(!token || expired){\n \n msg.method = \"POST\"\n msg.url = \"https://api.goslide.io/api/auth/login\" \n msg.payload = {\"email\": u,\"password\": p}\n msg.headers[\"Content-Type\"] = \"application/json\"\n msg.headers[\"X-Requested-With\"] = \"XMLHttpRequest\"\n \n}\nelse{\n r = env.get(\"request\");\n\n if(r==\"overview\"){\n msg.method = \"GET\"\n msg.url = \"https://api.goslide.io/api/slides/overview\" \n }\n if(r==\"info\"){\n msg.method = \"GET\"\n msg.url = \"https://api.goslide.io/api/slide/\"+slideid+\"/info\"\n }\n if(r==\"position\"){\n msg.payload = {\"pos\":msg.payload}\n msg.method = \"POST\"\n msg.url = \"https://api.goslide.io/api/slide/\"+slideid+\"/position\"\n }\n\n \n msg.headers[\"Content-Type\"] = \"application/json\"\n msg.headers[\"X-Requested-With\"] = \"XMLHttpRequest\"\n msg.headers[\"Authorization\"] =\"Bearer \" + token\n msg.headers[\"cache-control\"]= \"no-cache\"\n\n}\n\nreturn msg","outputs":1,"noerr":0,"x":207,"y":96,"wires":[["c03c4e79.2c558"]],"l":false},{"id":"cd93a89c.9f4638","type":"switch","z":"a9d27cb5.dcddc","name":"","property":"method","propertyType":"msg","rules":[{"t":"eq","v":"POST","vt":"str"},{"t":"eq","v":"GET","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":303,"y":96,"wires":[["4b5a6417.3dfd0c"],[]],"l":false},{"id":"6d049b37.24858c","type":"function","z":"a9d27cb5.dcddc","name":"","func":"flow.set(\"$parent.token.access_token\",msg.payload.access_token)\nflow.set(\"$parent.token.expires_at\",msg.payload.expires_at)","outputs":1,"noerr":0,"x":591,"y":72,"wires":[[]],"l":false},{"id":"4b5a6417.3dfd0c","type":"switch","z":"a9d27cb5.dcddc","name":"token request ?","property":"url","propertyType":"msg","rules":[{"t":"eq","v":"https://api.goslide.io/api/auth/login","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":464,"y":72,"wires":[["6d049b37.24858c"]]},{"id":"53c06b3a.62d294","type":"subflow:a9d27cb5.dcddc","z":"5a9f9611.f9bb2","name":"","x":624,"y":336,"wires":[[]]}]