Contains the information for a Webhooks event-type
Inheritance: extends PayPal\Common\PayPalResourceModel
 /**
  * @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 Webhook Sample
//
// This sample code demonstrate how you can get a webhook, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#get-a-webhook
// API used: GET /v1/notifications/webhooks/<Webhook-Id>
// ## List Subscribed Event Types
// Use this call to retrieve the list of events types that are subscribed to a webhook.
/** @var \PayPal\Api\Webhook $webhook */
$webhook = (require 'CreateWebhook.php');
$webhookId = $webhook->getId();
// ### Get List of Subscribed Event Types
try {
    $output = \PayPal\Api\WebhookEventType::subscribedEventTypes($webhookId, $apiContext);
} catch (Exception $ex) {
    // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
    ResultPrinter::printError("List subscribed webhook event types", "WebhookEventTypeList", null, $webhookId, $ex);
    exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("List subscribed webhook event types", "WebhookEventTypeList", null, null, $output);
return $output;
 /**
  * @depends testGet
  * @param $webhook Webhook
  * @return WebhookEventTypeList
  */
 public function testGetSubscribedEventTypes($webhook)
 {
     $result = WebhookEventType::subscribedEventTypes($webhook->getId(), $this->apiContext, $this->mockPayPalRestCall);
     $this->assertNotNull($result);
     $this->assertEquals(2, sizeof($result->getEventTypes()));
     return $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;
Ejemplo n.º 5
0
 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;
 }