1 <?php
2 namespace MailChimp\Lists;
3
4 class Webhooks extends Lists
5 {
6 /**
7 * Get a list of webhooks
8 * @param string $list_id
9 * @param array $query (See Above) OPTIONAL associative array of query parameters.
10 * @return object
11 */
12 public function getWebhooks($list_id, array $query = [])
13 {
14 return self::execute("GET", "lists/{$list_id}/webhooks", $query);
15 }
16
17 /**
18 * Get a single webhook
19 *
20 * @param string $list_id
21 * @param string $webhook_id
22 * @param array $query (See Above) OPTIONAL associative array of query parameters.
23 * @return object
24 */
25 public function getWebhook($list_id, $webhook_id, array $query = [])
26 {
27 return self::execute("GET", "lists/{$list_id}/webhooks/{$webhook_id}", $query);
28 }
29
30 /**
31 * Create a new webhook
32 *
33 * array["data"]
34 * ["url"] string A valid URL for the Webhook.
35 * ["events"] array The events that can trigger the webhook and whether they are enabled.
36 * "subscribe" boolean
37 * "unsubscribe" boolean
38 * "profile" boolean
39 * "cleaned" boolean
40 * "upemail" boolean
41 * "campaign" boolean
42 * ["sources"] array The possible sources of any events that can trigger the webhook and whether they are enabled.
43 * "user" boolean
44 * "admin" boolean
45 * "api" boolean
46 *
47 * @param string $list_id
48 * @param array $data
49 * @return object
50 */
51 public function createWebhook($list_id, array $data = [])
52 {
53 return self::execute("POST", "lists/{$list_id}/webhooks", $data);
54 }
55
56 /**
57 * Delete a webhook
58 *
59 * @param string $list_id
60 * @param string $webhook_id
61 */
62 public function deleteWebhook($list_id, $webhook_id)
63 {
64 return self::execute("DELETE", "lists/{$list_id}/webhooks/{$webhook_id}");
65 }
66
67 }
68