2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 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 import NetworkCalls from './networking/NetworkCalls.js';
26 } from './networking/NetworkConstants.js';
28 createEditEntityAttributeRequestObject
29 } from './networking/NetworkUtils.js';
31 setAttributesActionTypes,
32 EDIT_ENTITY_ATTRIBUTES_URL,
33 RESPONSE_CODE_SUCCESS,
34 RESPONSE_CODE_NOT_AUTHORIZED,
35 RESPONSE_MESSAGE_SUCCESS,
36 RESPONSE_MESSAGE_NOT_AUTHORIZED,
37 RESPONSE_MESSAGE_FAILURE,
38 RESPONSE_MESSAGE_NETWORK_ERROR
39 } from './EditAttributeConstants.js';
41 function errorReturnedEvent(errorMsg) {
43 type: setAttributesActionTypes.SET_ATTRIBUTE_ERROR,
44 data: {errorMsg: errorMsg}
48 function successReturnedEvent() {
50 type: setAttributesActionTypes.SET_ATTRIBUTE_SUCCESS,
51 data: {successMsg: RESPONSE_MESSAGE_SUCCESS}
55 function clearFeedbackMessageEvent() {
57 type: setAttributesActionTypes.CLEAR_FEEDBACK_MESSAGE,
62 export function clearFeebackMessage() {
64 dispatch(clearFeedbackMessageEvent());
68 export function requestEditEntityAttributes(entityURI, entityAttributes) {
70 let postBody = JSON.stringify(
71 createEditEntityAttributeRequestObject(entityURI, entityAttributes));
73 return NetworkCalls.fetchRequest(EDIT_ENTITY_ATTRIBUTES_URL,
74 CREDENTIALS, POST, BACKEND_POST_HEADER, postBody).then(
77 if (responseJson.resultCode === RESPONSE_CODE_SUCCESS) {
78 dispatch(successReturnedEvent());
79 } else if (responseJson.resultCode === RESPONSE_CODE_NOT_AUTHORIZED) {
80 dispatch(errorReturnedEvent(RESPONSE_MESSAGE_NOT_AUTHORIZED));
82 dispatch(errorReturnedEvent(RESPONSE_MESSAGE_FAILURE));
88 dispatch(errorReturnedEvent(RESPONSE_MESSAGE_NETWORK_ERROR));