/*
 * document.cpp
 *
 *  Created on: 27.5.2011
 *      Author: petr
 */

#include "document.h"

Document::Document() {
	objectType = "document";
}

int Document::get(string id) {
	//nacteni dat ze serveru
	int statusCode;
	string status;
	ParamMap params;

	Json::Value response = Comunicator::getInstance()->sendJsonRequest(objectType, "get", id, status, statusCode, params);

	if (statusCode != 200) {
		writeStatus(status, statusCode);
		return 0;
	}

	//nastaveni obecnych hodnot
	objectData = response;

	id = id;
	document_name = response["document"]["document_name"].asString();
	mime_type = response["document"]["mime_type"].asString();
	user_id = response["document"]["user_id"].asString();
	group_id = response["document"]["group_id"].asString();
	mask = response["document"]["mask"].asString();
	created_at = response["document"]["created_at"].asString();
	is_latest = response["document"]["is_latest"].asString();
	size = response["document"]["user_id"].asString();

	return 1;
}
