diff --git a/src/api/overTheBox/device/overTheBox-device.service.js b/src/api/overTheBox/device/overTheBox-device.service.js new file mode 100644 index 00000000..3d3fcb5b --- /dev/null +++ b/src/api/overTheBox/device/overTheBox-device.service.js @@ -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, + }; +}); diff --git a/src/api/overTheBox/device/overTheBox-device.v6.service.js b/src/api/overTheBox/device/overTheBox-device.v6.service.js new file mode 100644 index 00000000..7c31ff23 --- /dev/null +++ b/src/api/overTheBox/device/overTheBox-device.v6.service.js @@ -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; +}); diff --git a/src/api/overTheBox/overTheBox.service.js b/src/api/overTheBox/overTheBox.service.js index 56626433..52aeffd6 100644 --- a/src/api/overTheBox/overTheBox.service.js +++ b/src/api/overTheBox/overTheBox.service.js @@ -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, };