@@ -403,6 +403,73 @@ public function addContactToJourney($name, $contactId)
403
403
return $ response ;
404
404
}
405
405
406
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
407
+ // REST hooks methods
408
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
409
+
410
+ /**
411
+ * Get all REST hooks
412
+ *
413
+ * @return array
414
+ *
415
+ * @throws AutopilotException
416
+ */
417
+ public function allRestHooks ()
418
+ {
419
+ $ response = $ this ->apiGet ('hooks ' );
420
+
421
+ return $ response ['hooks ' ];
422
+ }
423
+
424
+ /**
425
+ * Deletes all REST hooks
426
+ *
427
+ * @return boolean
428
+ *
429
+ * @throws AutopilotException
430
+ */
431
+ public function deleteAllRestHooks ()
432
+ {
433
+ $ this ->apiDelete ('hooks ' );
434
+
435
+ return true ;
436
+ }
437
+
438
+ /**
439
+ * Add REST hook
440
+ *
441
+ * @param string $event
442
+ * @param string $targetUrl
443
+ *
444
+ * @return string Returns hook ID
445
+ *
446
+ * @throws AutopilotException
447
+ */
448
+ public function addRestHook ($ event , $ targetUrl )
449
+ {
450
+ $ request = ['event ' => $ event , 'target_url ' => $ targetUrl ];
451
+
452
+ $ response = $ this ->apiPost ('hook ' , $ request );
453
+
454
+ return $ response ['hook_id ' ];
455
+ }
456
+
457
+ /**
458
+ * Deletes a single REST hook
459
+ *
460
+ * @param string $hookId
461
+ *
462
+ * @return bool
463
+ *
464
+ * @throws AutopilotException
465
+ */
466
+ public function deleteRestHook ($ hookId )
467
+ {
468
+ $ this ->apiDelete ('hook/ ' . $ hookId );
469
+
470
+ return true ;
471
+ }
472
+
406
473
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
407
474
// REQUEST helpers
408
475
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0 commit comments