/**
  * Makes a subscription request
  *
  * @param string $email
  * @param array $merge_vars
  * @param int $related_object_id
  * @return string|boolean
  */
 protected function subscribe($email, array $merge_vars = array(), $related_object_id = null)
 {
     $lists = $this->get_lists();
     if (empty($lists)) {
         error_log(sprintf("MailChimp for WordPress: No lists selected for the %s integration.", $this->name));
         return false;
     }
     $merge_vars = MC4WP_Tools::guess_merge_vars($merge_vars);
     if (!isset($merge_vars['OPTIN_IP'])) {
         $merge_vars['OPTIN_IP'] = MC4WP_tools::get_client_ip();
     }
     $result = false;
     $config = array('double_optin' => $this->options['double_optin'], 'update_existing' => $this->options['update_existing'], 'send_welcome' => $this->options['send_welcome']);
     $extra = array('related_object_id' => $related_object_id, 'referer' => $_SERVER['HTTP_REFERER'], 'type' => 'integration', 'integration' => $this->name);
     foreach ($lists as $list_id) {
         $request = new MC4WP_API_Request('subscribe', $list_id, $email, $merge_vars, $config, $extra);
         /** @var MC4WP_API_Response $response */
         $response = $request->process();
     }
     if (!$response->success) {
         error_log(sprintf('MailChimp for WP: Subscribe request from %s integration failed. The following error was returned by the MailChimp API. "%s"', $this->name, $response->error));
     }
     return $result;
 }
 /**
  * Prepare the requests this form creates
  *
  * @return bool
  */
 public function prepare()
 {
     $lists = $this->get_lists();
     $merge_vars = $this->parse_merge_vars();
     $email = $this->data['EMAIL'];
     $config = array('email_type' => $this->get_email_type(), 'ip' => MC4WP_Tools::get_client_ip());
     $extra = array('related_object_id' => $this->form->ID, 'referer' => $_SERVER['HTTP_REFERER'], 'type' => 'form');
     // create a request object for each list
     foreach ($lists as $list_id) {
         $request = MC4WP_API_Request::create($this->config['action'], $list_id, $email, $merge_vars, $config, $extra);
         $this->requests[] = $request;
     }
     return true;
 }