You are here

function mailchimp_webhook_get in Mailchimp 7.4

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

Wrapper around MailchimpLists->getWebhooks().

Parameters

string $list_id: Mailchimp API List ID.

Return value

mixed Array of existing webhooks, or FALSE.

2 calls to mailchimp_webhook_get()
MailchimpListsTestCase::testGetWebhook in modules/mailchimp_lists/tests/mailchimp_lists.test
Tests retrieval of webhooks for a list.
mailchimp_lists_overview_page in modules/mailchimp_lists/includes/mailchimp_lists.admin.inc
Administrative display showing existing lists and allowing edits/adds.

File

./mailchimp.module, line 1292
Mailchimp module.

Code

function mailchimp_webhook_get($list_id) {
  try {

    /* @var \Mailchimp\MailchimpLists $mc_lists */
    $mc_lists = mailchimp_get_api_object('MailchimpLists');
    if (!$mc_lists) {
      throw new MailchimpException('Cannot get webhook without Mailchimp API. Check API key has been entered.');
    }
    $result = $mc_lists
      ->getWebhooks($list_id);
    return $result->total_items > 0 ? $result->webhooks : FALSE;
  } catch (Exception $e) {
    watchdog('mailchimp', 'An error occurred reading webhooks for list @list. "%message"', array(
      '@list' => $list_id,
      '%message' => $e
        ->getMessage(),
    ), WATCHDOG_ERROR);
    return FALSE;
  }
}