* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @copyright PayPal */ namespace PaypalAddons\classes\API\Request\V_1; use Exception; use PayPal\Api\WebhookEvent; use PaypalAddons\classes\AbstractMethodPaypal; use PaypalAddons\classes\API\Response\Error; use PaypalAddons\classes\API\Response\Response; class ResendWebhookEvent extends RequestAbstract { /** @var WebhookEvent */ protected $webhookEvent; public function __construct(AbstractMethodPaypal $method, WebhookEvent $webhookEvent) { parent::__construct($method); $this->webhookEvent = $webhookEvent; } public function execute() { $response = $this->getResponse(); try { $this->webhookEvent->resend($this->getApiContext()); $response->setSuccess(true); } catch (Exception $e) { $error = (new Error()) ->setMessage($e->getMessage()) ->setErrorCode($e->getMessage()); $response ->setSuccess(false) ->setError($error); } return $response; } protected function getResponse() { return new Response(); } }