Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

Commit

Permalink
feat(otb.service): add device submodule
Browse files Browse the repository at this point in the history
Signed-off-by: Stephanie Moallic <[email protected]>
  • Loading branch information
Stephanie Moallic committed May 29, 2020
1 parent c47367a commit a69374f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/api/overTheBox/device/overTheBox-device.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
angular.module('ovh-api-services').service('OvhApiOverTheBoxDevice', ($injector, $cacheFactory) => {
const cache = $cacheFactory('OvhApiOverTheBoxDevice');

return {
v6() {
return $injector.get('OvhApiOverTheBoxDeviceV6');
},
resetCache: cache.removeAll,
cache,
};
});
29 changes: 29 additions & 0 deletions src/api/overTheBox/device/overTheBox-device.v6.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
angular.module('ovh-api-services').service('OvhApiOverTheBoxDeviceV6', ($resource, OvhApiOverTheBoxDevice) => {
const interceptor = {
response(response) {
OvhApiOverTheBoxDevice.resetCache();
return response.resource;
},
};

const overTheBoxDevice = $resource('/overTheBox/:serviceName/device', {
serviceName: '@serviceName',
}, {
getActions: {
method: 'GET',
url: '/overTheBox/:serviceName/device/actions',
isArray: true,
},
getAction: {
method: 'GET',
url: '/overTheBox/:serviceName/device/actions/:actionId',
},
unlinkDevice: {
method: 'DELETE',
url: '/overTheBox/:serviceName/device',
interceptor,
},
});

return overTheBoxDevice;
});
3 changes: 3 additions & 0 deletions src/api/overTheBox/overTheBox.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ angular.module('ovh-api-services').service('OvhApiOverTheBox', ($injector, $cach
v7() {
return $injector.get('OvhApiOverTheBoxV7');
},
Device() {
return $injector.get('OvhApiOverTheBoxDevice');
},
resetCache: cache.removeAll,
cache,
};
Expand Down

0 comments on commit a69374f

Please sign in to comment.