/**
  * @param array $data
  * @param IMessageSenderService $new_purchase_order_message_sender
  * @throws EntityValidationException
  * @return mixed
  */
 public function registerPurchaseOrder(array $data, IMessageSenderService $new_purchase_order_message_sender)
 {
     $repository = $this->repository;
     $factory = $this->factory;
     $summit_packages_repository = $this->summit_packages_repository;
     $this->tx_manager->transaction(function () use($data, $repository, $summit_packages_repository, $factory, $new_purchase_order_message_sender) {
         $rules = array('package_id' => 'required|integer', 'summit_page_id' => 'required|integer', 'first_name' => 'required|text|max:250', 'last_name' => 'required|text|max:250', 'email' => 'required|text|max:250|email', 'organization' => 'required|text', 'organization_id' => 'sometimes|integer');
         $messages = array('first_name.required' => ':attribute is required', 'first_name.text' => ':attribute should be valid text.', 'first_name.max' => ':attribute should have less than 250 chars.', 'last_name.required' => ':attribute is required', 'last_name.text' => ':attribute should be valid text.', 'last_name.max' => ':attribute should have less than 250 chars.', 'email.required' => ':attribute is required', 'email.text' => ':attribute should be valid text.', 'email.max' => ':attribute should have less than 250 chars.', 'email.email' => ':attribute should be valid email.', 'organization.required' => ':attribute is required', 'organization.text' => ':attribute should be valid text.', 'package_id.required' => ':attribute is required', 'package_id.integer' => ':attribute should be valid integer.', 'summit_page_id.required' => ':attribute is required', 'summit_page_id.integer' => ':attribute should be valid integer.', 'organization_id.integer' => ':attribute should be valid integer.');
         $validator = ValidatorService::make($data, $rules, $messages);
         if ($validator->fails()) {
             throw new EntityValidationException($messages);
         }
         $package = $summit_packages_repository->getById($data['package_id']);
         if (is_null($package)) {
             throw new EntityValidationException(EntityValidationException::buildMessage(sprintf('package id %s does not exists!', $data['package_id'])));
         }
         if ($package->SoldOut()) {
             throw new EntityValidationException(EntityValidationException::buildMessage(sprintf('package id %s sold out!', $data['package_id'])));
         }
         if (!$package->isParentPage($data['summit_page_id'])) {
             throw new EntityValidationException(EntityValidationException::buildMessage(sprintf('package id %s does not belong to page id %s!', $data['package_id'], $data['summit_page_id'])));
         }
         $purchase_order = $factory->build($data);
         $repository->add($purchase_order);
         $new_purchase_order_message_sender->send($purchase_order);
     });
 }
Exemplo n.º 2
0
 /**
  * @param IMessageSenderService $service
  * @throws EntityValidationException
  */
 public function sentEmail(IMessageSenderService $service)
 {
     if ($this->BeenEmailed) {
         throw new EntityValidationException(array(array('message' => 'RSVP Email Already sent !')));
     }
     $this->BeenEmailed = true;
     $service->send($this);
 }
