<?php
require_once("SimpleRest.php");
require_once("Mobile.php");
		
class MobileRestHandler extends SimpleRest {
	function getItems() {	
		$mobile = new Mobile();
		$rawData = $mobile->getItem();
		if(empty($rawData)) {
            $statusCode = 200;
			$rawData = "ERROR"; // array('error' => 'No Respuesta found!');	
		} else {
			$statusCode = 200;
		}
		$requestContentType = 'application/json';//$_POST['HTTP_ACCEPT'];
		$this ->setHttpHeaders($requestContentType, $statusCode);
		$result["Datos"] =$rawData;
		if(strpos($requestContentType,'application/json') !== false){
			$response = $this->encodeJson($result);
			echo $response;
		}
	}
	
	function getInventarios(){	
		$mobile = new Mobile();
		$rawData = $mobile->getInventario();
		if(empty($rawData)) {
            $statusCode = 200;
			$rawData = "ERROR"; // array('error' => 'No Respuesta found!');	
		} else {
			$statusCode = 200;
		}
		$requestContentType = 'application/json';//$_POST['HTTP_ACCEPT'];
		$this ->setHttpHeaders($requestContentType, $statusCode);
		$result["Datos"] =$rawData;
		if(strpos($requestContentType,'application/json') !== false){
			$response = $this->encodeJson($result);
			echo $response;
		}
	}
	
	
    function getTiendas() {	
		$mobile = new Mobile();
		$rawData = $mobile->getTienda();
		if(empty($rawData)) {
            $statusCode = 200;
			$rawData = "ERROR"; // array('error' => 'No Respuesta found!');	
		} else {
			$statusCode = 200;
		}
		$requestContentType = 'application/json';//$_POST['HTTP_ACCEPT'];
		$this ->setHttpHeaders($requestContentType, $statusCode);
		$result["Datos"] =$rawData;
		if(strpos($requestContentType,'application/json') !== false){
			$response = $this->encodeJson($result);
			echo $response;
		}
	}
	
	
		function getUsuarios() {	
		$mobile = new Mobile();
		$rawData = $mobile->getUsuario();
		if(empty($rawData)) {
            $statusCode = 200;
			$rawData = "ERROR"; // array('error' => 'No Respuesta found!');		
		} else {
			$statusCode = 200;
		}
		$requestContentType = 'application/json';//$_POST['HTTP_ACCEPT'];
		$this ->setHttpHeaders($requestContentType, $statusCode);
		$result["Datos"] =$rawData;
		if(strpos($requestContentType,'application/json') !== false){
			$response = $this->encodeJson($result);
			echo $response;
		}
	}


	function getClientes() {	
		$mobile = new Mobile();
		$rawData = $mobile->getCliente();
		if(empty($rawData)) {
            $statusCode = 200;
			$rawData = "ERROR"; // array('error' => 'No Respuesta found!');		
		} else {
			$statusCode = 200;
		}
		$requestContentType = 'application/json';//$_POST['HTTP_ACCEPT'];
		$this ->setHttpHeaders($requestContentType, $statusCode);
		$result["Datos"] =$rawData;
		if(strpos($requestContentType,'application/json') !== false){
			$response = $this->encodeJson($result);
			echo $response;
		}
	}
	
	public function encodeJson($responseData) {
		  $jsonResponse = json_encode($responseData);
		  return $jsonResponse;		
	}
	
}
?>