2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 import NetworkCalls from './networking/NetworkCalls.js';
28 } from './networking/NetworkConstants.js';
30 createEditEntityAttributeRequestObject
31 } from './networking/NetworkUtils.js';
33 setAttributesActionTypes,
34 EDIT_ENTITY_ATTRIBUTES_URL,
35 RESPONSE_CODE_SUCCESS,
36 RESPONSE_CODE_NOT_AUTHORIZED,
37 RESPONSE_MESSAGE_SUCCESS,
38 RESPONSE_MESSAGE_NOT_AUTHORIZED,
39 RESPONSE_MESSAGE_FAILURE,
40 RESPONSE_MESSAGE_NETWORK_ERROR
41 } from './EditAttributeConstants.js';
43 function errorReturnedEvent(errorMsg) {
45 type: setAttributesActionTypes.SET_ATTRIBUTE_ERROR,
46 data: {errorMsg: errorMsg}
50 function successReturnedEvent() {
52 type: setAttributesActionTypes.SET_ATTRIBUTE_SUCCESS,
53 data: {successMsg: RESPONSE_MESSAGE_SUCCESS}
57 function clearFeedbackMessageEvent() {
59 type: setAttributesActionTypes.CLEAR_FEEDBACK_MESSAGE,
64 export function clearFeebackMessage() {
66 dispatch(clearFeedbackMessageEvent());
70 export function requestEditEntityAttributes(entityURI, entityAttributes) {
72 let postBody = JSON.stringify(
73 createEditEntityAttributeRequestObject(entityURI, entityAttributes));
75 return NetworkCalls.fetchRequest(EDIT_ENTITY_ATTRIBUTES_URL,
76 CREDENTIALS, POST, BACKEND_POST_HEADER, postBody).then(
79 if (responseJson.resultCode === RESPONSE_CODE_SUCCESS) {
80 dispatch(successReturnedEvent());
81 } else if (responseJson.resultCode === RESPONSE_CODE_NOT_AUTHORIZED) {
82 dispatch(errorReturnedEvent(RESPONSE_MESSAGE_NOT_AUTHORIZED));
84 dispatch(errorReturnedEvent(RESPONSE_MESSAGE_FAILURE));
90 dispatch(errorReturnedEvent(RESPONSE_MESSAGE_NETWORK_ERROR));