/** * Creates project * * @param Paysera_WalletApi_Entity_Project $project * * @return Paysera_WalletApi_Entity_Project * @throws Paysera_WalletApi_Exception_LogicException */ public function saveProject(Paysera_WalletApi_Entity_Project $project) { if ($project->getId() === null) { throw new Paysera_WalletApi_Exception_LogicException("Project must have id property set"); } $responseData = $this->put('project/' . $project->getId(), $this->mapper->encodeProject($project)); return $this->mapper->decodeProject($responseData); }
/** * Encodes project object to array * * @param Paysera_WalletApi_Entity_Project $project * * @return array * @throws Paysera_WalletApi_Exception_LogicException */ public function encodeProject(Paysera_WalletApi_Entity_Project $project) { $result = array(); if ($project->getTitle() === null) { throw new Paysera_WalletApi_Exception_LogicException("Project must have title property set"); } $result['title'] = $project->getTitle(); if ($project->getDescription()) { $result['description'] = $project->getDescription(); } if ($project->getWalletId()) { $result['wallet_id'] = $project->getWalletId(); } return $result; }