You are here

public function MailChimpTest::listSubscribe in Mailchimp 7.2

Subscribe a user to a list.

Return value

bool TRUE if user was added or subscribed, otherwise FALSE.

Overrides MCAPI::listSubscribe

1 call to MailChimpTest::listSubscribe()
MailChimpTest::listBatchSubscribe in tests/mailchimp_tests.inc
Batch subscribe method.

File

tests/mailchimp_tests.inc, line 60
A virtual MailChimp API implementation for use in testing.

Class

MailChimpTest
@file A virtual MailChimp API implementation for use in testing.

Code

public function listSubscribe($id, $email_address, $merge_vars = NULL, $email_type = 'html', $double_optin = TRUE, $update_existing = FALSE, $replace_interests = TRUE, $send_welcome = FALSE) {
  $lists = $this
    ->loadLists();
  if (isset($lists[$id])) {
    if (isset($lists[$id]['data'][$email_address])) {
      $lists[$id]['data'][$email_address]['subscribed'] = TRUE;
    }
    else {
      $lists[$id]['data'][$email_address] = array(
        'subscribed' => TRUE,
        'email_type' => $email_type,
        'merge_vars' => $merge_vars,
      );
    }
    $this
      ->writeLists($lists);
    return TRUE;
  }
  else {
    $this->errorMessage = "Could not add " . $email_address . " to non-existant list: " . $id;
    return FALSE;
  }
}