You are here

public function DrupalMailchimp::__construct in Mailchimp 7.3

Override __construct().

The parent constructor sets curl settings that we need to avoid. Much of code is duplicated from the parent.

File

includes/mailchimp.inc, line 24
Wrapper class around the Mailchimp API.

Class

DrupalMailchimp
Class DrupalMailchimp

Code

public function __construct($apikey = NULL, $opts = array()) {
  if (!$apikey) {
    $apikey = getenv('MAILCHIMP_APIKEY');
  }
  if (!$apikey) {
    $apikey = $this
      ->readConfigs();
  }
  if (!$apikey) {
    throw new Mailchimp_Error(t('You must provide a MailChimp API key'));
  }
  $this->apikey = $apikey;
  $dc = "us1";
  if (strstr($this->apikey, "-")) {
    $key_parts = explode("-", $this->apikey, 2);
    $dc = isset($key_parts[1]) ? $key_parts[1] : 'us1';
  }
  $this->root = str_replace('https://api', 'https://' . $dc . '.api', $this->root);
  $this->root = rtrim($this->root, '/') . '/';
  $this->timeout = isset($opts['timeout']) && is_int($opts['timeout']) ? $opts['timeout'] : 600;
  $this->folders = new Mailchimp_Folders($this);
  $this->templates = new Mailchimp_Templates($this);
  $this->users = new Mailchimp_Users($this);
  $this->helper = new Mailchimp_Helper($this);
  $this->mobile = new Mailchimp_Mobile($this);
  $this->ecomm = new Mailchimp_Ecomm($this);
  $this->neapolitan = new Mailchimp_Neapolitan($this);
  $this->lists = new Mailchimp_Lists($this);
  $this->campaigns = new Mailchimp_Campaigns($this);
  $this->vip = new Mailchimp_Vip($this);
  $this->reports = new Mailchimp_Reports($this);
  $this->gallery = new Mailchimp_Gallery($this);
}