WebhookList.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace PayPal\Api;
  3. use PayPal\Common\PayPalModel;
  4. /**
  5. * Class WebhookList
  6. *
  7. * List of webhooks.
  8. *
  9. * @package PayPal\Api
  10. *
  11. * @property \PayPal\Api\Webhook[] webhooks
  12. */
  13. class WebhookList extends PayPalModel
  14. {
  15. /**
  16. * A list of webhooks.
  17. *
  18. * @param \PayPal\Api\Webhook[] $webhooks
  19. *
  20. * @return $this
  21. */
  22. public function setWebhooks($webhooks)
  23. {
  24. $this->webhooks = $webhooks;
  25. return $this;
  26. }
  27. /**
  28. * A list of webhooks.
  29. *
  30. * @return \PayPal\Api\Webhook[]
  31. */
  32. public function getWebhooks()
  33. {
  34. return $this->webhooks;
  35. }
  36. /**
  37. * Append Webhooks to the list.
  38. *
  39. * @param \PayPal\Api\Webhook $webhook
  40. * @return $this
  41. */
  42. public function addWebhook($webhook)
  43. {
  44. if (!$this->getWebhooks()) {
  45. return $this->setWebhooks(array($webhook));
  46. } else {
  47. return $this->setWebhooks(
  48. array_merge($this->getWebhooks(), array($webhook))
  49. );
  50. }
  51. }
  52. /**
  53. * Remove Webhooks from the list.
  54. *
  55. * @param \PayPal\Api\Webhook $webhook
  56. * @return $this
  57. */
  58. public function removeWebhook($webhook)
  59. {
  60. return $this->setWebhooks(
  61. array_diff($this->getWebhooks(), array($webhook))
  62. );
  63. }
  64. }