/** * @param string $mobile * @param string $uniqueness * @param string $alias * @param string[] $topics * @param int $amount * * @throws TrialNotAcceptedInternalException * @throws ExistentMobileInternalException */ public function create($mobile, $uniqueness, $alias, $topics, $amount) { if ($this->checkOperationInternalWorker->checkTrial($mobile)) { throw new TrialNotAcceptedInternalException(); } try { $this->createSubscriptionInternalWorker->create($mobile, $uniqueness, $alias, $topics, $amount, 0, true); } catch (ExistentMobileInternalException $e) { throw $e; } $this->enqueueMessageApiWorker->enqueue($mobile, sprintf("Tu telefono se ha subscrito con %s sms gratis para recibir noticias %s que seleccionaste.", 10, count($topics) == 1 ? "del topico" : sprintf("de los %s topicos", count($topics)))); $this->logOperationInternalWorker->logTrial($mobile, $uniqueness, $topics, time()); }
/** * @param string $mobile * @param string $uniqueness * @param string $alias * @param string[] $topics * @param array $resellPackage * * @throws InsufficientBalanceInternalException * @throws ExistentMobileInternalException */ public function create($mobile, $uniqueness, $alias, $topics, $resellPackage) { if (!$this->checkBalanceInternalWorker->check($uniqueness, $resellPackage['amount'])) { throw new InsufficientBalanceInternalException(); } try { $this->createSubscriptionInternalWorker->create($mobile, $uniqueness, $alias, $topics, 0, $resellPackage['amount'], true); } catch (ExistentMobileInternalException $e) { throw $e; } $this->decreaseBalanceInternalWorker->decrease($uniqueness, $resellPackage['amount']); if (!$this->checkOperationInternalWorker->checkTrial($mobile) && !$this->checkOperationInternalWorker->checkCreate($mobile)) { $this->enqueueMessageApiWorker->enqueue($mobile, sprintf("Tu telefono se ha subscrito con %s sms para recibir noticias %s que seleccionaste.", $resellPackage['amount'], count($topics) == 1 ? "del topico" : sprintf("de los %s topicos", count($topics)))); } $this->logOperationInternalWorker->logCreate($mobile, $uniqueness, $topics, $resellPackage['amount'], time()); }
/** * Creates a subscription. * * @param string $mobile * @param string $uniqueness * @param string $alias * @param string[] $topics * @param int $trial * @param int $balance * @param boolean $active */ public function create($mobile, $uniqueness, $alias, $topics, $trial, $balance, $active) { $this->createSubscriptionInternalWorker->create($mobile, $uniqueness, $alias, $topics, $trial, $balance, $active); }