2014-11-19 17:38:15 +00:00
|
|
|
canvas = require('./_canvas')
|
2014-11-26 14:32:57 +00:00
|
|
|
_ = require('lodash')
|
|
|
|
Promise = require('bluebird')
|
2014-11-26 16:15:40 +00:00
|
|
|
errors = require('../../errors/errors')
|
2014-11-19 17:38:15 +00:00
|
|
|
|
|
|
|
exports.getAll = (applicationId) ->
|
|
|
|
return canvas.get
|
|
|
|
resource: 'device'
|
|
|
|
options:
|
|
|
|
filter:
|
|
|
|
application: applicationId
|
|
|
|
expand: 'application'
|
|
|
|
orderby: 'name asc'
|
2014-11-26 14:32:57 +00:00
|
|
|
.then (devices) ->
|
|
|
|
if _.isEmpty(devices)
|
|
|
|
return Promise.reject(new errors.NotAny('devices'))
|
|
|
|
|
|
|
|
return devices
|
2014-11-21 17:23:29 +00:00
|
|
|
|
|
|
|
exports.remove = (id) ->
|
|
|
|
return canvas.delete
|
|
|
|
resource: 'device'
|
|
|
|
id: id
|