예제 #1
0
 /**
  * Unsubscribe an answerer from one or more lists.
  *
  * @param       $answer_id
  * @param array $allLists
  */
 public function unSubscribeAnswerer($answer_id, array $allLists = [])
 {
     // Update database record
     $this->answers->unSubscribeAnswererFromResults($answer_id);
     // Find the email for the answer, and unsubscribe it to the list
     $email = $this->answers->find($answer_id)->email;
     foreach ($allLists as $list) {
         $this->newsletter->unSubscribeFrom($list, $email);
     }
 }
 /**
  * Importer class.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function import()
 {
     $index = 0;
     $batch = [];
     foreach ($this->medicalCenterRepository->all() as $index => $medCenter) {
         $email = $medCenter->email;
         if ($email === '') {
             continue;
         }
         $batch[] = ['email' => compact('email'), 'merge_vars' => ['TOKEN' => $medCenter->token, 'NAME' => $medCenter->name, 'COUNTRY' => $medCenter->country, 'EMAIL' => $medCenter->email]];
     }
     // Subscribe to Newsletter
     $results = $this->newsletter->batchSubscribeTo('TheseEcho', $batch, false, true);
     // Errors
     if ($results['error_count']) {
         return $this->response->make('There are errors ' . print_r($results['errors']) . '.', 405);
     }
     // Success
     return $this->response->make("Subscribed {$index} centers.", 200);
 }
예제 #3
0
 /**
  * Unsubscribe from results.
  *
  * @param $email
  *
  * @return \Illuminate\View\View
  */
 public function unSubscribeFromResults($email)
 {
     // Update database record
     try {
         $this->answers->unSubscribeToResults($email);
     } catch (NoAnswerFoundWithThisMailException $e) {
         return view('survey.error', ['message' => "Le mail {$email} n'existe pas dans la base de donnée !"]);
     }
     // Unsubscribe from mailing list
     try {
         $this->newsletter->unSubscribeFrom('Echo_results', $email);
     } catch (Mailchimp_List_NotSubscribed $e) {
         return view('survey.unsubscribed', compact('email'));
     }
     // Thank you for unsubscribing view
     return view('survey.unsubscribed', compact('email'));
 }