account; } /** * Utente dell'account * @var string */ private $user; public function getUser(){ return $this->user; } /** * Identificativo della richiesta (NULL in lettura) * @var string */ private $operationId; public function getOperationId(){ return $this->operationId; } /* * Metodi propri della classe */ /** * @param string $account Il token dell'account che fa la richiesta * @param string $user L'identificativo dell'utente (collegato all'account) che fa la richiesta * @param string $operationId Identificativo univoco del messaggio. UTILIZZARE SOLO IN SCRITTURA, IN LETTURA UTILIZZARE null * @param string $protocolVersion La versione del protocollo RAPI * @param RAPI_RequestDetails $details Il contenuto della richiesta * @param int $time Timestamp in microsecondi * @param string $digest Digest per valutare l'autenticità del messaggio */ public function __construct($account, $user, $operationId, $protocolVersion, RAPI_RequestDetails $details, $time = null, $digest = null){ parent::__construct($protocolVersion, $details, $time, $digest); $this->account = $account; $this->user = $user; $this->operationId = $operationId; } /** * Metodo di utility che richiama il metodo omonimo del request details. * Se una delle request è un checksumFake confronta solo i due checksum. * @param RAPI_Request $req * @return boolean */ public function isEqual(RAPI_Request $req){ return strcmp($this->getProtocolVersion(),$req->getProtocolVersion())==0 && strcmp($this->account,$req->account)==0 && strcmp($this->user,$req->user)==0 && strcmp($this->operationId,$req->operationId)==0 && $this->getDetails()->isEqual($req->getDetails()); } /** * Metodo di utility che richiama il metodo omonimo del request details. * @return bool */ public function isChecksumFake(){ return $this->getDetails()->isChecksumFake(); } /** * Genera la versione checksumFake della rapi request. * @return RAPI_Request */ public function generateChecksumFake(){ $rval = new RAPI_Request($this->account, $this->user, $this->getOperationId(), $this->getProtocolVersion(), $this->getDetails()->generateChecksumFake(), $this->getTime(), $this->getDigest()); return $rval; } /* * Abstract Implementations */ /** * @see RAPI_Message::generateEncryptionObject() */ protected function generateEncryptionObject(){ $rval = $this->generateEncryptionBaseObject(); $rval->account = $this->account; $rval->user = $this->user; $rval->operationId = $this->operationId; return $rval; } /** * @see RAPI_Message::isValidObjectForCreation() */ protected static function isValidObjectForCreation($obj){ return self::isValidObjectForCreationBase($obj) && property_exists($obj, "account") && property_exists($obj, "user") && property_exists($obj, "operationId"); } /** * @see RAPI_Message::createFromObject() */ public static function createFromObject($obj){ if (self::isValidObjectForCreation($obj)){ $details = RAPI_RequestDetailsFactory::generateFromEncryptionObject($obj->details); return new RAPI_Request($obj->account, $obj->user, $obj->operationId, $obj->version, $details, $obj->time, $obj->digest); } else { throw new RAPI_Exception("Invalid request format"); } } } ?>