Lists available events to which any webhook can subscribe. For a list of supported events, see Webhook events.
public static availableEventTypes ( |
||
$apiContext | is the APIContext for this call. It can be used to pass dynamic configuration and credentials. | |
$restCall | PayPalRestCall | is the Rest Call Service that is used to make rest calls |
return |
/** * @dataProvider mockProvider * @param WebhookEventType $obj */ public function testAvailableEventTypes($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock(); $mockPayPalRestCall->expects($this->any())->method('execute')->will($this->returnValue(WebhookEventTypeListTest::getJson())); $result = $obj->availableEventTypes($mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); }
<?php // # Get Reference List of all Webhook Event Types // // This sample code demonstrate how you can get reference list of all webhook event types, as documented here at: // https://developer.paypal.com/webapps/developer/docs/api/#get-a-reference-list-of-webhook-event-types // API used: GET /v1/notifications/webhooks-event-types $apiContext = (require __DIR__ . '/../bootstrap.php'); // ### Get List of all Webhook event types try { $output = \PayPal\Api\WebhookEventType::availableEventTypes($apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Get List of All Webhook Event Types", "WebhookEventTypeList", null, null, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Get List of All Webhook Event Types", "WebhookEventTypeList", null, null, $output); return $output;
function available_webhooks() { // auth $apiContext = $this->apiContext(); // set webhooks $webhooks_event = new WebhookEventType(); try { $WebhookList = $webhooks_event->availableEventTypes($apiContext); $valid = true; } catch (Exception $ex) { $this->LoggingManager->log(print_r($ex, true), 'DEBUG'); $valid = false; } // set array $list_array = array(); if ($valid === true) { $eventtypes = $WebhookList->getEventTypes(); for ($i = 0, $n = count($eventtypes); $i < $n; $i++) { $eventtype = $eventtypes[$i]; $list_array[] = array('name' => $eventtype->getName(), 'description' => $eventtype->getDescription()); } } return $list_array; }