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
<?php
namespace Catapult;
final class EventResource extends BaseResource {
public function __construct(&$object, $data) {
$data = Ensure::Input($data);
$args = Cleaner::Omit($data->get());
$type = $args['eventType'];
$splits = explode("-", $type);
$class = __CLASS__;
$object->eventType = $type;
if (sizeof($splits)>1) {
$g = "";
foreach($splits as $s) {
$g .= ucwords($g);
}
$class = "Catapult\\" . "Conference" . $g . "Event";
return $object->model = new Conference($args['id']);
}
if ($type == "sms") {
return $object->model = new Message($args['id']);
}
if (in_array($type, array("incoming", "hangup", "answer", "speak", "recording", "dtmf", "gather"))) {
$cl = "Catapult\\" . ucwords($type) . "CallEvent";
return $object->model = new Call($args['id']);
}
throw new \CatapultApiException("EventType was not found in list of events");
}
}