/*-
 * ============LICENSE_START=======================================================
 * ONAP CLAMP
 * ================================================================================
 * Copyright (C) 2019 AT&T Intellectual Property. All rights
 *                             reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END============================================
 * ===================================================================
 *
 */

export default class UserService {
	static notLoggedUserName='Anonymous';
	static login() {
		return fetch('/restservices/clds/v1/user/getUser', {
				method: 'GET',
				credentials: 'same-origin',
			})
		.then(function (response) {
			console.debug("getUser response received, status code:", response.status);
			if (response.ok) {
				return response.text();
			} else {
				console.error("getUser response is nok");
				return UserService.notLoggedUserName;
			}
		})
		.then(function (data) {
			console.info ("User connected:",data)
			return data;
		})
		.catch(function(error) {
			console.warn("getUser error received, user set to: ",UserService.notLoggedUserName);
			console.error("getUser error:",error);
			return UserService.notLoggedUserName;
		});
	}
	
	static logout() {
		return fetch('/restservices/clds/v1/user/logout', {
			method: 'POST',
			credentials: 'same-origin',
		})
		.then(function (response) {
			console.debug("logout response received, status code:", response.status);
			if (response.ok) {
				return response.text();
			} else {
				console.error("logout response is nok");
				return UserService.notLoggedUserName;
			}
		})
		.then(function (data) {
			console.info ("User disconnected:",data)
			return data;
		})
		.catch(function(error) {
			console.warn("logout error received, user set to: ",UserService.notLoggedUserName);
			console.error("logout error:",error);
			return UserService.notLoggedUserName;
		});
	}

	static getUserInfo() {
		return fetch('/restservices/clds/v1/clds/cldsInfo', {
				method: 'GET',
				credentials: 'same-origin',
			})
		.then(function (response) {
			console.debug("getUserInfo response received, status code:", response.status);
			if (response.ok) {
				return response.json();
			}
		})
		.then(function (data) {
			console.info ("User info received:",data)
			return data;
		})
		.catch(function(error) {
			console.warn("getUserInfo error received, user set to: ",UserService.notLoggedUserName);
			console.error("getUserInfo error:",error);
			return;
		});
	}
}
