Esempio n. 1
0
 /**
  * Send an MMS with nuts to an expert user.
  *
  * @param ExpertAnalysisReceived $event
  */
 public function handle(ExpertAnalysisReceived $event)
 {
     // grab the expert and enthusiast user info
     $expert = $event->getExpertUser();
     $submission = $event->getSubmission();
     // set up message and acorns picture URL
     $message = "Your expert analysis is off to " . $submission->user->name . "! You just earned 2 nuts!";
     $acornsURL = env('APP_URL') . "/images/acorns.png";
     // give the expert 2 nuts for the analysis
     $expert->addNuts(2);
     // send MMS to expert
     $this->twilio->sendMMS($expert->phone, $message, $acornsURL);
 }
 /**
  * Send a potential squirrel photo to an expert.
  *
  * @param EnthusiastPictureReceived $event
  */
 public function handle(EnthusiastPictureReceived $event)
 {
     // extract data from event
     $incomingText = $event->getIncomingText();
     $enthusiast = $event->getUser();
     // retrieve all expert users
     $experts = $this->userModel->getAllExperts();
     // create submission
     $submission = $this->submissionCreationService->saveSubmission($incomingText, $enthusiast);
     // build message
     $message = "#" . $submission->id . " Is this a squirrel? Respond: \"" . $submission->id . " Yes\" or \"" . $submission->id . " No\"";
     // send text to experts with the picture
     foreach ($experts as $expert) {
         $this->twilio->sendMMS($expert->phone, $message, $submission->photo_url);
     }
 }
 /**
  * Send an SMS to an enthusiast with an expert's analysis.
  *
  * @param ExpertAnalysisReceived $event
  */
 public function handle(ExpertAnalysisReceived $event)
 {
     // grab the expert and enthusiast user info
     $expert = $event->getExpertUser();
     $submission = $event->getSubmission();
     // save response
     $this->responseCreationService->saveResponse($submission, $expert, $event->wasSquirrel());
     // set message
     if ($event->wasSquirrel()) {
         $message = $expert->name . " says that was a squirrel in your photo! You just made " . $expert->name . " nuts!";
     } else {
         $message = $expert->name . " says it wasn't a squirrel in your photo. Better luck next time.";
     }
     // send SMS to enthusiast
     $this->twilio->sendSMS($submission->user->phone, $message);
 }