1 <?php
2
3 namespace PayPal\Api;
4
5 use PayPal\Common\PayPalResourceModel;
6 use PayPal\Validation\ArgumentValidator;
7 use PayPal\Api\WebhookEventTypeList;
8 use PayPal\Rest\ApiContext;
9
10 /**
11 * Class WebhookEventType
12 *
13 * A list of events.
14 *
15 * @package PayPal\Api
16 *
17 * @property string name
18 * @property string description
19 * @property string status
20 */
21 class WebhookEventType extends PayPalResourceModel
22 {
23 /**
24 * The unique event name.
25 *
26 * @param string $name
27 *
28 * @return $this
29 */
30 public function setName($name)
31 {
32 $this->name = $name;
33 return $this;
34 }
35
36 /**
37 * The unique event name.
38 *
39 * @return string
40 */
41 public function getName()
42 {
43 return $this->name;
44 }
45
46 /**
47 * A human-readable description of the event.
48 *
49 * @param string $description
50 *
51 * @return $this
52 */
53 public function setDescription($description)
54 {
55 $this->description = $description;
56 return $this;
57 }
58
59 /**
60 * A human-readable description of the event.
61 *
62 * @return string
63 */
64 public function getDescription()
65 {
66 return $this->description;
67 }
68
69 /**
70 * The status of a webhook event.
71 *
72 * @param string $status
73 *
74 * @return $this
75 */
76 public function setStatus($status)
77 {
78 $this->status = $status;
79 return $this;
80 }
81
82 /**
83 * The status of a webhook event.
84 *
85 * @return string
86 */
87 public function getStatus()
88 {
89 return $this->status;
90 }
91
92 /**
93 * Lists event subscriptions for a webhook, by ID.
94 *
95 * @param string $webhookId
96 * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
97 * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
98 * @return WebhookEventTypeList
99 */
100 public static function subscribedEventTypes($webhookId, $apiContext = null, $restCall = null)
101 {
102 ArgumentValidator::validate($webhookId, 'webhookId');
103 $payLoad = "";
104 $json = self::executeCall(
105 "/v1/notifications/webhooks/$webhookId/event-types",
106 "GET",
107 $payLoad,
108 null,
109 $apiContext,
110 $restCall
111 );
112 $ret = new WebhookEventTypeList();
113 $ret->fromJson($json);
114 return $ret;
115 }
116
117 /**
118 * Lists available events to which any webhook can subscribe. For a list of supported events, see [Webhook events](/docs/integration/direct/rest/webhooks/webhook-events/).
119 *
120 * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
121 * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
122 * @return WebhookEventTypeList
123 */
124 public static function availableEventTypes($apiContext = null, $restCall = null)
125 {
126 $payLoad = "";
127 $json = self::executeCall(
128 "/v1/notifications/webhooks-event-types",
129 "GET",
130 $payLoad,
131 null,
132 $apiContext,
133 $restCall
134 );
135 $ret = new WebhookEventTypeList();
136 $ret->fromJson($json);
137 return $ret;
138 }
139
140 }
141