Event.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. class ChargeBee_Event extends ChargeBee_Model
  3. {
  4. protected $allowed = array('id', 'occurredAt', 'source', 'user', 'webhookStatus', 'webhookFailureReason',
  5. 'webhooks', 'eventType');
  6. public function content()
  7. {
  8. return new ChargeBee_Content($this->_values['content']);
  9. }
  10. public static function deserialize($json)
  11. {
  12. $webhookData = json_decode($json, true);
  13. if(!$webhookData) {
  14. throw new Exception("Response not in JSON format. Might not be a ChargeBee webhook call.");
  15. }
  16. if($webhookData != null)
  17. {
  18. return new ChargeBee_Event($webhookData);
  19. }
  20. return null;
  21. }
  22. # OPERATIONS
  23. #-----------
  24. public static function all($params = array(), $env = null, $headers = array())
  25. {
  26. return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("events"), $params, $env, $headers);
  27. }
  28. public static function retrieve($id, $env = null, $headers = array())
  29. {
  30. return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("events",$id), array(), $env, $headers);
  31. }
  32. }
  33. ?>