/** * @group EricssonInt */ public function testAddCustomer() { $this->_suppServicesPack->save(); $data = $this->_spMapper->publish($this->_suppServicesPack->getId()); $this->assertNotNull($data); $this->assertTrue($data); $data = $this->_spMapper->addCustomer($this->_suppServicesPack->getId(), Organization\OrgCustomerModel::ORG_TYPE . '-' . self::CUSTOMER_ID); $this->assertNotNull($data); $this->assertTrue($data); }
/** * Get one supplServices, given its ID. * * @param mixed $id * @return mixed */ protected function _findOneById($id, $org = null) { if (!strlen((string) $id)) { throw new \Application\Exceptions\InvalidArgumentException(); } $proto = $this->_createProto(self::METHOD_NAME_GETDATA); $proto->setId($id); if ($org) { $orgNew = $this->_createOrganization($org->getId()); $proto->setOrganization($orgNew); } $response = $this->_sendRequest(self::METHOD_NAME_GETDATA, array('protoMessage' => $proto), $this->getEricssonService()); if ($this->_checkGetResponse($response)) { $data = $response->serialize(new \DrSlump\Protobuf\Codec\PhpArray()); if ($data) { unset($data['result']); } $result = new \Application\Model\SupplServicesModel($this->_mapEricssonModelToModel($data)); $result->setId($id); return $result; } return NULL; }
/** * @param Application\Model\SupplServicesModel $service * @return boolean */ public function removeCustomer(SupplServicesModel $service, OrgCustomerModel $org) { if (!strlen((string) $service->getId())) { throw new AppEx\InvalidArgumentException("Supplementary Services does not have an Id"); } if (!$org instanceof OrgCustomerModel) { throw new AppEx\InvalidArgumentException("Organization must be a customer."); } $orgId = $org->getId(); if (!isset($orgId) && !strlen($orgId)) { throw new AppEx\InvalidArgumentException("Organization customer does not have an Id"); } if ($service->getPublished() != \Application\Model\SupplServicesModel::STATUS_PUBLISHED) { throw new AppEx\InvalidArgumentException("Supplementary Services must be published to have customers"); } if ($service->subscriptionCount) { throw new AppEx\InvalidArgumentException("Customer sims are using supplementary services"); } $result = $this->getMapper()->removeCustomer($service->getId(), $org->getId()); \App::audit('Removed customer ' . $org->getId() . ' from supplementary services with Id ' . $service->getId(), $service); return $result; }
protected function _insertEricsson(\Application\Model\SupplServicesModel $supplServices) { $methodName = self::METHOD_NAME_CREATE; $proto = $this->_createProto($methodName); $createData = new \Application\Proto\SupplServices\SupplServicesSet(); $proto->setCreateData($createData); $mappedData = $this->_mapModelToEricssonModel($supplServices->exportData()); $createData->parse($mappedData, new \DrSlump\Protobuf\Codec\PhpArray()); $response = $this->_sendRequest($methodName, array('protoMessage' => $proto)); $ok = $this->_checkPostResponse($response); if ($ok) { $supplServices->setId($response->getId()); } }
/** * Update a supplServices identified by its Id */ public function putAction() { $supplService = $this->_getItem(); // Collect data $data = $this->_helper->requestData(); if (isset($data['serviceData'])) { $data = $data['serviceData']; } $data = $this->_mapToModel($data, false); $supplServiceNew = new SupplServicesModel($data); // Cannot modify applicationOriginatedSmsMsisdn if is already published if ($supplService->getPublished() == \Application\Model\SupplServicesModel::STATUS_PUBLISHED && $supplServiceNew->getApplicationOriginatedSmsMsisdn() && $supplService->getApplicationOriginatedSmsMsisdn() && $supplService->getApplicationOriginatedSmsMsisdn() != $supplServiceNew->getApplicationOriginatedSmsMsisdn()) { throw new AppEx\InvalidArgumentException("Invalid parameter value: applicationOriginatedSmsMsisdn. It can't be edited", Application\Error\ValidationCodes::MODEL_SUPPL_SERVICE_PACK); } if ($supplService->getPublished() != \Application\Model\SupplServicesModel::STATUS_NOT_PUBLISHED && $supplServiceNew->getCurrency()) { throw new AppEx\ValidateException('Invalid parameter value: currency. In published supplementary services pack it is not allowed to modify currency.'); } $this->_helper->allowed('update', $supplService); $this->_helper->filterNotAllowedFields('update_field', $supplService, $supplServiceNew); $supplService->importData($supplServiceNew->exportData()); $this->srv->update($supplService); $this->getResponse()->setHttpResponseCode(204); $this->_helper->viewRenderer->setNoRender(TRUE); }