From 101d8e3d60ff44a2e1da1adeb24eb6d1d68fad12 Mon Sep 17 00:00:00 2001 From: Stephanie Moallic Date: Mon, 29 Jul 2019 15:14:04 +0200 Subject: [PATCH] feat(spare): add spare management for telephony and xdsl Ref: UXCT-177 --- .../spare/telephony-spare.service.js | 15 +++++ .../spare/telephony-spare.v6.service.js | 61 +++++++++++++++++ src/api/xdsl/spare/xdsl-spare.service.js | 15 +++++ src/api/xdsl/spare/xdsl-spare.v6.service.js | 66 +++++++++++++++++++ 4 files changed, 157 insertions(+) create mode 100644 src/api/telephony/spare/telephony-spare.service.js create mode 100644 src/api/telephony/spare/telephony-spare.v6.service.js create mode 100644 src/api/xdsl/spare/xdsl-spare.service.js create mode 100644 src/api/xdsl/spare/xdsl-spare.v6.service.js diff --git a/src/api/telephony/spare/telephony-spare.service.js b/src/api/telephony/spare/telephony-spare.service.js new file mode 100644 index 00000000..c5aa3f76 --- /dev/null +++ b/src/api/telephony/spare/telephony-spare.service.js @@ -0,0 +1,15 @@ +angular.module("ovh-api-services").service("OvhApiTelephonySpare", function ($injector, $cacheFactory) { + "use strict"; + + var cache = $cacheFactory("OvhApiTelephonySpare"); + + return { + v6: function () { + return $injector.get("OvhApiTelephonySpareV6"); + }, + resetCache: function () { + cache.removeAll(); + }, + cache: cache + }; +}); diff --git a/src/api/telephony/spare/telephony-spare.v6.service.js b/src/api/telephony/spare/telephony-spare.v6.service.js new file mode 100644 index 00000000..31b7dd6f --- /dev/null +++ b/src/api/telephony/spare/telephony-spare.v6.service.js @@ -0,0 +1,61 @@ +angular.module("ovh-api-services").service("OvhApiTelephonySpareV6", function ($resource, $cacheFactory) { + "use strict"; + + var cache = $cacheFactory("OvhApiTelephonySpareV6"); + var queryCache = $cacheFactory("OvhApiTelephonySpareV6V6Query"); + + var interceptor = { + response: function (response) { + cache.remove(response.config.url); + queryCache.removeAll(); + return response.resource; + } + }; + + var spareResource = $resource("/telephony/spare", { + spare: "@spare" + }, { + query: { + method: "GET", + isArray: true, + cache: queryCache + }, + get: { + method: "GET", + cache: cache + }, + getSpare: { + method: "GET", + url: "/telephony/spare/:spare" + }, + replaceSpare: { + method: "POST", + url: "/telephony/spare/:spare/replace", + interceptor: interceptor + }, + deleteSpare: { + method: "DELETE", + url: "/telephony/spare/:spare", + interceptor: interceptor + }, + getBrands: { + method: "GET", + url: "/telephony/spare/brands", + }, + getNewSpare: { + method: "GET", + url: "/order/telephony/spare/new", + }, + orderNewSpare: { + method: "POST", + url: "/order/telephony/spare/new", + }, + }); + + spareResource.resetAllCache = function () { + cache.removeAll(); + queryCache.removeAll(); + }; + + return spareResource; +}); diff --git a/src/api/xdsl/spare/xdsl-spare.service.js b/src/api/xdsl/spare/xdsl-spare.service.js new file mode 100644 index 00000000..5a4342fd --- /dev/null +++ b/src/api/xdsl/spare/xdsl-spare.service.js @@ -0,0 +1,15 @@ +angular.module("ovh-api-services").service("OvhApiXdslSpare", function ($injector, $cacheFactory) { + "use strict"; + + var cache = $cacheFactory("OvhApiXdslSpare"); + + return { + v6: function () { + return $injector.get("OvhApiXdslSpareV6"); + }, + resetCache: function () { + cache.removeAll(); + }, + cache: cache + }; +}); diff --git a/src/api/xdsl/spare/xdsl-spare.v6.service.js b/src/api/xdsl/spare/xdsl-spare.v6.service.js new file mode 100644 index 00000000..d31b3128 --- /dev/null +++ b/src/api/xdsl/spare/xdsl-spare.v6.service.js @@ -0,0 +1,66 @@ +angular.module("ovh-api-services").service("OvhApiXdslSpareV6", function ($resource, $cacheFactory) { + "use strict"; + + var cache = $cacheFactory("OvhApiXdslSpareV6"); + var queryCache = $cacheFactory("OvhApiXdslSpareV6Query"); + + var interceptor = { + response: function (response) { + cache.remove(response.config.url); + queryCache.removeAll(); + return response.resource; + } + }; + + var spareResource = $resource("/xdsl/spare", { + spare: "@spare" + }, { + query: { + method: "GET", + isArray: true, + cache: queryCache + }, + get: { + method: "GET", + cache: cache + }, + getSpare: { + method: "GET", + url: "/xdsl/spare/:spare" + }, + replaceSpare: { + method: "POST", + url: "/xdsl/spare/:spare/replace", + interceptor: interceptor + }, + returnMerchandise: { + method: "POST", + url: "xdsl/spare/:spare/returnMerchandise", + interceptor: interceptor + }, + deleteSpare: { + method: "DELETE", + url: "/xdsl/spare/:spare", + interceptor: interceptor + }, + getBrands: { + method: "GET", + url: "/xdsl/spare/brands", + }, + getNewSpare: { + method: "GET", + url: "/order/xdsl/spare/new", + }, + orderNewSpare: { + method: "POST", + url: "/order/xdsl/spare/new", + }, + }); + + spareResource.resetAllCache = function () { + cache.removeAll(); + queryCache.removeAll(); + }; + + return spareResource; +});