/**
  * @param MailChimp $mailChimp
  * @param CampaignConfig $config
  * @param CampaignBuilder $builder
  * @return bool|null|void
  */
 public function handle(MailChimp $mailChimp, CampaignConfig $config, CampaignBuilder $builder)
 {
     $campaign = $this->campaign->translate($this->locale);
     try {
         $content = $builder->build($this->campaign, $this->locale);
     } catch (Exception $e) {
         throw new HttpException(400, 'There was a problem, check for any unfinished widgets', null, ['reason' => 'There was a problem, check for any unfinished widgets']);
     }
     try {
         $result = $mailChimp->call('campaigns/create', ['type' => 'regular', 'options' => ['list_id' => env('MAILCHIMP_DEFAULT_LIST_ID'), 'subject' => $campaign->subject, 'from_email' => $config->fromEmail(), 'from_name' => $config->fromName(), 'to_name' => $config->toName(), 'title' => $campaign->title], 'content' => ['html' => $content]]);
         if ($result && isset($result['id'])) {
             $campaign->mail_chimp_campaign_id = $result['id'];
             return $campaign->save() ? $campaign : false;
         }
     } catch (Exception $e) {
         throw new HttpException(400, 'Cannot contact mailservice, try again later', null, ['reason' => 'Cannot contact mailservice, try again later']);
     }
 }
 /**
  * @param Campaign $newsletter
  * @param CampaignBuilder $builder
  * @param MailChimp $mailChimp
  * @return array
  */
 protected function detailedResponse(Campaign $newsletter, CampaignBuilder $builder, MailChimp $mailChimp)
 {
     $newsletter->load($this->relations());
     $newsletter->availableWidgets = $builder->getAvailableWidgets();
     //we need to check each locale if it's been linked to a campaign.
     //if so, we'll need to hook that campaign data onto the response.
     foreach ($newsletter->translations as $translation) {
         if ($translation->mail_chimp_campaign_id) {
             $this->loadMailchimpDataForCampaign($mailChimp, $translation);
         }
     }
     return $newsletter->toArray();
 }