diff --git a/dist/api/api.js b/dist/api/api.js index d506753..674e892 100644 --- a/dist/api/api.js +++ b/dist/api/api.js @@ -38,6 +38,7 @@ this.server.get("/robots/:robotid", this.getRobotByName); this.server.get("/robots/:robotid/devices", this.getDevices); this.server.get("/robots/:robotid/devices/:deviceid", this.getDeviceByName); + this.server.get("/robots/:robotid/devices/:deviceid/commands", this.getDeviceCommands); this.server.listen(this.port, this.host, function() { return Logger.info("" + _this.server.name + " is listening at " + _this.server.url); }); @@ -78,6 +79,15 @@ }); }; + Server.prototype.getDeviceCommands = function(req, res, next) { + var deviceid, robotid; + robotid = req.params.robotid; + deviceid = req.params.deviceid; + return master.findRobotDevice(robotid, deviceid, function(err, device) { + return res.send(err ? err : device.data().commands); + }); + }; + return Server; })(); diff --git a/src/api/api.coffee b/src/api/api.coffee index 9db50c2..6d44630 100644 --- a/src/api/api.coffee +++ b/src/api/api.coffee @@ -29,6 +29,7 @@ namespace "Api", -> @server.get "/robots/:robotid", @getRobotByName @server.get "/robots/:robotid/devices", @getDevices @server.get "/robots/:robotid/devices/:deviceid", @getDeviceByName + @server.get "/robots/:robotid/devices/:deviceid/commands", @getDeviceCommands @server.listen @port, @host, => Logger.info "#{@server.name} is listening at #{@server.url}" @@ -50,3 +51,10 @@ namespace "Api", -> master.findRobotDevice robotid, deviceid, (err, device) -> res.send if err then err else device.data() + + getDeviceCommands: (req, res, next) -> + robotid = req.params.robotid + deviceid = req.params.deviceid + + master.findRobotDevice robotid, deviceid, (err, device) -> + res.send if err then err else device.data().commands