|
|
|
@ -43,7 +43,9 @@ function DeviceService($http, $q, $window, userService, attributeService, custom |
|
|
|
sendTwoWayRpcCommand: sendTwoWayRpcCommand, |
|
|
|
findByQuery: findByQuery, |
|
|
|
getDeviceTypes: getDeviceTypes, |
|
|
|
findByName: findByName |
|
|
|
findByName: findByName, |
|
|
|
claimDevice: claimDevice, |
|
|
|
unclaimDevice: unclaimDevice |
|
|
|
}; |
|
|
|
|
|
|
|
return service; |
|
|
|
@ -332,4 +334,28 @@ function DeviceService($http, $q, $window, userService, attributeService, custom |
|
|
|
}); |
|
|
|
return deferred.promise; |
|
|
|
} |
|
|
|
|
|
|
|
function claimDevice(deviceName, deviceSecret, config) { |
|
|
|
deviceSecret = deviceSecret || {}; |
|
|
|
config = config || {}; |
|
|
|
const deferred = $q.defer(); |
|
|
|
const url = '/api/customer/device/' + deviceName + '/claim'; |
|
|
|
$http.post(url, deviceSecret, config).then(function success(response) { |
|
|
|
deferred.resolve(response.data); |
|
|
|
}, function fail(rejection) { |
|
|
|
deferred.reject(rejection); |
|
|
|
}); |
|
|
|
return deferred.promise; |
|
|
|
} |
|
|
|
|
|
|
|
function unclaimDevice(deviceName) { |
|
|
|
const deferred = $q.defer(); |
|
|
|
const url = '/api/customer/device/' + deviceName + '/claim'; |
|
|
|
$http.delete(url).then(function success(response) { |
|
|
|
deferred.resolve(response.data); |
|
|
|
}, function fail(rejection) { |
|
|
|
deferred.reject(rejection); |
|
|
|
}); |
|
|
|
return deferred.promise; |
|
|
|
} |
|
|
|
} |
|
|
|
|