You are here

function mailchimp_webhook_get in Mailchimp 8

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

Returns all webhooks for a given Mailchimp list ID.

See also

Mailchimp_Lists::webhooks()

3 calls to mailchimp_webhook_get()
MailchimpListsWebhookSettingsForm::submitForm in modules/mailchimp_lists/src/Form/MailchimpListsWebhookSettingsForm.php
Form submission handler.
MailchimpListsWebhookTest::testGetWebhook in modules/mailchimp_lists/src/Tests/MailchimpListsWebhookTest.php
Tests retrieval of webhooks for a list.
mailchimp_lists_enabled_webhook_events in modules/mailchimp_lists/mailchimp_lists.module
Returns an array of enabled webhook events.

File

./mailchimp.module, line 949
Mailchimp module.

Code

function mailchimp_webhook_get($list_id) {
  try {

    /* @var \Mailchimp\MailchimpLists $mc_lists */
    $mc_lists = mailchimp_get_api_object('MailchimpLists');
    $result = $mc_lists
      ->getWebhooks($list_id);
    return $result->total_items > 0 ? $result->webhooks : FALSE;
  } catch (\Exception $e) {
    \Drupal::logger('mailchimp')
      ->error('An error occurred reading webhooks for list {list}. "{message}"', [
      'list' => $list_id,
      'message' => $e
        ->getMessage(),
    ]);
    return FALSE;
  }
}