Export.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. class ChargeBee_Export extends ChargeBee_Model
  3. {
  4. protected $allowed = array('operationType', 'mimeType', 'status', 'createdAt', 'id', 'download'
  5. );
  6. public function waitForExportCompletion($env = null, $headers = array()) {
  7. $count = 0;
  8. while($this->status == "in_process") {
  9. if( $count++ > 50) {
  10. throw new RuntimeException("Export is taking too long");
  11. }
  12. sleep(ChargeBee_Environment::$exportWaitInSecs);
  13. $this->_values = ChargeBee_Export::retrieve($this->id, $env, $headers)->export()->getValues();
  14. $this->_load();
  15. }
  16. return $this;
  17. }
  18. # OPERATIONS
  19. #-----------
  20. public static function retrieve($id, $env = null, $headers = array())
  21. {
  22. return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("exports",$id), array(), $env, $headers);
  23. }
  24. public static function revenueRecognition($params, $env = null, $headers = array())
  25. {
  26. return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("exports","revenue_recognition"), $params, $env, $headers);
  27. }
  28. public static function deferredRevenue($params, $env = null, $headers = array())
  29. {
  30. return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("exports","deferred_revenue"), $params, $env, $headers);
  31. }
  32. }
  33. ?>