public function timeandconsumptionAction() { $sim = $this->_getSim(); if ($this->getRequest()->isGet()) { // Sync request $this->_helper->allowed('read_time_and_consumption', $sim); $this->_simSrv->getTimeAndConsumptionVoucher($sim); $this->view->timeAndConsumptionVoucher = $sim->getTimeAndConsumption() ? $sim->getTimeAndConsumption()->exportData() : null; if (empty($this->view->timeAndConsumptionVoucher)) { unset($this->view->timeAndConsumptionVoucher); } } else { if ($this->getRequest()->isPut()) { // Async request $this->_helper->allowed('update_time_and_consumption', $sim); $data = $this->_helper->requestData(true, false); if (!empty($data)) { $sim->setTimeAndConsumption($data); $this->_simSrv->updateTimeAndConsumptionVoucher($sim, $sim->getTimeAndConsumption()); } } else { throw new UnexpectedException("Resquest must be GET or PUT"); } } }
public function timeandconsumptionAction() { $sim = $this->_getSim(); if ($this->getRequest()->isGet()) { // Sync request $this->_helper->allowed('read_time_and_consumption', $sim); $this->_simSrv->getTimeAndConsumptionVoucher($sim); $this->view->timeAndConsumptionVoucher = $sim->getTimeAndConsumption() ? $sim->getTimeAndConsumption()->exportData() : null; if (empty($this->view->timeAndConsumptionVoucher)) { unset($this->view->timeAndConsumptionVoucher); } } else { if ($this->getRequest()->isPut()) { // Async request try { $this->_helper->allowed('update_time_and_consumption', $sim); } catch (\Application\Exceptions\PermissionException $ex) { throw new \Application\Exceptions\NotAllowedException('Update time and consumption Operation is not allowed: ' . $ex->getMessage()); } $data = $this->_helper->requestData(true, false); if (!in_array($sim->lifeCycleStatus, array(LifeCycleModel::STATUS_ACTIVE, LifeCycleModel::STATUS_ACTIVATION_READY))) { throw new InvalidArgumentException("Invalid parameter value: {$this->_getType()}. Supported values are sim with active or Activation Ready lifecycle state"); } // chached sim status check because https://jira.tid.es/browse/GLOBALPORTAL-184652 if (!empty($data)) { $sim->setTimeAndConsumption($data); $this->_simSrv->updateTimeAndConsumptionVoucher($sim, $sim->getTimeAndConsumption()); } } else { throw new UnexpectedException("Resquest must be GET or PUT"); } } }
/** * @expectedException \Application\Exceptions\InvalidArgumentException */ public function testInvalidSimUpdateTimeAndConsumptionVoucher() { $sims = ""; $tc = array('enabled' => true, 'dataTime' => 242342, 'dataConsumption' => 2342); $timeAndConsumption = new \Application\Model\Sim\TimeAndConsumptionVoucherModel($tc); $this->_service->updateTimeAndConsumptionVoucher($sims, $timeAndConsumption); }
public function timeAndConsumptionAction() { $data = $this->_checkAndGetListData('update_time_and_consumption', true); if (!$data['timeAndConsumption']) { throw new InvalidArgumentException('Bad Request. Malformed Json. parameter {timeAndConsumption} is required'); } $timeAndConsumption = new \Application\Model\Sim\TimeAndConsumptionVoucherModel($data['timeAndConsumption']); $watcher = $this->_simSrv->updateTimeAndConsumptionVoucher($data['list'], $timeAndConsumption); $this->_helper->filterNotAllowedFields('read_field', $watcher); $this->view->watcher = $watcher; }