package com.libreecm.db.consumers;

import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;

import com.libreecm.commonAPI.auxiliars.exceptions.ErrorConsumingRESTException;
import com.libreecm.commonAPI.model.users.LibreECMUser;

public class UserConsumer {

	RestTemplate restTemplate = new RestTemplate();
	
	public UserConsumer(){ 
		
	}
	
	public LibreECMUser getCurrentUser(String url){
		LibreECMUser user = null;
		try {
			user =restTemplate.getForObject(url, LibreECMUser.class);
		} catch (HttpClientErrorException e){
			throw new ErrorConsumingRESTException(url);
		}
		
		return user;
	}
}
