You are here

public function Mailchimp::__construct in Mailchimp 8

Same name in this branch
  1. 8 lib/mailchimp-api-php/src/Mailchimp.php \Mailchimp\Mailchimp::__construct()
  2. 8 lib/mailchimp-api-php/tests/src/Mailchimp.php \Mailchimp\Tests\Mailchimp::__construct()

Mailchimp constructor.

Parameters

string $api_key: The Mailchimp API key.

string $api_user: The Mailchimp API username.

array $http_options: HTTP client options.

MailchimpHttpClientInterface $client: Optional custom HTTP client. $http_options are ignored if this is set.

7 methods override Mailchimp::__construct()
Mailchimp::__construct in lib/mailchimp-api-php/tests/src/Mailchimp.php
@inheritdoc
MailchimpAutomations::__construct in lib/mailchimp-api-php/tests/src/MailchimpAutomations.php
@inheritdoc
MailchimpCampaigns::__construct in lib/mailchimp-api-php/tests/src/MailchimpCampaigns.php
@inheritdoc
MailchimpEcommerce::__construct in lib/mailchimp-api-php/tests/src/MailchimpEcommerce.php
@inheritdoc
MailchimpLists::__construct in lib/mailchimp-api-php/tests/src/MailchimpLists.php
@inheritdoc

... See full list

File

lib/mailchimp-api-php/src/Mailchimp.php, line 103

Class

Mailchimp
Mailchimp library.

Namespace

Mailchimp

Code

public function __construct($api_key, $api_user = 'apikey', $http_options = [], MailchimpHttpClientInterface $client = NULL) {
  $this->api_key = $api_key;
  $this->api_user = $api_user;
  $dc = $this
    ->getDataCenter($this->api_key);
  $this->endpoint = str_replace(Mailchimp::DEFAULT_DATA_CENTER, $dc, $this->endpoint);
  if (!empty($client)) {
    $this->client = $client;
  }
  else {
    $this->client = $this
      ->getDefaultHttpClient($http_options);
  }
}