<?php

	include 'app.php';
	$app = new App();

	header('Content-Type: application/json');

	if(preg_match('/^(save-gcm-registration-id){1}$/', $_POST['method'])){

		$return = $app->register_phone($_POST['reg-id']);
		echo json_encode(array('feedback' => $return));

	}
	else if(preg_match('/^(login-client){1}$/', $_POST['method'])){

		echo $app->login($_POST['login'], $_POST['pass']);

	}
	else if(preg_match('/^(get-old-files){1}$/', $_POST['method'])){

		echo $app->get_old_files($_POST['id_user'], $_POST['type']);

	}
	else if(preg_match('/^(set-old-file){1}$/', $_POST['method'])){

		echo $app->set_old_file($_POST['id_user'], $_POST['id_file']);

	}
	else if(preg_match('/^(get-new-files){1}$/', $_POST['method'])){

		echo $app->get_new_files($_POST['id_user'], $_POST['type']);

	}
	else if(preg_match('/^(get-new-relatorios){1}$/', $_POST['method'])){

		echo $app->get_new_relatorios($_POST['id_user']);

	}
	else if(preg_match('/^(get-old-relatorios){1}$/', $_POST['method'])){

		echo $app->get_old_relatorios($_POST['id_user']);

	}
	else if(preg_match('/^(send-new-client){1}$/', $_POST['method'])){

		echo $app->send_new_client($_POST['nome'], $_POST['email'], $_POST['telefone'], $_POST['newsletter']);

	}
	else if(preg_match('/^(send-gcm-message){1}$/', $_POST['method'])){

		echo $app->send($_POST['id_user']);

	}
	else if(preg_match('/^(get-infos){1}$/', $_POST['method'])){

		echo $app->get_infos($_POST['id_user']);

	}
	else if(preg_match('/^(get-informativos){1}$/', $_POST['method'])){

		echo $app->get_informativos();

	}
	else if(preg_match('/^(get-informativo){1}$/', $_POST['method'])){

		echo $app->get_informativo($_POST['id']);

	}
?>