summaryrefslogtreecommitdiffstats
path: root/src/app/contextHandler
diff options
context:
space:
mode:
authorricharv <richard.vondadelszen@amdocs.com>2018-01-18 16:03:12 -0500
committerricharv <richard.vondadelszen@amdocs.com>2018-01-18 16:04:20 -0500
commit9f9553bdf90db2a02a742c4e038b2c1600c96036 (patch)
treeaed559460d9255d231731aff6bcd69797b5b3505 /src/app/contextHandler
parentfd2a6b124c62fe186364efd8eb28409ce7507902 (diff)
Handling new BE subscription payload
Issue-ID: AAI-676 Change-Id: I5c6307f43b20487068bc4ba3b6d9fee5b25e2027 Signed-off-by: richarv <richard.vondadelszen@amdocs.com>
Diffstat (limited to 'src/app/contextHandler')
-rw-r--r--src/app/contextHandler/ContextHandlerActions.js40
-rw-r--r--src/app/contextHandler/ContextHandlerConstants.js2
2 files changed, 21 insertions, 21 deletions
diff --git a/src/app/contextHandler/ContextHandlerActions.js b/src/app/contextHandler/ContextHandlerActions.js
index 889020a..0fe43ff 100644
--- a/src/app/contextHandler/ContextHandlerActions.js
+++ b/src/app/contextHandler/ContextHandlerActions.js
@@ -65,17 +65,22 @@ function getExternalParamValues(urlParams) {
}
function createSubscriptionPayloadEvent(payload) {
- return {
- type: contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_FOUND,
- data: payload
- };
-}
-function createSubscriptionIsEmptyEvent() {
- return {
- type: contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_EMPTY,
- data: {}
- };
+ let event = undefined;
+
+ if (payload.subscriptionEnabled) {
+ event = {
+ type: contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_FOUND,
+ data: payload
+ };
+ } else {
+ event = {
+ type: contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_EMPTY,
+ data: {}
+ };
+ }
+
+ return event;
}
function fetchSubscriptionPayload(fetchRequestCallback) {
@@ -86,26 +91,21 @@ function fetchSubscriptionPayload(fetchRequestCallback) {
return Promise.reject(new Error(response.status));
} else {
// assume 200 status
- return response;
+ return response.json();
}
}
).then(
(results)=> {
dispatch(createSubscriptionPayloadEvent(results));
-
}
).catch(
- (e) => {
- if(e.name === 'EmptyResponseException'){
- dispatch(getClearGlobalMessageEvent());
- dispatch(createSubscriptionIsEmptyEvent());
- } else{
- dispatch(getSetGlobalMessageEvent(SUBSCRIPTION_FAILED_MESSAGE , MESSAGE_LEVEL_WARNING));
- }
+ () => {
+ dispatch(getSetGlobalMessageEvent(SUBSCRIPTION_FAILED_MESSAGE , MESSAGE_LEVEL_WARNING));
}
);
};
}
+
export function getSubscriptionPayload() {
let externalfetchRequest =
() => networkCall.getRequest(SUBSCRIPTION_PAYLOAD_URL, GET);
@@ -113,6 +113,7 @@ export function getSubscriptionPayload() {
dispatch(fetchSubscriptionPayload(externalfetchRequest));
};
}
+
function validateExternalParams(externalURLParams) {
if(externalURLParams.view && externalURLParams.entityId && externalURLParams.entityType) {
return true;
@@ -121,7 +122,6 @@ function validateExternalParams(externalURLParams) {
}
-
function createSuggestionFoundEvent(suggestion) {
return {
type: contextHandlerActionTypes.SINGLE_SUGGESTION_FOUND,
diff --git a/src/app/contextHandler/ContextHandlerConstants.js b/src/app/contextHandler/ContextHandlerConstants.js
index 6229968..9abbb31 100644
--- a/src/app/contextHandler/ContextHandlerConstants.js
+++ b/src/app/contextHandler/ContextHandlerConstants.js
@@ -39,7 +39,7 @@ export const FAILED_REQUEST = 'Failed to pull result for the request.';
export const ZERO_RESULT = 'No result has been found for this request.';
export const MULTIPLE_RESULT = 'Multiple results were found for this request so none got selected.';
export const SUBSCRIPTION_FAILED_MESSAGE = 'Failed to fetch subscription payload.';
-export const SUBSCRIPTION_PAYLOAD_URL = BASE_URL + '/subscription/getsubscription';
+export const SUBSCRIPTION_PAYLOAD_URL = BASE_URL + '/rest/subscription/getsubscription';