@@ -1485,6 +1485,38 @@ public function destroy_broadcast(int $id)
1485
1485
return $ this ->delete (sprintf ('broadcasts/%s ' , $ id ));
1486
1486
}
1487
1487
1488
+ /**
1489
+ * List webhooks.
1490
+ *
1491
+ * @param boolean $include_total_count To include the total count of records in the response, use true.
1492
+ * @param string $after_cursor Return results after the given pagination cursor.
1493
+ * @param string $before_cursor Return results before the given pagination cursor.
1494
+ * @param integer $per_page Number of results to return.
1495
+ *
1496
+ * @since 2.0.0
1497
+ *
1498
+ * @see https://developers.convertkit.com/v4.html#list-webhooks
1499
+ *
1500
+ * @return false|mixed
1501
+ */
1502
+ public function get_webhooks (
1503
+ bool $ include_total_count = false ,
1504
+ string $ after_cursor = '' ,
1505
+ string $ before_cursor = '' ,
1506
+ int $ per_page = 100
1507
+ ) {
1508
+ // Send request.
1509
+ return $ this ->get (
1510
+ endpoint: 'webhooks ' ,
1511
+ args: $ this ->build_total_count_and_pagination_params (
1512
+ include_total_count: $ include_total_count ,
1513
+ after_cursor: $ after_cursor ,
1514
+ before_cursor: $ before_cursor ,
1515
+ per_page: $ per_page
1516
+ )
1517
+ );
1518
+ }
1519
+
1488
1520
/**
1489
1521
* Creates a webhook that will be called based on the chosen event types.
1490
1522
*
@@ -1494,7 +1526,7 @@ public function destroy_broadcast(int $id)
1494
1526
*
1495
1527
* @since 1.0.0
1496
1528
*
1497
- * @see https://developers.convertkit.com/#create-a-webhook
1529
+ * @see https://developers.convertkit.com/v4.html #create-a-webhook
1498
1530
*
1499
1531
* @throws \InvalidArgumentException If the event is not supported.
1500
1532
*
@@ -1506,6 +1538,8 @@ public function create_webhook(string $url, string $event, string $parameter = '
1506
1538
switch ($ event ) {
1507
1539
case 'subscriber.subscriber_activate ' :
1508
1540
case 'subscriber.subscriber_unsubscribe ' :
1541
+ case 'subscriber.subscriber_bounce ' :
1542
+ case 'subscriber.subscriber_complain ' :
1509
1543
case 'purchase.purchase_create ' :
1510
1544
$ eventData = ['name ' => $ event ];
1511
1545
break ;
@@ -1553,7 +1587,7 @@ public function create_webhook(string $url, string $event, string $parameter = '
1553
1587
1554
1588
// Send request.
1555
1589
return $ this ->post (
1556
- 'automations/hooks ' ,
1590
+ 'webhooks ' ,
1557
1591
[
1558
1592
'target_url ' => $ url ,
1559
1593
'event ' => $ eventData ,
@@ -1564,17 +1598,17 @@ public function create_webhook(string $url, string $event, string $parameter = '
1564
1598
/**
1565
1599
* Deletes an existing webhook.
1566
1600
*
1567
- * @param integer $rule_id Rule ID.
1601
+ * @param integer $id Webhook ID.
1568
1602
*
1569
1603
* @since 1.0.0
1570
1604
*
1571
- * @see https://developers.convertkit.com/#destroy -webhook
1605
+ * @see https://developers.convertkit.com/v4.html#delete-a -webhook
1572
1606
*
1573
1607
* @return false|object
1574
1608
*/
1575
- public function destroy_webhook (int $ rule_id )
1609
+ public function delete_webhook (int $ id )
1576
1610
{
1577
- return $ this ->delete (sprintf ('automations/hooks/ %s ' , $ rule_id ));
1611
+ return $ this ->delete (sprintf ('webhooks/ %s ' , $ id ));
1578
1612
}
1579
1613
1580
1614
/**
0 commit comments