Exemplo n.º 3
0
 /**
  * @param IMessageSenderService $service
  * @throws EntityValidationException
  */
 public function sentEmail(IMessageSenderService $service)
 {
     if ($this->BeenEmailed) {
         throw new EntityValidationException(array(array('message' => 'Survey Email Already sent !')));
     }
     if (!$this->isLastStep()) {
         throw new EntityValidationException(array(array('message' => 'Survey is not on last step!')));
     }
     $current_step = $this->currentStep();
     if (!$current_step->template() instanceof ISurveyThankYouStepTemplate) {
         return;
     }
     $this->BeenEmailed = true;
     $service->send($this);
 }
 /**
  * @param int $bach_size
  * @param IMessageSenderService $invite_sender
  * @param IMessageSenderService $create_sender
  * @return mixed
  */
 public function ingestEvents($bach_size, IMessageSenderService $invite_sender, IMessageSenderService $create_sender)
 {
     $repository = $this->repository;
     $api = $this->api;
     $member_repository = $this->member_repository;
     $attendee_factory = $this->attendee_factory;
     $attendee_repository = $this->attendee_repository;
     $summit_repository = $this->summit_repository;
     return $this->tx_manager->transaction(function () use($bach_size, $repository, $api, $member_repository, $attendee_factory, $attendee_repository, $summit_repository, $invite_sender, $create_sender) {
         list($list, $count) = $repository->getUnprocessed(0, $bach_size);
         $qty = 0;
         foreach ($list as $event) {
             $json_data = $api->getEntity($event->getApiUrl(), array('expand' => 'attendees'));
             if (isset($json_data['attendees'])) {
                 $order_date = $json_data['created'];
                 $status = $json_data['status'];
                 if ($status === 'placed') {
                     foreach ($json_data['attendees'] as $attendee) {
                         $profile = $attendee['profile'];
                         $email = $profile['email'];
                         $external_id = $attendee['id'];
                         $answers = $attendee['answers'];
                         $bought_date = $attendee['created'];
                         $changed_date = $attendee['changed'];
                         $order_id = $attendee['order_id'];
                         $event_id = $attendee['event_id'];
                         $ticket_class_id = $attendee['ticket_class_id'];
                         $cancelled = $attendee['cancelled'];
                         $refunded = $attendee['refunded'];
                         $status = $attendee['status'];
                         if ($cancelled || $refunded) {
                             continue;
                         }
                         if ($status !== 'Attending') {
                             continue;
                         }
                         if (empty($email)) {
                             continue;
                         }
                         $member = $member_repository->findByEmail($email);
                         if (is_null($member)) {
                             // member not found ... send email to invite to openstack.org membership
                             $invite_sender->send($email);
                             continue;
                         }
                         $current_summit = $summit_repository->getByExternalEventId($event_id);
                         if (!$current_summit) {
                             continue;
                         }
                         $ticket_type = $current_summit->findTicketTypeByExternalId($ticket_class_id);
                         if (!$ticket_type) {
                             continue;
                         }
                         $old_attendee = $attendee_repository->getByMemberAndSummit($member->getIdentifier(), $current_summit->getIdentifier());
                         $ticket = $attendee_factory->buildTicket($external_id, $order_id, $bought_date, $changed_date, $ticket_type);
                         if ($old_attendee) {
                             if ($old_attendee->hasTicket($ticket)) {
                                 continue;
                             }
                             $attendee = $old_attendee;
                         } else {
                             $attendee = $attendee_factory->build($member, $current_summit);
                             // send email informing that u became attendee...
                             $create_sender->send($attendee);
                         }
                         $attendee->addTicket($ticket);
                         $attendee_repository->add($attendee);
                     }
                 }
             }
             $event->markAsProcessed($status);
             $qty++;
         }
         return $qty;
     });
 }
Exemplo n.º 5
0
 /**
  * @param string $token
  * @param IMessageSenderService $sender_service
  * @throws NotFoundEntityException
  * @return Member
  */
 public function verify($token, IMessageSenderService $sender_service)
 {
     $repository = $this->repository;
     return $this->tx_manager->transaction(function () use($token, $repository, $sender_service) {
         $member = $repository->getByEmailVerificationToken($token);
         if (is_null($member)) {
             throw new NotFoundEntityException('Member', sprintf('email verification token %s', $token));
         }
         $member->doEmailConfirmation($token);
         $sender_service->send($member);
         return $member;
     });
 }
 /**
  * @param IPresentation $presentation
  * @param IMessageSenderService $speakers_message_sender
  * @param IMessageSenderService $creator_message_sender
  * @param IMessageSenderService $moderator_message_sender
  * @return IPresentation
  */
 public function completePresentation(IPresentation $presentation, IMessageSenderService $speakers_message_sender, IMessageSenderService $creator_message_sender, IMessageSenderService $moderator_message_sender)
 {
     return $this->tx_manager->transaction(function () use($presentation, $speakers_message_sender, $creator_message_sender, $moderator_message_sender) {
         $speakers = $presentation->Speakers()->exclude(array('MemberID' => $presentation->CreatorID));
         $presentation->markReceived()->write();
         foreach ($speakers as $speaker) {
             $speakers_message_sender->send(['Presentation' => $presentation, 'Speaker' => $speaker]);
         }
         $creator_message_sender->send(['Presentation' => $presentation]);
         if ($presentation->Moderator()->exists()) {
             $moderator_message_sender->send(['Presentation' => $presentation]);
         }
         return $presentation;
     });
 }