Index: sandbox/2.4-expresso-api/prototype/tests/rest/contact/DynamicContactsResourceTest.php
===================================================================
--- sandbox/2.4-expresso-api/prototype/tests/rest/contact/DynamicContactsResourceTest.php	(revision 6230)
+++ sandbox/2.4-expresso-api/prototype/tests/rest/contact/DynamicContactsResourceTest.php	(revision 6230)
@@ -0,0 +1,133 @@
+<?php
+
+require_once(__DIR__ . '/../../../api/controller.php');
+require_once(__DIR__ . '/../../../rest/oauth/OAuth2StorageUserCredential.php');
+
+class DynamicContactResourceTest extends PHPUnit_Framework_TestCase {
+
+    private $classOAuth = null;
+    private $user = 'user2';
+    private $pass = 'prognus';
+    private $accessToken = 'aaaaaa259f553ac148f01b6bbcbb101';
+    private $refreshToken = 'rrrrrr03fff3b8cdc51206244529agb';
+    private $url = 'http://expressodev.prognus.com.br/acoutinho/expressoAPI/rest/dynamiccontacts';
+    private $curlOPT;
+    private $client_id = 666;
+    private $user_id = 666;
+
+    public function setUp() {
+	$this->classOAuth = new OAuth2StorageUserCredential();
+	session_id('rrrrrr03fff3b8cdc51206244529agb');
+
+	$_SESSION['wallet']['user']['uid'] = $this->user;
+	$_SESSION['wallet']['user']['password'] = $this->pass;
+	$_SESSION['wallet']['user']['uidNumber'] = 42798;
+	//insere access token
+	$this->classOAuth->setAccessToken($this->accessToken, $this->client_id, $this->user_id, (time() + 3600), 'all', $this->refreshToken);
+
+	//insere refresh token
+	$this->classOAuth->setRefreshToken($this->refreshToken, $this->client_id, $this->user_id, (time() + 3600), 'all');
+	$this->curlOPT = array(CURLOPT_URL => $this->url, CURLOPT_HEADER => 0, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_TIMEOUT => 4, CURLOPT_HTTPHEADER => array('Authorization: OAUTH Bearer aaaaaa259f553ac148f01b6bbcbb101'));
+    }
+
+    public function testcreateResource() {
+
+	for ($i = 0; $i < 20; $i++) {
+	    Controller::service('PostgreSQL')->execResultSql("INSERT INTO expressomail_dynamic_contact (owner, name, mail, timestamp) values 
+		('42798', 'nameTeste" . $i . "', 'name" . $i . "@teste.com', '" . time() . "000');");
+	}
+	Controller::commit(array('service' => 'PostgreSQL'));
+    }
+
+    public function testCheckMaxResource() {
+	$c = curl_init();
+	curl_setopt_array($c, $this->curlOPT);
+	$r = curl_exec($c);
+	curl_close($c);
+
+	$body = json_decode($r, true);
+	$this->assertCount(20, $body['collection']['items']);
+    }
+
+    public function testCheckResource() {
+	$c = curl_init();
+	curl_setopt_array($c, $this->curlOPT);
+	$r = curl_exec($c);
+	curl_close($c);
+
+	$body = json_decode($r, true);
+
+	$this->assertArrayHasKey('collection', $body);
+	$this->assertArrayHasKey('data', $body['collection']);
+	$this->assertArrayHasKey('name', $body['collection']['data']);
+	$this->assertArrayHasKey('prompt', $body['collection']['data']);
+	$this->assertArrayHasKey('error', $body['collection']);
+	$this->assertArrayHasKey('href', $body['collection']);
+	$this->assertArrayHasKey('items', $body['collection']);
+	$this->assertArrayHasKey('pagination', $body['collection']);
+	$this->assertArrayHasKey('queries', $body['collection']);
+	$this->assertArrayHasKey('template', $body['collection']);
+	$this->assertArrayHasKey('dataType', $body['collection']['template']['data'][0]);
+	$this->assertArrayHasKey('maxLength', $body['collection']['template']['data'][0]);
+	$this->assertArrayHasKey('minLength', $body['collection']['template']['data'][0]);
+	$this->assertArrayHasKey('name', $body['collection']['template']['data'][0]);
+	$this->assertArrayHasKey('prompt', $body['collection']['template']['data'][0]);
+	$this->assertArrayHasKey('value', $body['collection']['template']['data'][0]);
+	$this->assertArrayHasKey('type', $body['collection']);
+	$this->assertArrayHasKey('version', $body);
+    }
+
+    public function testCreateNewResource() {
+
+	$data = array('name' => 'testUnitário', 'email' => 'teste@unitario.com.br');
+	$this->curlOPT[CURLOPT_URL] = $this->curlOPT[CURLOPT_URL];
+	$c = curl_init();
+	curl_setopt_array($c, $this->curlOPT);
+	curl_setopt($c, CURLOPT_POSTFIELDS, $data);
+	curl_setopt($c, CURLOPT_CUSTOMREQUEST, "POST");
+	$r = curl_exec($c);
+	curl_close($c);
+	$body = json_decode($r, true);
+
+	$this->assertNull($body);
+    }
+
+    public function testCreateInvalidNewResource() {
+
+	$data = array('name' => 'testUnitário', 'emailinvalido' => 'teste@unitario.com.br');
+	$this->curlOPT[CURLOPT_URL] = $this->curlOPT[CURLOPT_URL];
+	$c = curl_init();
+	curl_setopt_array($c, $this->curlOPT);
+	curl_setopt($c, CURLOPT_POSTFIELDS, $data);
+	curl_setopt($c, CURLOPT_CUSTOMREQUEST, "POST");
+	$r = curl_exec($c);
+	curl_close($c);
+	$body = json_decode($r, true);
+
+	$this->assertArrayHasKey('version', $body);
+	$this->assertArrayHasKey('collection', $body);
+	$this->assertArrayHasKey('code', $body['collection']['error']);
+	$this->assertArrayHasKey('title', $body['collection']['error']);
+	$this->assertArrayHasKey('description', $body['collection']['error']);
+    }
+
+    public function testCheckFinish() {
+	Controller::service('PostgreSQL')->execResultSql("DELETE from expressomail_dynamic_contact where owner = ('42798')");
+
+	$c = curl_init();
+	curl_setopt_array($c, $this->curlOPT);
+	$r = curl_exec($c);
+	curl_close($c);
+	$body = json_decode($r, true);
+
+	$this->assertNull($body['collection']['items']);
+    }
+
+    public function tearDown() {
+	$this->classOAuth->unsetRefreshToken($this->refreshToken);
+	$this->classOAuth->unsetAccessToken($this->accessToken);
+    }
+
+}
+
+?>
Index: sandbox/2.4-expresso-api/prototype/tests/rest/contact/DynamicContactResourceTest.php
===================================================================
--- sandbox/2.4-expresso-api/prototype/tests/rest/contact/DynamicContactResourceTest.php	(revision 6230)
+++ sandbox/2.4-expresso-api/prototype/tests/rest/contact/DynamicContactResourceTest.php	(revision 6230)
@@ -0,0 +1,156 @@
+<?php
+
+require_once(__DIR__ . '/../../../api/controller.php');
+require_once(__DIR__ . '/../../../rest/oauth/OAuth2StorageUserCredential.php');
+
+class DynamicContactResourceTest extends PHPUnit_Framework_TestCase {
+
+    private $classOAuth = null;
+    private $user = 'user2';
+    private $pass = 'prognus';
+    private $accessToken = 'aaaaaa259f553ac148f01b6bbcbb101';
+    private $refreshToken = 'rrrrrr03fff3b8cdc51206244529agb';
+    private $url = 'http://expressodev.prognus.com.br/acoutinho/expressoAPI/rest/dynamiccontacts';
+    private $curlOPT;
+    private $client_id = 666;
+    private $user_id = 666;
+
+    public function setUp() {
+	$this->classOAuth = new OAuth2StorageUserCredential();
+	session_id($this->refreshToken);
+	
+	$_SESSION['wallet']['user']['uid'] = $this->user;
+	$_SESSION['wallet']['user']['password'] = $this->pass;
+	$_SESSION['wallet']['user']['uidNumber'] = 42798;
+	
+	
+	//insere access token
+	$this->classOAuth->setAccessToken($this->accessToken, $this->client_id, $this->user_id, (time() + 3600), 'all', $this->refreshToken);
+
+	//insere refresh token
+	$this->classOAuth->setRefreshToken($this->refreshToken, $this->client_id, $this->user_id, (time() + 3600), 'all');
+	$this->curlOPT = array(CURLOPT_URL => $this->url, CURLOPT_HEADER => 0, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_TIMEOUT => 4, CURLOPT_HTTPHEADER => array('Authorization: OAUTH Bearer aaaaaa259f553ac148f01b6bbcbb101'));
+    }
+
+    public function testcreateResource() {
+	Controller::service('PostgreSQL')->execResultSql("INSERT INTO expressomail_dynamic_contact (owner, name, mail, timestamp) values 
+	    ('42798', 'nameTeste', 'name@teste.com', '" . time() . "000');");
+
+	Controller::commit(array('service' => 'PostgreSQL'));
+    }
+
+    public function testCheckMaxResource() {
+
+	$contact = Controller::service('PostgreSQL')->execResultSql("SELECT id from expressomail_dynamic_contact where owner = 42798");
+	$this->curlOPT[CURLOPT_URL] = $this->curlOPT[CURLOPT_URL] . '/' . $contact[0]['id'];
+	$c = curl_init();
+	curl_setopt_array($c, $this->curlOPT);
+	$r = curl_exec($c);
+	curl_close($c);
+
+	$body = json_decode($r, true);
+	$this->assertCount(1, $body['collection']['items']);
+    }
+
+    public function testCheckResource() {
+	$contact = Controller::service('PostgreSQL')->execResultSql("SELECT id from expressomail_dynamic_contact where owner = 42798");
+	$this->curlOPT[CURLOPT_URL] = $this->curlOPT[CURLOPT_URL] . '/' . $contact[0]['id'];
+
+	$c = curl_init();
+	curl_setopt_array($c, $this->curlOPT);
+	$r = curl_exec($c);
+	curl_close($c);
+
+	$body = json_decode($r, true);
+
+	$this->assertArrayHasKey('collection', $body);
+	$this->assertArrayHasKey('data', $body['collection']);
+	$this->assertArrayHasKey('name', $body['collection']['data']);
+	$this->assertArrayHasKey('prompt', $body['collection']['data']);
+	$this->assertArrayHasKey('error', $body['collection']);
+	$this->assertArrayHasKey('href', $body['collection']);
+	$this->assertArrayHasKey('items', $body['collection']);
+	$this->assertArrayHasKey('pagination', $body['collection']);
+	$this->assertArrayHasKey('queries', $body['collection']);
+	$this->assertArrayHasKey('template', $body['collection']);
+	$this->assertArrayHasKey('dataType', $body['collection']['template']['data'][0]);
+	$this->assertArrayHasKey('maxLength', $body['collection']['template']['data'][0]);
+	$this->assertArrayHasKey('minLength', $body['collection']['template']['data'][0]);
+	$this->assertArrayHasKey('name', $body['collection']['template']['data'][0]);
+	$this->assertArrayHasKey('prompt', $body['collection']['template']['data'][0]);
+	$this->assertArrayHasKey('value', $body['collection']['template']['data'][0]);
+	$this->assertArrayHasKey('type', $body['collection']);
+	$this->assertArrayHasKey('version', $body);
+    }
+
+    public function testCheckInvalidId() {
+	$this->curlOPT[CURLOPT_URL] = $this->curlOPT[CURLOPT_URL] . '/invalidIdXXX';
+
+	$c = curl_init();
+	curl_setopt_array($c, $this->curlOPT);
+	$r = curl_exec($c);
+	curl_close($c);
+
+	$body = json_decode($r, true);
+
+	$this->assertArrayHasKey('version', $body);
+	$this->assertArrayHasKey('collection', $body);
+	$this->assertArrayHasKey('error', $body['collection']);
+	$this->assertArrayHasKey('code', $body['collection']['error']);
+	$this->assertArrayHasKey('title', $body['collection']['error']);
+	$this->assertArrayHasKey('description', $body['collection']['error']);
+    }
+
+    public function testCheckInvalidDelete() {
+	$this->curlOPT[CURLOPT_URL] = $this->curlOPT[CURLOPT_URL] . '/invalidXXX';
+
+	$c = curl_init();
+	curl_setopt_array($c, $this->curlOPT);
+	curl_setopt($c, CURLOPT_CUSTOMREQUEST, "DELETE");
+	$r = curl_exec($c);
+	curl_close($c);
+
+	$body = json_decode($r, true);
+
+	$this->assertArrayHasKey('version', $body);
+	$this->assertArrayHasKey('collection', $body);
+	$this->assertArrayHasKey('code', $body['collection']['error']);
+	$this->assertArrayHasKey('title', $body['collection']['error']);
+	$this->assertArrayHasKey('description', $body['collection']['error']);
+    }
+
+    public function testCheckDelete() {
+	$contact = Controller::service('PostgreSQL')->execResultSql("SELECT id from expressomail_dynamic_contact where owner = 42798");
+	$this->curlOPT[CURLOPT_URL] = $this->curlOPT[CURLOPT_URL] . '/' . $contact[0]['id'];
+
+	$c = curl_init();
+	curl_setopt_array($c, $this->curlOPT);
+	curl_setopt($c, CURLOPT_CUSTOMREQUEST, "DELETE");
+	$r = curl_exec($c);
+	curl_close($c);
+
+	$body = json_decode($r, true);
+
+	$this->assertNull($body);
+    }
+
+    public function testCheckFinish() {
+	Controller::service('PostgreSQL')->execResultSql("DELETE from expressomail_dynamic_contact where owner = ('42798')");
+
+	$c = curl_init();
+	curl_setopt_array($c, $this->curlOPT);
+	$r = curl_exec($c);
+	curl_close($c);
+	$body = json_decode($r, true);
+
+	$this->assertNull($body['collection']['items']);
+    }
+
+    public function tearDown() {
+	$this->classOAuth->unsetRefreshToken($this->refreshToken);
+	$this->classOAuth->unsetAccessToken($this->accessToken);
+    }
+
+}
+
+?>
Index: sandbox/2.4-expresso-api/prototype/library/oauth2/lib/OAuth2.php
===================================================================
--- sandbox/2.4-expresso-api/prototype/library/oauth2/lib/OAuth2.php	(revision 5888)
+++ sandbox/2.4-expresso-api/prototype/library/oauth2/lib/OAuth2.php	(revision 6230)
@@ -459,6 +459,10 @@
 		session_write_close(); //Fecha session anterior
 		session_id($token['refresh_token']); //Define o id da session o mesmo do resfresh token
-		session_start();
-		
+		@session_start();
+		
+		/* TODO - Verificar melhor solução para verificação de tratamento para sessions já startadas
+		if(!isset($_SESSION))
+		    session_start();
+		*/
 		return $token;
 	}
Index: sandbox/2.4-expresso-api/prototype/library/tonic/lib/tonic.php
===================================================================
--- sandbox/2.4-expresso-api/prototype/library/tonic/lib/tonic.php	(revision 5888)
+++ sandbox/2.4-expresso-api/prototype/library/tonic/lib/tonic.php	(revision 6230)
@@ -126,4 +126,10 @@
     
     /**
+     * Body data of incoming request
+     * @var array
+     */
+    public $dataDecoded;
+    
+    /**
      * Array of if-match etags
      * @var str[]
@@ -298,7 +304,10 @@
         $this->method = strtoupper($this->getConfig($config, 'method', 'REQUEST_METHOD', $this->method));
         
-        // get HTTP request data
-        $this->data = $this->getConfig($config, 'data', NULL, file_get_contents("php://input"));
-        
+	// get HTTP request data
+	$this->data = $this->getConfig($config, 'data', NULL, file_get_contents("php://input"));
+
+        // get HTTP request dataDecode into array
+	$this->dataDecoded  = $this->__decodeData( $this->data );
+	
         // conditional requests
         if ($config['ifMatch']) {
@@ -415,5 +424,22 @@
     
     }
-    
+
+     /**
+     * Convert the string data into a array data
+     * @return array
+     * @codeCoverageIgnore
+     */
+    function __decodeData($data) {
+	$arrayData = array();
+	if($data){
+	    $arrayIndex = explode('&', $data);
+	    foreach($arrayIndex as $key => $value){
+		list($i,$val) = explode ('=', $value);
+		$arrayData[$i] = $val;
+	    }
+	}
+	return $arrayData;
+    }
+
     /**
      * Convert the object into a string suitable for printing
Index: sandbox/2.4-expresso-api/prototype/config/Tonic.srv
===================================================================
--- sandbox/2.4-expresso-api/prototype/config/Tonic.srv	(revision 5888)
+++ sandbox/2.4-expresso-api/prototype/config/Tonic.srv	(revision 6230)
@@ -9,4 +9,13 @@
 NewsLastResource = /news/NewsLastResource.php
 
+[/dynamiccontacts]
+DynamicContactsResource = /contact/DynamicContactsResource.php
+
+[/oi]
+DynamicContactDeleteResource = /contact/DynamicContactDeleteResource.php
+
+[/dynamiccontacts/:id]
+DynamicContactResource = /contact/DynamicContactResource.php
+
 [/token]
 TokenResource = /oauth/TokenResource.php
Index: sandbox/2.4-expresso-api/prototype/config/PostgreSQL.srv
===================================================================
--- sandbox/2.4-expresso-api/prototype/config/PostgreSQL.srv	(revision 5888)
+++ sandbox/2.4-expresso-api/prototype/config/PostgreSQL.srv	(revision 6230)
@@ -3,5 +3,5 @@
 [config]
 port = 5432
-dbname= expresso24cristianoAPI
+dbname= expressoApiCoutinho
 user=postgres
 host = /tmp
Index: sandbox/2.4-expresso-api/prototype/config/dynamicContact.ini
===================================================================
--- sandbox/2.4-expresso-api/prototype/config/dynamicContact.ini	(revision 6230)
+++ sandbox/2.4-expresso-api/prototype/config/dynamicContact.ini	(revision 6230)
@@ -0,0 +1,10 @@
+service = PostgreSQL
+PostgreSQL.concept = expressomail_dynamic_contact
+
+
+[PostgreSQL.mapping]
+id = id
+name = name
+mail = mail
+owner = owner
+timestamp = timestamp
Index: sandbox/2.4-expresso-api/prototype/api/datalayer.js
===================================================================
--- sandbox/2.4-expresso-api/prototype/api/datalayer.js	(revision 5888)
+++ sandbox/2.4-expresso-api/prototype/api/datalayer.js	(revision 6230)
@@ -198,4 +198,15 @@
 		    else
 			result = dt;
+
+		},
+	      'error': function( dt, textStatus, jqXHR ){
+
+		    if( callback )
+		    {
+			fired = true;
+			result = callback( $.parseJSON(dt.responseText), textStatus, jqXHR );
+		    }
+		    else
+			result = $.parseJSON(dt.responseText);
 
 		},
@@ -254,5 +265,5 @@
     create: function( uri, data, callback, accept ){
       
-	return this.send( this.dispatchPath + 'rest' + uri, [ 'post', accept || 'json' ], data, callback, !!!callback, 
+	return this.send( 'rest' + uri, [ 'post', accept || 'json' ], data, callback, !!!callback, 
 	{'beforeSend' : function (xhr){ 
 	    xhr.setRequestHeader('Authorization', "OAUTH Bearer " + DataLayer.me.token)} 
@@ -272,5 +283,5 @@
     update: function( uri, data, callback, accept ){
       
-	return this.send( this.dispatchPath + 'rest' + uri, [ 'put', accept || 'json' ], data, callback, !!!callback, 
+	return this.send( 'rest' + uri, [ 'put', accept || 'json' ], data, callback, !!!callback, 
 	{'beforeSend' : function (xhr){ 
 	    xhr.setRequestHeader('Authorization', "OAUTH Bearer " + DataLayer.me.token)} 
@@ -290,5 +301,5 @@
     "delete": function( uri, callback, accept ){
       
-	return this.send( this.dispatchPath + 'rest' + uri, [ 'delete', accept || 'json' ], false, callback, !!!callback, 
+	return this.send( 'rest' + uri, [ 'delete', accept || 'json' ], false, callback, !!!callback, 
 	{'beforeSend' : function (xhr){ 
 	    xhr.setRequestHeader('Authorization', "OAUTH Bearer " + DataLayer.me.token)} 
Index: sandbox/2.4-expresso-api/prototype/rest/dispatch.php
===================================================================
--- sandbox/2.4-expresso-api/prototype/rest/dispatch.php	(revision 5888)
+++ sandbox/2.4-expresso-api/prototype/rest/dispatch.php	(revision 6230)
@@ -37,5 +37,5 @@
 // handle request, passing the current env baseUri and autoload mapping;
 $request = new Request(array(
-	'baseUri'=> '/cristiano/expresso-api/rest',
+	'baseUri'=> '/acoutinho/expressoAPI/rest',
 	'autoload' => $autoload,
 ));
Index: sandbox/2.4-expresso-api/prototype/rest/hypermedia/data.php
===================================================================
--- sandbox/2.4-expresso-api/prototype/rest/hypermedia/data.php	(revision 6230)
+++ sandbox/2.4-expresso-api/prototype/rest/hypermedia/data.php	(revision 6230)
@@ -0,0 +1,71 @@
+<?php
+
+class Data {
+
+    public $name;
+    public $value;
+    public $prompt;
+    public $dataType;
+    public $maxLength;
+    public $minLength;
+    public $required;
+
+    function setName($name) {
+	$this->name = $name;
+    }
+
+    function getName() {
+	return $this->name;
+    }
+
+    function setValue($value) {
+	$this->value = $value;
+    }
+
+    function getVame() {
+	return $this->value;
+    }
+
+    function setPrompt($prompt) {
+	$this->prompt = $prompt;
+    }
+
+    function getPrompt() {
+	return $this->prompt;
+    }
+
+    function setDataType($dataType) {
+	$this->dataType = $dataType;
+    }
+
+    function getDataType() {
+	return $this->dataType;
+    }
+
+    function setMaxLength($maxLength) {
+	$this->maxLength = $maxLength;
+    }
+
+    function getMaxLength() {
+	return $this->maxLength;
+    }
+
+    function setMinLength($minLength) {
+	$this->minLength = $minLength;
+    }
+
+    function getMinLength() {
+	return $this->minLength;
+    }
+
+    function setRequired($required) {
+	$this->required = $required;
+    }
+
+    function getRequired() {
+	return $this->required;
+    }
+
+}
+
+?>
Index: sandbox/2.4-expresso-api/prototype/rest/hypermedia/error.php
===================================================================
--- sandbox/2.4-expresso-api/prototype/rest/hypermedia/error.php	(revision 6230)
+++ sandbox/2.4-expresso-api/prototype/rest/hypermedia/error.php	(revision 6230)
@@ -0,0 +1,35 @@
+<?php
+
+class Error {
+
+    public $code;
+    public $description;
+    public $title;
+
+    public function setCode($code) {
+	$this->code = $code;
+    }
+
+    public function setDescription($description) {
+	$this->description = $description;
+    }
+
+    public function setTitle($title) {
+	$this->title = $title;
+    }
+
+    public function getCode() {
+	return $this->code;
+    }
+
+    public function getDescription() {
+	return $this->description;
+    }
+
+    public function getTitle() {
+	return $this->title;
+    }
+
+}
+
+?>
Index: sandbox/2.4-expresso-api/prototype/rest/hypermedia/collection.php
===================================================================
--- sandbox/2.4-expresso-api/prototype/rest/hypermedia/collection.php	(revision 6230)
+++ sandbox/2.4-expresso-api/prototype/rest/hypermedia/collection.php	(revision 6230)
@@ -0,0 +1,84 @@
+<?php
+
+include_once('item.php');
+include_once('link.php');
+include_once('data.php');
+include_once('template.php');
+
+
+class Collection {
+
+    public $itens = array();
+    public $href;
+    public $error;
+    public $pagination;
+    public $queries;
+    public $template;
+    public $type;
+    public $data;
+
+    function __construct($config, $className) {
+	foreach ($config as $key => $value) {
+	    if ($value['class'] == $className) {
+		$uri = $key;
+		break;
+	    }
+	}
+	$this->href = $uri;
+    }
+
+    function addItem($item) {
+	$this->itens[] = $item;
+    }
+
+    function setData($data) {
+	$this->data = $data;
+    }
+
+    function getData() {
+	return $this->data;
+    }
+    
+    function setTemplate($template) {
+	$this->template = $template;
+    }
+
+    function getTemplate() {
+	return $this->template;
+    }
+
+    function setType($type) {
+	$this->type = $type;
+    }
+
+    function getType() {
+	return $this->type;
+    }
+
+    function setQueries($queries) {
+	$this->queries = $queries;
+    }
+
+    function getQueries() {
+	return $this->queries;
+    }
+
+    function setError($error) {
+	$this->error = $error;
+    }
+
+    function getError() {
+	return $this->error;
+    }
+
+    function setPagination($pagination) {
+	$this->pagination = $pagination;
+    }
+
+    function getPagination() {
+	return $this->pagination;
+    }
+
+}
+
+?>
Index: sandbox/2.4-expresso-api/prototype/rest/hypermedia/template.php
===================================================================
--- sandbox/2.4-expresso-api/prototype/rest/hypermedia/template.php	(revision 6230)
+++ sandbox/2.4-expresso-api/prototype/rest/hypermedia/template.php	(revision 6230)
@@ -0,0 +1,13 @@
+<?php
+
+class Template {
+
+    public $data = array();
+
+    public function addData($data) {
+	$this->data[] = $data;
+    }
+
+}
+
+?>
Index: sandbox/2.4-expresso-api/prototype/rest/hypermedia/link.php
===================================================================
--- sandbox/2.4-expresso-api/prototype/rest/hypermedia/link.php	(revision 6230)
+++ sandbox/2.4-expresso-api/prototype/rest/hypermedia/link.php	(revision 6230)
@@ -0,0 +1,53 @@
+<?php
+
+class Link {
+
+    public $href;
+    public $rel;
+    public $alt;
+    public $prompt;
+    public $render;
+
+    function setHref($href) {
+	$this->href = $href;
+    }
+
+    function getHref() {
+	return $this->href;
+    }
+
+    function setRel($rel) {
+	$this->rel = $rel;
+    }
+
+    function getRel() {
+	return $this->rel;
+    }
+
+    function setAlt($alt) {
+	$this->alt = $alt;
+    }
+
+    function getAlt() {
+	return $this->alt;
+    }
+
+    function setPrompt($prompt) {
+	$this->prompt = $prompt;
+    }
+
+    function getPrompt() {
+	return $this->prompt;
+    }
+
+    function setRender($render) {
+	$this->render = $render;
+    }
+
+    function getRender() {
+	return $this->render;
+    }
+
+}
+
+?>
Index: sandbox/2.4-expresso-api/prototype/rest/hypermedia/item.php
===================================================================
--- sandbox/2.4-expresso-api/prototype/rest/hypermedia/item.php	(revision 6230)
+++ sandbox/2.4-expresso-api/prototype/rest/hypermedia/item.php	(revision 6230)
@@ -0,0 +1,39 @@
+<?php
+
+class Item {
+
+    public $href;
+    public $data = array();
+    public $links = array();
+
+    function __construct($config, $className, $id) {
+
+	foreach ($config as $key => $value) {
+	    if ($value['class'] == $className) {
+		//TODO - Verificar expressão regular
+		$uri = preg_replace('/[:][a-zA-Z-0-9]+/', '', $key);
+		break;
+	    }
+	}
+	$this->href = $uri . $id;
+    }
+
+    function setHref($href) {
+	$this->href = $href;
+    }
+
+    function getHref() {
+	return $this->href;
+    }
+
+    function addData($data) {
+	$this->data[] = $data;
+    }
+
+    function addLink($link) {
+	$this->links[] = $link;
+    }
+
+}
+
+?>  
Index: sandbox/2.4-expresso-api/prototype/rest/hypermedia/query.php
===================================================================
--- sandbox/2.4-expresso-api/prototype/rest/hypermedia/query.php	(revision 6230)
+++ sandbox/2.4-expresso-api/prototype/rest/hypermedia/query.php	(revision 6230)
@@ -0,0 +1,7 @@
+<?php
+
+class Querie {
+    
+}
+
+?>
Index: sandbox/2.4-expresso-api/prototype/rest/hypermedia/hypermedia.php
===================================================================
--- sandbox/2.4-expresso-api/prototype/rest/hypermedia/hypermedia.php	(revision 6230)
+++ sandbox/2.4-expresso-api/prototype/rest/hypermedia/hypermedia.php	(revision 6230)
@@ -0,0 +1,70 @@
+<?php
+
+include_once('collection.php');
+
+class Hypermedia {
+
+    public $collection;
+    public $version = '0.1';
+
+    function setCollection($collection) {
+	$this->collection = $collection;
+    }
+
+    function getCollection() {
+	return $this->collection;
+    }
+
+    function getHypermeida($accept = 'json') {
+
+	$data = get_object_vars($this);
+
+	switch ($accept) {
+	    case 'json':
+		return json_encode($data);
+		break;
+	    case 'xml':
+		return $this->generateValidXmlFromArray($data);
+	    default :
+		return json_encode($data);
+	}
+    }
+
+// functions adopted from http://www.sean-barton.co.uk/2009/03/turning-an-array-or-object-into-xml-using-php/
+
+    function generateValidXmlFromObj(stdClass $obj, $node_block = 'nodes', $node_name = 'node') {
+	$arr = get_object_vars($obj);
+	return self::generateValidXmlFromArray($arr, $node_block, $node_name);
+    }
+
+    function generateValidXmlFromArray($array, $node_block = 'nodes', $node_name = 'node') {
+	$xml = '<?xml version="1.0" encoding="UTF-8" ?>';
+
+	$xml .= '<' . $node_block . '>';
+	$xml .= self::generateXmlFromArray($array, $node_name);
+	$xml .= '</' . $node_block . '>';
+
+	return $xml;
+    }
+
+    function generateXmlFromArray($array, $node_name) {
+	$xml = '';
+
+	if (is_array($array) || is_object($array)) {
+	    foreach ($array as $key => $value) {
+		if (is_numeric($key)) {
+		    $key = $node_name;
+		}
+
+		$xml .= '<' . $key . '>' . self::generateXmlFromArray($value, $node_name) . '</' . $key . '>';
+	    }
+	} else {
+	    $xml = htmlspecialchars($array, ENT_QUOTES);
+	}
+
+	return $xml;
+    }
+
+}
+
+?>
Index: sandbox/2.4-expresso-api/prototype/rest/calendar/CalendarLastResource.php
===================================================================
--- sandbox/2.4-expresso-api/prototype/rest/calendar/CalendarLastResource.php	(revision 5888)
+++ sandbox/2.4-expresso-api/prototype/rest/calendar/CalendarLastResource.php	(revision 6230)
@@ -16,5 +16,5 @@
     function GET($request){
 	$this->secured();
-	
+
 	$calendar = Controller::find( array( 'concept' => 'calendarSignature' ), array('calendar'), array( 'filter' => array( '=', 'user',  Config::me("uidNumber") ) ) );
 
Index: sandbox/2.4-expresso-api/prototype/rest/contact/DynamicContactDeleteResource.php
===================================================================
--- sandbox/2.4-expresso-api/prototype/rest/contact/DynamicContactDeleteResource.php	(revision 6230)
+++ sandbox/2.4-expresso-api/prototype/rest/contact/DynamicContactDeleteResource.php	(revision 6230)
@@ -0,0 +1,135 @@
+<?php
+
+include_once('/home/acoutinho/expressoAPI/prototype/rest/hypermedia/hypermedia.php');
+
+class DynamicContactDeleteResource extends Resource{
+
+    /**
+    * Busca os eventos contidos nas agendas assinas do usuário
+    *
+    * @license    http://www.gnu.org/copyleft/gpl.html GPL
+    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
+    * @sponsor    Caixa Econômica Federal
+    * @author     Adriano Coutinho da Silva
+    * @author     Adir Kuhn
+    * @return     Remove um resource do contato
+    * @access     public
+    **/
+	function get($request) {
+		try {
+		    
+		    $response = new Response($request);
+		    $response->addHeader('Content-type', 'aplication/json');
+		    $this->secured();
+		    $response->code = Response::OK;
+		    
+		    $dynamicContact = Controller::find(array('concept' => 'dynamicContact'), false, array('filter' => array('=', 'owner', Config::me("uidNumber"))));
+		    
+		    $h = new Hypermedia();
+		    $c = new Collection($request->resources, 'DynamicContactsResource');
+
+		    foreach($dynamicContact as $value){
+			$d = new Data();
+			$i = new Item($request->resources, 'DynamicContactResource', $value['id']);
+			
+			$d->setName('name');
+			$d->setValue($value['name']);
+			$d->setPrompt('Nome do contato');
+			$d->setDataType('string');
+			$d->setMaxLength('100');
+			$d->setMinLength(null);
+			$d->setRequired(false);
+			
+			$i->addData($d);
+
+			$d->setName('email');
+			$d->setValue($value['mail']);
+			$d->setPrompt('Email do contato');
+			$d->setDataType('string');
+			$d->setMaxLength('100');
+			$d->setMinLength(null);
+			$d->setRequired(true);
+			
+			$i->addData($d);			
+			$l = new Link();
+
+			$l->setHref($i->getHref());
+			$l->setRel('delete');
+			$l->setAlt('Remover');
+			$l->setPrompt('Remover');
+			$l->setRender('link');
+			
+			$i->addLink($l);
+			
+			$l->setHref($i->getHref());
+			$l->setRel('put');
+			$l->setAlt('Atualizar');
+			$l->setPrompt('Atualizar');
+			$l->setRender('link');
+			
+			$i->addLink($l);
+			
+			$l->setHref($i->getHref());
+			$l->setRel('get');
+			$l->setAlt('Buscar');
+			$l->setPrompt('Buscar');
+			$l->setRender('link');
+
+			$i->addLink($l);
+			$c->addItem($i);
+		    }
+
+		    $t = new Template();
+		    $d = new Data();
+
+		    $d->setName('name');
+		    $d->setValue(null);
+		    $d->setPrompt('Nome do contato');
+		    $d->setDataType('string');
+		    $d->setMaxLength(100);
+		    $d->setMinLength(null);
+		    $d->setRequired(false);
+
+		    $t->addData($d);
+		    $d = new Data();
+
+		    $d->setName('email');
+		    $d->setValue(null);
+		    $d->setPrompt('Email do contato');
+		    $d->setDataType('string');
+		    $d->setMaxLength(100);
+		    $d->setMinLength(null);
+		    $d->setRequired(true);
+
+		    $t->addData($d);
+
+		    $c->setTemplate($t);
+		    $d = new Data();
+
+		    $d->setName('Dynamic Contacts');
+		    $d->setValue(null);
+		    $d->setPrompt('Contatos Dinâmicos');
+		    $d->setDataType(null);
+		    $d->setMaxLength(null);
+		    $d->setMinLength(null);
+		    $d->setRequired(null);
+		    
+		    $c->setData($d);
+		    
+		    $h->setCollection($c);
+		    
+		}  catch (Exception $ex){
+			$response->code = Response::INTERNALSERVERERROR;
+			$error = array(
+				'code' => '500',
+				'title' => 'Internal Server Error',
+				'description' => $ex);
+			return $response;
+		}
+
+		$response->body = $h->getHypermeida($request->accept[10][0]);		
+		return $response;
+	}
+
+}
+?>
Index: sandbox/2.4-expresso-api/prototype/rest/contact/DynamicContactsResource.php
===================================================================
--- sandbox/2.4-expresso-api/prototype/rest/contact/DynamicContactsResource.php	(revision 6230)
+++ sandbox/2.4-expresso-api/prototype/rest/contact/DynamicContactsResource.php	(revision 6230)
@@ -0,0 +1,171 @@
+<?php
+
+class DynamicContactsResource extends Resource {
+
+    /**
+     * Busca os eventos contidos nas agendas assinas do usuário
+     *
+     * @license    http://www.gnu.org/copyleft/gpl.html GPL
+     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
+     * @sponsor    Caixa Econômica Federal
+     * @author     Adriano Coutinho da Silva
+     * @author     Adir Kuhn
+     * @return     Retorna a colection de contatos dinâmicos de um usuário
+     * @access     public
+     * */
+    function get($request) {
+	try {
+	    $response = new Response($request);
+	    $response->addHeader('Content-type', 'aplication/json');
+
+	    $this->secured();
+	    $dynamicContact = Controller::find(array('concept' => 'dynamicContact'), false, array('filter' => array('=', 'owner', Config::me("uidNumber"))));
+
+	    $response->code = Response::OK;
+	    $resourceHref = str_replace($request->baseUri, '', $request->uri);
+
+	    if ($dynamicContact) {
+		$data = array();
+		foreach ($dynamicContact as $key => $value) {
+		    $data[$key] = array(
+			'href' => '/dynamic-contacts/' . $value['id'],
+			'data' => array(
+			    array(
+				'name' => "name",
+				'value' => $value['name'],
+				'prompt' => "Nome do Contato"
+			    ),
+			    array(
+				"name" => "email",
+				"value" => $value['mail'],
+				"prompt" => "Email do Contato"
+			    )
+			),
+			'links' => array(
+			    array(
+				'href' => $resourceHref . "/" . $value['id'],
+				'rel' => 'delete',
+				'prompt' => 'Remover contato dinamico',
+				'name' => 'delete-contact',
+				'render' => 'link'
+			    ),
+			    array(
+				'href' => $resourceHref . '/' . $value['id'],
+				'rel' => 'update',
+				'prompt' => 'Editar contato dinamico',
+				'name' => 'edit-contact',
+				'render' => 'link'
+			    )
+			)
+		    );
+		}
+	    }else
+		$data = null;
+
+	    $result = array(
+		"version" => "0.1",
+		"collection" => array(
+		    "href" => $resourceHref,
+		    "type" => "dynamic-contacts",
+		    "data" => array(
+			"name" => "dynamic-contacts",
+			"prompt" => "Contatos dinâmicos"
+		    ),
+		    "pagination" => null,
+		    "items" => $data,
+		    "queries" => null,
+		    "template" => array(
+			"data" => array(
+			    array(
+				"name" => "name",
+				"value" => "",
+				"prompt" => "Nome do contato",
+				"dataType" => "string",
+				"minLength" => 0,
+				"maxLength" => 100,
+				"required" => false
+			    ),
+			    array(
+				"name" => "email",
+				"value" => "",
+				"prompt" => "Email do contato",
+				"dataType" => "string",
+				"minLength" => 0,
+				"maxLength" => 100,
+				"required" => true
+			    )
+			)
+		    ),
+		    'error' => null
+		)
+	    );
+	} catch (Exception $ex) {
+	    $this->createException($response, Response::INTERNALSERVERERROR, 'Internal Server Error', $ex);
+	    return $response;
+	}
+
+	$response->body = json_encode($result);
+	return $response;
+    }
+
+    function post($request) {
+
+	try {
+	    $response = new Response($request);
+	    $response->addHeader('Content-type', 'aplication/json');
+	    $data = $_POST;
+
+	    if ($this->validData($data)) {
+		$this->secured();
+
+		$response->code = Response::OK;
+
+		$exists = Controller::find(array('concept' => 'dynamicContact'), false, array('filter' => array('AND',
+				array('=', 'owner', Config::me("uidNumber")),
+				array('=', 'mail', $data['email'])
+				)));
+
+		if ($exists) {
+		    //Controller::update(array('concept' => 'dynamicContact', 'id' => $exists[0]['id']), array('name' => $data['name'], 'email' => $data['email'], 'timestamp' => time()));
+
+		    $this->createException($response, Response::BADREQUEST, 'Bad request', Controller::service('PostgreSQL')->error);
+		    return $response;
+		}else
+		    $newDynamicContact = Controller::create(array('concept' => 'dynamicContact'), array('name' => $data['name'], 'mail' => $data['email'], 'owner' => Config::me("uidNumber"), 'timestamp' => time()));
+
+		if (!$newDynamicContact)
+		    $this->createException($response, Response::INTERNALSERVERERROR, 'Internal Server Error', Controller::service('PostgreSQL')->error);
+	    } else {
+		$this->createException($response, Response::BADREQUEST, 'Bad request', 'Invalid template data');
+		return $response;
+	    }
+	} catch (Exception $ex) {
+	    $this->createException($response, Response::INTERNALSERVERERROR, 'Internal Server Error', $ex);
+	    return $response;
+	}
+
+	return $response;
+    }
+
+    private function createException(&$response, $code, $title, $description) {
+	$result = array(
+	    'version' => '0.1',
+	    'collection' => array(
+		'error' => array(
+		    'code' => $code,
+		    'title' => $title,
+		    'description' => $description
+		)
+	    )
+	);
+	$response->code = $code;
+	$response->body = json_encode($result);
+    }
+
+    private function validData($data) {
+	return ((array_key_exists('name', $data) && !empty($data['name'])) && (array_key_exists('email', $data) && !empty($data['email']))) ? true : false;
+    }
+
+}
+
+?>
Index: sandbox/2.4-expresso-api/prototype/rest/contact/DynamicContactResource.php
===================================================================
--- sandbox/2.4-expresso-api/prototype/rest/contact/DynamicContactResource.php	(revision 6230)
+++ sandbox/2.4-expresso-api/prototype/rest/contact/DynamicContactResource.php	(revision 6230)
@@ -0,0 +1,255 @@
+<?php
+
+class DynamicContactResource extends Resource {
+
+    /**
+     * Busca um contato dinâmico da lista do usuário
+     *
+     * @license    http://www.gnu.org/copyleft/gpl.html GPL
+     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
+     * @sponsor    Caixa Econômica Federal
+     * @author     Adriano Coutinho da Silva
+     * @author     Adir Kuhn
+     * @return     Retorna um item da colection de contatos dinâmicos de um usuário
+     * @access     public
+     * */
+    function get($request, $id) {
+	try {
+	    $response = new Response($request);
+	    $response->addHeader('Content-type', 'aplication/json');
+
+	    $isValidId = $this->isValidId($id);
+
+	    if (!$isValidId) {
+		$this->createException($response, Response::BADREQUEST, 'Malformed URL', 'Malformed URL');
+		return $response;
+	    }
+	    $response->code = Response::OK;
+
+	    $this->secured();
+	    //$dynamicContact = false;
+	    $dynamicContact = Controller::find(array('concept' => 'dynamicContact'), false, array('filter' => array('AND', array('=', 'owner', Config::me("uidNumber")), array('=', 'id', $id))));
+
+	    $resourceHref = str_replace($request->baseUri, '', $request->uri);
+
+	    if ($dynamicContact) {
+		$data = array();
+		foreach ($dynamicContact as $key => $value) {
+		    $data[$key] = array(
+			'href' => '/dynamiccontacts/' . $value['id'],
+			'data' => array(
+			    array(
+				'name' => "name",
+				'value' => $value['name'],
+				'prompt' => "Nome do Contato"
+			    ),
+			    array(
+				"name" => "email",
+				"value" => $value['mail'],
+				"prompt" => "Email do Contato"
+			    )
+			),
+			'links' => array(
+			    array(
+				'href' => $resourceHref,
+				'rel' => 'delete',
+				'prompt' => 'Remover contato dinamico',
+				'name' => 'delete-contact',
+				'render' => 'link'
+			    ),
+			    array(
+				'href' => $resourceHref,
+				'rel' => 'update',
+				'prompt' => 'Editar contato dinamico',
+				'name' => 'edit-contact',
+				'render' => 'link'
+			    )
+			)
+		    );
+		}
+	    } else {
+		$this->createException($response, Response::NOTFOUND, 'Contact not found', ( $isValidId ? "The contact " . $id . " wasn't found on this server" : 'url malformed'));
+		return $response;
+	    }
+
+	    $result = array(
+		"version" => "0.1",
+		"collection" => array(
+		    "href" => $resourceHref,
+		    "type" => "dynamic-contact",
+		    "data" => array(
+			"name" => "dynamic-contact-" . $id,
+			"prompt" => "Contato dinâmico"
+		    ),
+		    "pagination" => null,
+		    "items" => $data,
+		    "queries" => null,
+		    "template" => array(
+			"data" => array(
+			    array(
+				"name" => "name",
+				"value" => "",
+				"prompt" => "Nome do contato",
+				"dataType" => "string",
+				"minLength" => 0,
+				"maxLength" => 100,
+				"required" => false
+			    ),
+			    array(
+				"name" => "email",
+				"value" => "",
+				"prompt" => "Email do contato",
+				"dataType" => "string",
+				"minLength" => 0,
+				"maxLength" => 100,
+				"required" => true
+			    )
+			)
+		    ),
+		'error' => null
+		)
+	    );
+	} catch (Exception $ex) {
+	    $this->createException($response, Response::INTERNALSERVERERROR, 'Internal Server Error', $ex);
+	    return $response;
+	}
+
+	$response->body = json_encode($result);
+	return $response;
+    }
+
+    /**
+     * Deleta um item da coleção de contatos dinâmicos
+     *
+     * @license    http://www.gnu.org/copyleft/gpl.html GPL
+     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
+     * @sponsor    Caixa Econômica Federal
+     * @author     Adriano Coutinho da Silva
+     * @author     Adir Kuhn
+     * @return     status http
+     * @access     public
+     * */
+    function delete($request, $id) {
+
+	try {
+	    $response = new Response($request);
+	    $response->addHeader('Content-type', 'aplication/json');
+
+	    $isValidId = $this->isValidId($id);
+	    if (!$isValidId) {
+		$this->createException($response, Response::BADREQUEST, 'Malformed URL', 'Malformed URL');
+		return $response;
+	    }
+
+	    $this->secured();
+
+	    $response->code = Response::OK;
+	    $error = null;
+
+	    $exists = Controller::find(array('concept' => 'dynamicContact'), false, array('filter' => array('AND',
+			    array('=', 'owner', Config::me("uidNumber")),
+			    array('=', 'id', $id)
+			    )));
+
+	    if (!$exists) {
+		$this->createException($response, Response::BADREQUEST, 'Contact not found', "The contact " . $id . " wasn't found on this server");
+		return $response;
+	    }
+
+	    $deletedDynamicContact = Controller::delete(array('concept' => 'dynamicContact'), false, array('filter' => array('=', 'id', $id)));
+
+	    if (!$deletedDynamicContact)
+		$error = array(
+		    'code' => '500',
+		    'title' => 'Internal Server Error',
+		    'description' => Controller::service('PostgreSQL')->error
+		);
+	} catch (Exception $ex) {
+	    $this->createException($response, Response::INTERNALSERVERERROR, 'Internal Server Error', $ex);
+	    return $response;
+	}
+	return $response;
+    }
+
+    /**
+     * Atualiza um item da coleção de contatos dinâmicos
+     *
+     * @license    http://www.gnu.org/copyleft/gpl.html GPL
+     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
+     * @sponsor    Caixa Econômica Federal
+     * @author     Adriano Coutinho da Silva
+     * @author     Adir Kuhn
+     * @return     status http
+     * @access     public
+     * */
+    function put($request, $id) {
+	try {
+	    $response = new Response($request);
+	    $response->addHeader('Content-type', 'aplication/json');
+
+	    $isValidId = $this->isValidId($id);
+	    if (!$isValidId) {
+		$this->createException($response, Response::BADREQUEST, 'Malformed URL', 'Malformed URL');
+		return $response;
+	    }
+
+	    $data = $request->dataDecoded;
+
+	    if ($this->validData($data)) {
+
+		$this->secured();
+
+		$response->code = Response::OK;
+		$exists = Controller::find(array('concept' => 'dynamicContact'), false, array('filter' => array('AND',
+				array('=', 'owner', Config::me("uidNumber")),
+				array('=', 'mail', $data['email'])
+				)));
+
+		if (!empty($exists)) {
+		    $this->createException($response, Response::BADREQUEST, 'Bad request', Controller::service('PostgreSQL')->error);
+		    return $response;
+		}
+
+		$newDynamicContact = Controller::update(array('concept' => 'dynamicContact', 'id' => $id), array('name' => $data['name'], 'mail' => $data['email'], 'timestamp' => time()));
+
+		if (!$newDynamicContact)
+		    $this->createException($response, Response::INTERNALSERVERERROR, 'Internal Server Error', Controller::service('PostgreSQL')->error);
+	    } else
+		$this->createException($response, Response::BADREQUEST, 'Bad request', 'Invalid template data');
+	} catch (Exception $ex) {
+	    $this->createException($response, Response::INTERNALSERVERERROR, 'Internal Server Error', $ex);
+	    return $response;
+	}
+
+	return $response;
+    }
+
+    private function createException(&$response, $code, $title, $description) {
+	$result = array(
+	    'version' => '0.1',
+	    'collection' => array(
+		'error' => array(
+		    'code' => $code,
+		    'title' => $title,
+		    'description' => $description
+		)
+	    )
+	);
+	$response->code = $code;
+	$response->body = json_encode($result);
+    }
+
+    private function validData($data) {
+	return ((array_key_exists('name', $data) && !empty($data['name'])) && (array_key_exists('email', $data) && !empty($data['email']))) ? true : false;
+    }
+
+    private function isValidId($id) {
+	if (is_numeric($id)) {
+	    return strlen($id) > 10 ? false : true;
+	}else
+	    return false;
+    }
+
+}
+
+?>
