.

--

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

 * 
 * Generic Table Editor
 * 
 * A simple JSON Response class.
 * Inspired by http://extjs.com/deploy/dev/examples/writer/writer.html
 *
 * @author Bernhard Woehrlin
 * @copyright (c) 2008-2009, IT.CappuccinoNet.com
 * @date 2009-09-01 16:27:36
 * @version 1.3
 * @class Response
 * 
 */
class Response {
    public $success, $data, $message, $errors, $tid, $trace, $total;

    public function __construct($params = array()) {
        $this->success     = isset($params["success"]) ? $params["success"] : false;
        $this->message     = isset($params["message"]) ? $params["message"] : '';
        $this->total       = isset($params["total"])    ? $params["total"]    : null;
				$this->data        = isset($params["data"])    ? $params["data"]    : array();
        
    }

    public function to_json() {
    	
        return json_encode(array(
            'success'    => $this->success,
            'message'    => $this->message,
            'total'      => $this->total,
            'data'       => $this->data
        ));
    }
}