-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathj27330channelmanagement_rentalsunited_handle_webhook.class.php
87 lines (74 loc) · 3.14 KB
/
j27330channelmanagement_rentalsunited_handle_webhook.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* Core file.
*
* @author Vince Wooll <sales@jomres.net>
*
* @version Jomres 9.8.21
*
* @copyright 2005-2017 Vince Wooll
* Jomres (tm) PHP, CSS & Javascript files are released under both MIT and GPL2 licenses. This means that you can choose the license that best suits your project, and use it accordingly
**/
// ################################################################
defined('_JOMRES_INITCHECK') or die('');
// ################################################################
/**
* @package Jomres\Core\Minicomponents
*
* When a webhook is passed to the channel management framework the cmf webhook authmethod then hands the webhook to this script to allow this script to perform any actions required
*
*/
class j27330channelmanagement_rentalsunited_handle_webhook
{
/**
*
* Constructor
*
* Main functionality of the Minicomponent
*
*/
public function __construct($componentArgs)
{
// Must be in all minicomponents. Minicomponents with templates that can contain editable text should run $this->template_touch() else just return
$MiniComponents = jomres_singleton_abstract::getInstance('mcHandler');
if ($MiniComponents->template_touch) {
$this->template_touchable = false;
return;
}
$this_channel = 'rentalsunited';
logging::log_message("Starting RU 27330 webhook handling" , 'RENTALS_UNITED', 'DEBUG' , '' );
// This script will collate and send information to the remote site using the authentication information provided in the componentArgs variable.
$ePointFilepath=get_showtime('ePointFilepath');
jr_import('channelmanagement_rentalsunited_push_event_trigger_crossref');
$event_trigger_crossref = new channelmanagement_rentalsunited_push_event_trigger_crossref();
$push_events = $event_trigger_crossref->events;
$webhook_event = $componentArgs['webhook_notification']->webhook_event;
$channel_data = $componentArgs['channel_data'];
$managers = $componentArgs['managers'];
if ( isset($push_events[$webhook_event]) ) {
$push_tasks = $push_events[$webhook_event];
if (!empty($push_tasks) ) {
foreach ( $push_tasks as $task ) {
$file_name = $ePointFilepath.'xml_'.$task.'.php';
try {
if (file_exists($file_name)) {
$class_name = $task;
logging::log_message("About to run class : " .$class_name, 'RENTALS_UNITED', 'DEBUG' , '' );
require_once($file_name);
$new_class = new $class_name();
$new_class->trigger_event($webhook_event , $componentArgs['webhook_notification']->data , $channel_data , $managers , $this_channel );
unset($new_class);
}
} catch (Exception $e) {
logging::log_message("Failed to send notification to remote channel, failed with message ".$e->getMessage() , 'RENTALS_UNITED', 'ERROR' , '' );
}
}
}
}
logging::log_message("Completed RU 27330 webhook handling" , 'RENTALS_UNITED', 'DEBUG' , '' );
}
public function getRetVals()
{
return null;
}
}