You are here

public function MandrillAPI::addWebhook in Mandrill 8

Creates a new webhook.

Parameters

string $path:

array $events:

string $description:

Return value

array The created Mandrill webhook object.

Overrides MandrillAPIInterface::addWebhook

File

src/MandrillAPI.php, line 393

Class

MandrillAPI
Service class to integrate with Mandrill.

Namespace

Drupal\mandrill

Code

public function addWebhook($path, $events, $description = 'Drupal Webhook') {
  $result = NULL;
  try {
    if ($mandrill = $this
      ->getAPIObject()) {
      $result = $mandrill->webhooks
        ->add($GLOBALS['base_url'] . '/' . $path, $description, $events);
    }
  } catch (\Exception $e) {
    \Drupal::messenger()
      ->addError(t('Mandrill: %message', array(
      '%message' => $e
        ->getMessage(),
    )));
    $this->log
      ->error($e
      ->getMessage());
  }
  return $result;
}