You are here

function mailchimp_webhook_add in Mailchimp 7.3

Same name and namespace in other branches
  1. 8 mailchimp.module \mailchimp_webhook_add()
  2. 7.5 mailchimp.module \mailchimp_webhook_add()
  3. 7.4 mailchimp.module \mailchimp_webhook_add()
  4. 2.x mailchimp.module \mailchimp_webhook_add()

Wrapper around MCAPI->lists->webhookAdd().

Return value

bool TRUE if deletion was successful, otherwise FALSE.

3 calls to mailchimp_webhook_add()
MailchimpListsTestCase::testAddWebhook in modules/mailchimp_lists/tests/mailchimp_lists.test
Tests adding a webhook to a list.
MailchimpListsTestCase::testDeleteWebhook in modules/mailchimp_lists/tests/mailchimp_lists.test
Tests deletion of a webhook.
mailchimp_lists_webhook_form_submit in modules/mailchimp_lists/includes/mailchimp_lists.admin.inc
Submit handler for mailchimp_lists_webhook_form().

File

./mailchimp.module, line 1034
Mailchimp module.

Code

function mailchimp_webhook_add($list_id, $url, $actions = array(), $sources = array()) {
  try {
    $mcapi = mailchimp_get_api_object();
    if (!$mcapi) {
      throw new MailchimpException('Cannot add webhook without MailChimp API. Check API key has been entered.');
    }
    $result = $mcapi->lists
      ->webhookAdd($list_id, $url, $actions, $sources);
  } catch (Exception $e) {
    watchdog('mailchimp', t('An error occurred adding webhook for list @list. "%message"'), array(
      '@list' => $list_id,
      '%message' => $e
        ->getMessage(),
    ), WATCHDOG_ERROR);
    return FALSE;
  }
  return $result['id'];
}